stdio.h

Go to the documentation of this file.
00001 /*
00002  * stdio.h - input/output definitions
00003  *
00004  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
00005  * See the copyright notice in the ACK home directory, in the file "Copyright".
00006  */
00007 /* $Header: /opt/proj/minix/cvsroot/src/include/stdio.h,v 1.2 2005/09/01 13:07:08 beng Exp $ */
00008 
00009 #ifndef _STDIO_H
00010 #define _STDIO_H
00011 
00012 #ifndef _ANSI_H
00013 #include <ansi.h>
00014 #endif
00015 
00016 /*
00017  * Focus point of all stdio activity.
00018  */
00019 typedef struct __iobuf {
00020         int             _count;
00021         int             _fd;
00022         int             _flags;
00023         int             _bufsiz;
00024         unsigned char   *_buf;
00025         unsigned char   *_ptr;
00026 } FILE;
00027 
00028 #define _IOFBF          0x000
00029 #define _IOREAD         0x001
00030 #define _IOWRITE        0x002
00031 #define _IONBF          0x004
00032 #define _IOMYBUF        0x008
00033 #define _IOEOF          0x010
00034 #define _IOERR          0x020
00035 #define _IOLBF          0x040
00036 #define _IOREADING      0x080
00037 #define _IOWRITING      0x100
00038 #define _IOAPPEND       0x200
00039 #define _IOFIFO         0x400
00040 
00041 /* The following definitions are also in <unistd.h>. They should not
00042  * conflict.
00043  */
00044 #define SEEK_SET        0
00045 #define SEEK_CUR        1
00046 #define SEEK_END        2
00047 
00048 #define stdin           (&__stdin)
00049 #define stdout          (&__stdout)
00050 #define stderr          (&__stderr)
00051 
00052 #define BUFSIZ          1024
00053 #define NULL            ((void *)0)
00054 #define EOF             (-1)
00055 
00056 #define FOPEN_MAX       20
00057 
00058 #include <sys/dir.h>
00059 #define FILENAME_MAX    DIRSIZ
00060 
00061 #define TMP_MAX         999
00062 #define L_tmpnam        (sizeof("/tmp/") + FILENAME_MAX)
00063 #define __STDIO_VA_LIST__       void *
00064 
00065 typedef long int        fpos_t;
00066 
00067 #ifndef _SIZE_T
00068 #define _SIZE_T
00069 typedef unsigned int    size_t;         /* type returned by sizeof */
00070 #endif /* _SIZE_T */
00071 
00072 extern FILE     *__iotab[FOPEN_MAX];
00073 extern FILE     __stdin, __stdout, __stderr;
00074 
00075 _PROTOTYPE( int remove, (const char *_filename)                         );
00076 _PROTOTYPE( int rename, (const char *_old, const char *_new)            );
00077 _PROTOTYPE( FILE *tmpfile, (void)                                       );
00078 _PROTOTYPE( char *tmpnam, (char *_s)                                    );
00079 _PROTOTYPE( int fclose, (FILE *_stream)                                 );
00080 _PROTOTYPE( int fflush, (FILE *_stream)                                 );
00081 _PROTOTYPE( FILE *fopen, (const char *_filename, const char *_mode)     );
00082 _PROTOTYPE( FILE *freopen,
00083             (const char *_filename, const char *_mode, FILE *_stream)   );
00084 _PROTOTYPE( void setbuf, (FILE *_stream, char *_buf)                    );
00085 _PROTOTYPE( int setvbuf,
00086                 (FILE *_stream, char *_buf, int _mode, size_t _size)    );
00087 _PROTOTYPE( int fprintf, (FILE *_stream, const char *_format, ...)      );
00088 _PROTOTYPE( int printf, (const char *_format, ...)                      );
00089 _PROTOTYPE( int sprintf, (char *_s, const char *_format, ...)           );
00090 _PROTOTYPE( int vfprintf,
00091                 (FILE *_stream, const char *_format, char *_arg)        );
00092 _PROTOTYPE( int vprintf, (const char *_format, char *_arg)              );
00093 _PROTOTYPE( int vsprintf, (char *_s, const char *_format, char *_arg)   );
00094 _PROTOTYPE( int fscanf, (FILE *_stream, const char *_format, ...)       );
00095 _PROTOTYPE( int scanf, (const char *_format, ...)                       );
00096 _PROTOTYPE( int sscanf, (const char *_s, const char *_format, ...)      );
00097 #define vfscanf _doscan
00098 _PROTOTYPE( int vfscanf, (FILE *_stream, const char *_format, char *_arg));
00099 _PROTOTYPE( int vscanf, (const char *_format, char *_arg)               );
00100 _PROTOTYPE( int vsscanf, (const char *_s, const char *_format, char *_arg));
00101 _PROTOTYPE( int fgetc, (FILE *_stream)                                  );
00102 _PROTOTYPE( char *fgets, (char *_s, int _n, FILE *_stream)              );
00103 _PROTOTYPE( int fputc, (int _c, FILE *_stream)                          );
00104 _PROTOTYPE( int fputs, (const char *_s, FILE *_stream)                  );
00105 _PROTOTYPE( int getc, (FILE *_stream)                                   );
00106 _PROTOTYPE( int getchar, (void)                                         );
00107 _PROTOTYPE( char *gets, (char *_s)                                      );
00108 _PROTOTYPE( int putc, (int _c, FILE *_stream)                           );
00109 _PROTOTYPE( int putchar, (int _c)                                       );
00110 _PROTOTYPE( int puts, (const char *_s)                                  );
00111 _PROTOTYPE( int ungetc, (int _c, FILE *_stream)                         );
00112 _PROTOTYPE( size_t fread,
00113             (void *_ptr, size_t _size, size_t _nmemb, FILE *_stream)    );
00114 _PROTOTYPE( size_t fwrite,
00115         (const void *_ptr, size_t _size, size_t _nmemb, FILE *_stream)  );
00116 _PROTOTYPE( int fgetpos, (FILE *_stream, fpos_t *_pos)                  );
00117 _PROTOTYPE( int fseek, (FILE *_stream, long _offset, int _whence)       );
00118 _PROTOTYPE( int fsetpos, (FILE *_stream, fpos_t *_pos)                  );
00119 _PROTOTYPE( long ftell, (FILE *_stream)                                 );
00120 _PROTOTYPE( void rewind, (FILE *_stream)                                );
00121 _PROTOTYPE( void clearerr, (FILE *_stream)                              );
00122 _PROTOTYPE( int feof, (FILE *_stream)                                   );
00123 _PROTOTYPE( int ferror, (FILE *_stream)                                 );
00124 _PROTOTYPE( void perror, (const char *_s)                               );
00125 _PROTOTYPE( int __fillbuf, (FILE *_stream)                              );
00126 _PROTOTYPE( int __flushbuf, (int _c, FILE *_stream)                     );
00127 
00128 #define getchar()       getc(stdin)
00129 #define putchar(c)      putc(c,stdout)
00130 #define getc(p)         (--(p)->_count >= 0 ? (int) (*(p)->_ptr++) : \
00131                                 __fillbuf(p))
00132 #define putc(c, p)      (--(p)->_count >= 0 ? \
00133                          (int) (*(p)->_ptr++ = (c)) : \
00134                          __flushbuf((c),(p)))
00135 
00136 #define feof(p)         (((p)->_flags & _IOEOF) != 0)
00137 #define ferror(p)       (((p)->_flags & _IOERR) != 0)
00138 #define clearerr(p)     ((p)->_flags &= ~(_IOERR|_IOEOF))
00139 
00140 #ifdef _POSIX_SOURCE
00141 _PROTOTYPE( int fileno, (FILE *_stream)                                 );
00142 _PROTOTYPE (FILE *fdopen, (int _fildes, const char *_types) );
00143 #define fileno(stream)          ((stream)->_fd)
00144 #define L_ctermid 255   /* required by POSIX */
00145 #define L_cuserid 255   /* required by POSIX */
00146 #endif
00147 
00148 #ifdef _MINIX
00149 _PROTOTYPE(FILE *popen, (const char *_command, const char *_type));
00150 _PROTOTYPE(int pclose, (FILE *_stream));
00151 _PROTOTYPE(int snprintf, (char *_s, size_t _n, const char *_format, ...));
00152 _PROTOTYPE(int vsnprintf, (char *_s, size_t _n, const char *_format,
00153                                                         char *_arg)     );
00154 #endif
00155 
00156 #endif /* _STDIO_H */

Generated on Fri Apr 14 22:57:21 2006 for minix by  doxygen 1.4.6