Leaked source code of windows server 2003
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.

732 lines
25 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. * 07-15-01 PML Remove all ALPHA, MIPS, and PPC code
  187. * 03-07-02 PML Added DEFAULT_SECURITY_COOKIE
  188. *
  189. ****/
  190. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  191. #pragma once
  192. #endif
  193. #ifndef _INC_INTERNAL
  194. #define _INC_INTERNAL
  195. #ifndef _CRTBLD
  196. /*
  197. * This is an internal C runtime header file. It is used when building
  198. * the C runtimes only. It is not to be used as a public header file.
  199. */
  200. #error ERROR: Use of C runtime library internal header file.
  201. #endif /* _CRTBLD */
  202. #ifdef __cplusplus
  203. extern "C" {
  204. #endif
  205. #include <cruntime.h>
  206. /*
  207. * Conditionally include windows.h to pick up the definition of
  208. * CRITICAL_SECTION.
  209. */
  210. #ifdef _MT
  211. #include <windows.h>
  212. #endif
  213. #if !defined(_W64)
  214. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  215. #define _W64 __w64
  216. #else
  217. #define _W64
  218. #endif
  219. #endif
  220. /* Define _CRTIMP */
  221. #ifndef _CRTIMP
  222. #ifdef CRTDLL
  223. #define _CRTIMP __declspec(dllexport)
  224. #else /* ndef CRTDLL */
  225. #ifdef _DLL
  226. #define _CRTIMP __declspec(dllimport)
  227. #else /* ndef _DLL */
  228. #define _CRTIMP
  229. #endif /* _DLL */
  230. #endif /* CRTDLL */
  231. #endif /* _CRTIMP */
  232. /* Define _CRTIMP1 */
  233. #ifndef _CRTIMP1
  234. #ifdef CRTDLL1
  235. #define _CRTIMP1 __declspec(dllexport)
  236. #else /* ndef CRTDLL1 */
  237. #define _CRTIMP1 _CRTIMP
  238. #endif /* CRTDLL1 */
  239. #endif /* _CRTIMP1 */
  240. /* Define _CRTIMP2 */
  241. #ifndef _CRTIMP2
  242. #if defined(CRTDLL2)
  243. #define _CRTIMP2 __declspec(dllexport)
  244. #else /* ndef CRTDLL2 */
  245. #if defined(_DLL) && !defined(_STATIC_CPPLIB)
  246. #define _CRTIMP2 __declspec(dllimport)
  247. #else /* ndef _DLL && !STATIC_CPPLIB */
  248. #define _CRTIMP2
  249. #endif /* _DLL && !STATIC_CPPLIB */
  250. #endif /* CRTDLL2 */
  251. #endif /* _CRTIMP2 */
  252. /* Define __cdecl for non-Microsoft compilers */
  253. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  254. #define __cdecl
  255. #endif
  256. #ifndef _INTPTR_T_DEFINED
  257. #ifdef _WIN64
  258. typedef __int64 intptr_t;
  259. #else
  260. typedef _W64 int intptr_t;
  261. #endif
  262. #define _INTPTR_T_DEFINED
  263. #endif
  264. #ifndef _WCHAR_T_DEFINED
  265. typedef unsigned short wchar_t;
  266. #define _WCHAR_T_DEFINED
  267. #endif
  268. /* Define function types used in several startup sources */
  269. typedef void (__cdecl *_PVFV)(void);
  270. typedef int (__cdecl *_PIFV)(void);
  271. #if defined(_DLL) && defined(_M_IX86)
  272. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  273. _CRTIMP int * __p__commode(void);
  274. #endif
  275. #if defined(SPECIAL_CRTEXE) && defined(_DLL)
  276. extern int _commode;
  277. #else
  278. _CRTIMP extern int _commode;
  279. #endif /* defined(_DLL) && defined(SPECIAL_CRTEXE) */
  280. /*
  281. * Control structure for lowio file handles
  282. */
  283. typedef struct {
  284. intptr_t osfhnd; /* underlying OS file HANDLE */
  285. char osfile; /* attributes of file (e.g., open in text mode?) */
  286. char pipech; /* one char buffer for handles opened on pipes */
  287. #ifdef _MT
  288. int lockinitflag;
  289. CRITICAL_SECTION lock;
  290. #endif
  291. } ioinfo;
  292. /*
  293. * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
  294. * array of ioinfo structs.
  295. */
  296. #define IOINFO_L2E 5
  297. /*
  298. * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
  299. */
  300. #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
  301. /*
  302. * Definition of IOINFO_ARRAYS, maximum number of supported ioinfo arrays.
  303. */
  304. #define IOINFO_ARRAYS 64
  305. #define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
  306. /*
  307. * Access macros for getting at an ioinfo struct and its fields from a
  308. * file handle
  309. */
  310. #define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - \
  311. 1)) )
  312. #define _osfhnd(i) ( _pioinfo(i)->osfhnd )
  313. #define _osfile(i) ( _pioinfo(i)->osfile )
  314. #define _pipech(i) ( _pioinfo(i)->pipech )
  315. /*
  316. * Safer versions of the above macros. Currently, only _osfile_safe is
  317. * used.
  318. */
  319. #define _pioinfo_safe(i) ( ((i) != -1) ? _pioinfo(i) : &__badioinfo )
  320. #define _osfhnd_safe(i) ( _pioinfo_safe(i)->osfhnd )
  321. #define _osfile_safe(i) ( _pioinfo_safe(i)->osfile )
  322. #define _pipech_safe(i) ( _pioinfo_safe(i)->pipech )
  323. /*
  324. * Special, static ioinfo structure used only for more graceful handling
  325. * of a C file handle value of -1 (results from common errors at the stdio
  326. * level).
  327. */
  328. extern _CRTIMP ioinfo __badioinfo;
  329. /*
  330. * Array of arrays of control structures for lowio files.
  331. */
  332. extern _CRTIMP ioinfo * __pioinfo[];
  333. /*
  334. * Current number of allocated ioinfo structures (_NHANDLE_ is the upper
  335. * limit).
  336. */
  337. extern int _nhandle;
  338. int __cdecl _alloc_osfhnd(void);
  339. int __cdecl _free_osfhnd(int);
  340. int __cdecl _set_osfhnd(int, intptr_t);
  341. #ifdef _POSIX_
  342. extern long _dstoffset;
  343. #endif /* _POSIX_ */
  344. extern const char __dnames[];
  345. extern const char __mnames[];
  346. extern int _days[];
  347. extern int _lpdays[];
  348. #ifndef _TIME_T_DEFINED
  349. #ifdef _WIN64
  350. typedef __int64 time_t; /* time value */
  351. #else
  352. typedef _W64 long time_t; /* time value */
  353. #endif
  354. #define _TIME_T_DEFINED /* avoid multiple def's of time_t */
  355. #endif
  356. #ifndef _TIME64_T_DEFINED
  357. typedef __int64 __time64_t; /* 64-bit time value */
  358. #define _TIME64_T_DEFINED
  359. #endif
  360. extern time_t __cdecl __loctotime_t(int, int, int, int, int, int, int);
  361. extern __time64_t __cdecl __loctotime64_t(int, int, int, int, int, int, int);
  362. #ifdef _TM_DEFINED
  363. extern int __cdecl _isindst(struct tm *);
  364. #endif
  365. extern void __cdecl __tzset(void);
  366. extern int __cdecl _validdrive(unsigned);
  367. /*
  368. * This variable is in the C start-up; the length must be kept synchronized
  369. * It is used by the *cenvarg.c modules
  370. */
  371. extern char _acfinfo[]; /* "_C_FILE_INFO=" */
  372. #define CFI_LENGTH 12 /* "_C_FILE_INFO" is 12 bytes long */
  373. /* typedefs needed for subsequent prototypes */
  374. #ifndef _SIZE_T_DEFINED
  375. #ifdef _WIN64
  376. typedef unsigned __int64 size_t;
  377. #else
  378. typedef _W64 unsigned int size_t;
  379. #endif
  380. #define _SIZE_T_DEFINED
  381. #endif
  382. #ifndef _VA_LIST_DEFINED
  383. typedef char * va_list;
  384. #define _VA_LIST_DEFINED
  385. #endif
  386. /*
  387. * stdio internals
  388. */
  389. #ifndef _FILE_DEFINED
  390. struct _iobuf {
  391. char *_ptr;
  392. int _cnt;
  393. char *_base;
  394. int _flag;
  395. int _file;
  396. int _charbuf;
  397. int _bufsiz;
  398. char *_tmpfname;
  399. };
  400. typedef struct _iobuf FILE;
  401. #define _FILE_DEFINED
  402. #endif /* _FILE_DEFINED */
  403. #if !defined(_FILEX_DEFINED) && defined(_WINDOWS_)
  404. /*
  405. * Variation of FILE type used for the dynamically allocated portion of
  406. * __piob[]. For single thread, _FILEX is the same as FILE. For multithread
  407. * models, _FILEX has two fields: the FILE struct and the CRITICAL_SECTION
  408. * struct used to serialize access to the FILE.
  409. */
  410. #ifdef _MT
  411. typedef struct {
  412. FILE f;
  413. CRITICAL_SECTION lock;
  414. } _FILEX;
  415. #else /* ndef _MT */
  416. typedef FILE _FILEX;
  417. #endif /* _MT */
  418. #define _FILEX_DEFINED
  419. #endif /* _FILEX_DEFINED */
  420. /*
  421. * Number of entries supported in the array pointed to by __piob[]. That is,
  422. * the number of stdio-level files which may be open simultaneously. This
  423. * is normally set to _NSTREAM_ by the stdio initialization code.
  424. */
  425. extern int _nstream;
  426. /*
  427. * Pointer to the array of pointers to FILE/_FILEX structures that are used
  428. * to manage stdio-level files.
  429. */
  430. extern void **__piob;
  431. FILE * __cdecl _getstream(void);
  432. #ifdef _POSIX_
  433. FILE * __cdecl _openfile(const char *, const char *, FILE *);
  434. #else
  435. FILE * __cdecl _openfile(const char *, const char *, int, FILE *);
  436. #endif
  437. FILE * __cdecl _wopenfile(const wchar_t *, const wchar_t *, int, FILE *);
  438. void __cdecl _getbuf(FILE *);
  439. int __cdecl _filwbuf (FILE *);
  440. int __cdecl _flswbuf(int, FILE *);
  441. void __cdecl _freebuf(FILE *);
  442. int __cdecl _stbuf(FILE *);
  443. void __cdecl _ftbuf(int, FILE *);
  444. int __cdecl _output(FILE *, const char *, va_list);
  445. int __cdecl _woutput(FILE *, const wchar_t *, va_list);
  446. int __cdecl _input(FILE *, const unsigned char *, va_list);
  447. int __cdecl _winput(FILE *, const wchar_t *, va_list);
  448. int __cdecl _flush(FILE *);
  449. void __cdecl _endstdio(void);
  450. int __cdecl _fseeki64(FILE *, __int64, int);
  451. int __cdecl _fseeki64_lk(FILE *, __int64, int);
  452. __int64 __cdecl _ftelli64(FILE *);
  453. #ifdef _MT
  454. __int64 __cdecl _ftelli64_lk(FILE *);
  455. #else /* ndef _MT */
  456. #define _ftelli64_lk _ftelli64
  457. #endif /* _MT */
  458. #ifndef CRTDLL
  459. extern int _cflush;
  460. #endif /* CRTDLL */
  461. extern unsigned int _tempoff;
  462. extern unsigned int _old_pfxlen;
  463. extern int _umaskval; /* the umask value */
  464. extern char _pipech[]; /* pipe lookahead */
  465. extern char _exitflag; /* callable termination flag */
  466. extern int _C_Termination_Done; /* termination done flag */
  467. char * __cdecl _getpath(const char *, char *, unsigned);
  468. wchar_t * __cdecl _wgetpath(const wchar_t *, wchar_t *, unsigned);
  469. extern int _dowildcard; /* flag to enable argv[] wildcard expansion */
  470. #ifndef _PNH_DEFINED
  471. typedef int (__cdecl * _PNH)( size_t );
  472. #define _PNH_DEFINED
  473. #endif
  474. #ifdef ANSI_NEW_HANDLER
  475. /* ANSI C++ new handler */
  476. #ifndef _ANSI_NH_DEFINED
  477. typedef void (__cdecl * new_handler) ();
  478. #define _ANSI_NH_DEFINED
  479. #endif
  480. #ifndef _NO_ANSI_NH_DEFINED
  481. #define _NO_ANSI_NEW_HANDLER ((new_handler)-1)
  482. #define _NO_ANSI_NH_DEFINED
  483. #endif
  484. extern new_handler _defnewh; /* default ANSI C++ new handler */
  485. #endif /* ANSI_NEW_HANDLER */
  486. /* calls the currently installed new handler */
  487. int __cdecl _callnewh(size_t);
  488. extern int _newmode; /* malloc new() handler mode */
  489. /* pointer to initial environment block that is passed to [w]main */
  490. extern _CRTIMP wchar_t **__winitenv;
  491. extern _CRTIMP char **__initenv;
  492. /* startup set values */
  493. extern char *_aenvptr; /* environment ptr */
  494. extern wchar_t *_wenvptr; /* wide environment ptr */
  495. /* command line */
  496. #if defined(_DLL) && defined(_M_IX86)
  497. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  498. _CRTIMP char ** __cdecl __p__acmdln(void);
  499. _CRTIMP wchar_t ** __cdecl __p__wcmdln(void);
  500. #endif
  501. _CRTIMP extern char *_acmdln;
  502. _CRTIMP extern wchar_t *_wcmdln;
  503. /*
  504. * prototypes for internal startup functions
  505. */
  506. int __cdecl _cwild(void); /* wild.c */
  507. int __cdecl _wcwild(void); /* wwild.c */
  508. #ifdef _MT
  509. int __cdecl _mtinit(void); /* tidtable.c */
  510. void __cdecl _mtterm(void); /* tidtable.c */
  511. int __cdecl _mtinitlocks(void); /* mlock.c */
  512. void __cdecl _mtdeletelocks(void); /* mlock.c */
  513. int __cdecl _mtinitlocknum(int); /* mlock.c */
  514. #endif
  515. #ifdef _MT
  516. /* Wrapper for InitializeCriticalSection API, with default spin count */
  517. int __cdecl __crtInitCritSecAndSpinCount(PCRITICAL_SECTION, DWORD);
  518. #define _CRT_SPINCOUNT 4000
  519. #endif
  520. /*
  521. * C source build only!!!!
  522. *
  523. * more prototypes for internal startup functions
  524. */
  525. void __cdecl _amsg_exit(int); /* crt0.c */
  526. void __cdecl __crtExitProcess(int); /* crt0dat.c */
  527. void __cdecl __CRTDLL_CallStaticTerminators(void); /* crt0dat.c */
  528. int __cdecl _cinit(void); /* crt0dat.c */
  529. void __cdecl __doinits(void); /* astart.asm */
  530. void __cdecl __doterms(void); /* astart.asm */
  531. void __cdecl __dopreterms(void); /* astart.asm */
  532. void __cdecl _FF_MSGBANNER(void);
  533. void __cdecl _fptrap(void); /* crt0fp.c */
  534. int __cdecl _heap_init(int);
  535. void __cdecl _heap_term(void);
  536. void __cdecl _heap_abort(void);
  537. void __cdecl __initconin(void); /* initcon.c */
  538. void __cdecl __initconout(void); /* initcon.c */
  539. int __cdecl _ioinit(void); /* crt0.c, crtlib.c */
  540. void __cdecl _ioterm(void); /* crt0.c, crtlib.c */
  541. char * __cdecl _GET_RTERRMSG(int);
  542. void __cdecl _NMSG_WRITE(int);
  543. int __cdecl _setargv(void); /* setargv.c, stdargv.c */
  544. int __cdecl __setargv(void); /* stdargv.c */
  545. int __cdecl _wsetargv(void); /* wsetargv.c, wstdargv.c */
  546. int __cdecl __wsetargv(void); /* wstdargv.c */
  547. int __cdecl _setenvp(void); /* stdenvp.c */
  548. int __cdecl _wsetenvp(void); /* wstdenvp.c */
  549. void __cdecl __setmbctable(unsigned int); /* mbctype.c */
  550. #ifdef _MBCS
  551. int __cdecl __initmbctable(void); /* mbctype.c */
  552. #endif
  553. #ifndef _POSIX_
  554. int __cdecl main(int, char **, char **);
  555. int __cdecl wmain(int, wchar_t **, wchar_t **);
  556. #endif
  557. /* helper functions for wide/multibyte environment conversion */
  558. int __cdecl __mbtow_environ (void);
  559. int __cdecl __wtomb_environ (void);
  560. int __cdecl __crtsetenv (char *, const int);
  561. int __cdecl __crtwsetenv (wchar_t *, const int);
  562. _CRTIMP extern void (__cdecl * _aexit_rtn)(int);
  563. #if defined(_DLL) || defined(CRTDLL)
  564. #ifndef _STARTUP_INFO_DEFINED
  565. typedef struct
  566. {
  567. int newmode;
  568. #ifdef ANSI_NEW_HANDLER
  569. new_handler newh;
  570. #endif /* ANSI_NEW_HANDLER */
  571. } _startupinfo;
  572. #define _STARTUP_INFO_DEFINED
  573. #endif /* _STARTUP_INFO_DEFINED */
  574. _CRTIMP int __cdecl __getmainargs(int *, char ***, char ***,
  575. int, _startupinfo *);
  576. _CRTIMP int __cdecl __wgetmainargs(int *, wchar_t ***, wchar_t ***,
  577. int, _startupinfo *);
  578. #endif /* defined(_DLL) || defined(CRTDLL) */
  579. /*
  580. * Prototype, variables and constants which determine how error messages are
  581. * written out.
  582. */
  583. #define _UNKNOWN_APP 0
  584. #define _CONSOLE_APP 1
  585. #define _GUI_APP 2
  586. extern int __app_type;
  587. extern int __error_mode;
  588. _CRTIMP void __cdecl __set_app_type(int);
  589. /*
  590. * C source build only!!!!
  591. *
  592. * map Win32 errors into Xenix errno values -- for modules written in C
  593. */
  594. extern void __cdecl _dosmaperr(unsigned long);
  595. /*
  596. * internal routines used by the exec/spawn functions
  597. */
  598. extern intptr_t __cdecl _dospawn(int, const char *, char *, char *);
  599. extern intptr_t __cdecl _wdospawn(int, const wchar_t *, wchar_t *, wchar_t *);
  600. extern int __cdecl _cenvarg(const char * const *, const char * const *,
  601. char **, char **, const char *);
  602. extern int __cdecl _wcenvarg(const wchar_t * const *, const wchar_t * const *,
  603. wchar_t **, wchar_t **, const wchar_t *);
  604. #ifndef _M_IX86
  605. extern char ** _capture_argv(va_list *, const char *, char **, size_t);
  606. extern wchar_t ** _wcapture_argv(va_list *, const wchar_t *, wchar_t **, size_t);
  607. #endif
  608. /*
  609. * Default value used for the global /GS security cookie
  610. */
  611. #ifdef _WIN64
  612. #define DEFAULT_SECURITY_COOKIE 0x2B992DDFA23249D6
  613. #else
  614. #define DEFAULT_SECURITY_COOKIE 0xBB40E64E
  615. #endif
  616. #ifdef __cplusplus
  617. }
  618. #endif
  619. #endif /* _INC_INTERNAL */