Panda3D
 All Classes Functions Variables Enumerations
preprocess_argv.cxx
1 // Filename: preprocess_argv.cxx
2 // Created by: drose (08Nov11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "preprocess_argv.h"
16 #include "win32ArgParser.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: preprocess_argv
20 // Description: Processes the argc, argv pair as needed before
21 // passing it to getopt(). If this program is running
22 // on Windows, but not within Cygwin, this ignores the
23 // incoming argv, argv values, replacing them from the
24 // GetCommandLine() string, and expanding glob patterns
25 // like *.egg to a list of all matching egg files. On
26 // other platforms, this function does nothing and
27 // returns argc, argv unchanged.
28 //
29 // The argc and argv values are modified by this
30 // function, if necessary, to point to
31 // statically-allocated memory that will be valid until
32 // the next call to preprocess_argv().
33 ////////////////////////////////////////////////////////////////////
34 void
35 preprocess_argv(int &argc, char **&argv) {
36 #ifndef _WIN32
37  // Not Windows: do nothing.
38  (void) argc;
39  (void) argv;
40 #else // _WIN32
41  // Temporarily commenting out to fix build. Revisit shortly.
42  static Win32ArgParser parser;
43  if (!parser.do_glob()) {
44  // No globbing required.
45  return;
46  }
47 
48  // Globbing is required. Process the args.
49  parser.set_system_command_line();
50  argc = parser.get_argc();
51  argv = parser.get_argv();
52 #endif // _WIN32
53 }