stdio.h 5.8 KB
Newer Older
R
Rich Felker 已提交
1 2 3
#ifndef _STDIO_H
#define _STDIO_H

4 5 6 7 8
#ifdef __ICCARM__ /* for iar */
#include_next <stdio.h>
int rename(const char *, const char *);
#else

R
Rich Felker 已提交
9 10 11 12
#ifdef __cplusplus
extern "C" {
#endif

13
#include <features.h>
14

R
Rich Felker 已提交
15
#define __NEED_FILE
16
#define __NEED___isoc_va_list
R
Rich Felker 已提交
17
#define __NEED_size_t
18

19 20 21 22
#if __STDC_VERSION__ < 201112L
#define __NEED_struct__IO_FILE
#endif

23
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
24 25
 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
 || defined(_BSD_SOURCE)
R
Rich Felker 已提交
26 27
#define __NEED_ssize_t
#define __NEED_off_t
28
#define __NEED_va_list
29
#endif
R
Rich Felker 已提交
30 31 32

#include <bits/alltypes.h>

33
#ifdef __cplusplus
34
#define NULL 0L
35 36 37
#else
#define NULL ((void*)0)
#endif
R
Rich Felker 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

#undef EOF
#define EOF (-1)

#undef SEEK_SET
#undef SEEK_CUR
#undef SEEK_END
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2

#define _IOFBF 0
#define _IOLBF 1
#define _IONBF 2

53
#define BUFSIZ 1024
R
Rich Felker 已提交
54
#define FILENAME_MAX 4096
55 56 57
#define FOPEN_MAX 1000
#define TMP_MAX 10000
#define L_tmpnam 20
R
Rich Felker 已提交
58

59
typedef union _G_fpos64_t {
R
Rich Felker 已提交
60
	char __opaque[16];
61
	long long __lldata;
R
Rich Felker 已提交
62 63 64 65 66 67 68 69 70 71 72
	double __align;
} fpos_t;

extern FILE *const stdin;
extern FILE *const stdout;
extern FILE *const stderr;

#define stdin  (stdin)
#define stdout (stdout)
#define stderr (stderr)

73 74
FILE *fopen(const char *__restrict, const char *__restrict);
FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
R
Rich Felker 已提交
75 76 77 78 79 80 81 82 83 84 85 86 87 88
int fclose(FILE *);

int remove(const char *);
int rename(const char *, const char *);

int feof(FILE *);
int ferror(FILE *);
int fflush(FILE *);
void clearerr(FILE *);

int fseek(FILE *, long, int);
long ftell(FILE *);
void rewind(FILE *);

89
int fgetpos(FILE *__restrict, fpos_t *__restrict);
R
Rich Felker 已提交
90 91
int fsetpos(FILE *, const fpos_t *);

92 93
size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
R
Rich Felker 已提交
94 95 96 97 98 99 100 101 102 103

int fgetc(FILE *);
int getc(FILE *);
int getchar(void);
int ungetc(int, FILE *);

int fputc(int, FILE *);
int putc(int, FILE *);
int putchar(int);

104
char *fgets(char *__restrict, int, FILE *__restrict);
105
#if __STDC_VERSION__ < 201112L
R
Rich Felker 已提交
106
char *gets(char *);
107
#endif
R
Rich Felker 已提交
108

109
int fputs(const char *__restrict, FILE *__restrict);
R
Rich Felker 已提交
110 111
int puts(const char *);

112 113 114 115
int printf(const char *__restrict, ...);
int fprintf(FILE *__restrict, const char *__restrict, ...);
int sprintf(char *__restrict, const char *__restrict, ...);
int snprintf(char *__restrict, size_t, const char *__restrict, ...);
R
Rich Felker 已提交
116

117 118 119 120
int vprintf(const char *__restrict, __isoc_va_list);
int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
R
Rich Felker 已提交
121

122 123 124
int scanf(const char *__restrict, ...);
int fscanf(FILE *__restrict, const char *__restrict, ...);
int sscanf(const char *__restrict, const char *__restrict, ...);
125 126 127
int vscanf(const char *__restrict, __isoc_va_list);
int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
R
Rich Felker 已提交
128 129 130

void perror(const char *);

131 132
int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
void setbuf(FILE *__restrict, char *__restrict);
133 134 135 136 137

char *tmpnam(char *);
FILE *tmpfile(void);

#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
138 139
 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
 || defined(_BSD_SOURCE)
140
FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
R
Rich Felker 已提交
141
FILE *open_memstream(char **, size_t *);
142 143 144 145 146 147
FILE *fdopen(int, const char *);
FILE *popen(const char *, const char *);
int pclose(FILE *);
int fileno(FILE *);
int fseeko(FILE *, off_t, int);
off_t ftello(FILE *);
148
int dprintf(int, const char *__restrict, ...);
149
int vdprintf(int, const char *__restrict, __isoc_va_list);
R
Rich Felker 已提交
150 151 152 153 154 155 156
void flockfile(FILE *);
int ftrylockfile(FILE *);
void funlockfile(FILE *);
int getc_unlocked(FILE *);
int getchar_unlocked(void);
int putc_unlocked(int, FILE *);
int putchar_unlocked(int);
157 158
ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
159 160
int renameat(int, const char *, int, const char *);
char *ctermid(char *);
161
#define L_ctermid 20
162
#endif
R
Rich Felker 已提交
163 164


165 166
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
 || defined(_BSD_SOURCE)
167
#define P_tmpdir "/tmp"
R
Rich Felker 已提交
168
char *tempnam(const char *, const char *);
169
#endif
R
Rich Felker 已提交
170

171
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
172 173
#define L_cuserid 20
char *cuserid(char *);
174 175
void setlinebuf(FILE *);
void setbuffer(FILE *, char *, size_t);
176 177
int fgetc_unlocked(FILE *);
int fputc_unlocked(int, FILE *);
178 179 180 181 182 183 184
int fflush_unlocked(FILE *);
size_t fread_unlocked(void *, size_t, size_t, FILE *);
size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
void clearerr_unlocked(FILE *);
int feof_unlocked(FILE *);
int ferror_unlocked(FILE *);
int fileno_unlocked(FILE *);
R
Rich Felker 已提交
185 186
int getw(FILE *);
int putw(int, FILE *);
R
Rich Felker 已提交
187
char *fgetln(FILE *, size_t *);
R
Rich Felker 已提交
188
int asprintf(char **, const char *, ...);
189
int vasprintf(char **, const char *, __isoc_va_list);
R
Rich Felker 已提交
190 191
#endif

192
#ifdef _GNU_SOURCE
193 194
char *fgets_unlocked(char *, int, FILE *);
int fputs_unlocked(const char *, FILE *);
195 196 197 198 199 200

typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
typedef int (cookie_seek_function_t)(void *, off_t *, int);
typedef int (cookie_close_function_t)(void *);

201
typedef struct _IO_cookie_io_functions_t {
202 203 204 205 206 207 208
	cookie_read_function_t *read;
	cookie_write_function_t *write;
	cookie_seek_function_t *seek;
	cookie_close_function_t *close;
} cookie_io_functions_t;

FILE *fopencookie(void *, const char *, cookie_io_functions_t);
209
#endif
R
Rich Felker 已提交
210

211
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
212 213 214 215 216 217 218 219 220 221 222
#define tmpfile64 tmpfile
#define fopen64 fopen
#define freopen64 freopen
#define fseeko64 fseeko
#define ftello64 ftello
#define fgetpos64 fgetpos
#define fsetpos64 fsetpos
#define fpos64_t fpos_t
#define off64_t off_t
#endif

R
Rich Felker 已提交
223 224 225 226
#ifdef __cplusplus
}
#endif

227
#endif /* __ICCARM__ */
R
Rich Felker 已提交
228
#endif