3 * @copy 2012 MinGW.org project
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
26 * Code to initialize standard file handles and command line arguments.
27 * This file is #included in both crt1.c and dllcrt1.c.
31 * Access to a standard 'main'-like argument count and list. Also included
32 * is a table of environment variables.
37 /* NOTE: Thanks to Pedro A. Aranda Gutiirrez <paag@tid.es> for pointing
38 * this out to me. GetMainArgs (used below) takes a fourth argument
39 * which is an int that controls the globbing of the command line. If
40 * _CRT_glob is non-zero the command line will be globbed (e.g. *.*
41 * expanded to be all files in the startup directory). In the mingw32
42 * library a _CRT_glob variable is defined as being -1, enabling
43 * this command line globbing by default. To turn it off and do all
44 * command line processing yourself (and possibly escape bogons in
45 * MS's globbing code) include a line in one of your source modules
46 * defining _CRT_glob and setting it to zero, like this:
55 extern void __getmainargs (int *, char ***, char ***, int, _startupinfo *);
57 extern void __GetMainArgs (int *, char ***, char ***, int);
61 * Initialize the _argc, _argv and environ variables.
64 _mingw32_init_mainargs ()
66 /* The environ variable is provided directly in stdlib.h through
67 * a dll function call. */
70 _startupinfo start_info;
71 start_info.newmode = 0;
75 * Microsoft's runtime provides a function for doing just that.
78 (void) __getmainargs (&_argc, &_argv, &dummy_environ, _CRT_glob,
82 (void) __GetMainArgs (&_argc, &_argv, &dummy_environ, _CRT_glob);