diff options
author | Michi Henning <michi@zeroc.com> | 2004-12-08 06:11:21 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-12-08 06:11:21 +0000 |
commit | 37fa0d032659d3291c81628f9eb85fac538cb342 (patch) | |
tree | dd8acd3eecce7e1cb2df6f908c089337ae01ab02 /cpp/src | |
parent | Fixed bug in parsing for --Ice.Config: previous code dereferenced an (diff) | |
download | ice-37fa0d032659d3291c81628f9eb85fac538cb342.tar.bz2 ice-37fa0d032659d3291c81628f9eb85fac538cb342.tar.xz ice-37fa0d032659d3291c81628f9eb85fac538cb342.zip |
Added regular expression matching to property checking code.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 66 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/PropertyNames.cpp | 18 | ||||
-rw-r--r-- | cpp/src/Ice/PropertyNames.h | 2 |
4 files changed, 69 insertions, 19 deletions
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 6be3ce9d9a3..afc2a0b0ab5 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -91,6 +91,55 @@ Ice::PropertiesI::getPropertiesForPrefix(const string& prefix) return result; } +// +// Match `s' against the pattern `pat'. A * in the pattern acts +// as a wildcard: it matches any non-empty sequence of characters +// other than a period (`.'). We match by hand here because +// it's portable across platforms (whereas regex() isn't). +// + +bool +Ice::PropertiesI::match(const string& s, const string& pat) +{ + assert(!s.empty()); + assert(!pat.empty()); + + if(pat.find('*') == string::npos) + { + return s == pat; + } + + string::size_type sIndex = 0; + string::size_type patIndex = 0; + do + { + if(pat[patIndex] == '*') + { + if(s[sIndex] == '.') // Don't allow matching x..y against x.*.y -- star matches non-empty sequence only. + { + return false; + } + while(sIndex < s.size() && s[sIndex] != '.') + { + ++sIndex; + } + patIndex++; + } + else + { + if(pat[patIndex] != s[sIndex]) + { + return false; + } + ++sIndex; + ++patIndex; + } + } + while(sIndex < s.size() && patIndex < pat.size()); + + return sIndex == s.size() && patIndex == pat.size(); +} + void Ice::PropertiesI::setProperty(const string& key, const string& value) { @@ -110,10 +159,10 @@ Ice::PropertiesI::setProperty(const string& key, const string& value) string prefix = key.substr(0, dotPos); for(const char* const** i = IceInternal::PropertyNames::validProps; *i != 0; ++i) { - string property(*i[0]); - dotPos = property.find('.'); + string pattern(*i[0]); + dotPos = pattern.find('.'); assert(dotPos != string::npos); - string propPrefix = property.substr(0, dotPos); + string propPrefix = pattern.substr(0, dotPos); if(propPrefix != prefix) { continue; @@ -122,16 +171,7 @@ Ice::PropertiesI::setProperty(const string& key, const string& value) bool found = false; for(const char* const* j = *i; *j != 0 && !found; ++j) { - property = *j; - string::size_type starPos = property.find('*'); - if(starPos == string::npos) - { - found = property == key; - } - else - { - found = property.compare(0, starPos, key.substr(0, starPos)) == 0; - } + found = match(key, *j); } if(!found) { diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h index ac6a611224b..1ce58dc3b74 100644 --- a/cpp/src/Ice/PropertiesI.h +++ b/cpp/src/Ice/PropertiesI.h @@ -46,6 +46,8 @@ private: void loadConfig(); + static bool match(const std::string&, const std::string&); + std::map<std::string, std::string> _properties; }; diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index a9bfe8f8572..eb628761b0f 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -7,7 +7,7 @@ // // ********************************************************************** -// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Dec 6 12:29:15 2004 +// Generated by makeprops.py from file `../config/PropertyNames.def', Wed Dec 8 15:48:53 2004 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -184,7 +184,7 @@ const char* IceInternal::PropertyNames::IcePatch2Props[] = const char* IceInternal::PropertyNames::IceSSLProps[] = { - "IceSSL.Client.CertPath*", + "IceSSL.Client.CertPath", "IceSSL.Client.Config", "IceSSL.Client.Handshake.Retries", "IceSSL.Client.IgnoreValidPeriod", @@ -194,7 +194,7 @@ const char* IceInternal::PropertyNames::IceSSLProps[] = "IceSSL.Client.Overrides.RSA.Certificate", "IceSSL.Client.Overrides.RSA.PrivateKey", "IceSSL.Client.Passphrase.Retries", - "IceSSL.Server.CertPath*", + "IceSSL.Server.CertPath", "IceSSL.Server.Config", "IceSSL.Server.IgnoreValidPeriod", "IceSSL.Server.Overrides.CACertificate", @@ -335,8 +335,16 @@ const char* IceInternal::PropertyNames::Glacier2Props[] = const char* IceInternal::PropertyNames::FreezeProps[] = { - "Freeze.DbEnv.*", - "Freeze.Evictor.*", + "Freeze.DbEnv.*.DbCheckpointPeriod", + "Freeze.DbEnv.*.DbHome", + "Freeze.DbEnv.*.DbPrivate", + "Freeze.DbEnv.*.DbRecoverFatal", + "Freeze.DbEnv.*.OldLogsAutoDelete", + "Freeze.DbEnv.*.PeriodicCheckpointMinSize", + "Freeze.Evictor.*.*.MaxTxSize", + "Freeze.Evictor.*.*.SavePeriod", + "Freeze.Evictor.*.*.SaveSizeTrigger", + "Freeze.Evictor.*.*.StreamTimeout", "Freeze.Trace.DbEnv", "Freeze.Trace.Evictor", "Freeze.Trace.Map", diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index ad96a31770c..23f7207db13 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -7,7 +7,7 @@ // // ********************************************************************** -// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Dec 6 12:29:15 2004 +// Generated by makeprops.py from file `../config/PropertyNames.def', Wed Dec 8 15:48:53 2004 // IMPORTANT: Do not edit this file -- any edits made here will be lost! |