Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

726 lines
24 KiB

  1. /***
  2. *internal.h - contains declarations of internal routines and variables
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Declares routines and variables used internally by the C run-time.
  8. *
  9. * [Internal]
  10. *
  11. *Revision History:
  12. * 05-18-87 SKS Module created
  13. * 07-15-87 JCR Added _old_pfxlen and _tempoff
  14. * 08-05-87 JCR Added _getbuf (corrected by SKS)
  15. * 11-05-87 JCR Added _buferr
  16. * 11-18-87 SKS Add __tzset(), made _isindst() near, remove _dtoxmode
  17. * 01-26-88 SKS Make __tzset, _isindst, _dtoxtime near/far for QC
  18. * 02-10-88 JCR Cleaned up white space
  19. * 06-22-88 SKS _canonic/_getcdrv are now used by all models
  20. * 06-29-88 JCR Removed static buffers _bufout and _buferr
  21. * 08-18-88 GJF Revised to also work for the 386 (small model only).
  22. * 09-22-88 GJF Added declarations for _freebuf, _stbuf and _ftbuf.
  23. * 01-31-89 JCR Removed _canonic, _getcdrv, _getcdwd (see direct.h)
  24. * 06-07-89 PHG Added _dosret for i860 (N10) version of libs
  25. * 07-05-89 PHG Changed above to _dosmaperr, added startup variables
  26. * 08-17-89 GJF Cleanup, removed stuff not needed for 386
  27. * 10-25-89 JCR Added prototype for _getpath()
  28. * 10-30-89 GJF Fixed copyright
  29. * 11-02-89 JCR Changed "DLL" to "_DLL"
  30. * 03-01-90 GJF Added #ifndef _INC_INTERNAL and #include <cruntime.h>
  31. * stuff. Also, removed some (now) useless preprocessing
  32. * directives.
  33. * 03-21-90 GJF Put _CALLTYPE1 into prototypes.
  34. * 03-26-90 GJF Added prototypes for _output() and _input(). Filled
  35. * out the prototype for _openfile
  36. * 04-05-90 GJF Added prototype for __NMSG_WRITE() (C source build
  37. * only).
  38. * 04-10-90 GJF Added prototypes for startup functions.
  39. * 05-28-90 SBM Added _flush()
  40. * 07-11-90 SBM Added _commode, removed execload()
  41. * 07-20-90 SBM Changes supporting clean -W3 compiles (added _cftoe
  42. * and _cftof prototypes)
  43. * 08-01-90 SBM Moved _cftoe() and _cftof() to new header
  44. * <fltintrn.h>, formerly named <struct.h>
  45. * 08-21-90 GJF Changed prototypes for _amsg_exit() and _NMSG_WRITE().
  46. * 11-29-90 GJF Added some defs/decls for lowio under Win32.
  47. * 12-04-90 SRW Added _osfile back for win32. Changed _osfinfo from
  48. * an array of structures to an array of 32-bit handles
  49. * (_osfhnd)
  50. * 04-06-91 GJF Changed _heapinit to _heap_init.
  51. * 08-19-91 JCR Added _exitflag
  52. * 08-20-91 JCR C++ and ANSI naming
  53. * 01-05-92 GJF Added declaration for termination done flag [_WIN32_]
  54. * 01-08-92 GJF Added prototype for _GetMainArgs.
  55. * 01-18-92 GJF Added _aexit_rtn.
  56. * 01-22-92 GJF Fixed definitions of _acmdln and _aexit_rtn for the
  57. * of crtdll.dll, crtdll.lib.
  58. * 01-29-92 GJF Added support for linked-in options equivalent to
  59. * commode.obj and setargv.obj (i.e., special declarations
  60. * for _commode and _dowildcard).
  61. * 02-14-92 GJF Replace _nfile with _nhandle for Win32. Also, added
  62. * #define-s for _NHANDLE_.
  63. * 03-17-92 GJF Removed declaration of _tmpoff for Win32.
  64. * 03-30-92 DJM POSIX support.
  65. * 04-27-92 GJF Added prototypes for _ValidDrive (in stat.c).
  66. * 05-28-92 GJF Added prototype for _mtdeletelocks() for Win32.
  67. * 06-02-92 SKS Move prototype for _pgmptr to <DOS.H>
  68. * 06-02-92 KRS Added prototype for _woutput().
  69. * 08-06-92 GJF Function calling type and variable type macros.
  70. * 08-17-92 KRS Added prototype for _winput().
  71. * 08-21-92 GJF Merged last two changes above.
  72. * 08-24-92 PBS Added _dstoffset for posix TZ
  73. * 10-24-92 SKS Add a fourth parameter to _GetMainArgs: wildcard flag
  74. * _GetMainArgs => __GetMainArgs: 2 leading _'s = internal
  75. * 10-24-92 SKS Remove two unnecessary parameters from _cenvarg()
  76. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  77. * 03-30-93 GJF __gmtotime_t supercedes _dtoxtime.
  78. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  79. * Change _ValidDrive to _validdrive
  80. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  81. * Use link-time aliases for old names, not #define's
  82. * 04-13-93 SKS Add _mtterm (complement of _mtinit)
  83. * 04-26-93 SKS _mtinit now returns success (1) or failure (0)
  84. * 05-06-93 SKS Add _heap_term() - frees up memory upon DLL detach
  85. * 07-21-93 GJF __loctotime_t supercedes _gmtotime_t.
  86. * 09-15-93 CFW Added mbc init function prototypes.
  87. * 09-17-93 GJF Merged NT SDK and Cuda versions, added prototype for
  88. * _heap_abort.
  89. * 10-13-93 GJF Replaced _ALPHA_ with _M_ALPHA.
  90. * 10-21-93 GJF Changed _NTSDK definition of _commode slightly to
  91. * work with dllsuff\crtexe.c.
  92. * 10-22-93 CFW Test for invalid MB chars using global preset flag.
  93. * 10-26-93 GJF Added typedef for _PVFV.
  94. * 11-19-93 CFW Add _wcmdln, wmain, _wsetargv.
  95. * 11-23-93 CFW Undef GetEnvironmentStrings (TEMPORARY).
  96. * 11-29-93 CFW Remove GetEnvironmentStrings undef, NT 540 has fix.
  97. * 12-01-93 CFW Add _wenvptr and protos for wide environ functions.
  98. * 12-07-93 CFW Add _wcenvarg, _wcapture_argv, and wdospawn protos.
  99. * 01-11-94 GJF __GetMainArgs() instead of __getmainargs for NT SDK.
  100. * 03-04-94 SKS Add declarations of _newmode and _dowildcard.
  101. * Adjust decl of _[w]getmainargs for 4th parameter.
  102. * 03-25-94 GJF Added declaration of __[w]initenv
  103. * 03-25-94 GJF Made declarations of:
  104. * _acmdln, _wcmdln,
  105. * _aenvptr, _wenvptr
  106. * _C_Termination_Flag,
  107. * _exitflag,
  108. * __initenv, __winitenv,
  109. * __invalid_mb_chars
  110. * _lastiob,
  111. * _old_pfxlen,
  112. * _osfhnd[]
  113. * _osfile[],
  114. * _pipech[],
  115. * _tempoff,
  116. * _umaskval
  117. * conditional on DLL_FOR_WIN32S. Made declaration of
  118. * _newmode conditional on DLL_FOR_WIN32S and CRTDLL.
  119. * Made declaration of _cflush conditional on CRTDLL.
  120. * Defined _commode to be a dereferenced function return
  121. * for _DLL. Conditionally included win32s.h.
  122. * 04-14-94 GJF Added definition for FILE.
  123. * 05-03-94 GJF Made declarations of _commode, __initenv, __winitenv
  124. * _acmdln and _wcmdln also conditional on _M_IX86.
  125. * 05-09-94 CFW Add __fcntrlcomp, remove DLL_FOR_WIN32S protection
  126. * on __invalid_mb_chars.
  127. * 09-06-94 GJF Added declarations for __app_type, __set_app_type()
  128. * and related constants, and __error_mode.
  129. * 09-06-94 CFW Remove _MBCS_OS switch.
  130. * 12-14-94 SKS Increase file handle limit for MSVCRT30.DLL
  131. * 12-15-94 XY merged with mac header
  132. * 12-21-94 CFW Remove fcntrlcomp & invalid_mb NT 3.1 hacks.
  133. * 12-23-94 GJF Added prototypes for _fseeki64, _fseeki64_lk,
  134. * _ftelli64 and _ftelli64_lk.
  135. * 12-28-94 JCF Changed _osfhnd from long to int in _MAC_.
  136. * 01-17-95 BWT Don't define main/wmain for POSIX
  137. * 02-11-95 CFW Don't define __argc, __argv, _pgmptr for Mac.
  138. * 02-14-95 GJF Made __dnames[] and __mnames[] const.
  139. * 02-14-95 CFW Clean up Mac merge.
  140. * 03-03-95 GJF Changes to manage streams via __piob[], rather than
  141. * _iob[].
  142. * 03-29-95 BWT Define _commode properly for RISC _DLL CRTEXE case.
  143. * 03-29-95 CFW Add error message to internal headers.
  144. * 04-06-95 CFW Add parameter to _setenvp().
  145. * 05-08-95 CFW Official ANSI C++ new handler added.
  146. * 06-15-95 GJF Revised for ioinfo arrays.
  147. * 07-04-95 GJF Removed additional parameter from _setenvp().
  148. * 06-23-95 CFW ANSI new handler removed from build.
  149. * 07-26-95 GJF Added safe versions of ioinfo access macros.
  150. * 09-25-95 GJF Added parameter to __loctotime_t.
  151. * 12-08-95 SKS Add __initconin()/__initconout() for non-MAC platforms.
  152. * 12-14-95 JWM Add "#pragma once".
  153. * 04-12-96 SKS __badioinfo and __pioinfo must be exported for the
  154. * Old Iostreams DLLs (msvcirt.dll and msvcirtd.dll).
  155. * 04-22-96 GJF Return type of _heap_init changed.
  156. * 05-10-96 SKS Add definition of _CRTIMP1 -- needed by mtlock/mtunlock
  157. * 08-01-96 RDK For PMac, add extern for _osfileflags for extra byte of
  158. * file flags.
  159. * 08-22-96 SKS Add definition of _CRTIMP2
  160. * 02-03-97 GJF Cleaned out obsolete support for Win32s, _CRTAPI* and
  161. * _NTSDK. Replaced defined(_M_MPPC) || defined(_M_M68K)
  162. * with defined(_MAC). Also, detab-ed.
  163. * 04-16-97 GJF Restored the macros for _[w]initenv in the DLL model
  164. * because they prove useful in something else.
  165. * 07-23-97 GJF _heap_init changed slightly.
  166. * 02-07-98 GJF Changes for Win64: use intptr_t where appropriate,
  167. * and made time_t __int64.
  168. * 05-04-98 GJF Added __time64_t support.
  169. * 12-15-98 GJF Changes for 64-bit size_t.
  170. * 05-17-99 PML Remove all Macintosh support.
  171. * 05-28-99 GJF Changed prototype for __crt[w]setenv.
  172. * 06-01-99 PML Minor cleanup for 5/3/99 Plauger STL drop.
  173. * 10-06-99 PML Add _W64 modifier to types which are 32 bits in Win32,
  174. * 64 bits in Win64.
  175. * 10-14-99 PML Add __crtInitCritSecAndSpinCount and _CRT_SPINCOUNT.
  176. * 11-03-99 PML Add va_list definition for _M_CEE.
  177. * 11-12-99 PML Wrap __time64_t in its own #ifndef.
  178. * 03-06-00 PML Add __crtExitProcess.
  179. * 09-07-00 PML Remove va_list definition for _M_CEE (vs7#159777)
  180. * 02-20-01 PML vs7#172586 Avoid _RT_LOCK by preallocating all locks
  181. * that will be required, and returning failure back on
  182. * inability to allocate a lock.
  183. * 03-19-01 BWT Stop calling through functions on X86 to get environment
  184. * 03-27-01 PML Return success/failure code from several startup
  185. * routines instead of calling _amsg_exit (vs7#231220)
  186. *
  187. ****/
  188. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  189. #pragma once
  190. #endif
  191. #ifndef _INC_INTERNAL
  192. #define _INC_INTERNAL
  193. #ifndef _CRTBLD
  194. /*
  195. * This is an internal C runtime header file. It is used when building
  196. * the C runtimes only. It is not to be used as a public header file.
  197. */
  198. #error ERROR: Use of C runtime library internal header file.
  199. #endif /* _CRTBLD */
  200. #ifdef __cplusplus
  201. extern "C" {
  202. #endif
  203. #include <cruntime.h>
  204. /*
  205. * Conditionally include windows.h to pick up the definition of
  206. * CRITICAL_SECTION.
  207. */
  208. #ifdef _MT
  209. #include <windows.h>
  210. #endif
  211. #if !defined(_W64)
  212. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  213. #define _W64 __w64
  214. #else
  215. #define _W64
  216. #endif
  217. #endif
  218. /* Define _CRTIMP */
  219. #ifndef _CRTIMP
  220. #ifdef CRTDLL
  221. #define _CRTIMP __declspec(dllexport)
  222. #else /* ndef CRTDLL */
  223. #ifdef _DLL
  224. #define _CRTIMP __declspec(dllimport)
  225. #else /* ndef _DLL */
  226. #define _CRTIMP
  227. #endif /* _DLL */
  228. #endif /* CRTDLL */
  229. #endif /* _CRTIMP */
  230. /* Define _CRTIMP1 */
  231. #ifndef _CRTIMP1
  232. #ifdef CRTDLL1
  233. #define _CRTIMP1 __declspec(dllexport)
  234. #else /* ndef CRTDLL1 */
  235. #define _CRTIMP1 _CRTIMP
  236. #endif /* CRTDLL1 */
  237. #endif /* _CRTIMP1 */
  238. /* Define _CRTIMP2 */
  239. #ifndef _CRTIMP2
  240. #if defined(CRTDLL2)
  241. #define _CRTIMP2 __declspec(dllexport)
  242. #else /* ndef CRTDLL2 */
  243. #if defined(_DLL) && !defined(_STATIC_CPPLIB)
  244. #define _CRTIMP2 __declspec(dllimport)
  245. #else /* ndef _DLL && !STATIC_CPPLIB */
  246. #define _CRTIMP2
  247. #endif /* _DLL && !STATIC_CPPLIB */
  248. #endif /* CRTDLL2 */
  249. #endif /* _CRTIMP2 */
  250. /* Define __cdecl for non-Microsoft compilers */
  251. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  252. #define __cdecl
  253. #endif
  254. #ifndef _INTPTR_T_DEFINED
  255. #ifdef _WIN64
  256. typedef __int64 intptr_t;
  257. #else
  258. typedef _W64 int intptr_t;
  259. #endif
  260. #define _INTPTR_T_DEFINED
  261. #endif
  262. #ifndef _WCHAR_T_DEFINED
  263. typedef unsigned short wchar_t;
  264. #define _WCHAR_T_DEFINED
  265. #endif
  266. /* Define function types used in several startup sources */
  267. typedef void (__cdecl *_PVFV)(void);
  268. typedef int (__cdecl *_PIFV)(void);
  269. #if defined(_DLL) && defined(_M_IX86)
  270. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  271. _CRTIMP int * __p__commode(void);
  272. #endif
  273. #if defined(SPECIAL_CRTEXE) && defined(_DLL)
  274. extern int _commode;
  275. #else
  276. _CRTIMP extern int _commode;
  277. #endif /* defined(_DLL) && defined(SPECIAL_CRTEXE) */
  278. /*
  279. * Control structure for lowio file handles
  280. */
  281. typedef struct {
  282. intptr_t osfhnd; /* underlying OS file HANDLE */
  283. char osfile; /* attributes of file (e.g., open in text mode?) */
  284. char pipech; /* one char buffer for handles opened on pipes */
  285. #ifdef _MT
  286. int lockinitflag;
  287. CRITICAL_SECTION lock;
  288. #endif
  289. } ioinfo;
  290. /*
  291. * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
  292. * array of ioinfo structs.
  293. */
  294. #define IOINFO_L2E 5
  295. /*
  296. * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
  297. */
  298. #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
  299. /*
  300. * Definition of IOINFO_ARRAYS, maximum number of supported ioinfo arrays.
  301. */
  302. #define IOINFO_ARRAYS 64
  303. #define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
  304. /*
  305. * Access macros for getting at an ioinfo struct and its fields from a
  306. * file handle
  307. */
  308. #define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - \
  309. 1)) )
  310. #define _osfhnd(i) ( _pioinfo(i)->osfhnd )
  311. #define _osfile(i) ( _pioinfo(i)->osfile )
  312. #define _pipech(i) ( _pioinfo(i)->pipech )
  313. /*
  314. * Safer versions of the above macros. Currently, only _osfile_safe is
  315. * used.
  316. */
  317. #define _pioinfo_safe(i) ( ((i) != -1) ? _pioinfo(i) : &__badioinfo )
  318. #define _osfhnd_safe(i) ( _pioinfo_safe(i)->osfhnd )
  319. #define _osfile_safe(i) ( _pioinfo_safe(i)->osfile )
  320. #define _pipech_safe(i) ( _pioinfo_safe(i)->pipech )
  321. /*
  322. * Special, static ioinfo structure used only for more graceful handling
  323. * of a C file handle value of -1 (results from common errors at the stdio
  324. * level).
  325. */
  326. extern _CRTIMP ioinfo __badioinfo;
  327. /*
  328. * Array of arrays of control structures for lowio files.
  329. */
  330. extern _CRTIMP ioinfo * __pioinfo[];
  331. /*
  332. * Current number of allocated ioinfo structures (_NHANDLE_ is the upper
  333. * limit).
  334. */
  335. extern int _nhandle;
  336. int __cdecl _alloc_osfhnd(void);
  337. int __cdecl _free_osfhnd(int);
  338. int __cdecl _set_osfhnd(int, intptr_t);
  339. #ifdef _POSIX_
  340. extern long _dstoffset;
  341. #endif /* _POSIX_ */
  342. extern const char __dnames[];
  343. extern const char __mnames[];
  344. extern int _days[];
  345. extern int _lpdays[];
  346. #ifndef _TIME_T_DEFINED
  347. #ifdef _WIN64
  348. typedef __int64 time_t; /* time value */
  349. #else
  350. typedef _W64 long time_t; /* time value */
  351. #endif
  352. #define _TIME_T_DEFINED /* avoid multiple def's of time_t */
  353. #endif
  354. #ifndef _TIME64_T_DEFINED
  355. typedef __int64 __time64_t; /* 64-bit time value */
  356. #define _TIME64_T_DEFINED
  357. #endif
  358. extern time_t __cdecl __loctotime_t(int, int, int, int, int, int, int);
  359. extern __time64_t __cdecl __loctotime64_t(int, int, int, int, int, int, int);
  360. #ifdef _TM_DEFINED
  361. extern int __cdecl _isindst(struct tm *);
  362. #endif
  363. extern void __cdecl __tzset(void);
  364. extern int __cdecl _validdrive(unsigned);
  365. /*
  366. * This variable is in the C start-up; the length must be kept synchronized
  367. * It is used by the *cenvarg.c modules
  368. */
  369. extern char _acfinfo[]; /* "_C_FILE_INFO=" */
  370. #define CFI_LENGTH 12 /* "_C_FILE_INFO" is 12 bytes long */
  371. /* typedefs needed for subsequent prototypes */
  372. #ifndef _SIZE_T_DEFINED
  373. #ifdef _WIN64
  374. typedef unsigned __int64 size_t;
  375. #else
  376. typedef _W64 unsigned int size_t;
  377. #endif
  378. #define _SIZE_T_DEFINED
  379. #endif
  380. #ifndef _VA_LIST_DEFINED
  381. #ifdef _M_ALPHA
  382. typedef struct {
  383. char *a0; /* pointer to first homed integer argument */
  384. int offset; /* byte offset of next parameter */
  385. } va_list;
  386. #else
  387. typedef char * va_list;
  388. #endif
  389. #define _VA_LIST_DEFINED
  390. #endif
  391. /*
  392. * stdio internals
  393. */
  394. #ifndef _FILE_DEFINED
  395. struct _iobuf {
  396. char *_ptr;
  397. int _cnt;
  398. char *_base;
  399. int _flag;
  400. int _file;
  401. int _charbuf;
  402. int _bufsiz;
  403. char *_tmpfname;
  404. };
  405. typedef struct _iobuf FILE;
  406. #define _FILE_DEFINED
  407. #endif /* _FILE_DEFINED */
  408. #if !defined(_FILEX_DEFINED) && defined(_WINDOWS_)
  409. /*
  410. * Variation of FILE type used for the dynamically allocated portion of
  411. * __piob[]. For single thread, _FILEX is the same as FILE. For multithread
  412. * models, _FILEX has two fields: the FILE struct and the CRITICAL_SECTION
  413. * struct used to serialize access to the FILE.
  414. */
  415. #ifdef _MT
  416. typedef struct {
  417. FILE f;
  418. CRITICAL_SECTION lock;
  419. } _FILEX;
  420. #else /* ndef _MT */
  421. typedef FILE _FILEX;
  422. #endif /* _MT */
  423. #define _FILEX_DEFINED
  424. #endif /* _FILEX_DEFINED */
  425. /*
  426. * Number of entries supported in the array pointed to by __piob[]. That is,
  427. * the number of stdio-level files which may be open simultaneously. This
  428. * is normally set to _NSTREAM_ by the stdio initialization code.
  429. */
  430. extern int _nstream;
  431. /*
  432. * Pointer to the array of pointers to FILE/_FILEX structures that are used
  433. * to manage stdio-level files.
  434. */
  435. extern void **__piob;
  436. FILE * __cdecl _getstream(void);
  437. #ifdef _POSIX_
  438. FILE * __cdecl _openfile(const char *, const char *, FILE *);
  439. #else
  440. FILE * __cdecl _openfile(const char *, const char *, int, FILE *);
  441. #endif
  442. FILE * __cdecl _wopenfile(const wchar_t *, const wchar_t *, int, FILE *);
  443. void __cdecl _getbuf(FILE *);
  444. int __cdecl _filwbuf (FILE *);
  445. int __cdecl _flswbuf(int, FILE *);
  446. void __cdecl _freebuf(FILE *);
  447. int __cdecl _stbuf(FILE *);
  448. void __cdecl _ftbuf(int, FILE *);
  449. int __cdecl _output(FILE *, const char *, va_list);
  450. int __cdecl _woutput(FILE *, const wchar_t *, va_list);
  451. int __cdecl _input(FILE *, const unsigned char *, va_list);
  452. int __cdecl _winput(FILE *, const wchar_t *, va_list);
  453. int __cdecl _flush(FILE *);
  454. void __cdecl _endstdio(void);
  455. int __cdecl _fseeki64(FILE *, __int64, int);
  456. int __cdecl _fseeki64_lk(FILE *, __int64, int);
  457. __int64 __cdecl _ftelli64(FILE *);
  458. #ifdef _MT
  459. __int64 __cdecl _ftelli64_lk(FILE *);
  460. #else /* ndef _MT */
  461. #define _ftelli64_lk _ftelli64
  462. #endif /* _MT */
  463. #ifndef CRTDLL
  464. extern int _cflush;
  465. #endif /* CRTDLL */
  466. extern unsigned int _tempoff;
  467. extern unsigned int _old_pfxlen;
  468. extern int _umaskval; /* the umask value */
  469. extern char _pipech[]; /* pipe lookahead */
  470. extern char _exitflag; /* callable termination flag */
  471. extern int _C_Termination_Done; /* termination done flag */
  472. char * __cdecl _getpath(const char *, char *, unsigned);
  473. wchar_t * __cdecl _wgetpath(const wchar_t *, wchar_t *, unsigned);
  474. extern int _dowildcard; /* flag to enable argv[] wildcard expansion */
  475. #ifndef _PNH_DEFINED
  476. typedef int (__cdecl * _PNH)( size_t );
  477. #define _PNH_DEFINED
  478. #endif
  479. #ifdef ANSI_NEW_HANDLER
  480. /* ANSI C++ new handler */
  481. #ifndef _ANSI_NH_DEFINED
  482. typedef void (__cdecl * new_handler) ();
  483. #define _ANSI_NH_DEFINED
  484. #endif
  485. #ifndef _NO_ANSI_NH_DEFINED
  486. #define _NO_ANSI_NEW_HANDLER ((new_handler)-1)
  487. #define _NO_ANSI_NH_DEFINED
  488. #endif
  489. extern new_handler _defnewh; /* default ANSI C++ new handler */
  490. #endif /* ANSI_NEW_HANDLER */
  491. /* calls the currently installed new handler */
  492. int __cdecl _callnewh(size_t);
  493. extern int _newmode; /* malloc new() handler mode */
  494. /* pointer to initial environment block that is passed to [w]main */
  495. extern _CRTIMP wchar_t **__winitenv;
  496. extern _CRTIMP char **__initenv;
  497. /* startup set values */
  498. extern char *_aenvptr; /* environment ptr */
  499. extern wchar_t *_wenvptr; /* wide environment ptr */
  500. /* command line */
  501. #if defined(_DLL) && defined(_M_IX86)
  502. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  503. _CRTIMP char ** __cdecl __p__acmdln(void);
  504. _CRTIMP wchar_t ** __cdecl __p__wcmdln(void);
  505. #endif
  506. _CRTIMP extern char *_acmdln;
  507. _CRTIMP extern wchar_t *_wcmdln;
  508. /*
  509. * prototypes for internal startup functions
  510. */
  511. int __cdecl _cwild(void); /* wild.c */
  512. int __cdecl _wcwild(void); /* wwild.c */
  513. #ifdef _MT
  514. int __cdecl _mtinit(void); /* tidtable.c */
  515. void __cdecl _mtterm(void); /* tidtable.c */
  516. int __cdecl _mtinitlocks(void); /* mlock.c */
  517. void __cdecl _mtdeletelocks(void); /* mlock.c */
  518. int __cdecl _mtinitlocknum(int); /* mlock.c */
  519. #endif
  520. #ifdef _MT
  521. /* Wrapper for InitializeCriticalSection API, with default spin count */
  522. int __cdecl __crtInitCritSecAndSpinCount(PCRITICAL_SECTION, DWORD);
  523. #define _CRT_SPINCOUNT 4000
  524. #endif
  525. /*
  526. * C source build only!!!!
  527. *
  528. * more prototypes for internal startup functions
  529. */
  530. void __cdecl _amsg_exit(int); /* crt0.c */
  531. void __cdecl __crtExitProcess(int); /* crt0dat.c */
  532. int __cdecl _cinit(void); /* crt0dat.c */
  533. void __cdecl __doinits(void); /* astart.asm */
  534. void __cdecl __doterms(void); /* astart.asm */
  535. void __cdecl __dopreterms(void); /* astart.asm */
  536. void __cdecl _FF_MSGBANNER(void);
  537. void __cdecl _fptrap(void); /* crt0fp.c */
  538. int __cdecl _heap_init(int);
  539. void __cdecl _heap_term(void);
  540. void __cdecl _heap_abort(void);
  541. void __cdecl __initconin(void); /* initcon.c */
  542. void __cdecl __initconout(void); /* initcon.c */
  543. int __cdecl _ioinit(void); /* crt0.c, crtlib.c */
  544. void __cdecl _ioterm(void); /* crt0.c, crtlib.c */
  545. char * __cdecl _GET_RTERRMSG(int);
  546. void __cdecl _NMSG_WRITE(int);
  547. int __cdecl _setargv(void); /* setargv.c, stdargv.c */
  548. int __cdecl __setargv(void); /* stdargv.c */
  549. int __cdecl _wsetargv(void); /* wsetargv.c, wstdargv.c */
  550. int __cdecl __wsetargv(void); /* wstdargv.c */
  551. int __cdecl _setenvp(void); /* stdenvp.c */
  552. int __cdecl _wsetenvp(void); /* wstdenvp.c */
  553. void __cdecl __setmbctable(unsigned int); /* mbctype.c */
  554. #ifdef _MBCS
  555. int __cdecl __initmbctable(void); /* mbctype.c */
  556. #endif
  557. #ifndef _POSIX_
  558. int __cdecl main(int, char **, char **);
  559. int __cdecl wmain(int, wchar_t **, wchar_t **);
  560. #endif
  561. /* helper functions for wide/multibyte environment conversion */
  562. int __cdecl __mbtow_environ (void);
  563. int __cdecl __wtomb_environ (void);
  564. int __cdecl __crtsetenv (char *, const int);
  565. int __cdecl __crtwsetenv (wchar_t *, const int);
  566. _CRTIMP extern void (__cdecl * _aexit_rtn)(int);
  567. #if defined(_DLL) || defined(CRTDLL)
  568. #ifndef _STARTUP_INFO_DEFINED
  569. typedef struct
  570. {
  571. int newmode;
  572. #ifdef ANSI_NEW_HANDLER
  573. new_handler newh;
  574. #endif /* ANSI_NEW_HANDLER */
  575. } _startupinfo;
  576. #define _STARTUP_INFO_DEFINED
  577. #endif /* _STARTUP_INFO_DEFINED */
  578. _CRTIMP int __cdecl __getmainargs(int *, char ***, char ***,
  579. int, _startupinfo *);
  580. _CRTIMP int __cdecl __wgetmainargs(int *, wchar_t ***, wchar_t ***,
  581. int, _startupinfo *);
  582. #endif /* defined(_DLL) || defined(CRTDLL) */
  583. /*
  584. * Prototype, variables and constants which determine how error messages are
  585. * written out.
  586. */
  587. #define _UNKNOWN_APP 0
  588. #define _CONSOLE_APP 1
  589. #define _GUI_APP 2
  590. extern int __app_type;
  591. extern int __error_mode;
  592. _CRTIMP void __cdecl __set_app_type(int);
  593. /*
  594. * C source build only!!!!
  595. *
  596. * map Win32 errors into Xenix errno values -- for modules written in C
  597. */
  598. extern void __cdecl _dosmaperr(unsigned long);
  599. /*
  600. * internal routines used by the exec/spawn functions
  601. */
  602. extern intptr_t __cdecl _dospawn(int, const char *, char *, char *);
  603. extern intptr_t __cdecl _wdospawn(int, const wchar_t *, wchar_t *, wchar_t *);
  604. extern int __cdecl _cenvarg(const char * const *, const char * const *,
  605. char **, char **, const char *);
  606. extern int __cdecl _wcenvarg(const wchar_t * const *, const wchar_t * const *,
  607. wchar_t **, wchar_t **, const wchar_t *);
  608. #ifndef _M_IX86
  609. extern char ** _capture_argv(va_list *, const char *, char **, size_t);
  610. extern wchar_t ** _wcapture_argv(va_list *, const wchar_t *, wchar_t **, size_t);
  611. #endif
  612. #ifdef __cplusplus
  613. }
  614. #endif
  615. #endif /* _INC_INTERNAL */