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 | |
| 8 | #define __NEED_FILE |
| 9 | #define __NEED_va_list |
| 10 | #define __NEED_size_t |
Rich Felker | 80695b1 | 2011-02-14 05:10:10 -0500 | [diff] [blame] | 11 | |
| 12 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 13 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 14 | #define __NEED_ssize_t |
| 15 | #define __NEED_off_t |
Rich Felker | 80695b1 | 2011-02-14 05:10:10 -0500 | [diff] [blame] | 16 | #endif |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 17 | |
| 18 | #include <bits/alltypes.h> |
| 19 | |
| 20 | #undef NULL |
| 21 | #ifdef __cplusplus |
| 22 | #define NULL 0 |
| 23 | #else |
| 24 | #define NULL ((void*)0) |
| 25 | #endif |
| 26 | |
| 27 | #undef EOF |
| 28 | #define EOF (-1) |
| 29 | |
| 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 | |
| 37 | #define _IOFBF 0 |
| 38 | #define _IOLBF 1 |
| 39 | #define _IONBF 2 |
| 40 | |
Rich Felker | 571312d | 2011-02-15 19:47:22 -0500 | [diff] [blame] | 41 | #define BUFSIZ 1024 |
| 42 | #define FILENAME_MAX 4095 |
| 43 | #define FOPEN_MAX 1000 |
| 44 | #define TMP_MAX 10000 |
| 45 | #define L_tmpnam 20 |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 46 | |
| 47 | typedef union { |
| 48 | char __opaque[16]; |
| 49 | double __align; |
| 50 | } fpos_t; |
| 51 | |
| 52 | extern FILE *const stdin; |
| 53 | extern FILE *const stdout; |
| 54 | extern FILE *const stderr; |
| 55 | |
| 56 | #define stdin (stdin) |
| 57 | #define stdout (stdout) |
| 58 | #define stderr (stderr) |
| 59 | |
| 60 | FILE *fopen(const char *, const char *); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 61 | FILE *freopen(const char *, const char *, FILE *); |
| 62 | int fclose(FILE *); |
| 63 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 64 | int remove(const char *); |
| 65 | int rename(const char *, const char *); |
| 66 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 67 | int feof(FILE *); |
| 68 | int ferror(FILE *); |
| 69 | int fflush(FILE *); |
| 70 | void clearerr(FILE *); |
| 71 | |
| 72 | int fseek(FILE *, long, int); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 73 | long ftell(FILE *); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 74 | void rewind(FILE *); |
| 75 | |
| 76 | int fgetpos(FILE *, fpos_t *); |
| 77 | int fsetpos(FILE *, const fpos_t *); |
| 78 | |
| 79 | size_t fread(void *, size_t, size_t, FILE *); |
| 80 | size_t fwrite(const void *, size_t, size_t, FILE *); |
| 81 | |
| 82 | int fgetc(FILE *); |
| 83 | int getc(FILE *); |
| 84 | int getchar(void); |
| 85 | int ungetc(int, FILE *); |
| 86 | |
| 87 | int fputc(int, FILE *); |
| 88 | int putc(int, FILE *); |
| 89 | int putchar(int); |
| 90 | |
| 91 | char *fgets(char *, int, FILE *); |
| 92 | char *gets(char *); |
| 93 | |
| 94 | int fputs(const char *, FILE *); |
| 95 | int puts(const char *); |
| 96 | |
| 97 | int printf(const char *, ...); |
| 98 | int fprintf(FILE *, const char *, ...); |
| 99 | int sprintf(char *, const char *, ...); |
| 100 | int snprintf(char *, size_t, const char *, ...); |
| 101 | |
| 102 | int vprintf(const char *, va_list); |
| 103 | int vfprintf(FILE *, const char *, va_list); |
| 104 | int vsprintf(char *, const char *, va_list); |
| 105 | int vsnprintf(char *, size_t, const char *, va_list); |
| 106 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 107 | int scanf(const char *, ...); |
| 108 | int fscanf(FILE *, const char *, ...); |
| 109 | int sscanf(const char *, const char *, ...); |
| 110 | int vscanf(const char *, va_list); |
| 111 | int vfscanf(FILE *, const char *, va_list); |
| 112 | int vsscanf(const char *, const char *, va_list); |
| 113 | |
| 114 | void perror(const char *); |
| 115 | |
Rich Felker | 80695b1 | 2011-02-14 05:10:10 -0500 | [diff] [blame] | 116 | int setvbuf(FILE *, char *, int, size_t); |
| 117 | void setbuf(FILE *, char *); |
| 118 | |
| 119 | char *tmpnam(char *); |
| 120 | FILE *tmpfile(void); |
| 121 | |
| 122 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 123 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) |
| 124 | FILE *fdopen(int, const char *); |
| 125 | FILE *popen(const char *, const char *); |
| 126 | int pclose(FILE *); |
| 127 | int fileno(FILE *); |
| 128 | int fseeko(FILE *, off_t, int); |
| 129 | off_t ftello(FILE *); |
| 130 | int dprintf(int, const char *, ...); |
| 131 | int vdprintf(int, const char *, va_list); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 132 | void flockfile(FILE *); |
| 133 | int ftrylockfile(FILE *); |
| 134 | void funlockfile(FILE *); |
| 135 | int getc_unlocked(FILE *); |
| 136 | int getchar_unlocked(void); |
| 137 | int putc_unlocked(int, FILE *); |
| 138 | int putchar_unlocked(int); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 139 | ssize_t getdelim(char **, size_t *, int, FILE *); |
| 140 | ssize_t getline(char **, size_t *, FILE *); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 141 | int renameat(int, const char *, int, const char *); |
Rich Felker | 80695b1 | 2011-02-14 05:10:10 -0500 | [diff] [blame] | 142 | char *ctermid(char *); |
Rich Felker | 571312d | 2011-02-15 19:47:22 -0500 | [diff] [blame] | 143 | #define L_ctermid 20 |
Rich Felker | 80695b1 | 2011-02-14 05:10:10 -0500 | [diff] [blame] | 144 | #endif |
| 145 | |
| 146 | |
| 147 | #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) |
Rich Felker | 571312d | 2011-02-15 19:47:22 -0500 | [diff] [blame] | 148 | #define P_tmpdir "/tmp" |
Rich Felker | 80695b1 | 2011-02-14 05:10:10 -0500 | [diff] [blame] | 149 | char *tempnam(const char *, const char *); |
| 150 | #endif |
| 151 | |
| 152 | #if defined(_GNU_SOURCE) |
Rich Felker | 571312d | 2011-02-15 19:47:22 -0500 | [diff] [blame] | 153 | #define L_cuserid 20 |
| 154 | char *cuserid(char *); |
Rich Felker | 80695b1 | 2011-02-14 05:10:10 -0500 | [diff] [blame] | 155 | #undef off64_t |
| 156 | #define off64_t off_t |
Rich Felker | 46b9942 | 2011-02-20 17:17:09 -0500 | [diff] [blame] | 157 | int asprintf(char **, const char *, ...); |
| 158 | int vasprintf(char **, const char *, va_list); |
Rich Felker | e721800 | 2011-04-05 12:25:31 -0400 | [diff] [blame] | 159 | void setlinebuf(FILE *); |
| 160 | void setbuffer(FILE *, char *, size_t); |
Rich Felker | 7640497 | 2011-06-30 11:42:33 -0400 | [diff] [blame^] | 161 | int fpurge(FILE *); |
Rich Felker | 80695b1 | 2011-02-14 05:10:10 -0500 | [diff] [blame] | 162 | #endif |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 163 | |
| 164 | #ifdef __cplusplus |
| 165 | } |
| 166 | #endif |
| 167 | |
| 168 | #endif |