--- mstools/h/stdio.h 2018/08/09 18:20:01 1.1 +++ mstools/h/stdio.h 2018/08/09 18:23:06 1.1.1.4 @@ -1,7 +1,7 @@ /*** *stdio.h - definitions/declarations for standard I/O routines * -* Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved. +* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved. * *Purpose: * This file defines the structures, values, macros, and functions @@ -17,17 +17,54 @@ extern "C" { #endif -#if (_MSC_VER <= 600) -#define __cdecl _cdecl +/* + * Conditional macro definition for function calling type and variable type + * qualifiers. + */ +#if ( (_MSC_VER >= 800) && (_M_IX86 >= 300) ) + +/* + * Definitions for MS C8-32 (386/486) compiler + */ +#define _CRTAPI1 __cdecl +#define _CRTAPI2 __cdecl + +#else + +/* + * Other compilers (e.g., MIPS) + */ +#define _CRTAPI1 +#define _CRTAPI2 + #endif + #ifndef _SIZE_T_DEFINED typedef unsigned int size_t; #define _SIZE_T_DEFINED #endif +#ifndef _WCHAR_T_DEFINED +typedef unsigned short wchar_t; +#define _WCHAR_T_DEFINED +#endif + +#ifndef _WCTYPE_T_DEFINED +typedef wchar_t wint_t; +typedef wchar_t wctype_t; +#define _WCTYPE_T_DEFINED +#endif + #ifndef _VA_LIST_DEFINED -typedef char * va_list; +#if defined(_ALPHA_) +typedef struct { + char *a0; /* pointer to first homed integer argument */ + int offset; /* byte offset of next parameter */ +} va_list; +#else +typedef char * va_list; +#endif #define _VA_LIST_DEFINED #endif @@ -35,11 +72,19 @@ typedef char * va_list; /* buffered I/O macros */ #define BUFSIZ 512 + +/* + * Number of supported streams. _NFILE is confusing and obsolete, but + * supported anyway for backwards compatibility. + */ +#define _NFILE _NSTREAM_ #ifdef _MT -#define _NFILE 40 +#define _NSTREAM_ 40 #else -#define _NFILE 20 +#define _NSTREAM_ 20 #endif + + #define EOF (-1) #ifndef _FILE_DEFINED @@ -51,30 +96,40 @@ struct _iobuf { int _file; int _charbuf; int _bufsiz; - int __tmpnum; + char *_tmpfname; }; typedef struct _iobuf FILE; #define _FILE_DEFINED #endif -/* P_tmpnam: Directory where temporary files may be created. - * L_tmpnam size = size of P_tmpdir - * + 1 (in case P_tmpdir does not end in "\\") - * + 6 (for the temp number string) - * + 1 (for the null terminator) +/* Directory where temporary files may be created. */ +#ifdef _POSIX_ +#define _P_tmpdir "/" +#else +#define _P_tmpdir "\\" +#endif + +/* L_tmpnam = size of P_tmpdir + * + 1 (in case P_tmpdir does not end in "/") + * + 12 (for the filename string) + * + 1 (for the null terminator) */ +#define L_tmpnam sizeof(_P_tmpdir)+12 -#define _P_tmpdir "\\" -#define L_tmpnam sizeof(_P_tmpdir)+8 + +#ifdef _POSIX_ +#define L_ctermid 9 +#define L_cuserid 32 +#endif #define SEEK_CUR 1 #define SEEK_END 2 #define SEEK_SET 0 -#define FILENAME_MAX 63 -#define FOPEN_MAX 20 -#define _SYS_OPEN 20 -#define TMP_MAX 32767 +#define FILENAME_MAX 260 +#define FOPEN_MAX 20 +#define _SYS_OPEN 20 +#define TMP_MAX 32767 /* define NULL pointer value */ @@ -91,8 +146,12 @@ typedef struct _iobuf FILE; /* declare _iob[] array */ #ifndef _STDIO_DEFINED +#ifdef _DLL +extern FILE * _iob; +#else extern FILE _iob[]; #endif +#endif /* define file position type */ @@ -120,70 +179,122 @@ typedef long fpos_t; #define _IOERR 0x0020 #define _IOSTRG 0x0040 #define _IORW 0x0080 - +#ifdef _POSIX_ +#define _IOAPPEND 0x0200 +#endif /* function prototypes */ #ifndef _STDIO_DEFINED -int _filbuf(FILE *); -int _flsbuf(int, FILE *); -FILE * _fsopen(const char *, const char *, int); -void clearerr(FILE *); -int fclose(FILE *); -int _fcloseall(void); -FILE * _fdopen(int, const char *); -int feof(FILE *); -int ferror(FILE *); -int fflush(FILE *); -int fgetc(FILE *); -int _fgetchar(void); -int fgetpos(FILE *, fpos_t *); -char * fgets(char *, int, FILE *); -int _fileno(FILE *); -int _flushall(void); -FILE * fopen(const char *, const char *); -int fprintf(FILE *, const char *, ...); -int fputc(int, FILE *); -int _fputchar(int); -int fputs(const char *, FILE *); -size_t fread(void *, size_t, size_t, FILE *); -FILE * freopen(const char *, const char *, FILE *); -int fscanf(FILE *, const char *, ...); -int fsetpos(FILE *, const fpos_t *); -int fseek(FILE *, long, int); -long ftell(FILE *); -size_t fwrite(const void *, size_t, size_t, FILE *); -int getc(FILE *); -int getchar(void); -char * gets(char *); -int _getw(FILE *); -void perror(const char *); -int _pclose(FILE *); -FILE * _popen(const char *, const char *); -int printf(const char *, ...); -int putc(int, FILE *); -int putchar(int); -int puts(const char *); -int _putw(int, FILE *); -int remove(const char *); -int rename(const char *, const char *); -void rewind(FILE *); -int _rmtmp(void); -int scanf(const char *, ...); -void setbuf(FILE *, char *); -int setvbuf(FILE *, char *, int, size_t); -int _snprintf(char *, size_t, const char *, ...); -int sprintf(char *, const char *, ...); -int sscanf(const char *, const char *, ...); -char * _tempnam(char *, char *); -FILE * tmpfile(void); -char * tmpnam(char *); -int ungetc(int, FILE *); -int _unlink(const char *); -int vfprintf(FILE *, const char *, va_list); -int vprintf(const char *, va_list); -int _vsnprintf(char *, size_t, const char *, va_list); -int vsprintf(char *, const char *, va_list); +int _CRTAPI1 _filbuf(FILE *); +int _CRTAPI1 _flsbuf(int, FILE *); + +#ifdef _POSIX_ +FILE * _CRTAPI1 _fsopen(const char *, const char *); +#else +FILE * _CRTAPI1 _fsopen(const char *, const char *, int); +#endif + +void _CRTAPI1 clearerr(FILE *); +int _CRTAPI1 fclose(FILE *); +int _CRTAPI1 _fcloseall(void); +#ifdef _POSIX_ +FILE * _CRTAPI1 fdopen(int, const char *); +#else +FILE * _CRTAPI1 _fdopen(int, const char *); +#endif +int _CRTAPI1 feof(FILE *); +int _CRTAPI1 ferror(FILE *); +int _CRTAPI1 fflush(FILE *); +int _CRTAPI1 fgetc(FILE *); +int _CRTAPI1 _fgetchar(void); +int _CRTAPI1 fgetpos(FILE *, fpos_t *); +char * _CRTAPI1 fgets(char *, int, FILE *); +#ifdef _POSIX_ +int _CRTAPI1 fileno(FILE *); +#else +int _CRTAPI1 _fileno(FILE *); +#endif +int _CRTAPI1 _flushall(void); +FILE * _CRTAPI1 fopen(const char *, const char *); +int _CRTAPI2 fprintf(FILE *, const char *, ...); +int _CRTAPI1 fputc(int, FILE *); +int _CRTAPI1 _fputchar(int); +int _CRTAPI1 fputs(const char *, FILE *); +size_t _CRTAPI1 fread(void *, size_t, size_t, FILE *); +FILE * _CRTAPI1 freopen(const char *, const char *, FILE *); +int _CRTAPI2 fscanf(FILE *, const char *, ...); +int _CRTAPI1 fsetpos(FILE *, const fpos_t *); +int _CRTAPI1 fseek(FILE *, long, int); +long _CRTAPI1 ftell(FILE *); +size_t _CRTAPI1 fwrite(const void *, size_t, size_t, FILE *); +int _CRTAPI1 getc(FILE *); +int _CRTAPI1 getchar(void); +char * _CRTAPI1 gets(char *); +int _CRTAPI1 _getw(FILE *); +void _CRTAPI1 perror(const char *); +int _CRTAPI1 _pclose(FILE *); +FILE * _CRTAPI1 _popen(const char *, const char *); +int _CRTAPI2 printf(const char *, ...); +int _CRTAPI1 putc(int, FILE *); +int _CRTAPI1 putchar(int); +int _CRTAPI1 puts(const char *); +int _CRTAPI1 _putw(int, FILE *); +int _CRTAPI1 remove(const char *); +int _CRTAPI1 rename(const char *, const char *); +void _CRTAPI1 rewind(FILE *); +int _CRTAPI1 _rmtmp(void); +int _CRTAPI2 scanf(const char *, ...); +void _CRTAPI1 setbuf(FILE *, char *); +int _CRTAPI1 setvbuf(FILE *, char *, int, size_t); +int _CRTAPI2 _snprintf(char *, size_t, const char *, ...); +int _CRTAPI2 sprintf(char *, const char *, ...); +int _CRTAPI2 sscanf(const char *, const char *, ...); +char * _CRTAPI1 _tempnam(char *, char *); +FILE * _CRTAPI1 tmpfile(void); +char * _CRTAPI1 tmpnam(char *); +int _CRTAPI1 ungetc(int, FILE *); +int _CRTAPI1 _unlink(const char *); +int _CRTAPI1 vfprintf(FILE *, const char *, va_list); +int _CRTAPI1 vprintf(const char *, va_list); +int _CRTAPI1 _vsnprintf(char *, size_t, const char *, va_list); +int _CRTAPI1 vsprintf(char *, const char *, va_list); + +#if !__STDC__ +#ifndef _WSTDIO_DEFINED + +/* declared in wchar.h, officially */ +wint_t _CRTAPI1 fgetwc(FILE *); +wint_t _CRTAPI1 _fgetwchar(void); +wint_t _CRTAPI1 fputwc(wint_t, FILE *); +wint_t _CRTAPI1 _fputwchar(wint_t); +wint_t _CRTAPI1 getwc(FILE *); +wint_t _CRTAPI1 getwchar(void); +wint_t _CRTAPI1 putwc(wint_t, FILE *); +wint_t _CRTAPI1 putwchar(wint_t); +wint_t _CRTAPI1 ungetwc(wint_t, FILE *); + +int _CRTAPI2 fwprintf(FILE *, const wchar_t *, ...); +int _CRTAPI2 wprintf(const wchar_t *, ...); +int _CRTAPI2 _snwprintf(wchar_t *, size_t, const wchar_t *, ...); +int _CRTAPI2 swprintf(wchar_t *, const wchar_t *, ...); +int _CRTAPI1 vfwprintf(FILE *, const wchar_t *, va_list); +int _CRTAPI1 vwprintf(const wchar_t *, va_list); +int _CRTAPI1 _vsnwprintf(wchar_t *, size_t, const wchar_t *, va_list); +int _CRTAPI1 vswprintf(wchar_t *, const wchar_t *, va_list); +int _CRTAPI2 fwscanf(FILE *, const wchar_t *, ...); +int _CRTAPI2 swscanf(const wchar_t *, const wchar_t *, ...); +int _CRTAPI2 wscanf(const wchar_t *, ...); + +#define getwchar() fgetwc(stdin) +#define putwchar(_c) fputwc((_c),stdout) +#define getwc(_stm) fgetwc(_stm) +#define putwc(_c,_stm) fputwc(_c,_stm) + + +#define _WSTDIO_DEFINED +#endif +#endif /* !__STDC__ */ #define _STDIO_DEFINED #endif @@ -200,6 +311,7 @@ int vsprintf(char *, const char *, va_li #define getchar() getc(stdin) #define putchar(_c) putc((_c),stdout) + #ifdef _MT #undef getc #undef putc @@ -207,7 +319,7 @@ int vsprintf(char *, const char *, va_li #undef putchar #endif -#if !__STDC__ +#if !__STDC__ && !defined(_POSIX_) /* Non-ANSI names for compatibility */ #define P_tmpdir _P_tmpdir