blob: a2dc674bb368a510ff34655a7c0d9c2aafe2eb1d [file] [log] [blame]
Rich Felker0b44a032011-02-12 00:22:29 -05001#ifndef _STDIO_H
2#define _STDIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_FILE
9#define __NEED_va_list
10#define __NEED_size_t
Rich Felker80695b12011-02-14 05:10:10 -050011
12#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
Rich Felker419ae6d2012-05-22 21:52:08 -040013 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
14 || defined(_BSD_SOURCE)
Rich Felker0b44a032011-02-12 00:22:29 -050015#define __NEED_ssize_t
16#define __NEED_off_t
Rich Felker80695b12011-02-14 05:10:10 -050017#endif
Rich Felker0b44a032011-02-12 00:22:29 -050018
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
Rich Felker571312d2011-02-15 19:47:22 -050042#define BUFSIZ 1024
43#define FILENAME_MAX 4095
44#define FOPEN_MAX 1000
45#define TMP_MAX 10000
46#define L_tmpnam 20
Rich Felker0b44a032011-02-12 00:22:29 -050047
48typedef union {
49 char __opaque[16];
50 double __align;
51} fpos_t;
52
53extern FILE *const stdin;
54extern FILE *const stdout;
55extern FILE *const stderr;
56
57#define stdin (stdin)
58#define stdout (stdout)
59#define stderr (stderr)
60
61FILE *fopen(const char *, const char *);
Rich Felker0b44a032011-02-12 00:22:29 -050062FILE *freopen(const char *, const char *, FILE *);
63int fclose(FILE *);
64
Rich Felker0b44a032011-02-12 00:22:29 -050065int remove(const char *);
66int rename(const char *, const char *);
67
Rich Felker0b44a032011-02-12 00:22:29 -050068int feof(FILE *);
69int ferror(FILE *);
70int fflush(FILE *);
71void clearerr(FILE *);
72
73int fseek(FILE *, long, int);
Rich Felker0b44a032011-02-12 00:22:29 -050074long ftell(FILE *);
Rich Felker0b44a032011-02-12 00:22:29 -050075void rewind(FILE *);
76
77int fgetpos(FILE *, fpos_t *);
78int fsetpos(FILE *, const fpos_t *);
79
80size_t fread(void *, size_t, size_t, FILE *);
81size_t fwrite(const void *, size_t, size_t, FILE *);
82
83int fgetc(FILE *);
84int getc(FILE *);
85int getchar(void);
86int ungetc(int, FILE *);
87
88int fputc(int, FILE *);
89int putc(int, FILE *);
90int putchar(int);
91
92char *fgets(char *, int, FILE *);
93char *gets(char *);
94
95int fputs(const char *, FILE *);
96int puts(const char *);
97
98int printf(const char *, ...);
99int fprintf(FILE *, const char *, ...);
100int sprintf(char *, const char *, ...);
101int snprintf(char *, size_t, const char *, ...);
102
103int vprintf(const char *, va_list);
104int vfprintf(FILE *, const char *, va_list);
105int vsprintf(char *, const char *, va_list);
106int vsnprintf(char *, size_t, const char *, va_list);
107
Rich Felker0b44a032011-02-12 00:22:29 -0500108int scanf(const char *, ...);
109int fscanf(FILE *, const char *, ...);
110int sscanf(const char *, const char *, ...);
111int vscanf(const char *, va_list);
112int vfscanf(FILE *, const char *, va_list);
113int vsscanf(const char *, const char *, va_list);
114
115void perror(const char *);
116
Rich Felker80695b12011-02-14 05:10:10 -0500117int setvbuf(FILE *, char *, int, size_t);
118void setbuf(FILE *, char *);
119
120char *tmpnam(char *);
121FILE *tmpfile(void);
122
123#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
Rich Felker419ae6d2012-05-22 21:52:08 -0400124 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
125 || defined(_BSD_SOURCE)
Rich Felkerd4fa6f02011-09-03 23:26:17 -0400126FILE *fmemopen(void *, size_t, const char *);
Rich Felkerb158b322011-09-03 00:45:21 -0400127FILE *open_memstream(char **, size_t *);
Rich Felker80695b12011-02-14 05:10:10 -0500128FILE *fdopen(int, const char *);
129FILE *popen(const char *, const char *);
130int pclose(FILE *);
131int fileno(FILE *);
132int fseeko(FILE *, off_t, int);
133off_t ftello(FILE *);
134int dprintf(int, const char *, ...);
135int vdprintf(int, const char *, va_list);
Rich Felker0b44a032011-02-12 00:22:29 -0500136void flockfile(FILE *);
137int ftrylockfile(FILE *);
138void funlockfile(FILE *);
139int getc_unlocked(FILE *);
140int getchar_unlocked(void);
141int putc_unlocked(int, FILE *);
142int putchar_unlocked(int);
Rich Felker0b44a032011-02-12 00:22:29 -0500143ssize_t getdelim(char **, size_t *, int, FILE *);
144ssize_t getline(char **, size_t *, FILE *);
Rich Felker0b44a032011-02-12 00:22:29 -0500145int renameat(int, const char *, int, const char *);
Rich Felker80695b12011-02-14 05:10:10 -0500146char *ctermid(char *);
Rich Felker571312d2011-02-15 19:47:22 -0500147#define L_ctermid 20
Rich Felker80695b12011-02-14 05:10:10 -0500148#endif
149
150
Rich Felker419ae6d2012-05-22 21:52:08 -0400151#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
152 || defined(_BSD_SOURCE)
Rich Felker571312d2011-02-15 19:47:22 -0500153#define P_tmpdir "/tmp"
Rich Felker80695b12011-02-14 05:10:10 -0500154char *tempnam(const char *, const char *);
155#endif
156
Rich Felker419ae6d2012-05-22 21:52:08 -0400157#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
Rich Felker571312d2011-02-15 19:47:22 -0500158#define L_cuserid 20
159char *cuserid(char *);
Rich Felkere7218002011-04-05 12:25:31 -0400160void setlinebuf(FILE *);
161void setbuffer(FILE *, char *, size_t);
Rich Felker76404972011-06-30 11:42:33 -0400162int fpurge(FILE *);
Rich Felkerce17ea62011-09-11 22:50:02 -0400163int fgetc_unlocked(FILE *);
164int fputc_unlocked(int, FILE *);
Rich Felkerb63cab72012-05-28 22:53:24 -0400165int fflush_unlocked(FILE *);
166size_t fread_unlocked(void *, size_t, size_t, FILE *);
167size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
168void clearerr_unlocked(FILE *);
169int feof_unlocked(FILE *);
170int ferror_unlocked(FILE *);
171int fileno_unlocked(FILE *);
172#endif
173
174#ifdef _GNU_SOURCE
175int asprintf(char **, const char *, ...);
176int vasprintf(char **, const char *, va_list);
Rich Felkerce17ea62011-09-11 22:50:02 -0400177char *fgets_unlocked(char *, int, FILE *);
178int fputs_unlocked(const char *, FILE *);
Rich Felker80695b12011-02-14 05:10:10 -0500179#endif
Rich Felker0b44a032011-02-12 00:22:29 -0500180
Rich Felker2dd8d5e2012-05-04 00:13:23 -0400181#ifdef _LARGEFILE64_SOURCE
182#define tmpfile64 tmpfile
183#define fopen64 fopen
184#define freopen64 freopen
185#define fseeko64 fseeko
186#define ftello64 ftello
187#define fgetpos64 fgetpos
188#define fsetpos64 fsetpos
189#define fpos64_t fpos_t
190#define off64_t off_t
191#endif
192
Rich Felker0b44a032011-02-12 00:22:29 -0500193#ifdef __cplusplus
194}
195#endif
196
197#endif