stdio.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. /* $Id$ */
  8. #ifndef _STDIO_H
  9. #define _STDIO_H
  10. #include <stddef.h>
  11. /*
  12. * Focus point of all stdio activity.
  13. */
  14. typedef struct __iobuf {
  15. int _count;
  16. int _fd;
  17. int _flags;
  18. int _bufsiz;
  19. unsigned char *_buf;
  20. unsigned char *_ptr;
  21. } FILE;
  22. #define _IOFBF 0x000
  23. #define _IOREAD 0x001
  24. #define _IOWRITE 0x002
  25. #define _IONBF 0x004
  26. #define _IOMYBUF 0x008
  27. #define _IOEOF 0x010
  28. #define _IOERR 0x020
  29. #define _IOLBF 0x040
  30. #define _IOREADING 0x080
  31. #define _IOWRITING 0x100
  32. #define _IOAPPEND 0x200
  33. #define SEEK_SET 0
  34. #define SEEK_CUR 1
  35. #define SEEK_END 2
  36. #define stdin (&__stdin)
  37. #define stdout (&__stdout)
  38. #define stderr (&__stderr)
  39. #define BUFSIZ 1024
  40. #define EOF (-1)
  41. #define FOPEN_MAX 20
  42. #define FILENAME_MAX 255
  43. #define TMP_MAX 999
  44. #define L_tmpnam (sizeof("/tmp/") + 15)
  45. typedef long int fpos_t;
  46. extern FILE *__iotab[FOPEN_MAX];
  47. extern FILE __stdin, __stdout, __stderr;
  48. extern int remove(const char *_filename);
  49. extern int rename(const char *_old, const char *_new);
  50. extern FILE *tmpfile(void);
  51. extern char *tmpnam(char *_s);
  52. extern int fclose(FILE *_stream);
  53. extern int fflush(FILE *_stream);
  54. extern FILE *fopen(const char *_filename, const char *_mode);
  55. extern FILE *freopen(const char *_filename, const char *_mode, FILE *_stream);
  56. extern void setbuf(FILE *_stream, char *_buf);
  57. extern int setvbuf(FILE *_stream, char *_buf, int _mode, size_t _size);
  58. extern int fprintf(FILE *_stream, const char *_format, ...);
  59. extern int fscanf(FILE *_stream, const char *_format, ...);
  60. extern int printf(const char *_format, ...);
  61. extern int scanf(const char *_format, ...);
  62. extern int sprintf(char *_s, const char *_format, ...);
  63. extern int sscanf(const char *_s, const char *_format, ...);
  64. extern int vfprintf(FILE *_stream, const char *_format, char *_arg);
  65. extern int vprintf(const char *_format, char *_arg);
  66. extern int vsprintf(char *_s, const char *_format, char *_arg);
  67. extern int fgetc(FILE *_stream);
  68. extern char *fgets(char *_s, int _n, FILE *_stream);
  69. extern int fputc(int _c, FILE *_stream);
  70. extern int fputs(const char *_s, FILE *_stream);
  71. extern int getc(FILE *_stream);
  72. extern int getchar(void);
  73. extern char *gets(char *_s);
  74. extern int putc(int _c, FILE *_stream);
  75. extern int putchar(int _c);
  76. extern int puts(const char *_s);
  77. extern int ungetc(int _c, FILE *_stream);
  78. extern size_t fread(void *_ptr, size_t _size, size_t _nmemb, FILE *_stream);
  79. extern size_t fwrite(const void *_ptr, size_t _size, size_t _nmemb, FILE *_stream);
  80. extern int fgetpos(FILE *_stream, fpos_t *_pos);
  81. extern int fseek(FILE *_stream, long _offset, int _whence);
  82. extern int fsetpos(FILE *_stream, fpos_t *_pos);
  83. extern long ftell(FILE *_stream);
  84. extern void rewind(FILE *_stream);
  85. extern void clearerr(FILE *_stream);
  86. extern int feof(FILE *_stream);
  87. extern int ferror(FILE *_stream);
  88. extern void perror(const char *_s);
  89. extern int __fillbuf(FILE *_stream);
  90. extern int __flushbuf(int _c, FILE *_stream);
  91. #define getchar() getc(stdin)
  92. #define putchar(c) putc(c,stdout)
  93. #define getc(p) (--(p)->_count >= 0 ? (int) (*(p)->_ptr++) : \
  94. __fillbuf(p))
  95. #define putc(c, p) (--(p)->_count >= 0 ? \
  96. (int) (*(p)->_ptr++ = (c)) : \
  97. __flushbuf((c),(p)))
  98. #define feof(p) (((p)->_flags & _IOEOF) != 0)
  99. #define ferror(p) (((p)->_flags & _IOERR) != 0)
  100. #define clearerr(p) ((p)->_flags &= ~(_IOERR|_IOEOF))
  101. /* Non-standard extensions */
  102. extern int fileno(FILE *_stream);
  103. extern FILE* fdopen(int fildes, const char *type);
  104. #define fileno(stream) ((stream)->_fd)
  105. #endif /* _STDIO_H */