diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2002-07-10 14:24:28 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2002-07-10 14:24:28 +0000 |
commit | 6c774c01208e68fa4485a312d741eda6a101183b (patch) | |
tree | 64bb49cc9cde2f333aa827c7eba465b55d3bf8ef /cpp/src/IceBox/Server.cpp | |
parent | Fixed demos and exception test to get rid of case-insensitivity warnings. (diff) | |
download | ice-6c774c01208e68fa4485a312d741eda6a101183b.tar.bz2 ice-6c774c01208e68fa4485a312d741eda6a101183b.tar.xz ice-6c774c01208e68fa4485a312d741eda6a101183b.zip |
Add IceBox::FreezeService
Diffstat (limited to 'cpp/src/IceBox/Server.cpp')
-rw-r--r-- | cpp/src/IceBox/Server.cpp | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/cpp/src/IceBox/Server.cpp b/cpp/src/IceBox/Server.cpp index b182b46de59..167a419737b 100644 --- a/cpp/src/IceBox/Server.cpp +++ b/cpp/src/IceBox/Server.cpp @@ -15,10 +15,30 @@ using namespace std; using namespace Ice; using namespace IceBox; -static void -usage(const char* appName) +namespace IceBox { - cerr << "Usage: " << appName << " [options]\n"; + +class Server : public Application +{ +public: + + void usage(); + virtual int run(int, char*[]); +}; + +} // End namespace IceBox + +int +main(int argc, char* argv[]) +{ + Server server; + return server.main(argc, argv); +} + +void +Server::usage() +{ + cerr << "Usage: " << appName() << " [options]\n"; cerr << "Options:\n" "-h, --help Show this message.\n" @@ -27,63 +47,39 @@ usage(const char* appName) } int -main(int argc, char* argv[]) +Server::run(int argc, char* argv[]) { - CommunicatorPtr communicator; ServiceManagerPtr serviceManager; int status; - try - { - communicator = initialize(argc, argv); - - PropertiesPtr properties = communicator->getProperties(); - StringSeq args = argsToStringSeq(argc, argv); - args = properties->parseCommandLineOptions("IceBox", args); - stringSeqToArgs(args, argc, argv); + PropertiesPtr properties = communicator()->getProperties(); + StringSeq args = argsToStringSeq(argc, argv); + args = properties->parseCommandLineOptions("IceBox", args); + stringSeqToArgs(args, argc, argv); - for(int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) + { + if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { - if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) - { - usage(argv[0]); - return EXIT_SUCCESS; - } - else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) - { - cout << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; - } - else if(strncmp(argv[i], "--", 2) != 0) - { - cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } + usage(); + return EXIT_SUCCESS; } - - ServiceManagerI* serviceManagerImpl = new ServiceManagerI(communicator, argc, argv); - serviceManager = serviceManagerImpl; - status = serviceManagerImpl->run(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - try + else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { - communicator->destroy(); + cout << ICE_STRING_VERSION << endl; + return EXIT_SUCCESS; } - catch(const Exception& ex) + else if(strncmp(argv[i], "--", 2) != 0) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; + usage(); + return EXIT_FAILURE; } } - return status; + ServiceManagerI* serviceManagerImpl = new ServiceManagerI(this, argc, argv); + serviceManager = serviceManagerImpl; + status = serviceManagerImpl->run(); + + return EXIT_SUCCESS; } |