Merge branch 'master' into cde-next
[oweals/cde.git] / cde / lib / DtHelp / bufioI.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: bufioI.h /main/5 1995/10/26 12:36:33 rswiston $ */
24 #ifndef _DtHelpbufioI_h
25 #define _DtHelpbufioI_h
26
27 #include <stdio.h>              /* for FILE */
28
29 #ifndef NULL
30 #define NULL    0
31 #endif
32
33 #define BUFFILESIZE     4096
34 #define BUFFILEEOF      -1
35
36 typedef unsigned char BufChar;
37
38 typedef struct _buffile {
39     BufChar *bufp;
40     int     left;
41     BufChar buffer[BUFFILESIZE];
42     int     (*io)(/* BufFilePtr f */);
43     int     (*skip)(/* BufFilePtr f, int count */);
44     int     (*close)(/* BufFilePtr f */);
45     char    *hidden;
46 } BufFileRec, *BufFilePtr;
47
48 typedef struct _compressInfo{
49     int     fd;
50     int     size;
51 } CECompressInfo, *CECompressInfoPtr;
52
53 extern BufFilePtr   __DtBufFileCreate ();
54 extern BufFilePtr   _DtHelpCeBufFilePushZ ();
55 extern BufFilePtr   _DtHelpCeBufFileOpenWr ();
56 extern int          _DtHelpCeBufFileFlush ();
57 #define BufFileGet(f)   ((f)->left-- ? *(f)->bufp++ : (*(f)->io) (f))
58 #define BufFilePut(c,f) (--(f)->left ? *(f)->bufp++ = (c) : (*(f)->io) (c,f))
59 #define BufFilePutBack(c,f) { (f)->left++; *(--(f)->bufp) = (c); }
60 #define BufFileSkip(f,c)    ((*(f)->skip) (f, c))
61
62 #define FileStream(f)   ((FILE *)(f)->hidden)
63
64 extern  void            _DtHelpCeBufFileClose (
65                                 BufFilePtr      f,
66                                 int             doClose);
67 extern  BufFilePtr      _DtHelpCeBufFileCreate (
68                                 char            *hidden,
69                                 int             (*io)(),
70                                 int             (*skip)(),
71                                 int             (*close)());
72 extern  int             _DtHelpCeBufFileRd (
73                                 BufFilePtr       f,
74                                 char            *buffer,
75                                 int              request_size);
76 extern  BufFilePtr      _DtHelpCeBufFileRdWithFd (
77                                 int             fd);
78 extern  BufFilePtr      _DtHelpCeBufFileRdRawZ (
79                                 CECompressInfoPtr  file_info);
80 extern  BufFilePtr      _DtHelpCeCreatePipeBufFile (
81                                 FILE            *stream);
82 extern  int             _DtHelpCeUncompressFile (
83                                 char            *in_file,
84                                 char            *out_file);
85
86 #ifndef TRUE
87 #define TRUE 1
88 #endif
89 #ifndef FALSE
90 #define FALSE 0
91 #endif
92
93 #endif /* _DtHelpbufioI_h */