/* internal structure defs for FILE structs and the code that hacks on them */ /* buffer size */ #define BUFSIZE 1024 struct file { unsigned char open_p; /* 1-> this one's open */ unsigned char eof_p; /* 1-> at eof */ unsigned short flags; short handle; /* the file_handle GEMDOS gave us. -1 -> console */ short buf_index; /* idx into buf; signed cause it can be -1 when somebody ungetcs something */ short buf_max; /* end of valid data in buf */ unsigned long file_position; /* nbytes into file of buf */ int last_file_error; /* last error encountered */ short unchar_slush; /* in case we unchar at begin buf */ char buf[BUFSIZE]; /* and the buffer */ }; #define file_output_p(f) \ (((f->flags & 0x03) == O_WRONLY) || ((f->flags & 0x03) == O_RDWR)) #define file_input_p(f) \ (((f->flags & 0x03) == O_RDONLY) || ((f->flags & 0x03) == O_RDWR)) /* values that go in the top byte of the flags word. Note that these must not conflict with the ones in file.h. Sure, it's gross, but this is C, after all. If we had a real language, and could return multiple values etc, the options parser could be much cleaner, and thus this stuff too. Sigh. */ #define FILE_BINARY_P 0x0100 /* this file is open binary mode */ #define FILE_FLUSH_P 0x0200 /* flush after any output op */ /* ... */ #define EOF -1 #define NULL 0 extern struct file * stdin; extern struct file * stdout; extern struct file * stderr;