home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / cecko / install / devcpp4920.exe / include / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-17  |  9.8 KB  |  395 lines

  1. /*
  2.  * stdio.h
  3.  *
  4.  * Definitions of types and prototypes of functions for standard input and
  5.  * output.
  6.  *
  7.  * NOTE: The file manipulation functions provided by Microsoft seem to
  8.  * work with either slash (/) or backslash (\) as the path separator.
  9.  *
  10.  * This file is part of the Mingw32 package.
  11.  *
  12.  * Contributors:
  13.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  14.  *
  15.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  16.  *
  17.  *  This source code is offered for use in the public domain. You may
  18.  *  use, modify or distribute it freely.
  19.  *
  20.  *  This code is distributed in the hope that it will be useful but
  21.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  22.  *  DISCLAMED. This includes but is not limited to warranties of
  23.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24.  *
  25.  * $Revision: 1.6 $
  26.  * $Author: cgf $
  27.  * $Date: 2000/02/05 04:04:57 $
  28.  *
  29.  */
  30.  
  31. #ifndef _STDIO_H_
  32. #define    _STDIO_H_
  33.  
  34. /* All the headers include this file. */
  35. #include <_mingw.h>
  36.  
  37. #define __need_size_t
  38. #define __need_NULL
  39. #define __need_wchar_t
  40. #define    __need_wint_t
  41. #ifndef RC_INVOKED
  42. #include <stddef.h>
  43. #endif    /* Not RC_INVOKED */
  44.  
  45.  
  46. /* Flags for the iobuf structure  */
  47. #define    _IOREAD    1
  48. #define    _IOWRT    2
  49. #define    _IORW    0x0080 /* opened as "r+w" */
  50.  
  51.  
  52. /*
  53.  * The three standard file pointers provided by the run time library.
  54.  * NOTE: These will go to the bit-bucket silently in GUI applications!
  55.  */
  56. #define    STDIN_FILENO    0
  57. #define    STDOUT_FILENO    1
  58. #define    STDERR_FILENO    2
  59.  
  60. /* Returned by various functions on end of file condition or error. */
  61. #define    EOF    (-1)
  62.  
  63. /*
  64.  * The maximum length of a file name. You should use GetVolumeInformation
  65.  * instead of this constant. But hey, this works.
  66.  *
  67.  * NOTE: This is used in the structure _finddata_t (see io.h) so changing it
  68.  *       is probably not a good idea.
  69.  */
  70. #define    FILENAME_MAX    (260)
  71.  
  72. /*
  73.  * The maximum number of files that may be open at once. I have set this to
  74.  * a conservative number. The actual value may be higher.
  75.  */
  76. #define FOPEN_MAX    (20)
  77.  
  78. /* After creating this many names, tmpnam and tmpfile return NULL */
  79. #define TMP_MAX    32767
  80. /*
  81.  * Tmpnam, tmpfile and, sometimes, _tempnam try to create
  82.  * temp files in the root directory of the current drive
  83.  * (not in pwd, as suggested by some older MS doc's).
  84.  * Redefining these macros does not effect the CRT functions.
  85.  */
  86. #define _P_tmpdir   "\\"
  87. #define _wP_tmpdir  L"\\"
  88.  
  89. /*
  90.  * The maximum size of name (including NUL) that will be put in the user
  91.  * supplied buffer caName for tmpnam.
  92.  * Inferred from the size of the static buffer returned by tmpnam
  93.  * when passed a NULL argument. May actually be smaller.
  94.  */
  95. #define L_tmpnam (16)
  96.  
  97. #define _IOFBF        0x0000
  98. #define _IOLBF        0x0040
  99. #define _IONBF        0x0004
  100.  
  101. /*
  102.  * The buffer size as used by setbuf such that it is equivalent to
  103.  * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
  104.  */
  105. #define    BUFSIZ    512
  106.  
  107. /* Constants for nOrigin indicating the position relative to which fseek
  108.  * sets the file position. Enclosed in ifdefs because io.h could also
  109.  * define them. (Though not anymore since io.h includes this file now.) */
  110. #ifndef    SEEK_SET
  111. #define SEEK_SET    (0)
  112. #endif
  113.  
  114. #ifndef    SEEK_CUR
  115. #define    SEEK_CUR    (1)
  116. #endif
  117.  
  118. #ifndef    SEEK_END
  119. #define SEEK_END    (2)
  120. #endif
  121.  
  122.  
  123. #ifndef    RC_INVOKED
  124.  
  125. /*
  126.  * I used to include stdarg.h at this point, in order to allow for the
  127.  * functions later on in the file which use va_list. That conflicts with
  128.  * using stdio.h and varargs.h in the same file, so I do the typedef myself.
  129.  */
  130. #ifndef    _VA_LIST
  131. #define _VA_LIST
  132. #if defined __GNUC__ && __GNUC__ >= 3
  133. typedef __builtin_va_list va_list;
  134. #else
  135. typedef char* va_list;
  136. #endif
  137. #endif
  138. /*
  139.  * The structure underlying the FILE type.
  140.  *
  141.  * I still believe that nobody in their right mind should make use of the
  142.  * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
  143.  * <paag@tid.es>.
  144.  */
  145. #ifndef _FILE_DEFINED
  146. #define    _FILE_DEFINED
  147. typedef struct _iobuf
  148. {
  149.     char*    _ptr;
  150.     int    _cnt;
  151.     char*    _base;
  152.     int    _flag;
  153.     int    _file;
  154.     int    _charbuf;
  155.     int    _bufsiz;
  156.     char*    _tmpfname;
  157. } FILE;
  158. #endif    /* Not _FILE_DEFINED */
  159.  
  160.  
  161. /*
  162.  * The standard file handles
  163.  */
  164. #ifndef __DECLSPEC_SUPPORTED
  165.  
  166. extern FILE (*__imp__iob)[];    /* A pointer to an array of FILE */
  167.  
  168. #define _iob    (*__imp__iob)    /* An array of FILE */
  169.  
  170. #else /* __DECLSPEC_SUPPORTED */
  171.  
  172. __MINGW_IMPORT FILE _iob[];    /* An array of FILE imported from DLL. */
  173.  
  174. #endif /* __DECLSPEC_SUPPORTED */
  175.  
  176. #define stdin    (&_iob[STDIN_FILENO])
  177. #define stdout    (&_iob[STDOUT_FILENO])
  178. #define stderr    (&_iob[STDERR_FILENO])
  179.  
  180. #ifdef __cplusplus
  181. extern "C" {
  182. #endif
  183.  
  184. /*
  185.  * File Operations
  186.  */
  187. FILE*    fopen (const char*, const char*);
  188. FILE*    freopen (const char*, const char*, FILE*);
  189. int    fflush (FILE*);
  190. int    fclose (FILE*);
  191. /* MS puts remove & rename (but not wide versions) in io.h  also */
  192. int    remove (const char*);
  193. int    rename (const char*, const char*);
  194. FILE*    tmpfile (void);
  195. char*    tmpnam (char*);
  196. char*    _tempnam (const char*, const char*);
  197.  
  198. #ifndef    NO_OLDNAMES
  199. char*    tempnam (const char*, const char*);
  200. #endif
  201.  
  202. int    setvbuf (FILE*, char*, int, size_t);
  203.  
  204. void    setbuf (FILE*, char*);
  205.  
  206. /*
  207.  * Formatted Output
  208.  */
  209.  
  210. int    fprintf (FILE*, const char*, ...);
  211. int    printf (const char*, ...);
  212. int    sprintf (char*, const char*, ...);
  213. int     _snprintf (char*, size_t, const char*, ...);
  214. int    vfprintf (FILE*, const char*, va_list);
  215. int    vprintf (const char*, va_list);
  216. int    vsprintf (char*, const char*, va_list);
  217. int     _vsnprintf (char*, size_t, const char*, va_list);
  218.  
  219.  
  220. /*
  221.  * Formatted Input
  222.  */
  223.  
  224. int    fscanf (FILE*, const char*, ...);
  225. int    scanf (const char*, ...);
  226. int    sscanf (const char*, const char*, ...);
  227. /*
  228.  * Character Input and Output Functions
  229.  */
  230.  
  231. int    fgetc (FILE*);
  232. char*    fgets (char*, int, FILE*);
  233. int    fputc (int, FILE*);
  234. int    fputs (const char*, FILE*);
  235. int    getc (FILE*);
  236. int    getchar (void);
  237. char*    gets (char*);
  238. int    putc (int, FILE*);
  239. int    putchar (int);
  240. int    puts (const char*);
  241. int    ungetc (int, FILE*);
  242.  
  243. /*
  244.  * Direct Input and Output Functions
  245.  */
  246.  
  247. size_t    fread (void*, size_t, size_t, FILE*);
  248. size_t    fwrite (const void*, size_t, size_t, FILE*);
  249.  
  250. /*
  251.  * File Positioning Functions
  252.  */
  253.  
  254. int    fseek    (FILE*, long, int);
  255. long    ftell    (FILE*);
  256. void    rewind    (FILE*);
  257.  
  258. /*
  259.  * An opaque data type used for storing file positions... The contents of
  260.  * this type are unknown, but we (the compiler) need to know the size
  261.  * because the programmer using fgetpos and fsetpos will be setting aside
  262.  * storage for fpos_t structres. Actually I tested using a byte array and
  263.  * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
  264.  * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
  265.  * MSVCRT however, and for now `long long' will do.
  266.  */
  267. #ifdef __MSVCRT__
  268. typedef long long fpos_t;
  269. #else
  270. typedef long    fpos_t;
  271. #endif
  272.  
  273. int    fgetpos    (FILE*, fpos_t*);
  274. int    fsetpos (FILE*, const fpos_t*);
  275.  
  276. /*
  277.  * Error Functions
  278.  */
  279.  
  280. void    clearerr (FILE*);
  281. int    feof (FILE*);
  282. int    ferror (FILE*);
  283. void    perror (const char*);
  284.  
  285.  
  286. #ifndef __STRICT_ANSI__
  287. /*
  288.  * Pipes
  289.  */
  290. FILE*    _popen (const char*, const char*);
  291. int    _pclose (FILE*);
  292.  
  293. #ifndef NO_OLDNAMES
  294. FILE*    popen (const char*, const char*);
  295. int    pclose (FILE*);
  296. #endif
  297.  
  298. /*
  299.  * Other Non ANSI functions
  300.  */
  301. int  _flushall(void);
  302. int    _fgetchar (void);
  303. int    _fputchar (int);
  304. FILE*    _fdopen (int, const char*);
  305. int    _fileno (FILE*);
  306.  
  307. #ifndef _NO_OLDNAMES
  308. int    fgetchar (void);
  309. int    fputchar (int);
  310. FILE*    fdopen (int, const char*);
  311. int    fileno (FILE*);
  312. #endif    /* Not _NO_OLDNAMES */
  313.  
  314. #endif    /* Not __STRICT_ANSI__ */
  315.  
  316. /* Wide  versions */
  317.  
  318. #ifndef _WSTDIO_DEFINED
  319. /*  also in wchar.h - keep in sync */
  320. int    fwprintf (FILE*, const wchar_t*, ...);
  321. int    wprintf (const wchar_t*, ...);
  322. int    swprintf (wchar_t*, const wchar_t*, ...);
  323. int    vfwprintf (FILE*, const wchar_t*, va_list);
  324. int    vwprintf (const wchar_t*, va_list);
  325. int    vswprintf (wchar_t*, const wchar_t*, va_list);
  326. int    fwscanf (FILE*, const wchar_t*, ...);
  327. int    wscanf (const wchar_t*, ...);
  328. int    swscanf (const wchar_t*, const wchar_t*, ...);
  329. wint_t    fgetwc (FILE*);
  330. wint_t    fputwc (wchar_t, FILE*);
  331. wint_t    ungetwc (wchar_t, FILE*);
  332. #ifdef __MSVCRT__ 
  333. wchar_t*    fgetws (wchar_t*, int, FILE*);
  334. int         fputws (const wchar_t*, FILE*);
  335. wint_t        getwc (FILE*);
  336. wint_t        getwchar (void);
  337. wchar_t*    _getws (wchar_t*);
  338. wint_t        putwc (wint_t, FILE*);
  339. int         _putws (const wchar_t*);
  340. wint_t        putwchar (wint_t);
  341. FILE*    _wfopen (const wchar_t*, const wchar_t*);
  342. FILE*    _wfreopen (const wchar_t*, const wchar_t*, FILE*);
  343. FILE*   _wfsopen(const wchar_t*, const wchar_t*, int);
  344. wchar_t*    _wtmpnam (wchar_t*);
  345. wchar_t*    _wtempnam (const wchar_t*, const wchar_t*);
  346. int     _wrename(const wchar_t*, const wchar_t*);
  347. int     _wremove (const wchar_t*);
  348. void  _wperror(const wchar_t*);
  349. FILE*  _wpopen(const wchar_t*, const wchar_t*);
  350. #endif    /* __MSVCRT__ */
  351. #define _WSTDIO_DEFINED
  352. #endif /* _WSTDIO_DEFINED */
  353.  
  354. #ifndef __STRICT_ANSI__
  355. #ifdef __MSVCRT__
  356. #ifndef NO_OLDNAMES
  357. #if 0
  358. FILE*    wpopen (const wchar_t*, const wchar_t*);
  359. #else /* Always true */
  360. /*
  361.  * The above prototypeing is not possible unless the wpopen export is added
  362.  * to moldnames, which can't be done unless we make separate moldnames.def
  363.  * files for every supported runtime. For the time being we use a define
  364.  * instead. Pedro's modified dlltool should take care of this I think.
  365.  */
  366. #define wpopen _wpopen
  367. #endif    /* Always true */
  368. #endif /* not NO_OLDNAMES */
  369. #endif /* MSVCRT runtime */
  370.  
  371. /*
  372.  * Other Non ANSI wide functions
  373.  */
  374. wint_t    _fgetwchar(void);
  375. wint_t    _fputwchar(wint_t);
  376. int    _getw (FILE*);
  377. int    _putw (int, FILE*);
  378.  
  379. #ifndef _NO_OLDNAMES
  380. wint_t    fgetwchar(void);
  381. wint_t    fputwchar(wint_t);
  382. int    getw (FILE*);
  383. int    putw (int, FILE*);
  384. #endif    /* Not _NO_OLDNAMES */
  385.  
  386. #endif /* __STRICT_ANSI */
  387.  
  388. #ifdef __cplusplus
  389. }
  390. #endif
  391.  
  392. #endif    /* Not RC_INVOKED */
  393.  
  394. #endif /* _STDIO_H_ */
  395.