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