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