1/* 2 3Copyright 1993, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included 12in all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall 23not be used in advertising or otherwise to promote the sale, use or 24other dealings in this Software without prior written authorization 25from The Open Group. 26 27*/ 28 29#ifndef ___BUFIO_H___ 30#define ___BUFIO_H___ 1 31 32#include <X11/Xfuncproto.h> 33 34#define BUFFILESIZE 8192 35#define BUFFILEEOF -1 36 37typedef unsigned char BufChar; 38typedef struct _buffile *BufFilePtr; 39 40typedef struct _buffile { 41 BufChar *bufp; 42 int left; 43 int eof; 44 BufChar buffer[BUFFILESIZE]; 45 int (*input)( BufFilePtr /* f */); 46 int (*output)( int /* c */, BufFilePtr /* f */); 47 int (*skip)( BufFilePtr /* f */, int /* count */); 48 int (*close)( BufFilePtr /* f */, int /* doClose */); 49 char *private; 50} BufFileRec; 51 52extern BufFilePtr BufFileCreate ( 53 char*, 54 int (*)(BufFilePtr), 55 int (*)(int, BufFilePtr), 56 int (*)(BufFilePtr, int), 57 int (*)(BufFilePtr, int)); 58extern BufFilePtr BufFileOpenRead ( int ); 59extern BufFilePtr BufFileOpenWrite ( int ); 60extern BufFilePtr BufFilePushCompressed ( BufFilePtr ); 61#ifdef X_GZIP_FONT_COMPRESSION 62extern BufFilePtr BufFilePushZIP ( BufFilePtr ); 63#endif 64#ifdef X_BZIP2_FONT_COMPRESSION 65extern BufFilePtr BufFilePushBZIP2 ( BufFilePtr ); 66#endif 67extern int BufFileClose ( BufFilePtr, int ); 68extern int BufFileRead ( BufFilePtr, char*, int ); 69extern int BufFileWrite ( BufFilePtr, const char*, int ); 70 71#define BufFileGet(f) ((f)->left-- ? *(f)->bufp++ : ((f)->eof = (*(f)->input) (f))) 72#define BufFilePut(c,f) (--(f)->left ? *(f)->bufp++ = ((unsigned char)(c)) : (*(f)->output) ((unsigned char)(c),f)) 73#define BufFileSkip(f,c) ((f)->eof = (*(f)->skip) (f, c)) 74 75#ifndef TRUE 76#define TRUE 1 77#endif 78#ifndef FALSE 79#define FALSE 0 80#endif 81 82#endif /* ___BUFIO_H___ */ 83 84