fa1b4e9ba22f5e006c366ecad396d50c8e10bc0a
[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 char *gets(char *);
94
95 int fputs(const char *, FILE *);
96 int puts(const char *);
97
98 int printf(const char *, ...);
99 int fprintf(FILE *, const char *, ...);
100 int sprintf(char *, const char *, ...);
101 int snprintf(char *, size_t, const char *, ...);
102
103 int vprintf(const char *, va_list);
104 int vfprintf(FILE *, const char *, va_list);
105 int vsprintf(char *, const char *, va_list);
106 int vsnprintf(char *, size_t, const char *, va_list);
107
108 int scanf(const char *, ...);
109 int fscanf(FILE *, const char *, ...);
110 int sscanf(const char *, const char *, ...);
111 int vscanf(const char *, va_list);
112 int vfscanf(FILE *, const char *, va_list);
113 int vsscanf(const char *, const char *, va_list);
114
115 void perror(const char *);
116
117 int setvbuf(FILE *, char *, int, size_t);
118 void setbuf(FILE *, char *);
119
120 char *tmpnam(char *);
121 FILE *tmpfile(void);
122
123 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
124  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
125  || defined(_BSD_SOURCE)
126 FILE *fmemopen(void *, size_t, const char *);
127 FILE *open_memstream(char **, size_t *);
128 FILE *fdopen(int, const char *);
129 FILE *popen(const char *, const char *);
130 int pclose(FILE *);
131 int fileno(FILE *);
132 int fseeko(FILE *, off_t, int);
133 off_t ftello(FILE *);
134 int dprintf(int, const char *, ...);
135 int vdprintf(int, const char *, va_list);
136 void flockfile(FILE *);
137 int ftrylockfile(FILE *);
138 void funlockfile(FILE *);
139 int getc_unlocked(FILE *);
140 int getchar_unlocked(void);
141 int putc_unlocked(int, FILE *);
142 int putchar_unlocked(int);
143 ssize_t getdelim(char **, size_t *, int, FILE *);
144 ssize_t getline(char **, size_t *, FILE *);
145 int renameat(int, const char *, int, const char *);
146 char *ctermid(char *);
147 #define L_ctermid 20
148 #endif
149
150
151 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
152  || defined(_BSD_SOURCE)
153 #define P_tmpdir "/tmp"
154 char *tempnam(const char *, const char *);
155 #endif
156
157 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
158 #define L_cuserid 20
159 char *cuserid(char *);
160 void setlinebuf(FILE *);
161 void setbuffer(FILE *, char *, size_t);
162 int fgetc_unlocked(FILE *);
163 int fputc_unlocked(int, FILE *);
164 int fflush_unlocked(FILE *);
165 size_t fread_unlocked(void *, size_t, size_t, FILE *);
166 size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
167 void clearerr_unlocked(FILE *);
168 int feof_unlocked(FILE *);
169 int ferror_unlocked(FILE *);
170 int fileno_unlocked(FILE *);
171 #endif
172
173 #ifdef _GNU_SOURCE
174 int asprintf(char **, const char *, ...);
175 int vasprintf(char **, const char *, va_list);
176 char *fgets_unlocked(char *, int, FILE *);
177 int fputs_unlocked(const char *, FILE *);
178 #endif
179
180 #ifdef _LARGEFILE64_SOURCE
181 #define tmpfile64 tmpfile
182 #define fopen64 fopen
183 #define freopen64 freopen
184 #define fseeko64 fseeko
185 #define ftello64 ftello
186 #define fgetpos64 fgetpos
187 #define fsetpos64 fsetpos
188 #define fpos64_t fpos_t
189 #define off64_t off_t
190 #endif
191
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif