summaryrefslogtreecommitdiffstats
path: root/private/crt32/h/internal.h
blob: 8609f63bc0e517811e0535703e8f59578c7187c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/***
*internal.h - contains declarations of internal routines and variables
*
*	Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
*
*Purpose:
*	Declares routines and variables used internally by the C run-time.
*	[Internal]
*
*Revision History:
*	05-18-87  SKS	Module created
*	07-15-87  JCR	Added _old_pfxlen and _tempoff
*	08-05-87  JCR	Added _getbuf (corrected by SKS)
*	11-05-87  JCR	Added _buferr
*	11-18-87  SKS	Add __tzset(), made _isindst() near, remove _dtoxmode
*	01-26-88  SKS	Make __tzset, _isindst, _dtoxtime near/far for QC
*	02-10-88  JCR	Cleaned up white space
*	06-22-88  SKS	_canonic/_getcdrv are now used by all models
*	06-29-88  JCR	Removed static buffers _bufout and _buferr
*	08-18-88  GJF	Revised to also work for the 386 (small model only).
*	09-22-88  GJF	Added declarations for _freebuf, _stbuf and _ftbuf.
*	01-31-89  JCR	Removed _canonic, _getcdrv, _getcdwd (see direct.h)
*	06-07-89  PHG	Added _dosret for i860 (N10) version of libs
*	07-05-89  PHG	Changed above to _dosmaperr, added startup variables
*	08-17-89  GJF	Cleanup, removed stuff not needed for 386
*	10-25-89  JCR	Added prototype for _getpath()
*	10-30-89  GJF	Fixed copyright
*	11-02-89  JCR	Changed "DLL" to "_DLL"
*	03-01-90  GJF	Added #ifndef _INC_INTERNAL and #include <cruntime.h>
*			stuff. Also, removed some (now) useless preprocessing
*			directives.
*	03-21-90  GJF	Put _CALLTYPE1 into prototypes.
*	03-26-90  GJF	Added prototypes for _output() and _input(). Filled
*			out the prototype for _openfile
*	04-05-90  GJF	Added prototype for __NMSG_WRITE() (C source build
*			only).
*	04-10-90  GJF	Added prototypes for startup functions.
*	05-28-90  SBM	Added _flush()
*	07-11-90  SBM	Added _commode, removed execload()
*	07-20-90  SBM	Changes supporting clean -W3 compiles (added _cftoe
*			and _cftof prototypes)
*	08-01-90  SBM	Moved _cftoe() and _cftof() to new header
*			<fltintrn.h>, formerly named <struct.h>
*	08-21-90  GJF	Changed prototypes for _amsg_exit() and _NMSG_WRITE().
*	11-29-90  GJF	Added some defs/decls for lowio under Win32.
*	12-04-90  SRW	Added _osfile back for win32.  Changed _osfinfo from
*                       an array of structures to an array of 32-bit handles
*			(_osfhnd)
*	04-06-91  GJF	Changed _heapinit to _heap_init.
*	08-19-91  JCR	Added _exitflag
*	08-20-91  JCR	C++ and ANSI naming
*	01-05-92  GJF	Added declaration for termination done flag [_WIN32_]
*	01-08-92  GJF	Added prototype for _GetMainArgs.
*	01-18-92  GJF	Added _aexit_rtn.
*	01-22-92  GJF	Fixed definitions of _acmdln and _aexit_rtn for the
*			of crtdll.dll, crtdll.lib.
*	01-29-92  GJF	Added support for linked-in options equivalent to
*			commode.obj and setargv.obj (i.e., special declarations
*			for _commode and _dowildcard).
*	02-14-92  GJF	Replace _nfile with _nhandle for Win32. Also, added
*			#define-s for _NHANDLE_.
*	03-17-92  GJF	Removed declaration of _tmpoff for Win32.
*	03-30-92  DJM	POSIX support.
*	04-27-92  GJF	Added prototypes for _ValidDrive (in stat.c).
*	05-28-92  GJF	Added prototype for _mtdeletelocks() for Win32.
*	06-02-92  SKS	Move prototype for _pgmptr to <DOS.H>
*	06-02-92  KRS	Added prototype for _woutput().
*	08-06-92  GJF	Function calling type and variable type macros.
*	08-17-92  KRS	Added prototype for _winput().
*	08-21-92  GJF	Merged last two changes above.
*	08-24-92  PBS	Added _dstoffset for posix TZ
*	10-24-92  SKS	Add a fourth parameter to _GetMainArgs: wildcard flag
*			_GetMainArgs => __GetMainArgs: 2 leading _'s = internal
*	10-24-92  SKS	Remove two unnecessary parameters from _cenvarg()
*	01-21-93  GJF	Removed support for C6-386's _cdecl.
*	03-30-93  GJF	__gmtotime_t supercedes _dtoxtime.
*	04-17-93  SKS	Add _mtterm
*	05-11-93  SKS	_mtinit now returns success (1) or failure (0)
*			_C_Termination_Done needed in all models (for DLLs)
*	06-02-93  CFW	Add _flswbuf, _filwbuf protos.
*       07-15-93  SRW   Added _capture_argv function prototype
*       09-22-93  CFW   Test for invalid MB chars using global preset flag.
*
****/

#ifndef _INC_INTERNAL

#ifdef __cplusplus
extern "C" {
#endif

#include <cruntime.h>

/* Define function type used in several startup sources */

typedef void (__cdecl *_PVFV)(void);


/*
 * 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


#ifdef	_DLL
#define _commode    (*_commode_dll)
extern int * _commode_dll;
#else
#ifdef	CRTDLL
#define _commode    _commode_dll
#endif
extern int _commode;
#endif

#ifdef	_WIN32_

/*
 * Define the number of supported handles. This definition must exactly match
 * the one in os2dll.h.
 */
#ifdef	MTHREAD
#define _NHANDLE_   256
#else
#define _NHANDLE_   64
#endif

extern int _nhandle;		/* == _NHANDLE_, set in ioinit.c */

#else	/* ndef _WIN32_ */

extern int _nfile;

#endif	/* _WIN32_ */

extern char _osfile[];

#ifdef _WIN32_
extern	long _osfhnd[];
int _CRTAPI1 _alloc_osfhnd(void);
int _CRTAPI1 _free_osfhnd(int);
int _CRTAPI1 _set_osfhnd(int,long);
#endif	/* _WIN32_ */

#ifdef _POSIX_
extern long _dstoffset;
#endif /* _POSIX_ */

extern char __dnames[];
extern char __mnames[];

extern int _days[];
extern int _lpdays[];

#ifndef _TIME_T_DEFINED
typedef long time_t;		/* time value */
#define _TIME_T_DEFINED 	/* avoid multiple def's of time_t */
#endif

extern time_t _CRTAPI1 __gmtotime_t(int, int, int, int, int, int);

#ifdef	_TM_DEFINED
extern int _CRTAPI1 _isindst(struct tm *);
#endif

extern void _CRTAPI1 __tzset(void);
#ifdef _POSIX_
extern void _CRTAPI1 _tzset(void);
#endif

extern int _CRTAPI1 _ValidDrive(unsigned);


/**
** This variable is in the C start-up; the length must be kept synchronized
**  It is used by the *cenvarg.c modules
**/

extern char _acfinfo[]; /* "_C_FILE_INFO=" */

#define CFI_LENGTH  12	/* "_C_FILE_INFO" is 12 bytes long */

#ifndef _SIZE_T_DEFINED
typedef unsigned int size_t;
#define _SIZE_T_DEFINED
#endif

#ifndef _VA_LIST_DEFINED
#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

/*
 * stdio internals
 */
#ifdef	_FILE_DEFINED

extern FILE * _lastiob;

FILE * _CRTAPI1 _getstream(void);
#ifdef _POSIX_
FILE * _CRTAPI1 _openfile(const char *, const char *, FILE *);
#else
FILE * _CRTAPI1 _openfile(const char *, const char *, int, FILE *);
#endif
void _CRTAPI1 _getbuf(FILE *);
int _CRTAPI1 _filwbuf (FILE *);
int __cdecl _flswbuf(int, FILE *);
void _CRTAPI1 _freebuf(FILE *);
int _CRTAPI1 _stbuf(FILE *);
void _CRTAPI1 _ftbuf(int, FILE *);
int _CRTAPI1 _output(FILE *, const char *, va_list);
int _CRTAPI1 _woutput(FILE *, const wchar_t *, va_list);
int _CRTAPI1 _input(FILE *, const unsigned char *, va_list);
int _CRTAPI1 _winput(FILE *, const wchar_t *, va_list);
int _CRTAPI1 _flush(FILE *);
void _CRTAPI1 _endstdio(void);

#endif

extern int __invalid_mb_chars;

extern int _cflush;

#ifdef	_CRUISER_
extern unsigned int _tmpoff;
#endif	/* _CRUISER_ */

extern unsigned int _tempoff;

extern unsigned int _old_pfxlen;

extern int _umaskval;		/* the umask value */

extern char _pipech[];		/* pipe lookahead */

extern char _exitflag;		/* callable termination flag */

#if	defined(_WIN32_)
extern int _C_Termination_Done; /* termination done flag */
#endif	/* _WIN32_ */

char * _CRTAPI1 _getpath(const char *, char *, unsigned);

/* startup set values */
extern char **__argv;		/* argument vector */
extern int __argc;		/* argument count */
extern char *_aenvptr;		/* environment ptr */

/* command line */
#ifdef	_DLL
#define _acmdln     (*_acmdln_dll)
extern char **_acmdln_dll;
#else
#ifdef	CRTDLL
#define _acmdln     _acmdln_dll
#endif
extern char *_acmdln;
#endif

/*
 * prototypes for internal startup functions
 */
int _CRTAPI1 _cwild(void);			/* wild.c */
char * _CRTAPI1 _find(char *);			/* stdarg.asm or stdargv.c */
#ifdef MTHREAD
int _CRTAPI1 _mtinit(void);			/* tidtable.asm */
void _CRTAPI1 _mtinitlocks(void);		/* mlock.asm */
void _CRTAPI1 _mtterm(void);			/* tidtable.asm */
void _CRTAPI1 _mtdeletelocks(void);		/* mlock.asm */
#endif

/*
 * C source build only!!!!
 *
 * more prototypes for internal startup functions
 */
void _CRTAPI1 _amsg_exit(int);			/* crt0.c */
void _CRTAPI1 _cinit(void);			/* crt0dat.c */
void _CRTAPI1 __doinits(void);			/* astart.asm */
void _CRTAPI1 __doterms(void);			/* astart.asm */
void _CRTAPI1 __dopreterms(void);		/* astart.asm */
void _CRTAPI1 _FF_MSGBANNER(void);
void _CRTAPI1 _fptrap(void);			/* crt0fp.c */
void _CRTAPI1 _heap_init(void);
#ifdef	_WIN32_
void _CRTAPI1 _ioinit(void);			/* crt0.c, crtlib.c */
#endif	/* _WIN32_ */
void _CRTAPI1 _NMSG_WRITE(int);
void _CRTAPI1 _setargv(void);			/* setargv.c, stdargv.c */
void _CRTAPI1 __setargv(void);			/* stdargv.c */
void _CRTAPI1 _setenvp(void);			/* stdenvp.c */

#ifdef	_DLL
#define _aexit_rtn  (*_aexit_rtn_dll)
extern void (_CRTAPI1 ** _aexit_rtn_dll)(int);
#else
#ifdef	CRTDLL
#define _aexit_rtn  _aexit_rtn_dll
#endif
extern void (_CRTAPI1 * _aexit_rtn)(int);
#endif

#ifdef	_WIN32_
#if	defined(_DLL) || defined(CRTDLL)
void _CRTAPI1 __GetMainArgs(int *, char ***, char ***, int);
#endif
#endif	/* _WIN32_ */

/*
 * C source build only!!!!
 *
 * map OS/2 errors into Xenix errno values -- for modules written in C
 */
extern void _CRTAPI1 _dosmaperr(unsigned long);

/*
 * internal routines used by the exec/spawn functions
 */

extern int _CRTAPI1 _dospawn(int, const char *, char *, char *);
extern int _CRTAPI1 _cenvarg(const char * const *, const char * const *,
	char **, char **, const char *);
extern char ** _CRTAPI1 _capture_argv(
    va_list *,
    const char *,
    char **,
    size_t
    );

#ifdef __cplusplus
}
#endif

#define _INC_INTERNAL
#endif	/* _INC_INTERNAL */