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