[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash libbase/rc.cpp libbase/rc.h ./ChangeLog
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash libbase/rc.cpp libbase/rc.h ./ChangeLog |
Date: |
Mon, 29 May 2006 15:45:36 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: Rob Savoye <address@hidden> 06/05/29 15:45:36
Modified files:
libbase : rc.cpp rc.h
. : ChangeLog
Log message:
* libbase/rc.h: Add extractSetting() for support function to get
values from the config file.
* libbase/rc.cpp: Use extractSetting(), rather than duplicating
all the code.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/rc.cpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/rc.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.388&tr2=1.389&r1=text&r2=text
Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.388 gnash/ChangeLog:1.389
--- gnash/ChangeLog:1.388 Mon May 29 15:07:20 2006
+++ gnash/ChangeLog Mon May 29 15:45:36 2006
@@ -1,5 +1,9 @@
2006-05-29 Rob Savoye <address@hidden>
+ * libbase/rc.h: Add extractSetting() for support function to get
+ values from the config file.
+ * libbase/rc.cpp: Use extractSetting(), rather than duplicating
+ all the code.
* libbase/tu_types.h: Check for more variations of the ENDIAN
constants. Bug #16682.
Index: gnash/libbase/rc.cpp
diff -u gnash/libbase/rc.cpp:1.1 gnash/libbase/rc.cpp:1.2
--- gnash/libbase/rc.cpp:1.1 Mon May 29 14:22:05 2006
+++ gnash/libbase/rc.cpp Mon May 29 15:45:36 2006
@@ -91,6 +91,25 @@
return false;
}
+bool
+RcInitFile::extractSetting(const char *pattern, std::string &variable,
+ std::string &value)
+{
+// dbglogfile << variable << ":" << ":" << value << endl;
+
+ if (variable == pattern) {
+ if ((value == "on") || (value == "yes") || (value == "true")) {
+ dbglogfile << variable << ": Enabled " << endl;
+ return true;
+ }
+ if ((value == "off") || (value == "no") || (value == "false")) {
+ dbglogfile << variable << ": Disabled " << endl;
+ return false;
+ }
+ }
+ return false;
+}
+
// Parse the config file and set the variables.
bool
RcInitFile::parseFile(string filespec)
@@ -101,7 +120,7 @@
string value;
ifstream in;
- dbglogfile << "Seeing if " << filespec << " exists." << endl;
+// dbglogfile << "Seeing if " << filespec << " exists." << endl;
if (filespec.size() == 0) {
return false;
}
@@ -120,7 +139,7 @@
in >> action;
// Ignore comment lines
if (action[0] == '#') {
- dbglogfile << "Ignoring comment line " << endl;
+// dbglogfile << "Ignoring comment line " << endl;
// suck up the rest of the line
char name[128];
in.getline(name, 128);
@@ -130,79 +149,40 @@
in >> variable >> value;
// dbglogfile << action << variable << value << endl;
- cerr << variable << ":" << ":" << value << endl;
-
if (action == "set") {
- if (variable == "splash_screen") {
- if (value == "on") {
- _splash_screen = true;
- dbglogfile << "Splash Screen Enabled " << endl;
- }
- if (value == "off") {
- _splash_screen = false;
- dbglogfile << "Splash Screen Disabled " << endl;
- }
- continue;
- }
- if (variable == "localdomain") {
- if (value == "on") {
- if (_localhost_only) {
- _localhost_only = false;
- }
- _localdomain_only = true;
- dbglogfile << "Accessing Local Domain only " << endl;
- }
- if (value == "off") {
- _localdomain_only = false;
- dbglogfile << "Accessing all Domains" << endl;
- }
- continue;
- }
- // This is more restrictive than local domain
- if (variable == "localhost") {
- if (value == "on") {
- _localdomain_only = true;
- if (_localdomain_only) {
- _localdomain_only = false;
- }
- dbglogfile << "Accessing Localhost only " << endl;
- }
- if (value == "off") {
- _localdomain_only = false;
- dbglogfile << "Accessing all network hosts" << endl;
- }
- continue;
- }
- if (variable == "blacklist") {
- string::size_type pos;
- while ((pos = value.find(':', 0)) != string::npos) {
- _blacklist.push_back(value.substr(0, pos));
- value.erase(0, pos+1);
- }
- _blacklist.push_back(value);
- continue;
- }
- if (variable == "whitelist") {
- cerr << variable << ":" << ":" << value << endl;
- string::size_type pos;
- while ((pos = value.find(':', 0)) != string::npos) {
- _whitelist.push_back(value.substr(0, pos));
- value.erase(0, pos+1);
- }
- _whitelist.push_back(value);
- continue;
- }
+ _splash_screen = extractSetting("splash_screen", variable, value);
+ _localhost_only = extractSetting("localhost", variable, value);
+ _localdomain_only = extractSetting("localdomain", variable, value);
+
+ if (variable == "blacklist") {
+ string::size_type pos;
+ while ((pos = value.find(':', 0)) != string::npos) {
+ _blacklist.push_back(value.substr(0, pos));
+ value.erase(0, pos+1);
+ }
+ _blacklist.push_back(value);
+ continue;
+ }
+ if (variable == "whitelist") {
+ string::size_type pos;
+ while ((pos = value.find(':', 0)) != string::npos) {
+ _whitelist.push_back(value.substr(0, pos));
+ value.erase(0, pos+1);
+ }
+ _whitelist.push_back(value);
+ continue;
+ }
}
}
} else {
- if (in) {
- in.close();
- }
- return false;
+ if (in) {
+ in.close();
+ }
+ return false;
}
-
+
if (in) {
- in.close();
+ in.close();
}
return true;
}
Index: gnash/libbase/rc.h
diff -u gnash/libbase/rc.h:1.1 gnash/libbase/rc.h:1.2
--- gnash/libbase/rc.h:1.1 Mon May 29 14:22:05 2006
+++ gnash/libbase/rc.h Mon May 29 15:45:36 2006
@@ -66,6 +66,9 @@
bool useLocalHost() { return _localhost_only; };
void useLocalHost(bool value);
+ bool extractSetting(const char *pattern, std::string &variable,
+ std::string &value);
+
std::vector<std::string> getWhiteList() { return _whitelist; };
std::vector<std::string> getBlackList() { return _blacklist; };
private:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash libbase/rc.cpp libbase/rc.h ./ChangeLog,
Rob Savoye <=