1 #ifndef _STDIO_H 2 #define _STDIO_H 3 4 #ifdef __ICCARM__ /* for iar */ 5 #include_next <stdio.h> 6 int rename(const char *, const char *); 7 #else 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 #include <features.h> 14 15 #define __NEED_FILE 16 #define __NEED___isoc_va_list 17 #define __NEED_size_t 18 19 #if __STDC_VERSION__ < 201112L 20 #define __NEED_struct__IO_FILE 21 #endif 22 23 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 24 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 25 || defined(_BSD_SOURCE) 26 #define __NEED_ssize_t 27 #define __NEED_off_t 28 #define __NEED_va_list 29 #endif 30 31 #include <bits/alltypes.h> 32 33 #ifdef __cplusplus 34 #define NULL 0L 35 #else 36 #define NULL ((void*)0) 37 #endif 38 39 #undef EOF 40 #define EOF (-1) 41 42 #undef SEEK_SET 43 #undef SEEK_CUR 44 #undef SEEK_END 45 #define SEEK_SET 0 46 #define SEEK_CUR 1 47 #define SEEK_END 2 48 49 #define _IOFBF 0 50 #define _IOLBF 1 51 #define _IONBF 2 52 53 #define BUFSIZ 1024 54 #define FILENAME_MAX 4096 55 #define FOPEN_MAX 1000 56 #define TMP_MAX 10000 57 #define L_tmpnam 20 58 59 typedef union _G_fpos64_t { 60 char __opaque[16]; 61 long long __lldata; 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 196 typedef ssize_t (cookie_read_function_t)(void *, char *, size_t); 197 typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t); 198 typedef int (cookie_seek_function_t)(void *, off_t *, int); 199 typedef int (cookie_close_function_t)(void *); 200 201 typedef struct _IO_cookie_io_functions_t { 202 cookie_read_function_t *read; 203 cookie_write_function_t *write; 204 cookie_seek_function_t *seek; 205 cookie_close_function_t *close; 206 } cookie_io_functions_t; 207 208 FILE *fopencookie(void *, const char *, cookie_io_functions_t); 209 #endif 210 211 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) 212 #define tmpfile64 tmpfile 213 #define fopen64 fopen 214 #define freopen64 freopen 215 #define fseeko64 fseeko 216 #define ftello64 ftello 217 #define fgetpos64 fgetpos 218 #define fsetpos64 fsetpos 219 #define fpos64_t fpos_t 220 #define off64_t off_t 221 #endif 222 223 #ifdef __cplusplus 224 } 225 #endif 226 227 #endif /* __ICCARM__ */ 228 #endif 229