home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / libimage / flsbuf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.6 KB  |  63 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    iflsbuf -
  19.  *
  20.  *                Paul Haeberli - 1984
  21.  *
  22.  */
  23. #include    "image.h"
  24.  
  25. iflsbuf(image, c)
  26. register  IMAGE *image;
  27. unsigned long c;
  28. {
  29.     register unsigned short *base;
  30.     register n, rn;
  31.     char c1;
  32.     int size;
  33.  
  34.     if ((image->flags&_IOWRT)==0)
  35.         return(EOF);
  36.     if ((base=image->base)==NULL) {
  37.         size = IBUFSIZE(image->xsize);
  38.         if ((image->base=base=ibufalloc(image)) == NULL) {
  39.             i_errhdlr("flsbuf: error on buf alloc\n");
  40.             return EOF;
  41.         }
  42.         rn = n = 0;
  43.     } else if ((rn = n = image->ptr - base) > 0)  {
  44.             n = putrow(image,base,image->y,image->z);
  45.             if(++image->y >= image->ysize) {
  46.                 image->y = 0;
  47.                 if(++image->z >= image->zsize) {
  48.                 image->z = image->zsize-1;
  49.                 image->flags |= _IOEOF;
  50.                 return -1;
  51.                 }
  52.             }
  53.      }
  54.     image->cnt = image->xsize-1;
  55.     *base++ = c;
  56.     image->ptr = base;
  57.     if (rn != n) {
  58.         image->flags |= _IOERR;
  59.         return(EOF);
  60.     }
  61.     return(c);
  62. }
  63.