blob: 9a2093763505dc9bbd6444dd86229a629ca6b8a1 [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
Rich Felkerc1a96582012-09-07 23:13:55 -04008#include <features.h>
Rich Felker400c5e52012-09-06 22:44:55 -04009
Rich Felker0b44a032011-02-12 00:22:29 -050010#define __NEED_FILE
11#define __NEED_va_list
12#define __NEED_size_t
Rich Felker80695b12011-02-14 05:10:10 -050013
14#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
Rich Felker419ae6d2012-05-22 21:52:08 -040015 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
16 || defined(_BSD_SOURCE)
Rich Felker0b44a032011-02-12 00:22:29 -050017#define __NEED_ssize_t
18#define __NEED_off_t
Rich Felker80695b12011-02-14 05:10:10 -050019#endif
Rich Felker0b44a032011-02-12 00:22:29 -050020
21#include <bits/alltypes.h>
22
23#undef NULL
24#ifdef __cplusplus
25#define NULL 0
26#else
27#define NULL ((void*)0)
28#endif
29
30#undef EOF
31#define EOF (-1)
32
33#undef SEEK_SET
34#undef SEEK_CUR
35#undef SEEK_END
36#define SEEK_SET 0
37#define SEEK_CUR 1
38#define SEEK_END 2
39
40#define _IOFBF 0
41#define _IOLBF 1
42#define _IONBF 2
43
Rich Felker571312d2011-02-15 19:47:22 -050044#define BUFSIZ 1024
45#define FILENAME_MAX 4095
46#define FOPEN_MAX 1000
47#define TMP_MAX 10000
48#define L_tmpnam 20
Rich Felker0b44a032011-02-12 00:22:29 -050049
50typedef union {
51 char __opaque[16];
52 double __align;
53} fpos_t;
54
55extern FILE *const stdin;
56extern FILE *const stdout;
57extern FILE *const stderr;
58
59#define stdin (stdin)
60#define stdout (stdout)
61#define stderr (stderr)
62
Rich Felker400c5e52012-09-06 22:44:55 -040063FILE *fopen(const char *__restrict, const char *__restrict);
64FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
Rich Felker0b44a032011-02-12 00:22:29 -050065int fclose(FILE *);
66
Rich Felker0b44a032011-02-12 00:22:29 -050067int remove(const char *);
68int rename(const char *, const char *);
69
Rich Felker0b44a032011-02-12 00:22:29 -050070int feof(FILE *);
71int ferror(FILE *);
72int fflush(FILE *);
73void clearerr(FILE *);
74
75int fseek(FILE *, long, int);
Rich Felker0b44a032011-02-12 00:22:29 -050076long ftell(FILE *);
Rich Felker0b44a032011-02-12 00:22:29 -050077void rewind(FILE *);
78
Rich Felker400c5e52012-09-06 22:44:55 -040079int fgetpos(FILE *__restrict, fpos_t *__restrict);
Rich Felker0b44a032011-02-12 00:22:29 -050080int fsetpos(FILE *, const fpos_t *);
81
Rich Felker400c5e52012-09-06 22:44:55 -040082size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
83size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
Rich Felker0b44a032011-02-12 00:22:29 -050084
85int fgetc(FILE *);
86int getc(FILE *);
87int getchar(void);
88int ungetc(int, FILE *);
89
90int fputc(int, FILE *);
91int putc(int, FILE *);
92int putchar(int);
93
Rich Felker400c5e52012-09-06 22:44:55 -040094char *fgets(char *__restrict, int, FILE *__restrict);
Rich Felker9bff7c12012-08-25 23:15:13 -040095#if __STDC_VERSION__ < 201112L
Rich Felker0b44a032011-02-12 00:22:29 -050096char *gets(char *);
Rich Felker9bff7c12012-08-25 23:15:13 -040097#endif
Rich Felker0b44a032011-02-12 00:22:29 -050098
Rich Felker400c5e52012-09-06 22:44:55 -040099int fputs(const char *__restrict, FILE *__restrict);
Rich Felker0b44a032011-02-12 00:22:29 -0500100int puts(const char *);
101
Rich Felker400c5e52012-09-06 22:44:55 -0400102int printf(const char *__restrict, ...);
103int fprintf(FILE *__restrict, const char *__restrict, ...);
104int sprintf(char *__restrict, const char *__restrict, ...);
105int snprintf(char *__restrict, size_t, const char *__restrict, ...);
Rich Felker0b44a032011-02-12 00:22:29 -0500106
Rich Felker400c5e52012-09-06 22:44:55 -0400107int vprintf(const char *__restrict, va_list);
108int vfprintf(FILE *__restrict, const char *__restrict, va_list);
109int vsprintf(char *__restrict, const char *__restrict, va_list);
110int vsnprintf(char *__restrict, size_t, const char *__restrict, va_list);
Rich Felker0b44a032011-02-12 00:22:29 -0500111
Rich Felker400c5e52012-09-06 22:44:55 -0400112int scanf(const char *__restrict, ...);
113int fscanf(FILE *__restrict, const char *__restrict, ...);
114int sscanf(const char *__restrict, const char *__restrict, ...);
115int vscanf(const char *__restrict, va_list);
116int vfscanf(FILE *__restrict, const char *__restrict, va_list);
117int vsscanf(const char *__restrict, const char *__restrict, va_list);
Rich Felker0b44a032011-02-12 00:22:29 -0500118
119void perror(const char *);
120
Rich Felker400c5e52012-09-06 22:44:55 -0400121int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
122void setbuf(FILE *__restrict, char *__restrict);
Rich Felker80695b12011-02-14 05:10:10 -0500123
124char *tmpnam(char *);
125FILE *tmpfile(void);
126
127#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
Rich Felker419ae6d2012-05-22 21:52:08 -0400128 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
129 || defined(_BSD_SOURCE)
Rich Felker400c5e52012-09-06 22:44:55 -0400130FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
Rich Felkerb158b322011-09-03 00:45:21 -0400131FILE *open_memstream(char **, size_t *);
Rich Felker80695b12011-02-14 05:10:10 -0500132FILE *fdopen(int, const char *);
133FILE *popen(const char *, const char *);
134int pclose(FILE *);
135int fileno(FILE *);
136int fseeko(FILE *, off_t, int);
137off_t ftello(FILE *);
Rich Felker400c5e52012-09-06 22:44:55 -0400138int dprintf(int, const char *__restrict, ...);
139int vdprintf(int, const char *__restrict, va_list);
Rich Felker0b44a032011-02-12 00:22:29 -0500140void flockfile(FILE *);
141int ftrylockfile(FILE *);
142void funlockfile(FILE *);
143int getc_unlocked(FILE *);
144int getchar_unlocked(void);
145int putc_unlocked(int, FILE *);
146int putchar_unlocked(int);
Rich Felker400c5e52012-09-06 22:44:55 -0400147ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
148ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
Rich Felker0b44a032011-02-12 00:22:29 -0500149int renameat(int, const char *, int, const char *);
Rich Felker80695b12011-02-14 05:10:10 -0500150char *ctermid(char *);
Rich Felker571312d2011-02-15 19:47:22 -0500151#define L_ctermid 20
Rich Felker80695b12011-02-14 05:10:10 -0500152#endif
153
154
Rich Felker419ae6d2012-05-22 21:52:08 -0400155#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
156 || defined(_BSD_SOURCE)
Rich Felker571312d2011-02-15 19:47:22 -0500157#define P_tmpdir "/tmp"
Rich Felker80695b12011-02-14 05:10:10 -0500158char *tempnam(const char *, const char *);
159#endif
160
Rich Felker419ae6d2012-05-22 21:52:08 -0400161#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
Rich Felker571312d2011-02-15 19:47:22 -0500162#define L_cuserid 20
163char *cuserid(char *);
Rich Felkere7218002011-04-05 12:25:31 -0400164void setlinebuf(FILE *);
165void setbuffer(FILE *, char *, size_t);
Rich Felkerce17ea62011-09-11 22:50:02 -0400166int fgetc_unlocked(FILE *);
167int fputc_unlocked(int, FILE *);
Rich Felkerb63cab72012-05-28 22:53:24 -0400168int fflush_unlocked(FILE *);
169size_t fread_unlocked(void *, size_t, size_t, FILE *);
170size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
171void clearerr_unlocked(FILE *);
172int feof_unlocked(FILE *);
173int ferror_unlocked(FILE *);
174int fileno_unlocked(FILE *);
Rich Felker25b88f02012-07-04 12:18:04 -0400175int getw(FILE *);
176int putw(int, FILE *);
Rich Felkerb63cab72012-05-28 22:53:24 -0400177#endif
178
Rich Felker61718272012-08-11 18:10:38 -0400179#ifdef _BSD_SOURCE
180char *fgetln(FILE *, size_t *);
181#endif
182
Rich Felkerb63cab72012-05-28 22:53:24 -0400183#ifdef _GNU_SOURCE
184int asprintf(char **, const char *, ...);
185int vasprintf(char **, const char *, va_list);
Rich Felkerce17ea62011-09-11 22:50:02 -0400186char *fgets_unlocked(char *, int, FILE *);
187int fputs_unlocked(const char *, FILE *);
Rich Felker80695b12011-02-14 05:10:10 -0500188#endif
Rich Felker0b44a032011-02-12 00:22:29 -0500189
Rich Felker3b94dab2012-06-04 08:03:56 -0400190#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
Rich Felker2dd8d5e2012-05-04 00:13:23 -0400191#define tmpfile64 tmpfile
192#define fopen64 fopen
193#define freopen64 freopen
194#define fseeko64 fseeko
195#define ftello64 ftello
196#define fgetpos64 fgetpos
197#define fsetpos64 fsetpos
198#define fpos64_t fpos_t
199#define off64_t off_t
200#endif
201
Rich Felker0b44a032011-02-12 00:22:29 -0500202#ifdef __cplusplus
203}
204#endif
205
206#endif