OSDN Git Service

Generalise makefile references to subdirectories of lib.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / mingw / init.c
1 /*
2  * init.c
3  * This file has no copyright assigned and is placed in the Public Domain.
4  * This file is a part of the mingw-runtime package.
5  * No warranty is given; refer to the file DISCLAIMER within the package.
6  *
7  * Code to initialize standard file handles and command line arguments.
8  * This file is #included in both crt1.c and dllcrt1.c.
9  *
10  */
11
12 /*
13  * Access to a standard 'main'-like argument count and list. Also included
14  * is a table of environment variables.
15  */
16 int _argc = 0;
17 char **_argv = 0;
18
19 /* NOTE: Thanks to Pedro A. Aranda Gutiirrez <paag@tid.es> for pointing
20  * this out to me. GetMainArgs (used below) takes a fourth argument
21  * which is an int that controls the globbing of the command line. If
22  * _CRT_glob is non-zero the command line will be globbed (e.g. *.*
23  * expanded to be all files in the startup directory). In the mingw32
24  * library a _CRT_glob variable is defined as being -1, enabling
25  * this command line globbing by default. To turn it off and do all
26  * command line processing yourself (and possibly escape bogons in
27  * MS's globbing code) include a line in one of your source modules
28  * defining _CRT_glob and setting it to zero, like this:
29  *  int _CRT_glob = 0;
30  */
31 extern int _CRT_glob;
32
33 #ifdef __MSVCRT__
34 typedef struct {
35   int newmode;
36 } _startupinfo;
37 extern void __getmainargs (int *, char ***, char ***, int, _startupinfo *);
38 #else
39 extern void __GetMainArgs (int *, char ***, char ***, int);
40 #endif
41
42 /*
43  * Initialize the _argc, _argv and environ variables.
44  */
45 static void
46 _mingw32_init_mainargs ()
47 {
48   /* The environ variable is provided directly in stdlib.h through
49    * a dll function call. */
50   char **dummy_environ;
51 #ifdef __MSVCRT__
52   _startupinfo start_info;
53   start_info.newmode = 0;
54 #endif
55
56   /*
57    * Microsoft's runtime provides a function for doing just that.
58    */
59 #ifdef __MSVCRT__
60   (void) __getmainargs (&_argc, &_argv, &dummy_environ, _CRT_glob, 
61                         &start_info);
62 #else
63   /* CRTDLL version */
64   (void) __GetMainArgs (&_argc, &_argv, &dummy_environ, _CRT_glob);
65 #endif
66 }
67