home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-07  |  11.8 KB  |  477 lines

  1. /***
  2. *stdio.h - definitions/declarations for standard I/O routines
  3. *
  4. *       Copyright (c) 1985-2000, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       This file defines the structures, values, macros, and functions
  8. *       used by the level 2 I/O ("standard I/O") routines.
  9. *       [ANSI/System V]
  10. *
  11. *       [Public]
  12. *
  13. ****/
  14.  
  15. #if     _MSC_VER > 1000
  16. #pragma once
  17. #endif
  18.  
  19. #ifndef _INC_STDIO
  20. #define _INC_STDIO
  21.  
  22. #if     !defined(_WIN32) && !defined(_MAC)
  23. #error ERROR: Only Mac or Win32 targets supported!
  24. #endif
  25.  
  26.  
  27. #ifdef  _MSC_VER
  28. /*
  29.  * Currently, all MS C compilers for Win32 platforms default to 8 byte
  30.  * alignment.
  31.  */
  32. #pragma pack(push,8)
  33. #endif  /* _MSC_VER */
  34.  
  35. #ifdef  __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39.  
  40.  
  41. /* Define _CRTIMP */
  42.  
  43. #ifndef _CRTIMP
  44. #ifdef  _DLL
  45. #define _CRTIMP __declspec(dllimport)
  46. #else   /* ndef _DLL */
  47. #define _CRTIMP
  48. #endif  /* _DLL */
  49. #endif  /* _CRTIMP */
  50.  
  51.  
  52. /* Define __cdecl for non-Microsoft compilers */
  53.  
  54. #if     ( !defined(_MSC_VER) && !defined(__cdecl) )
  55. #define __cdecl
  56. #endif
  57.  
  58. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  59.  
  60. #ifndef _CRTAPI1
  61. #if    _MSC_VER >= 800 && _M_IX86 >= 300
  62. #define _CRTAPI1 __cdecl
  63. #else
  64. #define _CRTAPI1
  65. #endif
  66. #endif
  67.  
  68.  
  69. #ifndef _SIZE_T_DEFINED
  70. typedef unsigned int size_t;
  71. #define _SIZE_T_DEFINED
  72. #endif
  73.  
  74.  
  75. #ifndef _MAC
  76. #ifndef _WCHAR_T_DEFINED
  77. typedef unsigned short wchar_t;
  78. #define _WCHAR_T_DEFINED
  79. #endif
  80.  
  81.  
  82. #ifndef _WCTYPE_T_DEFINED
  83. typedef wchar_t wint_t;
  84. typedef wchar_t wctype_t;
  85. #define _WCTYPE_T_DEFINED
  86. #endif
  87. #endif /* ndef _MAC */
  88.  
  89.  
  90. #ifndef _VA_LIST_DEFINED
  91. #ifdef  _M_ALPHA
  92. typedef struct {
  93.         char *a0;       /* pointer to first homed integer argument */
  94.         int offset;     /* byte offset of next parameter */
  95. } va_list;
  96. #elif   defined(_M_CEE)
  97. typedef struct {
  98.     void *p[4];
  99. } va_list;
  100. #else
  101. typedef char *  va_list;
  102. #endif
  103. #define _VA_LIST_DEFINED
  104. #endif
  105.  
  106.  
  107. /* Buffered I/O macros */
  108.  
  109. #if     defined(_M_MPPC)
  110. #define BUFSIZ  4096
  111. #else  /* defined (_M_MPPC) */
  112. #define BUFSIZ  512
  113. #endif /* defined (_M_MPPC) */
  114.  
  115.  
  116. /*
  117.  * Default number of supported streams. _NFILE is confusing and obsolete, but
  118.  * supported anyway for backwards compatibility.
  119.  */
  120. #define _NFILE      _NSTREAM_
  121.  
  122. #ifdef  _WIN32
  123.  
  124. #define _NSTREAM_   512
  125.  
  126. /*
  127.  * Number of entries in _iob[] (declared below). Note that _NSTREAM_ must be
  128.  * greater than or equal to _IOB_ENTRIES.
  129.  */
  130. #define _IOB_ENTRIES 20
  131.  
  132. #else   /* ndef _WIN32 */
  133.  
  134. #ifdef  _DLL
  135. #define _NSTREAM_   128
  136. #else
  137. #ifdef  _MT
  138. #define _NSTREAM_   40
  139. #else
  140. #define _NSTREAM_   20
  141. #endif
  142. #endif  /* _DLL */
  143.  
  144. #endif  /* ndef _MAC */
  145.  
  146. #define EOF     (-1)
  147.  
  148.  
  149. #ifndef _FILE_DEFINED
  150. struct _iobuf {
  151.         char *_ptr;
  152.         int   _cnt;
  153.         char *_base;
  154.         int   _flag;
  155.         int   _file;
  156.         int   _charbuf;
  157.         int   _bufsiz;
  158.         char *_tmpfname;
  159.         };
  160. typedef struct _iobuf FILE;
  161. #define _FILE_DEFINED
  162. #endif
  163.  
  164.  
  165. #ifndef _MAC
  166.  
  167. /* Directory where temporary files may be created. */
  168.  
  169. #ifdef  _POSIX_
  170. #define _P_tmpdir   "/"
  171. #define _wP_tmpdir  L"/"
  172. #else
  173. #define _P_tmpdir   "\\"
  174. #define _wP_tmpdir  L"\\"
  175. #endif
  176.  
  177. /* L_tmpnam = size of P_tmpdir
  178.  *            + 1 (in case P_tmpdir does not end in "/")
  179.  *            + 12 (for the filename string)
  180.  *            + 1 (for the null terminator)
  181.  */
  182. #define L_tmpnam sizeof(_P_tmpdir)+12
  183.  
  184. #else   /* def _MAC */
  185.  
  186. #define L_tmpnam 255
  187.  
  188. #endif  /* _MAC */
  189.  
  190.  
  191. #ifdef  _POSIX_
  192. #define L_ctermid   9
  193. #define L_cuserid   32
  194. #endif
  195.  
  196.  
  197. /* Seek method constants */
  198.  
  199. #define SEEK_CUR    1
  200. #define SEEK_END    2
  201. #define SEEK_SET    0
  202.  
  203.  
  204. #define FILENAME_MAX    260
  205. #define FOPEN_MAX       20
  206. #define _SYS_OPEN       20
  207. #define TMP_MAX         32767
  208.  
  209.  
  210. /* Define NULL pointer value */
  211.  
  212. #ifndef NULL
  213. #ifdef  __cplusplus
  214. #define NULL    0
  215. #else
  216. #define NULL    ((void *)0)
  217. #endif
  218. #endif
  219.  
  220.  
  221. /* Declare _iob[] array */
  222.  
  223. #ifndef _STDIO_DEFINED
  224. _CRTIMP extern FILE _iob[];
  225. #endif  /* _STDIO_DEFINED */
  226.  
  227.  
  228. /* Define file position type */
  229.  
  230. #ifndef _FPOS_T_DEFINED
  231. #undef _FPOSOFF
  232.  
  233. #if defined (_POSIX_)
  234. typedef long fpos_t;
  235. #else /* _POSIX_ */
  236.  
  237. #if     !__STDC__ && _INTEGRAL_MAX_BITS >= 64
  238. typedef __int64 fpos_t;
  239. #define _FPOSOFF(fp) ((long)(fp))
  240. #else
  241. typedef struct fpos_t {
  242.         unsigned int lopart;
  243.         int          hipart;
  244.         } fpos_t;
  245. #define _FPOSOFF(fp) ((long)(fp).lopart)
  246. #endif
  247. #endif  /* _POSIX_ */
  248.  
  249. #define _FPOS_T_DEFINED
  250. #endif
  251.  
  252.  
  253. #define stdin  (&_iob[0])
  254. #define stdout (&_iob[1])
  255. #define stderr (&_iob[2])
  256.  
  257.  
  258. #define _IOREAD         0x0001
  259. #define _IOWRT          0x0002
  260.  
  261. #define _IOFBF          0x0000
  262. #define _IOLBF          0x0040
  263. #define _IONBF          0x0004
  264.  
  265. #define _IOMYBUF        0x0008
  266. #define _IOEOF          0x0010
  267. #define _IOERR          0x0020
  268. #define _IOSTRG         0x0040
  269. #define _IORW           0x0080
  270. #ifdef _POSIX_
  271. #define _IOAPPEND       0x0200
  272. #endif
  273.  
  274.  
  275. /* Function prototypes */
  276.  
  277. #ifndef _STDIO_DEFINED
  278.  
  279. _CRTIMP int __cdecl _filbuf(FILE *);
  280. _CRTIMP int __cdecl _flsbuf(int, FILE *);
  281.  
  282. #ifdef  _POSIX_
  283. _CRTIMP FILE * __cdecl _fsopen(const char *, const char *);
  284. #else
  285. _CRTIMP FILE * __cdecl _fsopen(const char *, const char *, int);
  286. #endif
  287.  
  288. _CRTIMP void __cdecl clearerr(FILE *);
  289. _CRTIMP int __cdecl fclose(FILE *);
  290. _CRTIMP int __cdecl _fcloseall(void);
  291.  
  292. #ifdef  _POSIX_
  293. _CRTIMP FILE * __cdecl fdopen(int, const char *);
  294. #else
  295. _CRTIMP FILE * __cdecl _fdopen(int, const char *);
  296. #endif
  297.  
  298. _CRTIMP int __cdecl feof(FILE *);
  299. _CRTIMP int __cdecl ferror(FILE *);
  300. _CRTIMP int __cdecl fflush(FILE *);
  301. _CRTIMP int __cdecl fgetc(FILE *);
  302. _CRTIMP int __cdecl _fgetchar(void);
  303. _CRTIMP int __cdecl fgetpos(FILE *, fpos_t *);
  304. _CRTIMP char * __cdecl fgets(char *, int, FILE *);
  305.  
  306. #ifdef  _POSIX_
  307. _CRTIMP int __cdecl fileno(FILE *);
  308. #else
  309. _CRTIMP int __cdecl _fileno(FILE *);
  310. #endif
  311.  
  312. _CRTIMP int __cdecl _flushall(void);
  313. _CRTIMP FILE * __cdecl fopen(const char *, const char *);
  314. _CRTIMP int __cdecl fprintf(FILE *, const char *, ...);
  315. _CRTIMP int __cdecl fputc(int, FILE *);
  316. _CRTIMP int __cdecl _fputchar(int);
  317. _CRTIMP int __cdecl fputs(const char *, FILE *);
  318. _CRTIMP size_t __cdecl fread(void *, size_t, size_t, FILE *);
  319. _CRTIMP FILE * __cdecl freopen(const char *, const char *, FILE *);
  320. _CRTIMP int __cdecl fscanf(FILE *, const char *, ...);
  321. _CRTIMP int __cdecl fsetpos(FILE *, const fpos_t *);
  322. _CRTIMP int __cdecl fseek(FILE *, long, int);
  323. _CRTIMP long __cdecl ftell(FILE *);
  324. _CRTIMP size_t __cdecl fwrite(const void *, size_t, size_t, FILE *);
  325. _CRTIMP int __cdecl getc(FILE *);
  326. _CRTIMP int __cdecl getchar(void);
  327. _CRTIMP int __cdecl _getmaxstdio(void);
  328. _CRTIMP char * __cdecl gets(char *);
  329. _CRTIMP int __cdecl _getw(FILE *);
  330. _CRTIMP void __cdecl perror(const char *);
  331. _CRTIMP int __cdecl _pclose(FILE *);
  332. _CRTIMP FILE * __cdecl _popen(const char *, const char *);
  333. _CRTIMP int __cdecl printf(const char *, ...);
  334. _CRTIMP int __cdecl putc(int, FILE *);
  335. _CRTIMP int __cdecl putchar(int);
  336. _CRTIMP int __cdecl puts(const char *);
  337. _CRTIMP int __cdecl _putw(int, FILE *);
  338. _CRTIMP int __cdecl remove(const char *);
  339. _CRTIMP int __cdecl rename(const char *, const char *);
  340. _CRTIMP void __cdecl rewind(FILE *);
  341. _CRTIMP int __cdecl _rmtmp(void);
  342. _CRTIMP int __cdecl scanf(const char *, ...);
  343. _CRTIMP void __cdecl setbuf(FILE *, char *);
  344. _CRTIMP int __cdecl _setmaxstdio(int);
  345. _CRTIMP int __cdecl setvbuf(FILE *, char *, int, size_t);
  346. _CRTIMP int __cdecl _snprintf(char *, size_t, const char *, ...);
  347. _CRTIMP int __cdecl sprintf(char *, const char *, ...);
  348. _CRTIMP int __cdecl sscanf(const char *, const char *, ...);
  349. _CRTIMP char * __cdecl _tempnam(const char *, const char *);
  350. _CRTIMP FILE * __cdecl tmpfile(void);
  351. _CRTIMP char * __cdecl tmpnam(char *);
  352. _CRTIMP int __cdecl ungetc(int, FILE *);
  353. _CRTIMP int __cdecl _unlink(const char *);
  354. _CRTIMP int __cdecl vfprintf(FILE *, const char *, va_list);
  355. _CRTIMP int __cdecl vprintf(const char *, va_list);
  356. _CRTIMP int __cdecl _vsnprintf(char *, size_t, const char *, va_list);
  357. _CRTIMP int __cdecl vsprintf(char *, const char *, va_list);
  358.  
  359. #ifndef _MAC
  360. #ifndef _WSTDIO_DEFINED
  361.  
  362. /* wide function prototypes, also declared in wchar.h  */
  363.  
  364. #ifndef WEOF
  365. #define WEOF (wint_t)(0xFFFF)
  366. #endif
  367.  
  368. #ifdef  _POSIX_
  369. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *);
  370. #else
  371. _CRTIMP FILE * __cdecl _wfsopen(const wchar_t *, const wchar_t *, int);
  372. #endif
  373.  
  374. _CRTIMP wint_t __cdecl fgetwc(FILE *);
  375. _CRTIMP wint_t __cdecl _fgetwchar(void);
  376. _CRTIMP wint_t __cdecl fputwc(wint_t, FILE *);
  377. _CRTIMP wint_t __cdecl _fputwchar(wint_t);
  378. _CRTIMP wint_t __cdecl getwc(FILE *);
  379. _CRTIMP wint_t __cdecl getwchar(void);
  380. _CRTIMP wint_t __cdecl putwc(wint_t, FILE *);
  381. _CRTIMP wint_t __cdecl putwchar(wint_t);
  382. _CRTIMP wint_t __cdecl ungetwc(wint_t, FILE *);
  383.  
  384. _CRTIMP wchar_t * __cdecl fgetws(wchar_t *, int, FILE *);
  385. _CRTIMP int __cdecl fputws(const wchar_t *, FILE *);
  386. _CRTIMP wchar_t * __cdecl _getws(wchar_t *);
  387. _CRTIMP int __cdecl _putws(const wchar_t *);
  388.  
  389. _CRTIMP int __cdecl fwprintf(FILE *, const wchar_t *, ...);
  390. _CRTIMP int __cdecl wprintf(const wchar_t *, ...);
  391. _CRTIMP int __cdecl _snwprintf(wchar_t *, size_t, const wchar_t *, ...);
  392. _CRTIMP int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
  393. _CRTIMP int __cdecl vfwprintf(FILE *, const wchar_t *, va_list);
  394. _CRTIMP int __cdecl vwprintf(const wchar_t *, va_list);
  395. _CRTIMP int __cdecl _vsnwprintf(wchar_t *, size_t, const wchar_t *, va_list);
  396. _CRTIMP int __cdecl vswprintf(wchar_t *, const wchar_t *, va_list);
  397. _CRTIMP int __cdecl fwscanf(FILE *, const wchar_t *, ...);
  398. _CRTIMP int __cdecl swscanf(const wchar_t *, const wchar_t *, ...);
  399. _CRTIMP int __cdecl wscanf(const wchar_t *, ...);
  400.  
  401. #define getwchar()              fgetwc(stdin)
  402. #define putwchar(_c)            fputwc((_c),stdout)
  403. #define getwc(_stm)             fgetwc(_stm)
  404. #define putwc(_c,_stm)          fputwc(_c,_stm)
  405.  
  406. _CRTIMP FILE * __cdecl _wfdopen(int, const wchar_t *);
  407. _CRTIMP FILE * __cdecl _wfopen(const wchar_t *, const wchar_t *);
  408. _CRTIMP FILE * __cdecl _wfreopen(const wchar_t *, const wchar_t *, FILE *);
  409. _CRTIMP void __cdecl _wperror(const wchar_t *);
  410. _CRTIMP FILE * __cdecl _wpopen(const wchar_t *, const wchar_t *);
  411. _CRTIMP int __cdecl _wremove(const wchar_t *);
  412. _CRTIMP wchar_t * __cdecl _wtempnam(const wchar_t *, const wchar_t *);
  413. _CRTIMP wchar_t * __cdecl _wtmpnam(wchar_t *);
  414.  
  415.  
  416. #define _WSTDIO_DEFINED
  417. #endif  /* _WSTDIO_DEFINED */
  418. #endif /* ndef _MAC */
  419.  
  420. #define _STDIO_DEFINED
  421. #endif  /* _STDIO_DEFINED */
  422.  
  423.  
  424. /* Macro definitions */
  425.  
  426. #define feof(_stream)     ((_stream)->_flag & _IOEOF)
  427. #define ferror(_stream)   ((_stream)->_flag & _IOERR)
  428. #define _fileno(_stream)  ((_stream)->_file)
  429. #define getc(_stream)     (--(_stream)->_cnt >= 0 \
  430.                 ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))
  431. #define putc(_c,_stream)  (--(_stream)->_cnt >= 0 \
  432.                 ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) :  _flsbuf((_c),(_stream)))
  433. #define getchar()         getc(stdin)
  434. #define putchar(_c)       putc((_c),stdout)
  435.  
  436.  
  437.  
  438. #ifdef  _MT
  439. #undef  getc
  440. #undef  putc
  441. #undef  getchar
  442. #undef  putchar
  443. #endif
  444.  
  445.  
  446.  
  447. #if     !__STDC__ && !defined(_POSIX_)
  448.  
  449. /* Non-ANSI names for compatibility */
  450.  
  451. #define P_tmpdir  _P_tmpdir
  452. #define SYS_OPEN  _SYS_OPEN
  453.  
  454. _CRTIMP int __cdecl fcloseall(void);
  455. _CRTIMP FILE * __cdecl fdopen(int, const char *);
  456. _CRTIMP int __cdecl fgetchar(void);
  457. _CRTIMP int __cdecl fileno(FILE *);
  458. _CRTIMP int __cdecl flushall(void);
  459. _CRTIMP int __cdecl fputchar(int);
  460. _CRTIMP int __cdecl getw(FILE *);
  461. _CRTIMP int __cdecl putw(int, FILE *);
  462. _CRTIMP int __cdecl rmtmp(void);
  463. _CRTIMP char * __cdecl tempnam(const char *, const char *);
  464. _CRTIMP int __cdecl unlink(const char *);
  465.  
  466. #endif  /* __STDC__ */
  467.  
  468. #ifdef  __cplusplus
  469. }
  470. #endif
  471.  
  472. #ifdef  _MSC_VER
  473. #pragma pack(pop)
  474. #endif  /* _MSC_VER */
  475.  
  476. #endif  /* _INC_STDIO */
  477.