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