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