stdio.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #ifndef _STDIO_H
  2. #define _STDIO_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #define __NEED_FILE
  8. #define __NEED___isoc_va_list
  9. #define __NEED_size_t
  10. #if __STDC_VERSION__ < 201112L
  11. #define __NEED_struct__IO_FILE
  12. #endif
  13. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  14. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  15. || defined(_BSD_SOURCE)
  16. #define __NEED_ssize_t
  17. #define __NEED_off_t
  18. #define __NEED_va_list
  19. #endif
  20. #include <bits/alltypes.h>
  21. #if __cplusplus >= 201103L
  22. #define NULL nullptr
  23. #elif defined(__cplusplus)
  24. #define NULL 0L
  25. #else
  26. #define NULL ((void*)0)
  27. #endif
  28. #undef EOF
  29. #define EOF (-1)
  30. #undef SEEK_SET
  31. #undef SEEK_CUR
  32. #undef SEEK_END
  33. #define SEEK_SET 0
  34. #define SEEK_CUR 1
  35. #define SEEK_END 2
  36. #define _IOFBF 0
  37. #define _IOLBF 1
  38. #define _IONBF 2
  39. #define BUFSIZ 1024
  40. #define FILENAME_MAX 4096
  41. #define FOPEN_MAX 1000
  42. #define TMP_MAX 10000
  43. #define L_tmpnam 20
  44. typedef union _G_fpos64_t {
  45. char __opaque[16];
  46. long long __lldata;
  47. double __align;
  48. } fpos_t;
  49. extern FILE *const stdin;
  50. extern FILE *const stdout;
  51. extern FILE *const stderr;
  52. #define stdin (stdin)
  53. #define stdout (stdout)
  54. #define stderr (stderr)
  55. FILE *fopen(const char *__restrict, const char *__restrict);
  56. FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
  57. int fclose(FILE *);
  58. int remove(const char *);
  59. int rename(const char *, const char *);
  60. int feof(FILE *);
  61. int ferror(FILE *);
  62. int fflush(FILE *);
  63. void clearerr(FILE *);
  64. int fseek(FILE *, long, int);
  65. long ftell(FILE *);
  66. void rewind(FILE *);
  67. int fgetpos(FILE *__restrict, fpos_t *__restrict);
  68. int fsetpos(FILE *, const fpos_t *);
  69. size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
  70. size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
  71. int fgetc(FILE *);
  72. int getc(FILE *);
  73. int getchar(void);
  74. int ungetc(int, FILE *);
  75. int fputc(int, FILE *);
  76. int putc(int, FILE *);
  77. int putchar(int);
  78. char *fgets(char *__restrict, int, FILE *__restrict);
  79. #if __STDC_VERSION__ < 201112L
  80. char *gets(char *);
  81. #endif
  82. int fputs(const char *__restrict, FILE *__restrict);
  83. int puts(const char *);
  84. int printf(const char *__restrict, ...);
  85. int fprintf(FILE *__restrict, const char *__restrict, ...);
  86. int sprintf(char *__restrict, const char *__restrict, ...);
  87. int snprintf(char *__restrict, size_t, const char *__restrict, ...);
  88. int vprintf(const char *__restrict, __isoc_va_list);
  89. int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
  90. int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
  91. int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
  92. int scanf(const char *__restrict, ...);
  93. int fscanf(FILE *__restrict, const char *__restrict, ...);
  94. int sscanf(const char *__restrict, const char *__restrict, ...);
  95. int vscanf(const char *__restrict, __isoc_va_list);
  96. int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
  97. int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
  98. void perror(const char *);
  99. int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
  100. void setbuf(FILE *__restrict, char *__restrict);
  101. char *tmpnam(char *);
  102. FILE *tmpfile(void);
  103. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  104. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  105. || defined(_BSD_SOURCE)
  106. FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
  107. FILE *open_memstream(char **, size_t *);
  108. FILE *fdopen(int, const char *);
  109. FILE *popen(const char *, const char *);
  110. int pclose(FILE *);
  111. int fileno(FILE *);
  112. int fseeko(FILE *, off_t, int);
  113. off_t ftello(FILE *);
  114. int dprintf(int, const char *__restrict, ...);
  115. int vdprintf(int, const char *__restrict, __isoc_va_list);
  116. void flockfile(FILE *);
  117. int ftrylockfile(FILE *);
  118. void funlockfile(FILE *);
  119. int getc_unlocked(FILE *);
  120. int getchar_unlocked(void);
  121. int putc_unlocked(int, FILE *);
  122. int putchar_unlocked(int);
  123. ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
  124. ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
  125. int renameat(int, const char *, int, const char *);
  126. char *ctermid(char *);
  127. #define L_ctermid 20
  128. #endif
  129. #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  130. || defined(_BSD_SOURCE)
  131. #define P_tmpdir "/tmp"
  132. char *tempnam(const char *, const char *);
  133. #endif
  134. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  135. #define L_cuserid 20
  136. char *cuserid(char *);
  137. void setlinebuf(FILE *);
  138. void setbuffer(FILE *, char *, size_t);
  139. int fgetc_unlocked(FILE *);
  140. int fputc_unlocked(int, FILE *);
  141. int fflush_unlocked(FILE *);
  142. size_t fread_unlocked(void *, size_t, size_t, FILE *);
  143. size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
  144. void clearerr_unlocked(FILE *);
  145. int feof_unlocked(FILE *);
  146. int ferror_unlocked(FILE *);
  147. int fileno_unlocked(FILE *);
  148. int getw(FILE *);
  149. int putw(int, FILE *);
  150. char *fgetln(FILE *, size_t *);
  151. int asprintf(char **, const char *, ...);
  152. int vasprintf(char **, const char *, __isoc_va_list);
  153. #endif
  154. #ifdef _GNU_SOURCE
  155. char *fgets_unlocked(char *, int, FILE *);
  156. int fputs_unlocked(const char *, FILE *);
  157. typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
  158. typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
  159. typedef int (cookie_seek_function_t)(void *, off_t *, int);
  160. typedef int (cookie_close_function_t)(void *);
  161. typedef struct _IO_cookie_io_functions_t {
  162. cookie_read_function_t *read;
  163. cookie_write_function_t *write;
  164. cookie_seek_function_t *seek;
  165. cookie_close_function_t *close;
  166. } cookie_io_functions_t;
  167. FILE *fopencookie(void *, const char *, cookie_io_functions_t);
  168. #endif
  169. #if defined(_LARGEFILE64_SOURCE)
  170. #define tmpfile64 tmpfile
  171. #define fopen64 fopen
  172. #define freopen64 freopen
  173. #define fseeko64 fseeko
  174. #define ftello64 ftello
  175. #define fgetpos64 fgetpos
  176. #define fsetpos64 fsetpos
  177. #define fpos64_t fpos_t
  178. #define off64_t off_t
  179. #endif
  180. #ifdef __cplusplus
  181. }
  182. #endif
  183. #endif