diff options
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp')
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp | 105 |
1 files changed, 51 insertions, 54 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp index 34da1320caf..ecaf693dde9 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp @@ -10,7 +10,7 @@ class ImR_Activator_Shutdown : public Shutdown_Functor { public: - ImR_Activator_Shutdown (ImR_Activator_i& act); + ImR_Activator_Shutdown(ImR_Activator_i& act); void operator() (int which_signal); private: @@ -28,7 +28,7 @@ ImR_Activator_Shutdown::operator() (int /*which_signal*/) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - this->act_.shutdown (true ACE_ENV_ARG_PARAMETER); + this->act_.shutdown(true ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } ACE_CATCHANY @@ -44,7 +44,7 @@ run_standalone (Activator_Options& opts) ImR_Activator_i server; ImR_Activator_Shutdown killer (server); - Service_Shutdown kill_contractor (killer); + Service_Shutdown kill_contractor(killer); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY @@ -117,59 +117,56 @@ run_service (void) static int run_service_command (Activator_Options& opts) { - if (opts.service_command () == Activator_Options::SC_NONE) + if (opts.service_command() == Activator_Options::SC_NONE) return 0; #if defined (ACE_WIN32) SERVICE::instance()->name (IMR_ACTIVATOR_SERVICE_NAME, IMR_ACTIVATOR_DISPLAY_NAME); - if (opts.service_command () == Activator_Options::SC_INSTALL || - opts.service_command () == Activator_Options::SC_INSTALL_NO_LOCATOR) - { - const DWORD MAX_PATH_LENGTH = 4096; - char pathname[MAX_PATH_LENGTH]; - - DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH); - if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s")) - { - ACE_ERROR ((LM_ERROR, "Error: Could not get module file name\n")); - return -1; - } - - // Append the command used for running the implrepo as a service - ACE_OS::strcat (pathname, ACE_TEXT (" -s")); - int ret = -1; - if (opts.service_command () == Activator_Options::SC_INSTALL) - { - const char* DEPENDS_ON = "TAOImR"; // Must match Locator_NT_Service.h - - ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, - SERVICE_ERROR_NORMAL, - pathname, - 0, // group - 0, // tag - DEPENDS_ON - ); - } - else - { - ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, - SERVICE_ERROR_NORMAL, - pathname); - } - if (ret != -1) + if (opts.service_command() == Activator_Options::SC_INSTALL || + opts.service_command() == Activator_Options::SC_INSTALL_NO_LOCATOR) + { + const DWORD MAX_PATH_LENGTH = 4096; + ACE_TCHAR pathname[MAX_PATH_LENGTH]; + + DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH); + if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s")) { - ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service installed.\n")); - opts.save_registry_options (); + ACE_ERROR ((LM_ERROR, "Error: Could not get module file name\n")); + return -1; } + + // Append the command used for running the implrepo as a service + ACE_OS::strcat (pathname, ACE_TEXT (" -s")); + int ret = -1; + if (opts.service_command() == Activator_Options::SC_INSTALL) + { + const ACE_TCHAR* DEPENDS_ON = ACE_TEXT("TAOImR"); // Must match Locator_NT_Service.h + + ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, + SERVICE_ERROR_NORMAL, + pathname, + 0, // group + 0, // tag + DEPENDS_ON + ); + } else - { - ACE_ERROR ((LM_ERROR, "Error: Failed to install service.\n")); - } + { + ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, + SERVICE_ERROR_NORMAL, + pathname); + } + if (ret != -1) { + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service installed.\n")); + opts.save_registry_options(); + } else { + ACE_ERROR((LM_ERROR, "Error: Failed to install service.\n")); + } if (ret == 0) return 1; } - else if (opts.service_command () == Activator_Options::SC_REMOVE) + else if (opts.service_command() == Activator_Options::SC_REMOVE) { int ret = SERVICE::instance ()->remove (); ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service removed.\n")); @@ -177,11 +174,11 @@ run_service_command (Activator_Options& opts) return 1; // If successfull, then we don't want to continue. } else - { - ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n", - opts.service_command ())); - return -1; - } + { + ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n", + opts.service_command())); + return -1; + } return -1; @@ -192,7 +189,7 @@ run_service_command (Activator_Options& opts) } int -main (int argc, char *argv[]) +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { Activator_Options opts; @@ -202,14 +199,14 @@ main (int argc, char *argv[]) else if (result > 0) return 0; // No error, but we should exit anyway. - result = run_service_command (opts); + result = run_service_command(opts); if (result < 0) return 1; // Error else if (result > 0) return 0; // No error, but we should exit anyway. - if (opts.service ()) - return run_service (); + if (opts.service()) + return run_service(); return run_standalone (opts); } |