stdio.h 3.7 KB

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