source: trunk/src/testing/app/bitplay/libimage/flsbuf.c @ 4

Revision 4, 2.7 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

  • Property svn:executable set to *
Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Copyright (C) 2004 Electronic Visualization Laboratory,
5 * University of Illinois at Chicago
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above
15 *    copyright notice, this list of conditions and the following disclaimer
16 *    in the documentation and/or other materials provided with the distribution.
17 *  * Neither the name of the University of Illinois at Chicago nor
18 *    the names of its contributors may be used to endorse or promote
19 *    products derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
34 *
35 *****************************************************************************/
36
37/*
38 *      iflsbuf -
39 *
40 *                              Paul Haeberli - 1984
41 *
42 */
43#include        "image.h"
44
45int iflsbuf( IMAGE *image, IMushort c )
46{
47        register IMushort *base;
48        register int n, rn;
49        int size;
50
51        if ((image->flags&_IOWRT)==0)
52                return(EOF);
53        if ((base=image->base)==NULL) {
54                size = IBUFSIZE(image->xsize);
55                if ((image->base=base=ibufalloc(image)) == NULL) {
56                        i_errhdlr("flsbuf: error on buf alloc\n");
57                        return EOF;
58                }
59                rn = n = 0;
60        } else if ((rn = n = image->ptr - base) > 0)  {
61                        n = putrow(image,base,image->y,image->z);
62                        if(++image->y >= image->ysize) {
63                            image->y = 0;
64                            if(++image->z >= image->zsize) {
65                                image->z = image->zsize-1;
66                                image->flags |= _IOEOF;
67                                return -1;
68                            }
69                        }
70        }
71        image->cnt = image->xsize-1;
72        *base++ = c;
73        image->ptr = base;
74        if (rn != n) {
75                image->flags |= _IOERR;
76                return(EOF);
77        }
78        return(c);
79}
Note: See TracBrowser for help on using the repository browser.