Back to index

tetex-bin  3.0
t1stdio.h
Go to the documentation of this file.
00001 /* $XConsortium: t1stdio.h,v 1.4 91/10/10 11:19:49 rws Exp $ */
00002 /* Copyright International Business Machines,Corp. 1991
00003  * All Rights Reserved
00004  *
00005  * License to use, copy, modify, and distribute this software
00006  * and its documentation for any purpose and without fee is
00007  * hereby granted, provided that the above copyright notice
00008  * appear in all copies and that both that copyright notice and
00009  * this permission notice appear in supporting documentation,
00010  * and that the name of IBM not be used in advertising or
00011  * publicity pertaining to distribution of the software without
00012  * specific, written prior permission.
00013  *
00014  * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
00015  * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
00016  * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
00018  * THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE QUALITY AND
00019  * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
00020  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF
00021  * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
00022  * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN
00023  * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00024  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
00025  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
00026  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
00027  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00028  * SOFTWARE.
00029  */
00030 /* T1IO FILE structure and related stuff */
00031 
00032 #include "types.h"
00033 
00034 #define FILE F_FILE
00035 typedef unsigned char F_char;
00036  
00037 typedef struct F_FILE {
00038   F_char  *b_base;    /* Pointer to beginning of buffer */
00039   LONG    b_size;     /* Size of the buffer */
00040   F_char  *b_ptr;     /* Pointer to next char in buffer */
00041   LONG    b_cnt;      /* Number of chars remaining in buffer */
00042   F_char  flags;      /* other flags; != 0 means getc must call fgetc */
00043   F_char  ungotc;     /* Place for ungotten char; flag set if present */
00044   short   error;      /* error status */
00045   int     fd;         /* underlying file descriptor */
00046 } F_FILE;
00047  
00048  
00049 /* defines for flags */
00050 #define UNGOTTENC (0x01)
00051 #define FIOEOF    (0x80)
00052 #define FIOERROR  (0x40)
00053  
00054 #ifndef NULL
00055 #define NULL 0       /* null pointer */
00056 #endif
00057 #define EOF (-1)     /* end of file */
00058 #define F_BUFSIZ (512)
00059  
00060 #ifdef fopen
00061 #undef fopen
00062 #endif
00063 
00064 #ifdef fclose
00065 #undef fclose
00066 #endif
00067 
00068 #ifdef feof
00069 #undef feof
00070 #endif
00071 
00072 #ifdef ferror
00073 #undef ferror
00074 #endif
00075 
00076 #ifdef fread
00077 #undef fread
00078 #endif
00079 
00080 #ifdef getc
00081 #undef getc
00082 #endif
00083 
00084 #ifdef ungetc
00085 #undef ungetc
00086 #endif
00087 
00088 #ifdef fgetc
00089 #undef fgetc
00090 #endif
00091  
00092 #define getc(f) \
00093   ( \
00094    ( ((f)->b_cnt > 0) && ((f)->flags == 0) ) ? \
00095    ( (f)->b_cnt--, (unsigned int)*( (f)->b_ptr++ ) ) : \
00096    T1Getc(f) \
00097   )
00098  
00099 extern FILE *T1Open(), *T1eexec();
00100 extern int T1Close(), T1ungetc(), T1Read();
00101  
00102 #define  fclose(f)          T1Close(f)
00103 #define  fopen(name,mode)   T1Open(name,mode)
00104 #define  ungetc(c,f)        T1Ungetc(c,f)
00105 #define  fgetc(f)           T1Getc(f)
00106 #define  fread(bufP,size,n,f) T1Read(bufP,size,n,f)
00107 #define  feof(f)            (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
00108 #define  ferror(f)          (((f)->flags & FIOERROR)?(f)->error:0)