1 /* $XConsortium: t1stdio.h,v 1.4 91/10/10 11:19:49 rws Exp $ */
2 /* Copyright International Business Machines,Corp. 1991
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.
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
30 /* T1IO FILE structure and related stuff */
32 typedef unsigned char F_char;
34 typedef struct F_FILE {
35 F_char *b_base; /* Pointer to beginning of buffer */
36 long b_size; /* Size of the buffer */
37 F_char *b_ptr; /* Pointer to next char in buffer */
38 long b_cnt; /* Number of chars remaining in buffer */
39 F_char flags; /* other flags; != 0 means getc must call fgetc */
40 F_char ungotc; /* Place for ungotten char; flag set if present */
41 short error; /* error status */
42 int fd; /* underlying file descriptor */
46 /* defines for flags */
47 #define UNGOTTENC (0x01)
49 #define FIOERROR (0x40)
52 #define NULL 0 /* null pointer */
54 #define EOF (-1) /* end of file */
55 #define F_BUFSIZ (512)
59 ( ((f)->b_cnt > 0) && ((f)->flags == 0) ) ? \
60 ( (f)->b_cnt--, (unsigned int)*( (f)->b_ptr++ ) ) : \
64 extern FILE *T1Open(), *T1eexec();
65 extern int T1Close(), T1ungetc(), T1Read();
67 #define fclose(f) T1Close(f)
68 #define fopen(name,mode) T1Open(name,mode)
69 #define ungetc(c,f) T1Ungetc(c,f)
70 #define fgetc(f) T1Getc(f)
71 #define fread(bufP,size,n,f) T1Read(bufP,size,n,f)
72 #define feof(f) (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
73 #define ferror(f) (((f)->flags & FIOERROR)?(f)->error:0)