home *** CD-ROM | disk | FTP | other *** search
- /*
- * This defines a VAX-11 "C" runtime compatible stdio interface
- */
- #ifndef __STDIO_DEFINED
- #define __STDIO_DEFINED
-
- /*
- * The maximum number of files we can have open at a time
- */
- #define _NFILE 20
-
- /*
- * STDIO buffer size (sure wish it could be 1Kb)
- */
- #define BUFSIZ 512
- /* # define _IONBF 0 */
- # define _IOLBF 1
- # define _IOFBF 2
-
- #define _IOREAD 0x01
- #define _IOWRT 0x02
- #define _IONBF 0x04
- #define _IOMYBUF 0x08
- #define _IOEOF 0x10
- #define _IOERR 0x20
- #define _IOSTRG 0x40
- #define _IORW 0x80
-
-
- /*
- * This is what the VAX-11 "C" runtime stdio FILE structure looks like
- */
- struct _iobuf {
- int _cnt; /* # of characters in the buffer */
- char *_ptr; /* Pointer into the buffer */
- char *_base; /* Pointer to start of buffer */
- char _flag; /* STDIO flags */
- char _file; /* File descriptor */
- };
-
- /*
- * Instead of passing around pointers to _iobuf structures, VAX-11 "C"
- * passes around pointers to pointers.
- */
- typedef struct _iobuf *FILE;
-
- /*
- * Also, stdin/stdout/stderr need to be defined
- * [We also use a hack here that makes the GCC assembler modify
- * the psect attributes to match those of the VAX-11 "C" runtime]
- */
- #ifdef vax11c
- extern noshare FILE *stdin, *stdout, *stderr;
- #else
- #define stdin $$PsectAttributes_NOSHR$$stdin
- #define stdout $$PsectAttributes_NOSHR$$stdout
- #define stderr $$PsectAttributes_NOSHR$$stderr
- extern FILE *stdin;
- extern FILE *stdout;
- extern FILE *stderr;
- #endif
-
- /*
- * Define NULL and EOF
- */
- #define NULL 0
- #define EOF (-1)
-
- /*
- * Define the stdio macros
- */
- #define getc(p) fgetc(p)
- #define getchar() fgetc(stdin)
- #define putc(x,p) fputc(x,p)
- #define putchar(x) fputc(x,stdout)
- #define feof(p) (((*p)->_flag&_IOEOF)!=0)
- #define ferror(p) (p == stdout) ? 0 : (((*p)->_flag&_IOERR)!=0)
- #define fileno(p) ((*p)->_file)
- #define clearerr(p) ((*p)->_flag &= ~(_IOERR|_IOEOF))
-
- /*
- * Declare stdio routines
- */
- FILE *fopen();
- FILE *fdopen();
- FILE *freopen();
- char *fgets();
- long ftell();
-
- #define random rand
- #define srandom srand
- #endif __STDIO_DEFINED
-