diff options
author | Phil Mesnier <mesnier_p@ociweb.com> | 2014-06-20 16:56:06 +0000 |
---|---|---|
committer | Phil Mesnier <mesnier_p@ociweb.com> | 2014-06-20 16:56:06 +0000 |
commit | 94593b89cdd2f6935cbac4c4a6801da146b5f5c7 (patch) | |
tree | 6e4b4c425f7657b60a6186dd14d996cf482f9e93 /TAO/orbsvcs/Notify_Service/NT_Notify_Server.cpp | |
parent | 5177d03a0bdb65aa4b5c8dfce8a32ad7da2ce182 (diff) | |
download | ATCD-94593b89cdd2f6935cbac4c4a6801da146b5f5c7.tar.gz |
Fri Jun 20 16:47:17 UTC 2014 Phil Mesnier <mesnier_p@ociweb.com>
* orbsvcs/IFR_Service/README:
* orbsvcs/ImplRepo_Service/README:
* orbsvcs/Naming_Service/README:
* orbsvcs/Notify_Service/README:
update executable names and other content to be current.
* orbsvcs/Notify_Service/NT_Notify_Server.cpp:
* orbsvcs/Notify_Service/NT_Notify_Service.h:
* orbsvcs/Notify_Service/NT_Notify_Service.cpp:
Added command line interface for populating the service command line
arguments without the need to invoke regedit.
Diffstat (limited to 'TAO/orbsvcs/Notify_Service/NT_Notify_Server.cpp')
-rw-r--r-- | TAO/orbsvcs/Notify_Service/NT_Notify_Server.cpp | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/TAO/orbsvcs/Notify_Service/NT_Notify_Server.cpp b/TAO/orbsvcs/Notify_Service/NT_Notify_Server.cpp index 4375e1a3462..4e6f8e94226 100644 --- a/TAO/orbsvcs/Notify_Service/NT_Notify_Server.cpp +++ b/TAO/orbsvcs/Notify_Service/NT_Notify_Server.cpp @@ -62,8 +62,10 @@ private: void print_usage_and_die (void); private: - char progname[128]; + ACE_TCHAR progname[128]; + int opt_setargs; + const ACE_TCHAR *opt_args; int opt_install; int opt_remove; int opt_start; @@ -77,7 +79,9 @@ private: typedef ACE_Singleton<Options, ACE_Mutex> OPTIONS; Options::Options (void) - : opt_install (0), + : opt_setargs (0), + opt_args (0), + opt_install (0), opt_remove (0), opt_start (0), opt_kill (0), @@ -86,7 +90,7 @@ Options::Options (void) opt_startup (0) { ACE_OS::strcpy (progname, - "service"); + ACE_TEXT ("service")); ACE::init (); } @@ -99,14 +103,15 @@ void Options::print_usage_and_die (void) { ORBSVCS_DEBUG ((LM_INFO, - "Usage: %s" - " -in -r -s -k -tn -d\n" - " -i: Install this program as an NT service, with specified startup\n" - " -r: Remove this program from the Service Manager\n" - " -s: Start the service\n" - " -k: Kill the service\n" - " -t: Set startup for an existing service\n" - " -d: Debug; run as a regular application\n", + ACE_TEXT ("Usage: %s") + ACE_TEXT (" -c [<args>] -in -r -s -k -tn -d\n") + ACE_TEXT (" -c: set or retrieve command line arguments for NT service\n") + ACE_TEXT (" -i: Install this program as an NT service, with specified startup\n") + ACE_TEXT (" -r: Remove this program from the Service Manager\n") + ACE_TEXT (" -s: Start the service\n") + ACE_TEXT (" -k: Kill the service\n") + ACE_TEXT (" -t: Set startup for an existing service\n") + ACE_TEXT (" -d: Debug; run as a regular application\n"), progname, 0)); ACE_OS::exit (1); @@ -115,12 +120,16 @@ Options::print_usage_and_die (void) void Options::parse_args (int argc, ACE_TCHAR *argv[]) { - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("i:rskt:d")); + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("c:i:rskt:d")); int c; while ((c = get_opt ()) != -1) switch (c) { + case 'c': + opt_setargs = 1; + opt_args = get_opt.opt_arg (); + break; case 'i': opt_install = 1; opt_startup = ACE_OS::atoi (get_opt.optarg); @@ -146,13 +155,19 @@ Options::parse_args (int argc, ACE_TCHAR *argv[]) //opt_debug = 1; break; default: - // -i can also be given without a value - if so, it defaults + // -c and -i can also be given without a value - if so, it defaults // to defined value. + const ACE_TCHAR *lastarg = get_opt.argv ()[get_opt.opt_ind () - 1]; if (ACE_OS::strcmp (get_opt.argv_[get_opt.optind-1], ACE_TEXT ("-i")) == 0) { opt_install = 1; opt_startup = DEFAULT_SERVICE_INIT_STARTUP; } + else if (ACE_OS::strcmp (lastarg, ACE_TEXT ("-c")) == 0) + { + opt_setargs = 1; + opt_args = 0; + } else this->print_usage_and_die (); break; @@ -189,6 +204,9 @@ Options::run (int argc, ACE_TCHAR* argv[]) if (opt_start && opt_kill) print_usage_and_die (); + if (opt_setargs) + return SERVICE::instance ()->set_args (opt_args); + if (opt_start) return SERVICE::instance ()->start_svc (); @@ -213,8 +231,8 @@ Options::run (int argc, ACE_TCHAR* argv[]) ret); if (ret == 0) ORBSVCS_ERROR ((LM_ERROR, - "%p\n", - "Couldn't start service")); + ACE_TEXT ("%p\n"), + ACE_TEXT ("Couldn't start service"))); } return 0; |