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