blob: b54fe195b9a28a27c4e294f357302b872f6fecef [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) \
13 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
Rich Felker0b44a032011-02-12 00:22:29 -050014#define __NEED_ssize_t
15#define __NEED_off_t
Rich Felker80695b12011-02-14 05:10:10 -050016#endif
Rich Felker0b44a032011-02-12 00:22:29 -050017
18#include <bits/alltypes.h>
19
20#undef NULL
21#ifdef __cplusplus
22#define NULL 0
23#else
24#define NULL ((void*)0)
25#endif
26
27#undef EOF
28#define EOF (-1)
29
30#undef SEEK_SET
31#undef SEEK_CUR
32#undef SEEK_END
33#define SEEK_SET 0
34#define SEEK_CUR 1
35#define SEEK_END 2
36
37#define _IOFBF 0
38#define _IOLBF 1
39#define _IONBF 2
40
Rich Felker571312d2011-02-15 19:47:22 -050041#define BUFSIZ 1024
42#define FILENAME_MAX 4095
43#define FOPEN_MAX 1000
44#define TMP_MAX 10000
45#define L_tmpnam 20
Rich Felker0b44a032011-02-12 00:22:29 -050046
47typedef union {
48 char __opaque[16];
49 double __align;
50} fpos_t;
51
52extern FILE *const stdin;
53extern FILE *const stdout;
54extern FILE *const stderr;
55
56#define stdin (stdin)
57#define stdout (stdout)
58#define stderr (stderr)
59
60FILE *fopen(const char *, const char *);
Rich Felker0b44a032011-02-12 00:22:29 -050061FILE *freopen(const char *, const char *, FILE *);
62int fclose(FILE *);
63
Rich Felker0b44a032011-02-12 00:22:29 -050064int remove(const char *);
65int rename(const char *, const char *);
66
Rich Felker0b44a032011-02-12 00:22:29 -050067int feof(FILE *);
68int ferror(FILE *);
69int fflush(FILE *);
70void clearerr(FILE *);
71
72int fseek(FILE *, long, int);
Rich Felker0b44a032011-02-12 00:22:29 -050073long ftell(FILE *);
Rich Felker0b44a032011-02-12 00:22:29 -050074void rewind(FILE *);
75
76int fgetpos(FILE *, fpos_t *);
77int fsetpos(FILE *, const fpos_t *);
78
79size_t fread(void *, size_t, size_t, FILE *);
80size_t fwrite(const void *, size_t, size_t, FILE *);
81
82int fgetc(FILE *);
83int getc(FILE *);
84int getchar(void);
85int ungetc(int, FILE *);
86
87int fputc(int, FILE *);
88int putc(int, FILE *);
89int putchar(int);
90
91char *fgets(char *, int, FILE *);
92char *gets(char *);
93
94int fputs(const char *, FILE *);
95int puts(const char *);
96
97int printf(const char *, ...);
98int fprintf(FILE *, const char *, ...);
99int sprintf(char *, const char *, ...);
100int snprintf(char *, size_t, const char *, ...);
101
102int vprintf(const char *, va_list);
103int vfprintf(FILE *, const char *, va_list);
104int vsprintf(char *, const char *, va_list);
105int vsnprintf(char *, size_t, const char *, va_list);
106
Rich Felker0b44a032011-02-12 00:22:29 -0500107int scanf(const char *, ...);
108int fscanf(FILE *, const char *, ...);
109int sscanf(const char *, const char *, ...);
110int vscanf(const char *, va_list);
111int vfscanf(FILE *, const char *, va_list);
112int vsscanf(const char *, const char *, va_list);
113
114void perror(const char *);
115
Rich Felker80695b12011-02-14 05:10:10 -0500116int setvbuf(FILE *, char *, int, size_t);
117void setbuf(FILE *, char *);
118
119char *tmpnam(char *);
120FILE *tmpfile(void);
121
122#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
123 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
124FILE *fdopen(int, const char *);
125FILE *popen(const char *, const char *);
126int pclose(FILE *);
127int fileno(FILE *);
128int fseeko(FILE *, off_t, int);
129off_t ftello(FILE *);
130int dprintf(int, const char *, ...);
131int vdprintf(int, const char *, va_list);
Rich Felker0b44a032011-02-12 00:22:29 -0500132void flockfile(FILE *);
133int ftrylockfile(FILE *);
134void funlockfile(FILE *);
135int getc_unlocked(FILE *);
136int getchar_unlocked(void);
137int putc_unlocked(int, FILE *);
138int putchar_unlocked(int);
Rich Felker0b44a032011-02-12 00:22:29 -0500139ssize_t getdelim(char **, size_t *, int, FILE *);
140ssize_t getline(char **, size_t *, FILE *);
Rich Felker0b44a032011-02-12 00:22:29 -0500141int renameat(int, const char *, int, const char *);
Rich Felker80695b12011-02-14 05:10:10 -0500142char *ctermid(char *);
Rich Felker571312d2011-02-15 19:47:22 -0500143#define L_ctermid 20
Rich Felker80695b12011-02-14 05:10:10 -0500144#endif
145
146
147#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
Rich Felker571312d2011-02-15 19:47:22 -0500148#define P_tmpdir "/tmp"
Rich Felker80695b12011-02-14 05:10:10 -0500149char *tempnam(const char *, const char *);
150#endif
151
152#if defined(_GNU_SOURCE)
Rich Felker571312d2011-02-15 19:47:22 -0500153#define L_cuserid 20
154char *cuserid(char *);
Rich Felker80695b12011-02-14 05:10:10 -0500155#undef off64_t
156#define off64_t off_t
Rich Felker46b99422011-02-20 17:17:09 -0500157int asprintf(char **, const char *, ...);
158int vasprintf(char **, const char *, va_list);
Rich Felkere7218002011-04-05 12:25:31 -0400159void setlinebuf(FILE *);
160void setbuffer(FILE *, char *, size_t);
Rich Felker76404972011-06-30 11:42:33 -0400161int fpurge(FILE *);
Rich Felker80695b12011-02-14 05:10:10 -0500162#endif
Rich Felker0b44a032011-02-12 00:22:29 -0500163
164#ifdef __cplusplus
165}
166#endif
167
168#endif