cstdio 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. // -*- C++ -*-
  2. //===---------------------------- cstdio ----------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_CSTDIO
  11. #define _LIBCPP_CSTDIO
  12. /*
  13. cstdio synopsis
  14. Macros:
  15. BUFSIZ
  16. EOF
  17. FILENAME_MAX
  18. FOPEN_MAX
  19. L_tmpnam
  20. NULL
  21. SEEK_CUR
  22. SEEK_END
  23. SEEK_SET
  24. TMP_MAX
  25. _IOFBF
  26. _IOLBF
  27. _IONBF
  28. stderr
  29. stdin
  30. stdout
  31. namespace std
  32. {
  33. Types:
  34. FILE
  35. fpos_t
  36. size_t
  37. int remove(const char* filename);
  38. int rename(const char* old, const char* new);
  39. FILE* tmpfile(void);
  40. char* tmpnam(char* s);
  41. int fclose(FILE* stream);
  42. int fflush(FILE* stream);
  43. FILE* fopen(const char* restrict filename, const char* restrict mode);
  44. FILE* freopen(const char* restrict filename, const char * restrict mode,
  45. FILE * restrict stream);
  46. void setbuf(FILE* restrict stream, char* restrict buf);
  47. int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
  48. int fprintf(FILE* restrict stream, const char* restrict format, ...);
  49. int fscanf(FILE* restrict stream, const char * restrict format, ...);
  50. int printf(const char* restrict format, ...);
  51. int scanf(const char* restrict format, ...);
  52. int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
  53. int sprintf(char* restrict s, const char* restrict format, ...);
  54. int sscanf(const char* restrict s, const char* restrict format, ...);
  55. int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
  56. int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
  57. int vprintf(const char* restrict format, va_list arg);
  58. int vscanf(const char* restrict format, va_list arg); // C99
  59. int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
  60. va_list arg);
  61. int vsprintf(char* restrict s, const char* restrict format, va_list arg);
  62. int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
  63. int fgetc(FILE* stream);
  64. char* fgets(char* restrict s, int n, FILE* restrict stream);
  65. int fputc(int c, FILE* stream);
  66. int fputs(const char* restrict s, FILE* restrict stream);
  67. int getc(FILE* stream);
  68. int getchar(void);
  69. char* gets(char* s); // removed in C++14
  70. int putc(int c, FILE* stream);
  71. int putchar(int c);
  72. int puts(const char* s);
  73. int ungetc(int c, FILE* stream);
  74. size_t fread(void* restrict ptr, size_t size, size_t nmemb,
  75. FILE* restrict stream);
  76. size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
  77. FILE* restrict stream);
  78. int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
  79. int fseek(FILE* stream, long offset, int whence);
  80. int fsetpos(FILE*stream, const fpos_t* pos);
  81. long ftell(FILE* stream);
  82. void rewind(FILE* stream);
  83. void clearerr(FILE* stream);
  84. int feof(FILE* stream);
  85. int ferror(FILE* stream);
  86. void perror(const char* s);
  87. } // std
  88. */
  89. #include <__config>
  90. #include <stdio.h>
  91. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  92. #pragma GCC system_header
  93. #endif
  94. // snprintf
  95. #if defined(_LIBCPP_MSVCRT)
  96. #if !defined(_LIBCPP_SGX_CONFIG)
  97. #include "support/win32/support.h"
  98. #endif // !defined(_LIBCPP_SGX_CONFIG)
  99. #endif
  100. #ifdef getc
  101. inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);}
  102. #undef getc
  103. inline _LIBCPP_INLINE_VISIBILITY int getc(FILE* __stream) {return __libcpp_getc(__stream);}
  104. #endif // getc
  105. #ifdef putc
  106. inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);}
  107. #undef putc
  108. inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
  109. #endif // putc
  110. #ifdef clearerr
  111. inline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) { return clearerr(__stream); }
  112. #undef clearerr
  113. inline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) { return __libcpp_clearerr(__stream); }
  114. #endif // clearerr
  115. #ifdef feof
  116. inline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) { return feof(__stream); }
  117. #undef feof
  118. inline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) { return __libcpp_feof(__stream); }
  119. #endif // feof
  120. #ifdef ferror
  121. inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) { return ferror(__stream); }
  122. #undef ferror
  123. inline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) { return __libcpp_ferror(__stream); }
  124. #endif // ferror
  125. _LIBCPP_BEGIN_NAMESPACE_STD
  126. #ifndef _LIBCPP_SGX_CONFIG
  127. using ::FILE;
  128. using ::fpos_t;
  129. #endif //_LIBCPP_SGX_CONFIG
  130. using ::size_t;
  131. #ifndef _LIBCPP_SGX_CONFIG
  132. using ::fclose;
  133. using ::fflush;
  134. using ::setbuf;
  135. using ::setvbuf;
  136. using ::fprintf;
  137. using ::fscanf;
  138. #endif //_LIBCPP_SGX_CONFIG
  139. using ::snprintf;
  140. #ifndef _LIBCPP_SGX_CONFIG
  141. using ::sprintf;
  142. using ::sscanf;
  143. #endif //_LIBCPP_SGX_CONFIG
  144. #ifndef _LIBCPP_SGX_CONFIG
  145. using ::vfprintf;
  146. using ::vfscanf;
  147. using ::vsscanf;
  148. #endif // _LIBCPP_SGX_CONFIG
  149. using ::vsnprintf;
  150. #ifndef _LIBCPP_SGX_CONFIG
  151. using ::vsprintf;
  152. using ::fgetc;
  153. using ::fgets;
  154. using ::fputc;
  155. using ::fputs;
  156. using ::getc;
  157. using ::putc;
  158. using ::ungetc;
  159. using ::fread;
  160. using ::fwrite;
  161. using ::fgetpos;
  162. using ::fseek;
  163. using ::fsetpos;
  164. using ::ftell;
  165. using ::rewind;
  166. using ::clearerr;
  167. using ::feof;
  168. using ::ferror;
  169. using ::perror;
  170. #endif //_LIBCPP_SGX_CONFIG
  171. #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
  172. using ::fopen;
  173. using ::freopen;
  174. using ::remove;
  175. using ::rename;
  176. using ::tmpfile;
  177. using ::tmpnam;
  178. #endif
  179. #ifndef _LIBCPP_HAS_NO_STDIN
  180. using ::getchar;
  181. #if _LIBCPP_STD_VER <= 11
  182. using ::gets;
  183. #endif
  184. using ::scanf;
  185. using ::vscanf;
  186. #endif
  187. #ifndef _LIBCPP_HAS_NO_STDOUT
  188. using ::printf;
  189. using ::putchar;
  190. using ::puts;
  191. using ::vprintf;
  192. #endif
  193. _LIBCPP_END_NAMESPACE_STD
  194. #endif // _LIBCPP_CSTDIO