summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2005-09-01 14:44:08 +0000
committerBenoit Foucher <benoit@zeroc.com>2005-09-01 14:44:08 +0000
commita3fef020a305338363ec933dba834b475510c48e (patch)
tree7f782b5e3e3823fde01fe7004aaf3560e2fe3b23 /cpp
parentIceGrid Windows port. (diff)
downloadice-a3fef020a305338363ec933dba834b475510c48e.tar.bz2
ice-a3fef020a305338363ec933dba834b475510c48e.tar.xz
ice-a3fef020a305338363ec933dba834b475510c48e.zip
Added support for env variable substitution (Unix only for now).
Diffstat (limited to 'cpp')
-rw-r--r--cpp/config/PropertyNames.def1
-rw-r--r--cpp/src/IceGrid/Activator.cpp13
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp2
-rw-r--r--cpp/src/IceGrid/Makefile4
-rw-r--r--cpp/src/IceGrid/ServerI.cpp67
-rw-r--r--cpp/src/Makefile3
-rw-r--r--cpp/test/Makefile3
7 files changed, 81 insertions, 12 deletions
diff --git a/cpp/config/PropertyNames.def b/cpp/config/PropertyNames.def
index 05977cfd78b..aff3f9dd2a8 100644
--- a/cpp/config/PropertyNames.def
+++ b/cpp/config/PropertyNames.def
@@ -252,6 +252,7 @@ IceGrid:
Node.Trace.Activator
Node.Trace.Adapter
Node.Trace.Server
+ Node.Trace.Patch
Node.WaitTime
Node.BackgroundRegistration
Registry.Admin.AdapterId
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index bcb96168b7d..3b246ed95f1 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -12,6 +12,7 @@
#include <IceGrid/Admin.h>
#include <IceGrid/Internal.h>
#include <IceGrid/TraceLevels.h>
+#include <IceGrid/Util.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -441,13 +442,13 @@ Activator::activate(const string& name,
out << "\n";
out << "path = " << path << "\n";
out << "pwd = " << pwd << "\n";
- out << "args = ";
-
- StringSeq::const_iterator p = args.begin();
- ++p;
- for(StringSeq::const_iterator q = p; q != args.end(); ++q)
+ if(!envs.empty())
+ {
+ out << "envs = " << toString(envs, ", ") << "\n";
+ }
+ if(!args.empty())
{
- out << " " << *q;
+ out << "args = " << toString(args);
}
}
}
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index 5ce2dbdf2f3..1952fbfa78a 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -2142,7 +2142,7 @@ ApplicationHelper::printDiff(Output& out, const ApplicationHelper& helper) const
NodeHelperDict::const_iterator q = helper._nodes.find(r->first);
if(q != helper._nodes.end())
{
- p->second.printDiff(out, q->second);
+ r->second.printDiff(out, q->second);
}
}
for(Ice::StringSeq::const_iterator s = removed.begin(); s != removed.end(); ++s)
diff --git a/cpp/src/IceGrid/Makefile b/cpp/src/IceGrid/Makefile
index fdb1af0d0e1..c491551036d 100644
--- a/cpp/src/IceGrid/Makefile
+++ b/cpp/src/IceGrid/Makefile
@@ -158,12 +158,12 @@ $(OBSERVER): $(OBSERVER_OBJS) $(LIBTARGETS)
$(REGISTRY_SERVER): $(REGISTRY_SVR_OBJS) $(LIBTARGETS)
rm -f $@
$(CXX) $(LDFLAGS) -o $@ $(REGISTRY_SVR_OBJS) -lIceGrid -lIceStormService -lGlacier2 -lIcePatch2 -lFreeze \
- -lIceXML $(LIBS) $(DB_LIBS)
+ -lIceBox -lIceXML $(LIBS) $(DB_LIBS)
$(NODE_SERVER): $(NODE_SVR_OBJS) $(LIBTARGETS)
rm -f $@
$(CXX) $(LDFLAGS) -o $@ $(NODE_SVR_OBJS) -lIceGrid -lIcePatch2 -lIceStormService -lGlacier2 -lFreeze -lIceXML \
- $(LIBS) $(DB_LIBS)
+ -lIceBox $(LIBS) $(DB_LIBS)
$(LOCAL_HDIR)/%.h %.cpp: $(SDIR)/%.ice $(SLICE2CPP)
rm -f $(HDIR)/$(*F).h $(*F).cpp
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index db592fcfe73..4ebac6eb1e4 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -65,6 +65,71 @@ private:
const ServerIPtr _server;
};
+struct EnvironmentEval : std::unary_function<string, string>
+{
+ string
+ operator()(const std::string& value)
+ {
+ string::size_type assignment = value.find("=");
+ if(assignment == string::npos || assignment >= value.size() - 1)
+ {
+ return value;
+ }
+
+ string v = value.substr(assignment + 1);
+ assert(v.size());
+ string::size_type beg = 0;
+ string::size_type end;
+#ifdef _WIN32
+// char buf[32767];
+// while((beg = v.find("%", beg)) != string::npos && beg < v.size() - 1)
+// {
+// end = v.find("%");
+// if(end == string::npos)
+// {
+// return v;
+// }
+// string variable = v.substr(beg + 2, end - beg - 2);
+// int ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf));
+// string valstr = ret > 0 ? string(buf) : "";
+// v.replace(beg, end - beg + 1, valstr);
+// beg += strlen(value);
+// }
+ return value;
+#else
+ while((beg = v.find("$", beg)) != string::npos && beg < v.size() - 1)
+ {
+ string variable;
+ if(v[beg + 1] == '{')
+ {
+ end = v.find("}");
+ if(end == string::npos)
+ {
+ return v;
+ }
+ variable = v.substr(beg + 2, end - beg - 2);
+ }
+ else
+ {
+ end = beg + 1;
+ while((isalnum(v[end]) || v[end] == '_') && end < v.size())
+ {
+ ++end;
+ }
+ variable = v.substr(beg + 1, end - beg - 1);
+ --end;
+ }
+
+ char* val = getenv(variable.c_str());
+ string valstr = val ? string(val) : "";
+ v.replace(beg, end - beg + 1, valstr);
+ beg += valstr.size();
+ }
+#endif
+ return value.substr(0, assignment) + "=" + v;
+ }
+};
+
}
ServerI::ServerI(const NodeIPtr& node, const ServerPrx& proxy, const string& serversDir, const string& id, int wt) :
@@ -479,7 +544,7 @@ ServerI::startInternal(ServerActivation act, const AMD_Server_startPtr& amdCB)
options.push_back("--Ice.Config=" + _serverDir + "/config/config");
Ice::StringSeq envs;
- copy(desc->envs.begin(), desc->envs.end(), back_inserter(envs));
+ transform(desc->envs.begin(), desc->envs.end(), back_inserter(envs), EnvironmentEval());
string pwd = desc->pwd;
if(pwd.empty())
diff --git a/cpp/src/Makefile b/cpp/src/Makefile
index b0578d0abfb..e3a252c4c54 100644
--- a/cpp/src/Makefile
+++ b/cpp/src/Makefile
@@ -33,7 +33,8 @@ SUBDIRS = IceUtil \
IceStorm \
IcePack \
Glacier2 \
- IcePatch2
+ IcePatch2 \
+ IceGrid
$(EVERYTHING)::
@for subdir in $(SUBDIRS); \
diff --git a/cpp/test/Makefile b/cpp/test/Makefile
index c6c676c858f..b1953c35528 100644
--- a/cpp/test/Makefile
+++ b/cpp/test/Makefile
@@ -18,7 +18,8 @@ SUBDIRS = IceUtil \
IcePack \
Freeze \
FreezeScript \
- Glacier2
+ Glacier2 \
+ IceGrid
$(EVERYTHING)::
@for subdir in $(SUBDIRS); \