summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/ServerI.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2009-07-29 21:50:06 +0200
committerJose <jose@zeroc.com>2009-07-29 21:50:06 +0200
commitdb9adf0e14f01d0aa8eb288a172995847c006f57 (patch)
tree9690b02e0f0c85377c0feedb18b3a203d73928fb /cpp/src/IceGrid/ServerI.cpp
parentbug 4003 - update bindist READMEs for bzip2 (diff)
downloadice-db9adf0e14f01d0aa8eb288a172995847c006f57.tar.bz2
ice-db9adf0e14f01d0aa8eb288a172995847c006f57.tar.xz
ice-db9adf0e14f01d0aa8eb288a172995847c006f57.zip
Changes for bug 3962 and 4714
Diffstat (limited to 'cpp/src/IceGrid/ServerI.cpp')
-rw-r--r--cpp/src/IceGrid/ServerI.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 901fc5eae30..c1bfc9752e0 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -7,7 +7,9 @@
//
// **********************************************************************
+#include <IceUtil/FileUtil.h>
#include <Ice/Ice.h>
+#include <Ice/Instance.h>
#include <IceGrid/ServerI.h>
#include <IceGrid/TraceLevels.h>
#include <IceGrid/Activator.h>
@@ -21,7 +23,6 @@
#include <IceUtil/FileUtil.h>
#include <sys/types.h>
-#include <sys/stat.h>
#ifdef _WIN32
# include <direct.h>
@@ -97,8 +98,9 @@ chownRecursive(const string& path, uid_t uid, gid_t gid)
{
name = path + "/" + name;
- OS::structstat buf;
- if(OS::osstat(name, &buf) == -1)
+
+ IceUtilInternal::structstat buf;
+ if(IceUtilInternal::stat(name, &buf) == -1)
{
throw "cannot stat `" + name + "':\n" + IceUtilInternal::lastErrorToString();
}
@@ -276,6 +278,11 @@ private:
struct EnvironmentEval : std::unary_function<string, string>
{
+ EnvironmentEval(const Ice::StringConverterPtr& converter)
+ {
+ this->converter = converter;
+ }
+
string
operator()(const std::string& value)
{
@@ -290,7 +297,7 @@ struct EnvironmentEval : std::unary_function<string, string>
string::size_type beg = 0;
string::size_type end;
#ifdef _WIN32
- char buf[32767];
+ wchar_t buf[32767];
while((beg = v.find("%", beg)) != string::npos && beg < v.size() - 1)
{
end = v.find("%", beg + 1);
@@ -299,8 +306,15 @@ struct EnvironmentEval : std::unary_function<string, string>
break;
}
string variable = v.substr(beg + 1, end - beg - 1);
- DWORD ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf));
- string valstr = (ret > 0 && ret < sizeof(buf)) ? string(buf) : string("");
+ DWORD ret = GetEnvironmentVariableW(IceUtil::stringToWstring(variable).c_str(), buf, sizeof(buf));
+ string valstr = (ret > 0 && ret < sizeof(buf)) ? IceUtil::wstringToString(buf) : string("");
+ if(converter)
+ {
+ string tmp;
+ converter->fromUTF8(reinterpret_cast<const Ice::Byte*>(valstr.data()),
+ reinterpret_cast<const Ice::Byte*>(valstr.data() + valstr.size()), tmp);
+ valstr.swap(tmp);
+ }
v.replace(beg, end - beg + 1, valstr);
beg += valstr.size();
}
@@ -336,6 +350,8 @@ struct EnvironmentEval : std::unary_function<string, string>
#endif
return value.substr(0, assignment) + "=" + v;
}
+
+ Ice::StringConverterPtr converter;
};
}
@@ -1430,8 +1446,10 @@ ServerI::activate()
copy(desc->options.begin(), desc->options.end(), back_inserter(options));
options.push_back("--Ice.Config=" + escapeProperty(_serverDir + "/config/config"));
+ Ice::StringConverterPtr converter =
+ IceInternal::getInstance(_node->getCommunicator())->initializationData().stringConverter;
Ice::StringSeq envs;
- transform(desc->envs.begin(), desc->envs.end(), back_inserter(envs), EnvironmentEval());
+ transform(desc->envs.begin(), desc->envs.end(), back_inserter(envs), EnvironmentEval(converter));
//
// Clear the adapters direct proxy (this is usefull if the server