#include <Activator_Options.h>
Public Types | |
enum | SERVICE_COMMAND { SC_NONE, SC_INSTALL, SC_REMOVE, SC_INSTALL_NO_LOCATOR } |
enum | ACTIVATOR_PROCESS { ENVIRONMENT_BUFFER = 16 * 1024 } |
Public Member Functions | |
Activator_Options () | |
int | init (int argc, char *argv[]) |
Parse the command-line arguments and initialize the options. | |
int | init_from_registry () |
This version should only be used when run as an nt service. | |
bool | service (void) const |
Service Mode. | |
bool | notify_imr (void) const |
unsigned int | debug (void) const |
Debug level for the Implementation Repository. | |
const ACE_CString & | ior_filename (void) const |
Returns the file where the IOR should be stored. | |
SERVICE_COMMAND | service_command (void) const |
The nt service command to run (install/remove). | |
int | save_registry_options () |
Save the command line arguments as registry settings. (Windows only). | |
const char * | cmdline (void) const |
const ACE_CString & | name (void) const |
int | env_buf_len (void) const |
Private Member Functions | |
int | parse_args (int &argc, char *argv[]) |
Parses and pulls out arguments for the ImR. | |
void | print_usage (void) const |
Print the usage information. | |
int | load_registry_options () |
Loads options from the registry. | |
Private Attributes | |
ACE_CString | cmdline_ |
Our extra command line arguments. | |
unsigned int | debug_ |
Debug level. | |
ACE_CString | ior_output_file_ |
File where the IOR of the server object is stored. | |
bool | service_ |
Should we run as a service? | |
bool | notify_imr_ |
SERVICE_COMMAND | service_command_ |
SC_NONE, SC_INSTALL, SC_REMOVE, ... | |
ACE_CString | name_ |
int | env_buf_len_ |
The default environment buffer length. |
|
Definition at line 45 of file Activator_Options.h.
00046 { 00047 ENVIRONMENT_BUFFER = 16 * 1024 00048 }; |
|
Definition at line 36 of file Activator_Options.h.
00036 { 00037 SC_NONE, 00038 SC_INSTALL, 00039 SC_REMOVE, 00040 SC_INSTALL_NO_LOCATOR 00041 }; |
|
Definition at line 27 of file Activator_Options.cpp.
00028 : debug_ (1) 00029 , service_ (false) 00030 , notify_imr_ (false) 00031 , service_command_(SC_NONE) 00032 , env_buf_len_ (Activator_Options::ENVIRONMENT_BUFFER) 00033 { 00034 } |
|
Definition at line 356 of file Activator_Options.cpp. References cmdline_. Referenced by ImR_Activator_i::init().
00357 { 00358 return this->cmdline_.c_str (); 00359 } |
|
Debug level for the Implementation Repository.
Definition at line 338 of file Activator_Options.cpp. Referenced by ImR_Activator_i::init_with_orb().
00339 { 00340 return this->debug_; 00341 } |
|
Definition at line 368 of file Activator_Options.cpp. References env_buf_len_. Referenced by ImR_Activator_i::init_with_orb().
00369 { 00370 return this->env_buf_len_; 00371 } |
|
Parse the command-line arguments and initialize the options.
Definition at line 162 of file Activator_Options.cpp. References ACE_CString, cmdline_, and parse_args(). Referenced by ImR_Activator_Loader::init(), and main().
00163 { 00164 // Make an initial pass through and grab the arguments that we recognize. 00165 // This may also run the commands to install or remove the nt service. 00166 int result = this->parse_args (argc, argv); 00167 if (result != 0) 00168 { 00169 return result; 00170 } 00171 00172 for (int i = 0; i < argc; ++i) 00173 { 00174 this->cmdline_ += ACE_CString (argv[i]) + ACE_CString (" "); 00175 } 00176 00177 return 0; 00178 } |
|
This version should only be used when run as an nt service.
Definition at line 181 of file Activator_Options.cpp. References load_registry_options(). Referenced by Activator_NT_Service::svc().
00182 { 00183 this->load_registry_options(); 00184 return 0; 00185 } |
|
Returns the file where the IOR should be stored.
Definition at line 344 of file Activator_Options.cpp. References ior_output_file_. Referenced by ImR_Activator_i::init_with_orb().
00345 { 00346 return this->ior_output_file_; 00347 } |
|
Loads options from the registry.
Definition at line 253 of file Activator_Options.cpp. References ACE_ASSERT, ACE_TEXT_RegOpenKeyEx, ACE_TEXT_RegQueryValueEx, cmdline_, ior_output_file_, notify_imr_, SERVICE_REG_PATH, and SERVICE_REG_ROOT. Referenced by init_from_registry().
00254 { 00255 #if defined (ACE_WIN32) 00256 HKEY key = 0; 00257 // Create or open the parameters key 00258 LONG err = ACE_TEXT_RegOpenKeyEx (SERVICE_REG_ROOT, 00259 SERVICE_REG_PATH, 00260 0, 00261 KEY_READ, 00262 &key 00263 ); 00264 if (err != ERROR_SUCCESS) 00265 { 00266 // If there aren't any saved parameters, then that's ok. 00267 return 0; 00268 } 00269 char tmpstr[4096]; 00270 DWORD sz = sizeof (tmpstr); 00271 DWORD type = 0; 00272 err = ACE_TEXT_RegQueryValueEx (key, "ORBInitOptions", 0, &type, 00273 (LPBYTE) tmpstr, &sz); 00274 if (err == ERROR_SUCCESS) 00275 { 00276 ACE_ASSERT (type == REG_SZ); 00277 tmpstr[sz - 1] = '\0'; 00278 this->cmdline_ = tmpstr; 00279 } 00280 00281 sz = sizeof(tmpstr); 00282 err = ACE_TEXT_RegQueryValueEx (key, "IORFile", 0, &type, 00283 (LPBYTE) tmpstr, &sz); 00284 if (err == ERROR_SUCCESS) 00285 { 00286 ACE_ASSERT (type == REG_SZ); 00287 tmpstr[sz - 1] = '\0'; 00288 this->ior_output_file_ = tmpstr; 00289 } 00290 00291 sz = sizeof(debug_); 00292 err = ACE_TEXT_RegQueryValueEx (key, "DebugLevel", 0, &type, 00293 (LPBYTE) &this->debug_ , &sz); 00294 if (err == ERROR_SUCCESS) 00295 { 00296 ACE_ASSERT (type == REG_DWORD); 00297 } 00298 00299 sz = sizeof(tmpstr); 00300 err = ACE_TEXT_RegQueryValueEx (key, "Name", 0, &type, 00301 (LPBYTE) tmpstr, &sz); 00302 if (err == ERROR_SUCCESS) 00303 { 00304 ACE_ASSERT (type == REG_SZ); 00305 tmpstr[sz - 1] = '\0'; 00306 this->name_ = tmpstr; 00307 } 00308 00309 DWORD tmpint = 0; 00310 sz = sizeof(tmpint); 00311 err = ACE_TEXT_RegQueryValueEx (key, "NotifyImR", 0, &type, 00312 (LPBYTE) &tmpint , &sz); 00313 if (err == ERROR_SUCCESS) 00314 { 00315 ACE_ASSERT (type == REG_DWORD); 00316 } 00317 this->notify_imr_ = tmpint != 0; 00318 00319 err = ::RegCloseKey (key); 00320 ACE_ASSERT(err == ERROR_SUCCESS); 00321 #endif /* ACE_WIN32 */ 00322 return 0; 00323 } |
|
Definition at line 362 of file Activator_Options.cpp. Referenced by ImR_Activator_i::init_with_orb().
00363 { 00364 return this->name_; 00365 } |
|
Notify the ImR when server processes die. Note : Currently this only works on Unix. Definition at line 332 of file Activator_Options.cpp. References notify_imr_. Referenced by ImR_Activator_i::init_with_orb().
00333 { 00334 return this->notify_imr_; 00335 } |
|
Parses and pulls out arguments for the ImR.
Definition at line 37 of file Activator_Options.cpp. References ACE_Arg_Shifter, ACE_ERROR, ACE_TEXT, ACE_OS::atoi(), env_buf_len_, ior_output_file_, LM_ERROR, notify_imr_, print_usage(), SC_INSTALL, SC_INSTALL_NO_LOCATOR, SC_REMOVE, service_command_, and ACE_OS::strcasecmp(). Referenced by init().
00038 { 00039 ACE_Arg_Shifter shifter (argc, argv); 00040 00041 while (shifter.is_anything_left ()) 00042 { 00043 if (ACE_OS::strcasecmp (shifter.get_current (), 00044 ACE_TEXT ("-c")) == 0) 00045 { 00046 shifter.consume_arg (); 00047 00048 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00049 { 00050 ACE_ERROR ((LM_ERROR, "Error: -c option needs a command\n")); 00051 this->print_usage (); 00052 return -1; 00053 } 00054 00055 if (ACE_OS::strcasecmp (shifter.get_current (), 00056 ACE_TEXT ("install")) == 0) 00057 { 00058 this->service_command_ = SC_INSTALL; 00059 } 00060 else if (ACE_OS::strcasecmp (shifter.get_current (), 00061 ACE_TEXT ("remove")) == 0) 00062 { 00063 this->service_command_ = SC_REMOVE; 00064 } 00065 else if (ACE_OS::strcasecmp (shifter.get_current (), 00066 ACE_TEXT ("install_no_imr")) == 0) 00067 { 00068 this->service_command_ = SC_INSTALL_NO_LOCATOR; 00069 } 00070 else 00071 { 00072 ACE_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current())); 00073 this->print_usage (); 00074 return -1; 00075 } 00076 } 00077 else if (ACE_OS::strcasecmp (shifter.get_current (), 00078 ACE_TEXT ("-d")) == 0) 00079 { 00080 shifter.consume_arg (); 00081 00082 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00083 { 00084 ACE_ERROR ((LM_ERROR, "Error: -d option needs a debuglevel\n")); 00085 this->print_usage (); 00086 return -1; 00087 } 00088 00089 this->debug_ = ACE_OS::atoi (shifter.get_current ()); 00090 } 00091 else if (ACE_OS::strcasecmp (shifter.get_current (), 00092 ACE_TEXT ("-e")) == 0) 00093 { 00094 shifter.consume_arg (); 00095 00096 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00097 { 00098 ACE_ERROR ((LM_ERROR, "Error: -e option needs " 00099 "an environment buffer length\n")); 00100 this->print_usage (); 00101 return -1; 00102 } 00103 00104 this->env_buf_len_ = ACE_OS::atoi (shifter.get_current ()); 00105 } 00106 else if (ACE_OS::strcasecmp (shifter.get_current (), 00107 ACE_TEXT ("-o")) == 0) 00108 { 00109 shifter.consume_arg (); 00110 00111 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00112 { 00113 ACE_ERROR ((LM_ERROR, "Error: -o option needs a filename\n")); 00114 this->print_usage (); 00115 return -1; 00116 } 00117 this->ior_output_file_ = shifter.get_current (); 00118 } 00119 else if (ACE_OS::strcasecmp (shifter.get_current (), 00120 ACE_TEXT ("-s")) == 0) 00121 { 00122 this->service_ = true; 00123 } 00124 else if ((ACE_OS::strcasecmp (shifter.get_current (), 00125 ACE_TEXT ("-?")) == 0) 00126 || (ACE_OS::strcasecmp (shifter.get_current (), 00127 ACE_TEXT ("-h")) == 0)) 00128 { 00129 this->print_usage (); 00130 return 1; 00131 } 00132 else if (ACE_OS::strcasecmp (shifter.get_current (), 00133 ACE_TEXT ("-n")) == 0) 00134 { 00135 shifter.consume_arg (); 00136 00137 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') 00138 { 00139 ACE_ERROR ((LM_ERROR, "Error: -n option needs a name\n")); 00140 this->print_usage (); 00141 return -1; 00142 } 00143 this->name_ = shifter.get_current (); 00144 } 00145 else if (ACE_OS::strcasecmp (shifter.get_current (), 00146 ACE_TEXT ("-l")) == 0) 00147 { 00148 this->notify_imr_ = true; 00149 } 00150 else 00151 { 00152 shifter.ignore_arg (); 00153 continue; 00154 } 00155 00156 shifter.consume_arg (); 00157 } 00158 return 0; 00159 } |
|
Print the usage information.
Definition at line 188 of file Activator_Options.cpp. References ACE_ERROR, and LM_ERROR. Referenced by parse_args().
00189 { 00190 ACE_ERROR ((LM_ERROR, 00191 "Usage:\n" 00192 "\n" 00193 "ImR_Activator [-c cmd] [-d 0|1|2] [-e buflen] [-o file] [-l] [-n name]\n" 00194 "\n" 00195 " -c command Runs service commands \n" 00196 " ('install' or 'remove' or 'install_no_imr')\n" 00197 " -d level Sets the debug level\n" 00198 " -e buflen Set the environment buffer length in bytes for activated servants\n" 00199 " -o file Outputs the ImR's IOR to a file\n" 00200 " -l Notify the ImR when a process exits\n" 00201 " -n name Specify a name for the Activator\n") 00202 ); 00203 } |
|
Save the command line arguments as registry settings. (Windows only).
Definition at line 206 of file Activator_Options.cpp. References ACE_ASSERT, ACE_TEXT_RegCreateKeyEx, ACE_TEXT_RegSetValueEx, cmdline_, ior_output_file_, notify_imr_, SERVICE_REG_PATH, and SERVICE_REG_ROOT. Referenced by run_service_command().
00207 { 00208 #if defined (ACE_WIN32) 00209 HKEY key = 0; 00210 // Create or open the parameters key 00211 LONG err = ACE_TEXT_RegCreateKeyEx (SERVICE_REG_ROOT, 00212 SERVICE_REG_PATH, 00213 0, 00214 "", // class 00215 REG_OPTION_NON_VOLATILE, 00216 KEY_ALL_ACCESS, 00217 0, 00218 &key, 00219 0 00220 ); 00221 if (err != ERROR_SUCCESS) 00222 { 00223 return -1; 00224 } 00225 err = ACE_TEXT_RegSetValueEx (key, "ORBInitOptions", 0, REG_SZ, 00226 (LPBYTE) this->cmdline_.c_str (), this->cmdline_.length () + 1); 00227 ACE_ASSERT (err == ERROR_SUCCESS); 00228 00229 err = ACE_TEXT_RegSetValueEx (key, "IORFile", 0, REG_SZ, 00230 (LPBYTE) this->ior_output_file_.c_str (), this->ior_output_file_.length () + 1); 00231 ACE_ASSERT (err == ERROR_SUCCESS); 00232 00233 err = ACE_TEXT_RegSetValueEx (key, "DebugLevel", 0, REG_DWORD, 00234 (LPBYTE) &this->debug_ , sizeof (this->debug_)); 00235 ACE_ASSERT (err == ERROR_SUCCESS); 00236 00237 err = ACE_TEXT_RegSetValueEx( key, "Name", 0, REG_SZ, 00238 (LPBYTE) this->name_.c_str (), this->name_.length () + 1); 00239 ACE_ASSERT (err == ERROR_SUCCESS); 00240 00241 DWORD tmpint = this->notify_imr_; 00242 err = ACE_TEXT_RegSetValueEx (key, "NotifyImR", 0, REG_DWORD, 00243 (LPBYTE) &tmpint , sizeof (tmpint)); 00244 ACE_ASSERT (err == ERROR_SUCCESS); 00245 00246 err = ::RegCloseKey (key); 00247 ACE_ASSERT (err == ERROR_SUCCESS); 00248 #endif 00249 return 0; 00250 } |
|
Service Mode.
Definition at line 326 of file Activator_Options.cpp. Referenced by main().
00327 { 00328 return this->service_; 00329 } |
|
The nt service command to run (install/remove).
Definition at line 350 of file Activator_Options.cpp. References service_command_. Referenced by run_service_command().
00351 { 00352 return this->service_command_; 00353 } |
|
Our extra command line arguments.
Definition at line 95 of file Activator_Options.h. Referenced by cmdline(), init(), load_registry_options(), and save_registry_options(). |
|
Debug level.
Definition at line 98 of file Activator_Options.h. |
|
The default environment buffer length.
Definition at line 114 of file Activator_Options.h. Referenced by env_buf_len(), and parse_args(). |
|
File where the IOR of the server object is stored.
Definition at line 101 of file Activator_Options.h. Referenced by ior_filename(), load_registry_options(), parse_args(), and save_registry_options(). |
|
Definition at line 111 of file Activator_Options.h. |
|
Definition at line 106 of file Activator_Options.h. Referenced by load_registry_options(), notify_imr(), parse_args(), and save_registry_options(). |
|
Should we run as a service?
Definition at line 104 of file Activator_Options.h. |
|
SC_NONE, SC_INSTALL, SC_REMOVE, ...
Definition at line 109 of file Activator_Options.h. Referenced by parse_args(), and service_command(). |