home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / src / mingw-runtime-19991107 / mingw / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-30  |  2.5 KB  |  85 lines

  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.  *  Maintained by Mumit Khan <khan@xraylith.wisc.EDU>
  12.  *
  13.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  14.  *
  15.  *  This source code is offered for use in the public domain. You may
  16.  *  use, modify or distribute it freely.
  17.  *
  18.  *  This code is distributed in the hope that it will be useful but
  19.  *  WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
  20.  *  DISCLAMED. This includes but is not limited to warrenties of
  21.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  22.  *
  23.  * $Revision: 1.3 $
  24.  * $Author: khan $
  25.  * $Date: 1998/09/03 16:31:17 $
  26.  *
  27.  */
  28.  
  29. /*
  30.  * Access to a standard 'main'-like argument count and list. Also included
  31.  * is a table of environment variables.
  32.  */
  33. int _argc = 0;
  34. char **_argv = 0;
  35.  
  36. /* NOTE: Thanks to Pedro A. Aranda Gutiirrez <paag@tid.es> for pointing
  37.  * this out to me. GetMainArgs (used below) takes a fourth argument
  38.  * which is an int that controls the globbing of the command line. If
  39.  * _CRT_glob is non-zero the command line will be globbed (e.g. *.*
  40.  * expanded to be all files in the startup directory). In the mingw32
  41.  * library a _CRT_glob variable is defined as being -1, enabling
  42.  * this command line globbing by default. To turn it off and do all
  43.  * command line processing yourself (and possibly escape bogons in
  44.  * MS's globbing code) include a line in one of your source modules
  45.  * defining _CRT_glob and setting it to zero, like this:
  46.  *  int _CRT_glob = 0;
  47.  */
  48. extern int _CRT_glob;
  49.  
  50. #ifdef __MSVCRT__
  51. typedef struct {
  52.   int newmode;
  53. } _startupinfo;
  54. extern void __getmainargs (int *, char ***, char ***, int, _startupinfo *);
  55. #else
  56. extern void __GetMainArgs (int *, char ***, char ***, int);
  57. #endif
  58.  
  59. /*
  60.  * Initialize the _argc, _argv and environ variables.
  61.  */
  62. static void
  63. _mingw32_init_mainargs ()
  64. {
  65.   /* The environ variable is provided directly in stdlib.h through
  66.    * a dll function call. */
  67.   char **dummy_environ;
  68. #ifdef __MSVCRT__
  69.   _startupinfo start_info;
  70.   start_info.newmode = 0;
  71. #endif
  72.  
  73.   /*
  74.    * Microsoft's runtime provides a function for doing just that.
  75.    */
  76. #ifdef __MSVCRT__
  77.   (void) __getmainargs (&_argc, &_argv, &dummy_environ, _CRT_glob, 
  78.                         &start_info);
  79. #else
  80.   /* CRTDLL version */
  81.   (void) __GetMainArgs (&_argc, &_argv, &dummy_environ, _CRT_glob);
  82. #endif
  83. }
  84.  
  85.