Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. // -*- C++ -*- header wrapper.
  2.  
  3. // Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library.  This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 2, or (at your option)
  9. // any later version.
  10.  
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. // GNU General Public License for more details.
  15.  
  16. // You should have received a copy of the GNU General Public License along
  17. // with this library; see the file COPYING.  If not, write to the Free
  18. // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  19. // USA.
  20.  
  21. // As a special exception, you may use this file as part of a free software
  22. // library without restriction.  Specifically, if other files instantiate
  23. // templates or use macros or inline functions from this file, or you compile
  24. // this file and link it with other files to produce an executable, this
  25. // file does not by itself cause the resulting executable to be covered by
  26. // the GNU General Public License.  This exception does not however
  27. // invalidate any other reasons why the executable file might be covered by
  28. // the GNU General Public License.
  29.  
  30. //
  31. // ISO C++ 14882: 27.8.2  C Library files
  32. //
  33.  
  34. #ifndef _CPP_CSTDIO
  35. #define _CPP_CSTDIO 1
  36.  
  37. # include <bits/std_cstddef.h>  
  38. # include <bits/std_cstdarg.h>  
  39.  
  40. namespace _C_legacy {
  41.   extern "C" {
  42. #     define _IN_C_LEGACY_
  43. #     undef __need_FILE
  44. #     pragma GCC system_header
  45. #     include_next <stdio.h>
  46.   }
  47.  
  48.   typedef FILE _CPP_FILE_capture;
  49.   typedef fpos_t _CPP_fpos_t_capture;
  50.  
  51.   inline FILE*
  52.   _CPP_stderr_capture() { return stderr; }
  53.  
  54.   inline FILE*
  55.   _CPP_stdin_capture()  { return stdin; }
  56.  
  57.   inline FILE*
  58.   _CPP_stdout_capture() { return stdout; }
  59.  
  60.   inline int
  61.   _CPP_getc_capture(FILE* __f) { return getc(__f); }
  62.  
  63.   inline int
  64.   _CPP_getchar_capture() { return getchar(); }
  65.  
  66.   inline int
  67.   _CPP_putc_capture(int __c, FILE* __f) { return putc(__c, __f); }
  68.  
  69.   inline int
  70.   _CPP_putchar_capture(int __c) { return putchar(__c); }
  71.  
  72.   inline int
  73.   _CPP_feof_capture(FILE* __f) { return feof(__f); }
  74.  
  75. } // namespace _C_legacy
  76.  
  77. # undef FILE
  78. # undef fpos_t
  79.  
  80. # undef remove
  81. # undef rename
  82. # undef tmpfile
  83. # undef tmpnam
  84. # undef fclose
  85. # undef fflush
  86. # undef fopen
  87. # undef freopen
  88. # undef setbuf
  89. # undef setvbuf
  90. # undef fprintf
  91. # undef fscanf
  92. # undef printf
  93. # undef scanf
  94. # undef sprintf
  95. # undef sscanf
  96. # undef vfprintf
  97. # undef vprintf
  98. # undef vsprintf
  99. # undef fgetc
  100. # undef fgets
  101. # undef fputc
  102. # undef fputs
  103. # undef getc
  104. # undef getchar
  105. # undef gets
  106. # undef putc
  107. # undef putchar
  108. # undef puts
  109. # undef ungetc
  110. # undef fread
  111. # undef fwrite
  112. # undef fgetpos
  113. # undef fseek
  114. # undef fsetpos
  115. # undef ftell
  116. # undef rewind
  117. # undef clearerr
  118. # undef feof
  119. # undef ferror
  120. # undef perror
  121.  
  122. # undef stderr
  123. # define stderr std::_CPP_stderr()
  124. # undef stdin
  125. # define stdin  std::_CPP_stdin()
  126. # undef stdout
  127. # define stdout std::_CPP_stdout()
  128.  
  129. namespace std {
  130.   struct FILE : _C_legacy::_CPP_FILE_capture { };
  131.   struct fpos_t { _C_legacy::_CPP_fpos_t_capture _M_dummy; };
  132.  
  133.   using _C_legacy::remove;
  134.   using _C_legacy::rename;
  135.   using _C_legacy::tmpnam;
  136.   using _C_legacy::printf;
  137.   using _C_legacy::scanf;
  138.   using _C_legacy::sprintf;
  139.   using _C_legacy::sscanf;
  140.   using _C_legacy::gets;
  141.   using _C_legacy::perror;
  142.  
  143.   inline FILE*
  144.   _CPP_stderr()
  145.   { return reinterpret_cast<FILE*>(_C_legacy::_CPP_stderr_capture() ); }
  146.  
  147.   inline FILE*
  148.   _CPP_stdin()
  149.   { return reinterpret_cast<FILE*>(_C_legacy::_CPP_stdin_capture() ); }
  150.  
  151.   inline FILE*
  152.   _CPP_stdout()
  153.   { return reinterpret_cast<FILE*>(_C_legacy::_CPP_stdout_capture() ); }
  154.  
  155.   inline FILE*
  156.   tmpfile() { return reinterpret_cast<FILE*>(_C_legacy::tmpfile()); }
  157.  
  158.   inline int
  159.   fclose(FILE* __f) { return _C_legacy::fclose(__f); }
  160.  
  161.   inline int
  162.   fflush(FILE* __f) { return _C_legacy::fflush(__f); }
  163.  
  164.   inline FILE*
  165.   fopen(char const* __name, char const* __mode)
  166.   { return reinterpret_cast<FILE*>(_C_legacy::fopen(__name,__mode)); }
  167.  
  168.   inline FILE*
  169.   freopen(char const* __name, char const* __mode, FILE* __f)
  170.   { return reinterpret_cast<FILE*>(_C_legacy::freopen(__name,__mode,__f)); }
  171.  
  172.   inline void
  173.   setbuf(FILE* __f, char* __buf)
  174.   { return _C_legacy::setbuf(__f, __buf); }
  175.  
  176.   inline int
  177.   setvbuf(FILE* __f, char* __buf, int __mode, size_t __size)
  178.   { return _C_legacy::setvbuf(__f, __buf, __mode, __size); }
  179.  
  180.   inline int
  181.   fprintf(FILE* __f, char const* __fmt, ...)
  182.   {
  183.     va_list __v;
  184.     va_start(__v,__fmt);
  185.     int __i = _C_legacy::vfprintf(__f, __fmt, __v);
  186.     va_end(__v);
  187.     return __i;
  188.   }
  189.  
  190.   inline int
  191.   fscanf(FILE* __f, char const* __fmt, ...)
  192.   {
  193.     va_list __v;
  194.     va_start(__v,__fmt);
  195.     int __i = _C_legacy::vfscanf(__f, __fmt, __v);
  196.     va_end(__v);
  197.     return __i;
  198.   }
  199.  
  200.   inline int
  201.   vfprintf(FILE* __f, char const* __fmt, va_list __v)
  202.   { return _C_legacy::vfprintf(__f, __fmt, __v); }
  203.  
  204.   inline int
  205.   vprintf(char const* __fmt, va_list __v)
  206.   { return _C_legacy::vprintf(__fmt, __v); }
  207.  
  208.   inline int
  209.   vsprintf(char* __buf, char const* __fmt, va_list __v)
  210.   { return _C_legacy::vsprintf(__buf, __fmt, __v); }
  211.  
  212.   inline int
  213.   fgetc(FILE* __f) { return _C_legacy::fgetc(__f); }
  214.  
  215.   inline char*
  216.   fgets(char* __buf, int __n, FILE* __f)
  217.   { return _C_legacy::fgets(__buf, __n, __f); }
  218.  
  219.   inline int
  220.   fputc(int __c, FILE* __f) { return _C_legacy::fputc(__c, __f); }
  221.  
  222.   inline int
  223.   fputs(char const* __s, FILE* __f)
  224.   { return _C_legacy::fputs(__s, __f); }
  225.  
  226.   inline int
  227.   getc(FILE* __f) { return _C_legacy::_CPP_getc_capture(__f); }
  228.  
  229.   inline int
  230.   getchar() { return _C_legacy::_CPP_getchar_capture(); }
  231.  
  232.   inline int
  233.   putc(int __c, FILE* __f)
  234.   { return _C_legacy::_CPP_putc_capture(__c, __f); }
  235.  
  236.   inline int
  237.   putchar(int __c) { return _C_legacy::_CPP_putchar_capture(__c); }
  238.  
  239.   using _C_legacy::puts;
  240.  
  241.   inline int
  242.   ungetc(int __c, FILE* __f) { return _C_legacy::ungetc(__c, __f); }
  243.  
  244.   inline size_t
  245.   fread(void* __p, size_t __z, size_t __n, FILE* __f)
  246.   { return _C_legacy::fread(__p,__z,__n,__f); }
  247.  
  248.   inline size_t
  249.   fwrite(void const* __p, size_t __z, size_t __n, FILE* __f)
  250.   { return _C_legacy::fwrite(__p,__z,__n,__f); }
  251.  
  252.   inline int
  253.   fgetpos(FILE* __f, fpos_t* __pos)
  254.   { return _C_legacy::fgetpos(__f,&__pos->_M_dummy); }
  255.  
  256.   inline int
  257.   fseek(FILE* __f, long __off, int __how)
  258.   { return _C_legacy::fseek(__f,__off,__how); }
  259.  
  260.   inline int
  261.   fsetpos(FILE* __f, fpos_t const* __pos)
  262.   { return _C_legacy::fsetpos(__f,&__pos->_M_dummy); }
  263.  
  264.   inline long
  265.   ftell(FILE* __f) { return _C_legacy::ftell(__f); }
  266.  
  267.   inline void
  268.   rewind(FILE* __f) { return _C_legacy::rewind(__f); }
  269.  
  270.   inline void
  271.   clearerr(FILE* __f) { return _C_legacy::clearerr(__f); }
  272.  
  273.   inline int
  274.   feof(FILE* __f) { return _C_legacy::_CPP_feof_capture(__f); }
  275.  
  276.   inline int
  277.   ferror(FILE* __f) { return _C_legacy::ferror(__f); }
  278. } // namespace std
  279.  
  280. # undef _IN_C_LEGACY_
  281.  
  282. #endif
  283.  
  284.