123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- #ifndef __STDIO_H
- #define __STDIO_H
- #include <features.h>
- #include <stdarg.h>
- #include <sys/types.h>
- #ifndef SEEK_SET
- #define SEEK_SET 0
- #define SEEK_CUR 1
- #define SEEK_END 2
- #endif
- #define _IOFBF 0x00
- #define _IOLBF 0x01
- #define _IONBF 0x02
- #define __MODE_BUF 0x03
- #define __MODE_FREEBUF 0x04
- #define __MODE_FREEFIL 0x08
- #define __MODE_READ 0x10
- #define __MODE_WRITE 0x20
- #define __MODE_RDWR 0x30
- #define __MODE_READING 0x40
- #define __MODE_WRITING 0x80
- #define __MODE_EOF 0x100
- #define __MODE_ERR 0x200
- #define __MODE_UNGOT 0x400
- #define __MODE_IOTRAN 0
- struct __stdio_file {
- unsigned char *bufpos;
- unsigned char *bufread;
- unsigned char *bufwrite;
- unsigned char *bufstart;
- unsigned char *bufend;
- int fd;
- int mode;
- char unbuf[8];
- struct __stdio_file * next;
- };
- #define EOF (-1)
- #ifndef NULL
- #define NULL (0)
- #endif
- typedef struct __stdio_file FILE;
- #define BUFSIZ (500)
- extern FILE stdin[1];
- extern FILE stdout[1];
- extern FILE stderr[1];
- #define stdio_pending(fp) ((fp)->bufread>(fp)->bufpos)
- extern size_t fread __P ((void *__restrict __ptr, size_t __size,
- size_t __n, FILE *__restrict __stream));
- extern size_t fwrite __P ((__const void *__restrict __ptr, size_t __size,
- size_t __n, FILE *__restrict __s));
- #define putc(c, stream) \
- (((stream)->bufpos >= (stream)->bufwrite) ? fputc((c), (stream)) \
- : (unsigned char) (*(stream)->bufpos++ = (c)) )
- #define getc(stream) \
- (((stream)->bufpos >= (stream)->bufread) ? fgetc(stream): \
- (*(stream)->bufpos++))
- #define putchar(c) putc((c), stdout)
- #define getchar() getc(stdin)
- #define ferror(fp) (((fp)->mode&__MODE_ERR) != 0)
- #define feof(fp) (((fp)->mode&__MODE_EOF) != 0)
- #define clearerr(fp) ((fp)->mode &= ~(__MODE_EOF|__MODE_ERR),0)
- #define fileno(fp) ((fp)->fd)
- #define setlinebuf(__fp) setvbuf((__fp), (char*)0, _IOLBF, 0)
- extern int setvbuf __P((FILE*, char*, int, size_t));
- #define setbuf(__fp, __buf) setbuffer((__fp), (__buf), BUFSIZ)
- extern void setbuffer __P((FILE*, char*, int));
- extern int fgetc __P ((FILE *__stream));
- extern int getc __P ((FILE *__stream));
- extern int ungetc __P ((int __c, FILE *__stream));
- extern int getchar __P ((void));
- extern int fputc __P ((int __c, FILE *__stream));
- extern int putc __P ((int __c, FILE *__stream));
- extern int putchar __P ((int __c));
- extern int fclose __P ((FILE *__stream));
- extern int fflush __P ((FILE *__stream));
- extern char *gets __P ((char *__s));
- extern char *fgets __P ((char *__restrict __s, int __n,
- FILE *__restrict __stream));
- extern FILE *__fopen __P((__const char *__restrict __filename, int __fd,
- FILE *__restrict __stream, __const char *__restrict __modes));
- #define fopen(__file, __mode) __fopen((__file), -1, (FILE*)0, (__mode))
- #define freopen(__file, __mode, __fp) __fopen((__file), -1, (__fp), (__mode))
- #define fdopen(__file, __mode) __fopen((char*)0, (__file), (FILE*)0, (__mode))
- extern int fseek __P ((FILE *__stream, long int __off, int __whence));
- extern long int ftell __P ((FILE *__stream));
- extern void rewind __P ((FILE *__stream));
- extern int puts __P ((__const char *__s));
- extern int fputs __P ((__const char *__restrict __s,
- FILE *__restrict __stream));
- extern int printf __P ((__const char *__restrict __format, ...));
- extern int fprintf __P ((FILE *__restrict __stream,
- __const char *__restrict __format, ...));
- extern int sprintf __P ((char *__restrict __s,
- __const char *__restrict __format, ...));
- extern int vprintf __P ((__const char *__restrict __format,
- va_list __arg));
- extern int vfprintf __P ((FILE *__restrict __s,
- __const char *__restrict __format,
- va_list __arg));
- extern int vsprintf __P ((char *__restrict __s,
- __const char *__restrict __format,
- va_list __arg));
- extern int scanf __P ((__const char *__restrict __format, ...));
- extern int sscanf __P ((__const char *__restrict __s,
- __const char *__restrict __format, ...));
- extern int fscanf __P ((FILE *__restrict __stream,
- __const char *__restrict __format, ...));
- extern int vscanf __P ((__const char *__restrict __format, va_list __arg))
- __attribute__ ((__format__ (__scanf__, 1, 0)));
- extern int vsscanf __P ((__const char *__restrict __s,
- __const char *__restrict __format,
- va_list __arg))
- __attribute__ ((__format__ (__scanf__, 2, 0)));
- extern int vfscanf __P ((FILE *__restrict __s,
- __const char *__restrict __format,
- va_list __arg))
- __attribute__ ((__format__ (__scanf__, 2, 0)));
- extern void perror __P ((__const char *__s));
- #endif
|