cstdio revision 288943
1227825Stheraven// -*- C++ -*-
2227825Stheraven//===---------------------------- cstdio ----------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_CSTDIO
12227825Stheraven#define _LIBCPP_CSTDIO
13227825Stheraven
14227825Stheraven/*
15227825Stheraven    cstdio synopsis
16227825Stheraven
17227825StheravenMacros:
18227825Stheraven
19227825Stheraven    BUFSIZ
20227825Stheraven    EOF
21227825Stheraven    FILENAME_MAX
22227825Stheraven    FOPEN_MAX
23227825Stheraven    L_tmpnam
24227825Stheraven    NULL
25227825Stheraven    SEEK_CUR
26227825Stheraven    SEEK_END
27227825Stheraven    SEEK_SET
28227825Stheraven    TMP_MAX
29227825Stheraven    _IOFBF
30227825Stheraven    _IOLBF
31227825Stheraven    _IONBF
32227825Stheraven    stderr
33227825Stheraven    stdin
34227825Stheraven    stdout
35227825Stheraven
36227825Stheravennamespace std
37227825Stheraven{
38227825Stheraven
39227825StheravenTypes:
40227825Stheraven
41227825StheravenFILE
42227825Stheravenfpos_t
43227825Stheravensize_t
44227825Stheraven
45227825Stheravenint remove(const char* filename);
46227825Stheravenint rename(const char* old, const char* new);
47227825StheravenFILE* tmpfile(void);
48227825Stheravenchar* tmpnam(char* s);
49227825Stheravenint fclose(FILE* stream);
50227825Stheravenint fflush(FILE* stream);
51227825StheravenFILE* fopen(const char* restrict filename, const char* restrict mode);
52227825StheravenFILE* freopen(const char* restrict filename, const char * restrict mode,
53227825Stheraven              FILE * restrict stream);
54227825Stheravenvoid setbuf(FILE* restrict stream, char* restrict buf);
55227825Stheravenint setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
56227825Stheravenint fprintf(FILE* restrict stream, const char* restrict format, ...);
57227825Stheravenint fscanf(FILE* restrict stream, const char * restrict format, ...);
58227825Stheravenint printf(const char* restrict format, ...);
59227825Stheravenint scanf(const char* restrict format, ...);
60227825Stheravenint snprintf(char* restrict s, size_t n, const char* restrict format, ...);    // C99
61227825Stheravenint sprintf(char* restrict s, const char* restrict format, ...);
62227825Stheravenint sscanf(const char* restrict s, const char* restrict format, ...);
63227825Stheravenint vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
64227825Stheravenint vfscanf(FILE* restrict stream, const char* restrict format, va_list arg);  // C99
65227825Stheravenint vprintf(const char* restrict format, va_list arg);
66227825Stheravenint vscanf(const char* restrict format, va_list arg);                          // C99
67227825Stheravenint vsnprintf(char* restrict s, size_t n, const char* restrict format,         // C99
68227825Stheraven              va_list arg);
69227825Stheravenint vsprintf(char* restrict s, const char* restrict format, va_list arg);
70227825Stheravenint vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
71227825Stheravenint fgetc(FILE* stream);
72227825Stheravenchar* fgets(char* restrict s, int n, FILE* restrict stream);
73227825Stheravenint fputc(int c, FILE* stream);
74227825Stheravenint fputs(const char* restrict s, FILE* restrict stream);
75227825Stheravenint getc(FILE* stream);
76227825Stheravenint getchar(void);
77261272Sdimchar* gets(char* s);  // removed in C++14
78227825Stheravenint putc(int c, FILE* stream);
79227825Stheravenint putchar(int c);
80227825Stheravenint puts(const char* s);
81227825Stheravenint ungetc(int c, FILE* stream);
82227825Stheravensize_t fread(void* restrict ptr, size_t size, size_t nmemb,
83227825Stheraven             FILE* restrict stream);
84227825Stheravensize_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
85227825Stheraven              FILE* restrict stream);
86227825Stheravenint fgetpos(FILE* restrict stream, fpos_t* restrict pos);
87227825Stheravenint fseek(FILE* stream, long offset, int whence);
88227825Stheravenint fsetpos(FILE*stream, const fpos_t* pos);
89227825Stheravenlong ftell(FILE* stream);
90227825Stheravenvoid rewind(FILE* stream);
91227825Stheravenvoid clearerr(FILE* stream);
92227825Stheravenint feof(FILE* stream);
93227825Stheravenint ferror(FILE* stream);
94227825Stheravenvoid perror(const char* s);
95227825Stheraven
96227825Stheraven}  // std
97227825Stheraven*/
98227825Stheraven
99227825Stheraven#include <__config>
100227825Stheraven#include <stdio.h>
101227825Stheraven
102227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
103227825Stheraven#pragma GCC system_header
104227825Stheraven#endif
105227825Stheraven
106261272Sdim// snprintf
107261272Sdim#if defined(_LIBCPP_MSVCRT)
108261272Sdim#include "support/win32/support.h"
109261272Sdim#endif
110261272Sdim
111241900Sdim#ifdef getc
112241900Sdiminline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);}
113241900Sdim#undef getc
114241900Sdiminline _LIBCPP_INLINE_VISIBILITY int getc(FILE* __stream) {return __libcpp_getc(__stream);}
115241900Sdim#endif  // getc
116241900Sdim
117241900Sdim#ifdef putc
118241900Sdiminline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);}
119241900Sdim#undef putc
120241900Sdiminline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
121241900Sdim#endif  // putc
122241900Sdim
123288943Sdim#ifdef clearerr
124288943Sdiminline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) { return clearerr(__stream); }
125288943Sdim#undef clearerr
126288943Sdiminline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) { return __libcpp_clearerr(__stream); }
127288943Sdim#endif  // clearerr
128288943Sdim
129288943Sdim#ifdef feof
130288943Sdiminline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) { return feof(__stream); }
131288943Sdim#undef feof
132288943Sdiminline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) { return __libcpp_feof(__stream); }
133288943Sdim#endif  // feof
134288943Sdim
135288943Sdim#ifdef ferror
136288943Sdiminline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) { return ferror(__stream); }
137288943Sdim#undef ferror
138288943Sdiminline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) { return __libcpp_ferror(__stream); }
139288943Sdim#endif  // ferror
140288943Sdim
141227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
142227825Stheraven
143227825Stheravenusing ::FILE;
144227825Stheravenusing ::fpos_t;
145227825Stheravenusing ::size_t;
146227825Stheraven
147227825Stheravenusing ::fclose;
148227825Stheravenusing ::fflush;
149227825Stheravenusing ::setbuf;
150227825Stheravenusing ::setvbuf;
151227825Stheravenusing ::fprintf;
152227825Stheravenusing ::fscanf;
153227825Stheravenusing ::snprintf;
154227825Stheravenusing ::sprintf;
155227825Stheravenusing ::sscanf;
156261272Sdim#ifndef _LIBCPP_MSVCRT
157227825Stheravenusing ::vfprintf;
158227825Stheravenusing ::vfscanf;
159227825Stheravenusing ::vsscanf;
160261272Sdim#endif // _LIBCPP_MSVCRT
161227825Stheravenusing ::vsnprintf;
162227825Stheravenusing ::vsprintf;
163227825Stheravenusing ::fgetc;
164227825Stheravenusing ::fgets;
165227825Stheravenusing ::fputc;
166227825Stheravenusing ::fputs;
167227825Stheravenusing ::getc;
168227825Stheravenusing ::putc;
169227825Stheravenusing ::ungetc;
170227825Stheravenusing ::fread;
171227825Stheravenusing ::fwrite;
172227825Stheravenusing ::fgetpos;
173227825Stheravenusing ::fseek;
174227825Stheravenusing ::fsetpos;
175227825Stheravenusing ::ftell;
176227825Stheravenusing ::rewind;
177227825Stheravenusing ::clearerr;
178227825Stheravenusing ::feof;
179227825Stheravenusing ::ferror;
180227825Stheravenusing ::perror;
181227825Stheraven
182288943Sdim#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
183288943Sdimusing ::fopen;
184288943Sdimusing ::freopen;
185288943Sdimusing ::remove;
186288943Sdimusing ::rename;
187288943Sdimusing ::tmpfile;
188288943Sdimusing ::tmpnam;
189288943Sdim#endif
190288943Sdim
191288943Sdim#ifndef _LIBCPP_HAS_NO_STDIN
192288943Sdimusing ::getchar;
193288943Sdim#if _LIBCPP_STD_VER <= 11
194288943Sdimusing ::gets;
195288943Sdim#endif
196288943Sdimusing ::scanf;
197288943Sdimusing ::vscanf;
198288943Sdim#endif
199288943Sdim
200288943Sdim#ifndef _LIBCPP_HAS_NO_STDOUT
201288943Sdimusing ::printf;
202288943Sdimusing ::putchar;
203288943Sdimusing ::puts;
204288943Sdimusing ::vprintf;
205288943Sdim#endif
206288943Sdim
207227825Stheraven_LIBCPP_END_NAMESPACE_STD
208227825Stheraven
209227825Stheraven#endif  // _LIBCPP_CSTDIO
210