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