]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wxSWIG/SWIG/getopt.cxx
1 /*******************************************************************************
2 * Simplified Wrapper and Interface Generator (SWIG)
4 * Author : David Beazley
6 * Department of Computer Science
7 * University of Chicago
10 * beazley@cs.uchicago.edu
12 * Please read the file LICENSE for the copyright and terms by which SWIG
13 * can be used and distributed.
14 *******************************************************************************/
18 /*******************************************************************************
23 * This file defines a few functions for handling command line arguments.
24 * C++ makes this really funky---especially since each language module
25 * may want to extract it's own command line arguments.
27 * My own special version of getopt. This is a bit weird, because we
28 * don't know what the options are in advance (they could be determined
29 * by a language module).
30 *******************************************************************************/
36 // -----------------------------------------------------------------------------
37 // void init_args(int argc, char **argv)
39 // Initializes the argument list.
42 // argc = Argument count
43 // argv = Argument array
47 // Side Effects : Saves local copy of argc and argv
48 // -----------------------------------------------------------------------------
51 init_args(int argc
, char **argv
)
56 marked
= new int[numargs
];
57 for (i
= 0; i
< argc
; i
++) {
63 // -----------------------------------------------------------------------------
64 // void mark_arg(int n)
66 // Marks an argument as being parsed. All modules should do this whenever they
67 // parse a command line option.
69 // Inputs : n = Argument number
73 // Side Effects : Sets a status bit internally
74 // -----------------------------------------------------------------------------
82 // -----------------------------------------------------------------------------
83 // void check_options()
85 // Checks for unparsed command line options. If so, issues an error and exits.
91 // Side Effects : exits if there are unparsed options
92 // -----------------------------------------------------------------------------
94 void check_options() {
100 fprintf(stderr
,"Must specify an input file. Use -help for available options.\n");
103 for (i
= 1; i
< numargs
-1; i
++) {
105 fprintf(stderr
,"swig error : Unrecognized option %s\n", args
[i
]);
111 fprintf(stderr
,"Use 'swig -help' for available options.\n");
115 if (marked
[numargs
-1]) {
116 fprintf(stderr
,"Must specify an input file. Use -help for available options.\n");
121 // -----------------------------------------------------------------------------
124 // Generates a generic error message and exits.
130 // Side Effects : Exits
131 // -----------------------------------------------------------------------------
134 fprintf(stderr
,"SWIG : Unable to parse command line options.\n");
135 fprintf(stderr
,"Use 'swig -help' for available options.\n");