Debian Codegraph @

texk/ps2pk/t1stdio.h

raw
1 /* $XConsortium: t1stdio.h,v 1.4 91/10/10 11:19:49 rws Exp $ */
2 /* Copyright International Business Machines,Corp. 1991
3 * All Rights Reserved
4 *
5 * License to use, copy, modify, and distribute this software
6 * and its documentation for any purpose and without fee is
7 * hereby granted, provided that the above copyright notice
8 * appear in all copies and that both that copyright notice and
9 * this permission notice appear in supporting documentation,
10 * and that the name of IBM not be used in advertising or
11 * publicity pertaining to distribution of the software without
12 * specific, written prior permission.
13 *
14 * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
15 * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
16 * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
18 * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
19 * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
20 * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
21 * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
22 * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
23 * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
25 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
26 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
27 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
28 * SOFTWARE.
29 */
30 /* T1IO FILE structure and related stuff */
31
32 #include "types.h"
33
34 #define FILE F_FILE
35 typedef unsigned char F_char;
36
37 typedef struct F_FILE {
38 F_char *b_base; /* Pointer to beginning of buffer */
39 int32_t b_size; /* Size of the buffer */
40 F_char *b_ptr; /* Pointer to next char in buffer */
41 int32_t b_cnt; /* Number of chars remaining in buffer */
42 F_char flags; /* other flags; != 0 means getc must call fgetc */
43 F_char ungotc; /* Place for ungotten char; flag set if present */
44 short error; /* error status */
45 int fd; /* underlying file descriptor */
46 } F_FILE;
47
48
49 /* defines for flags */
50 #define UNGOTTENC (0x01)
51 #define FIOEOF (0x80)
52 #define FIOERROR (0x40)
53
54 #ifndef NULL
55 #define NULL 0 /* null pointer */
56 #endif
57 #define EOF (-1) /* end of file */
58 #define F_BUFSIZ (512)
59
60 #ifdef fopen
61 #undef fopen
62 #endif
63
64 #ifdef fclose
65 #undef fclose
66 #endif
67
68 #ifdef feof
69 #undef feof
70 #endif
71
72 #ifdef ferror
73 #undef ferror
74 #endif
75
76 #ifdef fread
77 #undef fread
78 #endif
79
80 #ifdef getc
81 #undef getc
82 #endif
83
84 #ifdef ungetc
85 #undef ungetc
86 #endif
87
88 #ifdef fgetc
89 #undef fgetc
90 #endif
91
92 #define getc(f) \
93 ( \
94 ( ((f)->b_cnt > 0) && ((f)->flags == 0) ) ? \
95 ( (f)->b_cnt--, (unsigned int)*( (f)->b_ptr++ ) ) : \
96 T1Getc(f) \
97 )
98
99 extern F_FILE *T1Open(char *, char *), *T1eexec(F_FILE *);
100 extern int T1Close(F_FILE *);
101 extern int T1Read(char *, int, int, F_FILE *),
102 T1Getc(F_FILE *), T1Ungetc(int, F_FILE *);
103
104 #define fclose(f) T1Close(f)
105 #define fopen(name,mode) T1Open(name,mode)
106 #define ungetc(c,f) T1Ungetc(c,f)
107 #define fgetc(f) T1Getc(f)
108 #define fread(bufP,size,n,f) T1Read(bufP,size,n,f)
109 #define feof(f) (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
110 #define ferror(f) (((f)->flags & FIOERROR)?(f)->error:0)