summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/Client.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/Client.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/Client.cpp')
-rw-r--r--cpp/src/IceGrid/Client.cpp60
1 files changed, 37 insertions, 23 deletions
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index e975172743d..2f40e7d83fc 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -156,8 +156,8 @@ class Client : public IceUtil::Monitor<IceUtil::Mutex>
public:
void usage();
- int main(int argc, char* argv[]);
- int run(int, char*[]);
+ int main(Ice::StringSeq& args);
+ int run(Ice::StringSeq& args);
void interrupted();
Ice::CommunicatorPtr communicator() const { return _communicator; }
@@ -183,11 +183,22 @@ interruptCallback(int signal)
}
}
+#ifdef _WIN32
+
+int
+wmain(int argc, wchar_t* argv[])
+
+#else
+
int
main(int argc, char* argv[])
+
+#endif
{
Client app;
- return app.main(argc, argv);
+ Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
+ int rc = app.main(args);
+ return rc;
}
void
@@ -208,15 +219,18 @@ Client::usage()
;
}
+
int
-Client::main(int argc, char* argv[])
+Client::main(Ice::StringSeq& args)
{
int status = EXIT_SUCCESS;
try
{
- _appName = argv[0];
- _communicator = Ice::initialize(argc, argv);
+ _appName = args[0].c_str();
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties();
+ _communicator = Ice::initialize(args, initData);
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(_staticMutex);
@@ -226,7 +240,7 @@ Client::main(int argc, char* argv[])
try
{
- status = run(argc, argv);
+ status = run(args);
}
catch(const Ice::CommunicatorDestroyedException&)
{
@@ -310,7 +324,7 @@ Client::interrupted()
}
int
-Client::run(int argc, char* argv[])
+Client::run(Ice::StringSeq& args)
{
string commands;
bool debug;
@@ -326,13 +340,13 @@ Client::run(int argc, char* argv[])
opts.addOpt("s", "server");
opts.addOpt("r", "replica", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::NoRepeat);
- vector<string> args;
+ vector<string> noArgs;
try
{
#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600)
IceUtil::DummyBCC dummy;
#endif
- args = opts.parse(argc, (const char**)argv);
+ noArgs = opts.parse(args);
}
catch(const IceUtilInternal::BadOptException& e)
{
@@ -340,9 +354,9 @@ Client::run(int argc, char* argv[])
usage();
return EXIT_FAILURE;
}
- if(!args.empty())
+ if(!noArgs.empty())
{
- cerr << argv[0] << ": too many arguments" << endl;
+ cerr << _appName << ": too many arguments" << endl;
usage();
return EXIT_FAILURE;
}
@@ -419,13 +433,13 @@ Client::run(int argc, char* argv[])
router = Glacier2::RouterPrx::checkedCast(communicator()->getDefaultRouter()->ice_preferSecure(true));
if(!router)
{
- cerr << argv[0] << ": configured router is not a Glacier2 router" << endl;
+ cerr << _appName << ": configured router is not a Glacier2 router" << endl;
return EXIT_FAILURE;
}
}
catch(const Ice::LocalException& ex)
{
- cerr << argv[0] << ": could not contact the default router:" << endl << ex << endl;
+ cerr << _appName << ": could not contact the default router:" << endl << ex << endl;
return EXIT_FAILURE;
}
@@ -434,7 +448,7 @@ Client::run(int argc, char* argv[])
session = AdminSessionPrx::uncheckedCast(router->createSessionFromSecureConnection());
if(!session)
{
- cerr << argv[0]
+ cerr << _appName
<< ": Glacier2 returned a null session, please set the Glacier2.SSLSessionManager property"
<< endl;
return EXIT_FAILURE;
@@ -458,7 +472,7 @@ Client::run(int argc, char* argv[])
password = "";
if(!session)
{
- cerr << argv[0]
+ cerr << _appName
<< ": Glacier2 returned a null session, please set the Glacier2.SessionManager property"
<< endl;
return EXIT_FAILURE;
@@ -491,14 +505,14 @@ Client::run(int argc, char* argv[])
locator = IceGrid::LocatorPrx::checkedCast(communicator()->getDefaultLocator());
if(!locator)
{
- cerr << argv[0] << ": configured locator is not an IceGrid locator" << endl;
+ cerr << _appName << ": configured locator is not an IceGrid locator" << endl;
return EXIT_FAILURE;
}
localRegistry = locator->getLocalRegistry();
}
catch(const Ice::LocalException& ex)
{
- cerr << argv[0] << ": could not contact the default locator:" << endl << ex << endl;
+ cerr << _appName << ": could not contact the default locator:" << endl << ex << endl;
return EXIT_FAILURE;
}
@@ -519,19 +533,19 @@ Client::run(int argc, char* argv[])
registry = RegistryPrx::checkedCast(communicator()->stringToProxy(strId));
if(!registry)
{
- cerr << argv[0] << ": could not contact an IceGrid registry" << endl;
+ cerr << _appName << ": could not contact an IceGrid registry" << endl;
}
}
catch(const Ice::NotRegisteredException&)
{
- cerr << argv[0] << ": no active registry replica named `" << replica << "'" << endl;
+ cerr << _appName << ": no active registry replica named `" << replica << "'" << endl;
return EXIT_FAILURE;
}
catch(const Ice::LocalException& ex)
{
if(!replica.empty())
{
- cerr << argv[0] << ": could not contact the registry replica named `" << replica << "':\n";
+ cerr << _appName << ": could not contact the registry replica named `" << replica << "':\n";
cerr << ex << endl;
return EXIT_FAILURE;
}
@@ -548,7 +562,7 @@ Client::run(int argc, char* argv[])
{
name = name.substr(prefix.size());
}
- cerr << argv[0] << ": warning: could not contact master, using slave `" << name << "'" << endl;
+ cerr << _appName << ": warning: could not contact master, using slave `" << name << "'" << endl;
}
}
}
@@ -597,7 +611,7 @@ Client::run(int argc, char* argv[])
}
else // No default locator or router set.
{
- cerr << argv[0] << ": could not contact the registry:" << endl;
+ cerr << _appName << ": could not contact the registry:" << endl;
cerr << "no default locator or router configured" << endl;
return EXIT_FAILURE;
}