1 /* 2 * stdio.h - input/output definitions 3 * 4 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. 5 * See the copyright notice in the ACK home directory, in the file "Copyright". 6 */ 7 /* $Header$ */ 8 9 #ifndef _STDIO_H 10 #define _STDIO_H 11 12 #ifndef _ANSI_H 13 #include <ansi.h> 14 #endif 15 16 /* 17 * Focus point of all stdio activity. 18 */ 19 typedef struct __iobuf { 20 int _count; 21 int _fd; 22 int _flags; 23 int _bufsiz; 24 unsigned char *_buf; 25 unsigned char *_ptr; 26 } FILE; 27 28 #define _IOFBF 0x000 29 #define _IOREAD 0x001 30 #define _IOWRITE 0x002 31 #define _IONBF 0x004 32 #define _IOMYBUF 0x008 33 #define _IOEOF 0x010 34 #define _IOERR 0x020 35 #define _IOLBF 0x040 36 #define _IOREADING 0x080 37 #define _IOWRITING 0x100 38 #define _IOAPPEND 0x200 39 #define _IOFIFO 0x400 40 41 /* The following definitions are also in <unistd.h>. They should not 42 * conflict. 43 */ 44 #define SEEK_SET 0 45 #define SEEK_CUR 1 46 #define SEEK_END 2 47 48 #define stdin (&__stdin) 49 #define stdout (&__stdout) 50 #define stderr (&__stderr) 51 52 #define BUFSIZ 4096 53 #define NULL ((void *)0) 54 #define EOF (-1) 55 56 #define FOPEN_MAX 20 57 58 #include <minix/dir.h> 59 #define FILENAME_MAX DIRSIZ 60 61 #define TMP_MAX 999 62 #define L_tmpnam (sizeof("/tmp/") + FILENAME_MAX) 63 #define __STDIO_VA_LIST__ void * 64 65 typedef long int fpos_t; 66 67 #ifndef _SIZE_T 68 #define _SIZE_T 69 typedef unsigned int size_t; /* type returned by sizeof */ 70 #endif /* _SIZE_T */ 71 72 extern FILE *__iotab[FOPEN_MAX]; 73 extern FILE __stdin, __stdout, __stderr; 74 75 _PROTOTYPE( int remove, (const char *_filename) ); 76 _PROTOTYPE( int rename, (const char *_old, const char *_new) ); 77 _PROTOTYPE( FILE *tmpfile, (void) ); 78 _PROTOTYPE( char *tmpnam, (char *_s) ); 79 _PROTOTYPE( int fclose, (FILE *_stream) ); 80 _PROTOTYPE( int fflush, (FILE *_stream) ); 81 _PROTOTYPE( FILE *fopen, (const char *_filename, const char *_mode) ); 82 _PROTOTYPE( FILE *freopen, 83 (const char *_filename, const char *_mode, FILE *_stream) ); 84 _PROTOTYPE( void setbuf, (FILE *_stream, char *_buf) ); 85 _PROTOTYPE( int setvbuf, 86 (FILE *_stream, char *_buf, int _mode, size_t _size) ); 87 _PROTOTYPE( int fprintf, (FILE *_stream, const char *_format, ...) ); 88 _PROTOTYPE( int printf, (const char *_format, ...) ); 89 _PROTOTYPE( int sprintf, (char *_s, const char *_format, ...) ); 90 _PROTOTYPE( int vfprintf, 91 (FILE *_stream, const char *_format, char *_arg) ); 92 _PROTOTYPE( int vprintf, (const char *_format, char *_arg) ); 93 _PROTOTYPE( int vsprintf, (char *_s, const char *_format, char *_arg) ); 94 _PROTOTYPE( int fscanf, (FILE *_stream, const char *_format, ...) ); 95 _PROTOTYPE( int scanf, (const char *_format, ...) ); 96 _PROTOTYPE( int sscanf, (const char *_s, const char *_format, ...) ); 97 #define vfscanf _doscan 98 _PROTOTYPE( int vfscanf, (FILE *_stream, const char *_format, char *_arg)); 99 _PROTOTYPE( int vscanf, (const char *_format, char *_arg) ); 100 _PROTOTYPE( int vsscanf, (const char *_s, const char *_format, char *_arg)); 101 _PROTOTYPE( int fgetc, (FILE *_stream) ); 102 _PROTOTYPE( char *fgets, (char *_s, int _n, FILE *_stream) ); 103 _PROTOTYPE( int fputc, (int _c, FILE *_stream) ); 104 _PROTOTYPE( int fputs, (const char *_s, FILE *_stream) ); 105 _PROTOTYPE( int getc, (FILE *_stream) ); 106 _PROTOTYPE( int getchar, (void) ); 107 _PROTOTYPE( char *gets, (char *_s) ); 108 _PROTOTYPE( int putc, (int _c, FILE *_stream) ); 109 _PROTOTYPE( int putchar, (int _c) ); 110 _PROTOTYPE( int puts, (const char *_s) ); 111 _PROTOTYPE( int ungetc, (int _c, FILE *_stream) ); 112 _PROTOTYPE( size_t fread, 113 (void *_ptr, size_t _size, size_t _nmemb, FILE *_stream) ); 114 _PROTOTYPE( size_t fwrite, 115 (const void *_ptr, size_t _size, size_t _nmemb, FILE *_stream) ); 116 _PROTOTYPE( int fgetpos, (FILE *_stream, fpos_t *_pos) ); 117 _PROTOTYPE( int fseek, (FILE *_stream, long _offset, int _whence) ); 118 _PROTOTYPE( int fsetpos, (FILE *_stream, fpos_t *_pos) ); 119 _PROTOTYPE( long ftell, (FILE *_stream) ); 120 _PROTOTYPE( void rewind, (FILE *_stream) ); 121 _PROTOTYPE( void clearerr, (FILE *_stream) ); 122 _PROTOTYPE( int feof, (FILE *_stream) ); 123 _PROTOTYPE( int ferror, (FILE *_stream) ); 124 _PROTOTYPE( void perror, (const char *_s) ); 125 _PROTOTYPE( int __fillbuf, (FILE *_stream) ); 126 _PROTOTYPE( int __flushbuf, (int _c, FILE *_stream) ); 127 128 #define getchar() getc(stdin) 129 #define putchar(c) putc(c,stdout) 130 #define getc(p) (--(p)->_count >= 0 ? (int) (*(p)->_ptr++) : \ 131 __fillbuf(p)) 132 #define putc(c, p) (--(p)->_count >= 0 ? \ 133 (int) (*(p)->_ptr++ = (c)) : \ 134 __flushbuf((c),(p))) 135 136 #define feof(p) (((p)->_flags & _IOEOF) != 0) 137 #define ferror(p) (((p)->_flags & _IOERR) != 0) 138 #define clearerr(p) ((p)->_flags &= ~(_IOERR|_IOEOF)) 139 140 #ifdef _POSIX_SOURCE 141 _PROTOTYPE( int fileno, (FILE *_stream) ); 142 _PROTOTYPE (FILE *fdopen, (int _fildes, const char *_types) ); 143 #define fileno(stream) ((stream)->_fd) 144 #define L_ctermid 255 /* required by POSIX */ 145 #define L_cuserid 255 /* required by POSIX */ 146 147 _PROTOTYPE(FILE *popen, (const char *_command, const char *_type)); 148 _PROTOTYPE(int pclose, (FILE *_stream)); 149 _PROTOTYPE(int snprintf, (char *_s, size_t _n, const char *_format, ...)); 150 _PROTOTYPE(int vsnprintf, (char *_s, size_t _n, const char *_format, 151 char *_arg) ); 152 _PROTOTYPE(char *fgetln, (FILE *stream, size_t *len)); 153 #endif 154 155 #endif /* _STDIO_H */ 156