/*
**   ----------------------------------------------------------------- 
**        Copyright (C) 1990, 1991 Sun Microsystems, Inc
**                   All rights reserved.
**         Notice of copyright on this source code
**         product does not indicate publication.
**   
**   RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by
**   the U.S. Government is subject to restrictions as set forth
**   in subparagraph (c)(1)(ii) of the Rights in Technical Data
**   and Computer Software Clause at DFARS 252.227-7013 (Oct. 1988)
**   and FAR 52.227-19 (c) (June 1987).
**   
**     Sun Microsystems, Inc., 2550 Garcia Avenue,
**     Mountain View, California 94043.
**   ----------------------------------------------------------------- 
*/
#ifndef _BUFFUTIL_H
#define _BUFFUTIL_H

#ifndef	NOIDENT
#ident  "@(#)buffutil.h	3.3    91/07/23 include/Xol SMI"    /* olmisc:buffutil.h 1.3	*/
#endif


/*	Copyright (c) 1990 UNIX System Laboratories, Inc.	*/
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF     	*/
/*	UNIX System Laboratories, Inc.                     	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/


	/* shouldn't check for SEEK_SET because it defined in unistd.h  */
	/* in SVR3.2 and X11/Xos.h will include this header file if USG */

typedef char BufferElement;

#define Bufferof(type) \
   struct \
      { \
      int    size; \
      int    used; \
      int    esize; \
      type * p; \
      }

typedef struct _Buffer
   {
   int    size;
   int    used;
   int    esize;
   BufferElement * p;
   } Buffer;

#define LNMIN       8
#define LNINCRE    24

#define BufferFilled(b)  (b-> size == b-> used)
#define BufferLeft(b)    (b-> size - b-> used)
#define BufferEmpty(b)   (b-> used == 0)

extern Buffer * AllocateBuffer();
extern void     GrowBuffer();
extern Buffer * CopyBuffer();
extern void     FreeBuffer();
extern int      InsertIntoBuffer();
extern int      ReadFileIntoBuffer();
extern int      ReadStringIntoBuffer();

extern Buffer * stropen();
extern int      strgetc();
extern void     strclose();


#endif	/* !_BUFFUTIL_H */
