migrate substitution keywords to SVN
[reactos.git] / reactos / lib / crtdll / misc / init.c
1 /*
2 * init.c
3 *
4 * Code to initialize standard file handles and command line arguments.
5 * This file is #included in both crt1.c and dllcrt1.c.
6 *
7 * This file is part of the Mingw32 package.
8 *
9 * Contributors:
10 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
11 *
12 * THIS SOFTWARE IS NOT COPYRIGHTED
13 *
14 * This source code is offered for use in the public domain. You may
15 * use, modify or distribute it freely.
16 *
17 * This code is distributed in the hope that it will be useful but
18 * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
19 * DISCLAMED. This includes but is not limited to warrenties of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 *
22 * $Revision: 1.4 $
23 * $Author$
24 * $Date$
25 *
26 */
27
28 /*
29 * Access to a standard 'main'-like argument count and list. Also included
30 * is a table of environment variables.
31 */
32 int _argc = 0;
33 char** _argv = 0;
34
35 /* NOTE: Thanks to Pedro A. Aranda Gutiirrez <paag@tid.es> for pointing
36 * this out to me. GetMainArgs (used below) takes a fourth argument
37 * which is an int that controls the globbing of the command line. If
38 * _CRT_glob is non-zero the command line will be globbed (e.g. *.*
39 * expanded to be all files in the startup directory). In the mingw32
40 * library a _CRT_glob variable is defined as being -1, enabling
41 * this command line globbing by default. To turn it off and do all
42 * command line processing yourself (and possibly escape bogons in
43 * MS's globbing code) include a line in one of your source modules
44 * defining _CRT_glob and setting it to zero, like this:
45 * int _CRT_glob = 0;
46 */
47 extern int _CRT_glob;
48
49 extern void __GetMainArgs(int *, char***, char***, int);
50
51 /*
52 * Initialize the _argc, _argv and environ variables.
53 */
54 static void
55 _mingw32_init_mainargs (void)
56 {
57 /* The environ variable is provided directly in stdlib.h through
58 * a dll function call. */
59 char** dummy_environ;
60
61 /*
62 * Microsoft's runtime provides a function for doing just that.
63 */
64 #ifdef _MSVCRT_LIB_
65 (void) __getmainargs(&_argc, &_argv, &dummy_environ, _CRT_glob);
66 #else
67 /* CRTDLL version */
68 (void) __GetMainArgs(&_argc, &_argv, &dummy_environ, _CRT_glob);
69 #endif
70 }
71