upload tizen2.0 source
[framework/uifw/xorg/lib/libxfont.git] / include / X11 / fonts / bufio.h
1 /*
2
3 Copyright 1993, 1998  The Open Group
4
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
25 from 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
37 typedef unsigned char BufChar;
38 typedef struct _buffile *BufFilePtr;
39
40 typedef 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
52 extern BufFilePtr BufFileCreate (
53     char*,
54     int (*)(BufFilePtr),
55     int (*)(int, BufFilePtr),
56     int (*)(BufFilePtr, int),
57     int (*)(BufFilePtr, int));
58 extern BufFilePtr BufFileOpenRead ( int );
59 extern BufFilePtr BufFileOpenWrite ( int );
60 extern BufFilePtr BufFilePushCompressed ( BufFilePtr );
61 #ifdef X_GZIP_FONT_COMPRESSION
62 extern BufFilePtr BufFilePushZIP ( BufFilePtr );
63 #endif
64 #ifdef X_BZIP2_FONT_COMPRESSION
65 extern BufFilePtr BufFilePushBZIP2 ( BufFilePtr );
66 #endif
67 extern int BufFileClose ( BufFilePtr, int );
68 extern int BufFileRead ( BufFilePtr, char*, int );
69 extern int BufFileWrite ( BufFilePtr, 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