2 * Copyright (c) 2003 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "base/inifile.hh"
35 #include "base/cprintf.hh"
44 cout
<< "Usage: " << progname
<< " <ini file>\n";
49 char *defines
= getenv("CONFIG_DEFINES");
52 while ((c
= strchr(c
, ' ')) != NULL
) {
62 main(int argc
, char *argv
[])
68 vector
<char *> cppArgs
;
70 vector
<char *> cpp_options
;
71 cpp_options
.reserve(argc
* 2);
73 for (int i
= 1; i
< argc
; ++i
) {
74 char *arg_str
= argv
[i
];
76 // if arg starts with '-', parse as option,
77 // else treat it as a configuration file name and load it
78 if (arg_str
[0] == '-') {
80 // switch on second char
85 // cpp options: record & pass to cpp. Note that these
86 // cannot have spaces, i.e., '-Dname=val' is OK, but
87 // '-D name=val' is not. I don't consider this a
88 // problem, since even though gnu cpp accepts the
89 // latter, other cpp implementations do not (Tru64,
91 cppArgs
.push_back(arg_str
);
95 // command-line configuration parameter:
96 // '--<section>:<parameter>=<value>'
98 if (!simConfigDB
.add(arg_str
+ 2)) {
101 "Could not parse configuration argument '%s'\n"
102 "Expecting --<section>:<parameter>=<value>\n",
113 // no '-', treat as config file name
115 if (!simConfigDB
.loadCPP(arg_str
, cppArgs
)) {
116 cprintf("Error processing file %s\n", arg_str
);
125 if (simConfigDB.find(C, E, value)) \
126 cout << ">" << value << "<\n"; \
128 cout << "Not Found!\n"
130 FIND("General", "Test2");
131 FIND("Junk", "Test3");
132 FIND("Junk", "Test4");
133 FIND("General", "Test1");
134 FIND("Junk2", "test3");
135 FIND("General", "Test3");