1 // rc.cpp: "Run Command" configuration file, for Gnash.
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 // This is generated by autoconf
23 # include "gnashconfig.h"
26 #include "StringPredicates.h"
34 #include <sys/types.h>
35 #include "GnashSystemIOHeaders.h" // for getuid()
37 #include <boost/cstdint.hpp>
39 #include <cctype> // for toupper
46 using namespace gnash
;
49 /// This namespace is for all the Cygnal specific classes.
52 /// \brief Return the default instance of RC file,
54 CRcInitFile::getDefaultInstance()
56 // TODO: allocate on the heap and provide a destroyDefaultInstance,
57 // for finer control of destruction order
58 static CRcInitFile crcfile
;
62 CRcInitFile::CRcInitFile()
69 _certfile("server.pem"),
70 _certdir("/etc/pki/tls")
72 // GNASH_REPORT_FUNCTION;
76 //Never destroy (TODO: add a destroyDefaultInstance)
77 CRcInitFile::~CRcInitFile()
79 // GNASH_REPORT_FUNCTION;
82 /// \brief Load all the configuration files.
83 /// This includes parsing the default .gnashrc file for
84 /// Gnash settings that control the swf parser and virtual
85 /// machine. These setting can be overridden in the
86 /// .cygnalrc file, plus the Cygnal specific file has
87 /// options only used by Cygnal.
89 CRcInitFile::loadFiles()
91 // GNASH_REPORT_FUNCTION;
93 // Check the default system location
94 string loadfile
= "/etc/cygnalrc";
97 // Check the default config location
98 loadfile
= "/usr/local/etc/cygnalrc";
101 // Check the users home directory
102 char *home
= getenv("HOME");
105 loadfile
+= "/.cygnalrc";
109 // Check the GNASHRC environment variable
110 char *cygnalrc
= getenv("CYGNALRC");
113 return parseFile(loadfile
);
119 /// \brief Parse and load configuration file
121 /// @param filespec The path and file name of the disk file to parse.
123 /// @return True if the file was parsed successfully, false if not.
125 CRcInitFile::parseFile(const std::string
& filespec
)
127 // GNASH_REPORT_FUNCTION;
134 StringNoCaseEqual noCaseCompare
;
136 // log_debug ("Seeing if %s exists", filespec);
137 if (filespec
.size() == 0) {
141 if (stat(filespec
.c_str(), &stats
) == 0) {
142 in
.open(filespec
.c_str());
145 log_error(_("Couldn't open file: %s"), filespec
.c_str());
149 // Read in each line and parse it
152 // Make sure action is empty, otherwise the last loop (with no new
153 // data) keeps action, variable and value from the previous loop. This
154 // causes problems if set blacklist or set whitelist are last, because
155 // value is erased while parsing and the lists are thus deleted.
158 // Get the first token
161 // Ignore comment lines
162 if (action
[0] == '#') {
163 // suck up the rest of the line
165 in
.getline(name
, 128);
172 // cout << "Parsing " << variable << endl;
174 // Read in rest of line for parsing.
177 // Erase leading spaces.
178 string::size_type position
= value
.find_first_not_of(' ');
179 if(position
!= string::npos
) value
.erase(0, position
);
181 if (noCaseCompare(variable
, "debuglog")) {
187 if (noCaseCompare(variable
, "documentroot") ) {
188 setDocumentRoot(value
);
192 if (noCaseCompare(variable
, "cgiroot") ) {
197 if (noCaseCompare(variable
, "documentroot") ) {
202 if (noCaseCompare(variable
, "CertDir") ) {
208 if (noCaseCompare(variable
, "CertFile") ) {
220 // Get the standard options inherited froom Gnash's config file
221 if ( extractSetting(test
, "actionDump", variable
, value
) )
223 else if ( extractSetting(test
, "parserDump", variable
, value
) )
225 else if ( extractNumber(num
, "verbosity", variable
, value
) )
228 // Get the options specific to Cygnal's config file.
229 else if ( extractSetting(admin
, "admin", variable
, value
) )
231 else if ( extractSetting(netdebug
, "netdebug", variable
, value
) )
232 setNetDebugFlag(netdebug
);
233 else if ( extractSetting(test
, "testing", variable
, value
) )
234 setTestingFlag(test
);
235 else if ( extractSetting(threads
, "threading", variable
, value
) )
236 setThreadingFlag(threads
);
237 else if (extractNumber(num
, "fdThread", variable
, value
) )
239 else if (extractNumber(num
, "portOffset", variable
, value
) )
258 /// \brief Dump the internal data of this class in a human readable form.
259 /// @remarks This should only be used for debugging purposes.
261 CRcInitFile::dump(std::ostream
& os
) const
263 os
<< endl
<< "Dump CRcInitFile:" << endl
;
264 os
<< "\tVerbosity Level: " << _verbosity
<< endl
;
265 os
<< "\tDump ActionScript processing: "
266 << ((_actionDump
)?"enabled":"disabled") << endl
;
267 os
<< "\tDump parser info: "
268 << ((_parserDump
)?"enabled":"disabled") << endl
;
269 os
<< "\tActionScript coding errors verbosity: "
270 << ((_verboseASCodingErrors
)?"enabled":"disabled") << endl
;
271 os
<< "\tPort Offset: " << _port_offset
<< endl
;
272 os
<< "\tThreading support: "
273 << ((_threading
)?"enabled":"disabled") << endl
;
274 os
<< "\tSpecial Testing output for Gnash: "
275 << ((_testing
)?"enabled":"disabled") << endl
;
277 // RcInitFile::dump();
280 } // end of namespace cygnal
284 // indent-tabs-mode: t