summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-12-08 06:11:21 +0000
committerMichi Henning <michi@zeroc.com>2004-12-08 06:11:21 +0000
commit37fa0d032659d3291c81628f9eb85fac538cb342 (patch)
treedd8acd3eecce7e1cb2df6f908c089337ae01ab02 /cpp
parentFixed bug in parsing for --Ice.Config: previous code dereferenced an (diff)
downloadice-37fa0d032659d3291c81628f9eb85fac538cb342.tar.bz2
ice-37fa0d032659d3291c81628f9eb85fac538cb342.tar.xz
ice-37fa0d032659d3291c81628f9eb85fac538cb342.zip
Added regular expression matching to property checking code.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/config/PropertyNames.def34
-rw-r--r--cpp/config/makeprops.py21
-rw-r--r--cpp/src/Ice/PropertiesI.cpp66
-rw-r--r--cpp/src/Ice/PropertiesI.h2
-rw-r--r--cpp/src/Ice/PropertyNames.cpp18
-rw-r--r--cpp/src/Ice/PropertyNames.h2
6 files changed, 103 insertions, 40 deletions
diff --git a/cpp/config/PropertyNames.def b/cpp/config/PropertyNames.def
index 7ba538cc8c9..86a63304747 100644
--- a/cpp/config/PropertyNames.def
+++ b/cpp/config/PropertyNames.def
@@ -34,22 +34,22 @@
# trailing comment.
#
-# A '*' character in a property is a wildcard. If used, it must appear
-# at the end of the property.
+# The token "<any>" is a wildcard and matches any non-empty sequence
+# of non-whitespace characters, excluding '.'.
#
# Examples:
#
-# "Ice.Foo.*" allows all properties with that prefix, such as
+# "Ice.Foo.<any>" allows all properties with that prefix, such as
# "Ice.Foo.Bar".
#
-# "Ice.Foo*" allows properties such as "Ice.Foo.Bar" and "Ice.FooBar".
+# "Ice.Foo<any>" allows properties such as "Ice.Foo.Bar" and "Ice.FooBar".
#
# Property definitions are translated into each language by
# makeprops.py. For example, consider the following definitions:
#
# Ice:
# ChangeUser
-# Package.*
+# Package.<any>
#
# IceBox:
# LoadOrder
@@ -119,8 +119,8 @@ Ice:
Override.Compress
Override.ConnectTimeout
Override.Timeout
- Package.*
- Plugin.*
+ Package.<any>
+ Plugin.<any>
PrintAdapterReady
PrintProcessId
ProgramName
@@ -158,7 +158,7 @@ Ice:
IceBox:
LoadOrder
PrintServicesReady
- Service.*
+ Service.<any>
ServiceManager.AdapterId
ServiceManager.Endpoints
ServiceManager.Identity
@@ -168,7 +168,7 @@ IceBox:
ServiceManager.ThreadPool.SizeMax
ServiceManager.ThreadPool.SizeWarn
ServiceManager.ThreadPool.StackSize
- UseSharedCommunicator.*
+ UseSharedCommunicator.<any>
IcePack:
Node.AdapterId
@@ -256,7 +256,7 @@ IcePatch2:
ThreadPool.StackSize
IceSSL:
- Client.CertPath*
+ Client.CertPath
Client.Config
Client.Handshake.Retries
Client.IgnoreValidPeriod
@@ -266,7 +266,7 @@ IceSSL:
Client.Overrides.RSA.Certificate
Client.Overrides.RSA.PrivateKey
Client.Passphrase.Retries
- Server.CertPath*
+ Server.CertPath
Server.Config
Server.IgnoreValidPeriod
Server.Overrides.CACertificate
@@ -395,8 +395,16 @@ Glacier2:
Trace.Session
Freeze:
- DbEnv.*
- Evictor.*
+ DbEnv.<any>.DbCheckpointPeriod
+ DbEnv.<any>.DbHome
+ DbEnv.<any>.DbPrivate
+ DbEnv.<any>.DbRecoverFatal
+ DbEnv.<any>.OldLogsAutoDelete
+ DbEnv.<any>.PeriodicCheckpointMinSize
+ Evictor.<any>.<any>.MaxTxSize
+ Evictor.<any>.<any>.SavePeriod
+ Evictor.<any>.<any>.SaveSizeTrigger
+ Evictor.<any>.<any>.StreamTimeout
Trace.DbEnv
Trace.Evictor
Trace.Map
diff --git a/cpp/config/makeprops.py b/cpp/config/makeprops.py
index a37df868537..d49683cbe93 100644
--- a/cpp/config/makeprops.py
+++ b/cpp/config/makeprops.py
@@ -8,7 +8,7 @@
#
# **********************************************************************
-import os, sys, shutil, re, signal, time
+import os, sys, shutil, re, signal, time, string
progname = os.path.basename(sys.argv[0])
infile = ""
@@ -188,15 +188,20 @@ def endSection(lang):
file.write("\n")
return
+wildcard = re.compile(".*<any>.*")
+
def writeEntry(lang, label, entry):
file = outputFiles[0][1]
if lang == "cpp":
- file.write(" ")
+ file.write(" \"" + label + '.' + string.replace(entry, "<any>", "*") + "\",\n")
elif lang == "java":
- file.write(" ")
+ pattern = string.replace(entry, ".", "\\\\.")
+ pattern = string.replace(pattern, "<any>", "[^\\\\s.]+")
+ file.write(" " + "\"^" + label + "\\\\." + pattern + "$\",\n")
elif lang == "cs":
- file.write(" ")
- file.write("\"" + label + '.' + entry + "\",\n")
+ pattern = string.replace(entry, ".", "\\.")
+ pattern = string.replace(pattern, "<any>", "[^\\s.]+")
+ file.write(" " + "@\"^" + label + "\\." + pattern + "$\",\n")
def processFile(lang):
@@ -213,7 +218,7 @@ def processFile(lang):
#
# Set up regular expressions for empty and comment lines, section headings, and entry lines.
#
- ignore = re.compile("^\s*(?:#.*)?$") # Empty line or comment line
+ ignore = re.compile("^\s*(?:#.*)?$") # Empty line or comment line
section = re.compile("^\s*([a-zA-z_]\w*)\s*:\s*$") # Section heading
entry = re.compile("^\s*([^ \t\n\r\f\v#]+)(?:\s*#.*)?$") # Any non-whitespace character sequence, except for #
@@ -235,8 +240,8 @@ def processFile(lang):
labels = {} # Records the line number on which each label is defined
atSectionStart = 0 # True for the line on which a label is defined
- seenSection = 0 # Set to true (and the remains as true) once the first label is defined
- numEntries = 0 # Number of entries within a section
+ seenSection = 0 # Set to true (and the remains as true) once the first label is defined
+ numEntries = 0 # Number of entries within a section
errors = 0 # Number of syntax errors in the input file
#
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!