Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / Locator_Options.cpp
blob282c8f2324ab96dac6a475292cf4b5f812ceb12d
1 //=============================================================================
2 /**
3 * @file Locator_Options.cpp
5 * @author Darrell Brunsch <brunsch@cs.wustl.edu>
6 */
7 //=============================================================================
9 #include "Locator_Options.h"
10 #include "ace/Arg_Shifter.h"
11 #include "orbsvcs/Log_Macros.h"
12 #include "ace/OS_NS_strings.h"
13 #include "ace/OS_NS_time.h"
15 #if defined (ACE_WIN32)
16 static const HKEY SERVICE_REG_ROOT = HKEY_LOCAL_MACHINE;
17 // This string must agree with the one used in Locator_NT_Service.h
18 static const ACE_TCHAR *SERVICE_REG_PATH =
19 ACE_TEXT ("SYSTEM\\CurrentControlSet\\Services\\TAOImR\\Parameters");
20 #endif /* ACE_WIN32 */
22 static const int DEFAULT_PING_INTERVAL = 10; // seconds
23 static const int DEFAULT_PING_TIMEOUT = 1; // seconds
24 static const int DEFAULT_START_TIMEOUT = 60; // seconds
25 static const long DEFAULT_FT_UPDATE_DELAY = 0; //250000; // useconds
26 Options::Options ()
27 : repo_mode_ (REPO_NONE)
28 , erase_repo_ (false)
29 , debug_ (0)
30 , multicast_ (false)
31 , service_ (false)
32 , ping_external_ (false)
33 , ping_interval_ (DEFAULT_PING_INTERVAL)
34 , ping_timeout_ (DEFAULT_PING_TIMEOUT)
35 , startup_timeout_ (DEFAULT_START_TIMEOUT)
36 , readonly_ (false)
37 , service_command_ (SC_NONE)
38 , unregister_if_address_reused_ (false)
39 , lockout_ (false)
40 , imr_type_ (STANDALONE_IMR)
41 , throw_shutdown_exceptions_ (false)
42 , pinger_ (0)
43 , ft_endpoint_ ()
44 , ft_update_delay_ (0, DEFAULT_FT_UPDATE_DELAY)
48 int
49 Options::parse_args (int &argc, ACE_TCHAR *argv[])
51 ACE_Arg_Shifter shifter (argc, argv);
53 // Don't let persistence options co-mingle.
54 bool binary_persistence_used = false;
55 bool xml_persistence_used = false;
56 bool directory_persistence_used = false;
58 while (shifter.is_anything_left ())
60 if (ACE_OS::strcasecmp (shifter.get_current (),
61 ACE_TEXT ("-c")) == 0)
63 shifter.consume_arg ();
65 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
67 ORBSVCS_ERROR ((LM_ERROR, "Error: -c option needs a command\n"));
68 this->print_usage ();
69 return -1;
72 if (ACE_OS::strcasecmp (shifter.get_current (),
73 ACE_TEXT ("install")) == 0)
75 this->service_command_ = SC_INSTALL;
77 else if (ACE_OS::strcasecmp (shifter.get_current (),
78 ACE_TEXT ("remove")) == 0)
80 this->service_command_ = SC_REMOVE;
82 else
84 ORBSVCS_ERROR ((
85 LM_ERROR,
86 ACE_TEXT ("Error: Unknown service command : %s\n"),
87 shifter.get_current ()));
88 this->print_usage ();
89 return -1;
92 else if (ACE_OS::strcasecmp (shifter.get_current (),
93 ACE_TEXT ("-d")) == 0)
95 shifter.consume_arg ();
97 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
99 ORBSVCS_ERROR ((LM_ERROR, "Error: -d option needs a debuglevel\n"));
100 this->print_usage ();
101 return -1;
104 this->debug_ = ACE_OS::atoi (shifter.get_current ());
106 else if (ACE_OS::strcasecmp (shifter.get_current (),
107 ACE_TEXT ("-m")) == 0)
109 this->multicast_ = true;
111 else if (ACE_OS::strcasecmp (shifter.get_current (),
112 ACE_TEXT ("-o")) == 0)
114 shifter.consume_arg ();
116 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
118 ORBSVCS_ERROR ((LM_ERROR, "Error: -o option needs a filename\n"));
119 this->print_usage ();
120 return -1;
122 this->ior_output_file_ = shifter.get_current();
124 else if (ACE_OS::strcasecmp (shifter.get_current (),
125 ACE_TEXT ("-s")) == 0)
127 // Run as a service
128 this->service_ = true;
130 else if ((ACE_OS::strcasecmp (shifter.get_current (),
131 ACE_TEXT ("-?")) == 0)
132 || (ACE_OS::strcasecmp (shifter.get_current (),
133 ACE_TEXT ("-h")) == 0))
135 this->print_usage ();
136 return 1;
138 else if (ACE_OS::strcasecmp (shifter.get_current (),
139 ACE_TEXT ("-l")) == 0)
141 this->readonly_ = true;
143 else if (ACE_OS::strcasecmp (shifter.get_current (),
144 ACE_TEXT ("-p")) == 0)
146 shifter.consume_arg ();
148 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
150 ORBSVCS_ERROR ((LM_ERROR, "Error: -p option needs a filename\n"));
151 this->print_usage ();
152 return -1;
155 this->persist_file_name_ = shifter.get_current ();
156 this->repo_mode_ = REPO_HEAP_FILE;
157 binary_persistence_used = true;
159 else if ((ACE_OS::strcasecmp (shifter.get_current (),
160 ACE_TEXT ("-UnregisterIfAddressReused")) == 0) ||
161 (ACE_OS::strcasecmp (shifter.get_current (),
162 ACE_TEXT ("--UnregisterIfAddressReused")) == 0) ||
163 (ACE_OS::strcasecmp (shifter.get_current (),
164 ACE_TEXT ("-u")) == 0))
166 this->unregister_if_address_reused_ = true;
168 else if (ACE_OS::strcasecmp (shifter.get_current (),
169 ACE_TEXT ("--lockout")) == 0)
171 this->lockout_ = true;
173 else if (ACE_OS::strcasecmp (shifter.get_current (),
174 ACE_TEXT ("-r")) == 0)
176 this->repo_mode_ = REPO_REGISTRY;
178 else if (ACE_OS::strcasecmp (shifter.get_current (),
179 ACE_TEXT ("-x")) == 0)
181 shifter.consume_arg ();
183 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
185 ORBSVCS_ERROR ((LM_ERROR, "Error: -x option needs a filename\n"));
186 this->print_usage ();
187 return -1;
190 this->persist_file_name_ = shifter.get_current ();
191 this->repo_mode_ = REPO_XML_FILE;
192 xml_persistence_used = true;
194 else if (ACE_OS::strcasecmp (shifter.get_current (),
195 ACE_TEXT ("--primary")) == 0)
197 this->imr_type_ = PRIMARY_IMR;
199 else if (ACE_OS::strcasecmp (shifter.get_current (),
200 ACE_TEXT ("--backup")) == 0)
202 this->imr_type_ = BACKUP_IMR;
204 else if (ACE_OS::strcasecmp (shifter.get_current (),
205 ACE_TEXT ("--directory")) == 0)
207 shifter.consume_arg ();
209 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
211 ORBSVCS_ERROR ((LM_ERROR,
212 ACE_TEXT ("Error: --directory option needs a filename\n")));
213 this->print_usage ();
214 return -1;
217 this->persist_file_name_ = shifter.get_current ();
218 this->repo_mode_ = REPO_SHARED_FILES;
220 if (this->persist_file_name_.length() &&
221 this->persist_file_name_[this->persist_file_name_.length() - 1] != '/')
223 this->persist_file_name_ += '/';
225 directory_persistence_used = true;
227 else if (ACE_OS::strcasecmp (shifter.get_current (),
228 ACE_TEXT ("-e")) == 0)
230 this->erase_repo_ = true;
232 else if (ACE_OS::strcasecmp (shifter.get_current (),
233 ACE_TEXT ("-t")) == 0)
235 shifter.consume_arg ();
237 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
239 ORBSVCS_ERROR ((LM_ERROR,
240 ACE_TEXT ("Error: -t option needs a value\n")));
241 this->print_usage ();
242 return -1;
244 this->startup_timeout_ =
245 ACE_Time_Value (ACE_OS::atoi (shifter.get_current ()));
247 else if (ACE_OS::strcasecmp (shifter.get_current (),
248 ACE_TEXT ("-i")) == 0)
250 this->ping_external_ = true;
252 else if (ACE_OS::strcasecmp (shifter.get_current (),
253 ACE_TEXT ("-v")) == 0)
255 shifter.consume_arg ();
257 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
259 ORBSVCS_ERROR ((LM_ERROR,
260 ACE_TEXT ("Error: -v option needs a value\n")));
261 this->print_usage ();
262 return -1;
264 this->ping_interval_ =
265 ACE_Time_Value (0, 1000 * ACE_OS::atoi (shifter.get_current ()));
267 else if (ACE_OS::strcasecmp (shifter.get_current (),
268 ACE_TEXT ("-n")) == 0)
270 shifter.consume_arg ();
272 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
274 ORBSVCS_ERROR ((LM_ERROR,
275 ACE_TEXT ("Error: -n option needs a value\n")));
276 this->print_usage ();
277 return -1;
279 this->ping_timeout_ =
280 ACE_Time_Value (0, 1000 * ACE_OS::atoi (shifter.get_current ()));
282 else if (ACE_OS::strcasecmp (shifter.get_current (),
283 ACE_TEXT ("--ftendpoint")) == 0)
285 shifter.consume_arg ();
287 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
289 ORBSVCS_ERROR ((LM_ERROR,
290 ACE_TEXT ("Error: --FtEndpoint option needs a value\n")));
291 this->print_usage ();
292 return -1;
294 this->ft_endpoint_ = ACE_TEXT_ALWAYS_CHAR (shifter.get_current ());
296 else if (ACE_OS::strcasecmp (shifter.get_current (),
297 ACE_TEXT ("--ftupdatedelay")) == 0)
299 shifter.consume_arg ();
301 if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
303 ORBSVCS_ERROR ((LM_ERROR,
304 ACE_TEXT ("Error: -FtUpdateDelay option needs a value\n")));
305 this->print_usage ();
306 return -1;
308 this->ft_update_delay_ =
309 ACE_Time_Value (0, 1000 * ACE_OS::atoi (shifter.get_current ()));
311 else
313 shifter.ignore_arg ();
314 continue;
317 shifter.consume_arg ();
320 if ((this->imr_type_ == BACKUP_IMR || this->imr_type_ == PRIMARY_IMR) &&
321 !directory_persistence_used)
323 ORBSVCS_ERROR ((LM_ERROR,
324 "Error: Redundancy is used but the "
325 "--directory option is not passed\n"));
326 this->print_usage ();
327 return -1;
330 if ((binary_persistence_used + directory_persistence_used +
331 xml_persistence_used)
332 > 1)
334 ORBSVCS_ERROR ((LM_ERROR,
335 "Error: Only one persistence option can be used\n"));
336 this->print_usage ();
337 return -1;
340 return 0;
344 Options::init (int argc, ACE_TCHAR *argv[])
346 // Make an initial pass through and grab the arguments that we recognize.
347 // This may also run the commands to install or remove the nt service.
348 int result = this->parse_args (argc, argv);
349 if (result != 0)
351 return result;
354 for (int i = 0; i < argc; ++i)
356 this->cmdline_ += ACE_CString (ACE_TEXT_ALWAYS_CHAR(argv[i])) + ACE_CString (" ");
358 return 0;
362 Options::init_from_registry ()
364 this->load_registry_options ();
365 return 0;
369 void
370 Options::print_usage () const
372 ORBSVCS_ERROR ((LM_ERROR,
373 ACE_TEXT ("Usage:\n")
374 ACE_TEXT ("\n")
375 ACE_TEXT ("ImplRepo_Service [-c cmd] [-d 0..5] [-e] [-m] [-o file]\n")
376 ACE_TEXT (" [-r|-p file|-x file|--directory dir [--primary|--backup] ]\n")
377 ACE_TEXT (" [-s] [-t secs] [-v msecs]\n")
378 ACE_TEXT (" -c command Runs nt service commands ('install' or 'remove')\n")
379 ACE_TEXT (" -d level Sets the debug level (default 0)\n")
380 ACE_TEXT (" -e Erase the persisted repository at startup\n")
381 ACE_TEXT (" -l Lock the database as read only\n")
382 ACE_TEXT (" -m Turn on multicast\n")
383 ACE_TEXT (" -o file Outputs the ImR's IOR to a file\n")
384 ACE_TEXT (" -p file Use file for storing/loading settings\n")
385 ACE_TEXT (" -x file Use XML file for storing/loading settings\n")
386 ACE_TEXT (" --directory dir Use individual XML files for storing/loading\n")
387 ACE_TEXT (" settings in the provided directory\n")
388 ACE_TEXT (" --primary Replicate the ImplRepo as the primary ImR\n")
389 ACE_TEXT (" --backup Replicate the ImplRepo as the backup ImR\n")
390 ACE_TEXT (" -r Use the registry for storing/loading settings\n")
391 ACE_TEXT (" -s Run as a service\n")
392 ACE_TEXT (" -t secs Server startup timeout.(Default = %ds)\n")
393 ACE_TEXT (" -v msecs Server verification interval.(Default = %dms)\n")
394 ACE_TEXT (" -n msecs Ping request timeout.(Default = %dms)\n")
395 ACE_TEXT (" -i Ping servers started without activators too.\n")
396 ACE_TEXT (" --lockout Prevent excessive restart attempts until manual reset.\n")
397 ACE_TEXT (" --UnregisterIfAddressReused,\n")
398 ACE_TEXT (" -u Unregister server if its endpoint is used by another\n"),
399 DEFAULT_START_TIMEOUT,
400 DEFAULT_PING_INTERVAL * ACE_U_ONE_SECOND_IN_MSECS,
401 DEFAULT_PING_TIMEOUT * ACE_U_ONE_SECOND_IN_MSECS));
405 Options::save_registry_options ()
407 #if defined (ACE_WIN32)
408 HKEY key = 0;
409 // Create or open the parameters key
410 LONG err = ACE_TEXT_RegCreateKeyEx (SERVICE_REG_ROOT,
411 SERVICE_REG_PATH,
413 const_cast<ACE_TCHAR*> (ACE_TEXT ("")), // class
414 REG_OPTION_NON_VOLATILE,
415 KEY_ALL_ACCESS,
417 &key,
420 if (err != ERROR_SUCCESS)
422 return -1;
424 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("ORBInitOptions"), 0, REG_SZ,
425 (LPBYTE) this->cmdline_.c_str (), (DWORD) this->cmdline_.length () + 1);
426 ACE_ASSERT (err == ERROR_SUCCESS);
428 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("IORFile"), 0, REG_SZ,
429 (LPBYTE) ior_output_file_.c_str (), (DWORD) ior_output_file_.length () + 1);
430 ACE_ASSERT (err == ERROR_SUCCESS);
432 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("DebugLevel"), 0, REG_DWORD,
433 (LPBYTE) &debug_ , sizeof (debug_));
434 ACE_ASSERT(err == ERROR_SUCCESS);
436 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("PersistFile"), 0, REG_SZ,
437 (LPBYTE) this->persist_file_name_.c_str (), (DWORD) this->persist_file_name_.length () + 1);
438 ACE_ASSERT (err == ERROR_SUCCESS);
440 DWORD tmp = this->ping_external_ ? 1 : 0;
441 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("PingExternals"), 0, REG_DWORD,
442 (LPBYTE) &tmp, sizeof (DWORD));
443 ACE_ASSERT (err == ERROR_SUCCESS);
445 tmp = this->ping_interval_.msec ();
446 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("PingInterval"), 0, REG_DWORD,
447 (LPBYTE) &tmp, sizeof (DWORD));
448 ACE_ASSERT (err == ERROR_SUCCESS);
450 tmp = this->ping_timeout_.msec ();
451 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("PingTimeout"), 0, REG_DWORD,
452 (LPBYTE) &tmp, sizeof (DWORD));
453 ACE_ASSERT (err == ERROR_SUCCESS);
455 tmp = this->readonly_ ? 1 : 0;
456 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("Lock"), 0, REG_DWORD,
457 (LPBYTE) &tmp, sizeof (DWORD));
458 ACE_ASSERT (err == ERROR_SUCCESS);
460 tmp = this->lockout_ ? 1 : 0;
461 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("LockOut"), 0, REG_DWORD,
462 (LPBYTE) &tmp, sizeof (DWORD));
463 ACE_ASSERT (err == ERROR_SUCCESS);
465 tmp = this->repo_mode_;
466 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("PersistType"), 0, REG_DWORD,
467 (LPBYTE) &tmp, sizeof (DWORD));
468 ACE_ASSERT (err == ERROR_SUCCESS);
470 tmp = static_cast<DWORD> (this->startup_timeout_.sec());
471 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("Timeout"), 0, REG_DWORD,
472 (LPBYTE) &tmp, sizeof (DWORD));
473 ACE_ASSERT (err == ERROR_SUCCESS);
475 tmp = this->multicast_ ? 1 : 0;
476 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("Multicast"), 0, REG_DWORD,
477 (LPBYTE) &tmp, sizeof (DWORD));
478 ACE_ASSERT (err == ERROR_SUCCESS);
480 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("ImrType"), 0, REG_DWORD,
481 (LPBYTE) &this->imr_type_ , sizeof (this->imr_type_));
482 ACE_ASSERT (err == ERROR_SUCCESS);
484 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("FtEndpoint"), 0, REG_SZ,
485 (LPBYTE) this->ft_endpoint_.c_str (), (DWORD) this->ft_endpoint_.length () + 1);
486 ACE_ASSERT (err == ERROR_SUCCESS);
488 tmp = this->ft_update_delay_.msec ();
489 err = ACE_TEXT_RegSetValueEx (key, ACE_TEXT ("FtUpdateDelay"), 0, REG_DWORD,
490 (LPBYTE) &tmp, sizeof (DWORD));
491 ACE_ASSERT (err == ERROR_SUCCESS);
493 err = ::RegCloseKey (key);
494 ACE_ASSERT (err == ERROR_SUCCESS);
495 #endif
496 return 0;
500 Options::load_registry_options ()
502 #if defined (ACE_WIN32)
503 HKEY key = 0;
504 // Create or open the parameters key
505 LONG err = ACE_TEXT_RegOpenKeyEx (SERVICE_REG_ROOT,
506 SERVICE_REG_PATH,
508 KEY_READ,
509 &key
511 if (err != ERROR_SUCCESS)
513 // If there aren't any saved parameters, then that's ok.
514 return 0;
516 ACE_TCHAR tmpstr[4096];
517 DWORD sz = sizeof (tmpstr);
518 DWORD type = 0;
519 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("ORBInitOptions"), 0, &type,
520 (LPBYTE) tmpstr, &sz);
521 if (err == ERROR_SUCCESS)
523 ACE_ASSERT (type == REG_SZ);
524 tmpstr[sz - 1] = '\0';
525 this->cmdline_ = ACE_TEXT_ALWAYS_CHAR(tmpstr);
528 sz = sizeof(tmpstr);
529 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("IORFile"), 0, &type,
530 (LPBYTE) tmpstr, &sz);
531 if (err == ERROR_SUCCESS)
533 ACE_ASSERT (type == REG_SZ);
534 tmpstr[sz - 1] = '\0';
535 this->ior_output_file_ = tmpstr;
538 sz = sizeof(debug_);
539 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("DebugLevel"), 0, &type,
540 (LPBYTE) &this->debug_ , &sz);
541 if (err == ERROR_SUCCESS)
543 ACE_ASSERT (type == REG_DWORD);
546 DWORD tmp = 0;
547 sz = sizeof(tmp);
548 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("PingExternal"), 0, &type,
549 (LPBYTE) &tmp, &sz);
550 if (err == ERROR_SUCCESS)
552 ACE_ASSERT (type == REG_DWORD);
553 ping_external_ = tmp != 0;
556 tmp = 0;
557 sz = sizeof(tmp);
558 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("PingInterval"), 0, &type,
559 (LPBYTE) &tmp, &sz);
560 if (err == ERROR_SUCCESS)
562 ACE_ASSERT (type == REG_DWORD);
563 ping_interval_.msec (static_cast<long> (tmp));
566 tmp = 0;
567 sz = sizeof(tmp);
568 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("PingTimeout"), 0, &type,
569 (LPBYTE) &tmp, &sz);
570 if (err == ERROR_SUCCESS)
572 ACE_ASSERT (type == REG_DWORD);
573 ping_timeout_.msec (static_cast<long> (tmp));
576 tmp = 0;
577 sz = sizeof(tmp);
578 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("Lock"), 0, &type,
579 (LPBYTE) &tmp, &sz);
580 if (err == ERROR_SUCCESS)
582 ACE_ASSERT (type == REG_DWORD);
583 readonly_ = tmp != 0;
586 tmp = 0;
587 sz = sizeof(tmp);
588 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("LockOut"), 0, &type,
589 (LPBYTE) &tmp, &sz);
590 if (err == ERROR_SUCCESS)
592 ACE_ASSERT (type == REG_DWORD);
593 lockout_ = tmp != 0;
596 sz = sizeof(this->repo_mode_);
597 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("PersistType"), 0, &type,
598 (LPBYTE) &this->repo_mode_, &sz);
599 if (err == ERROR_SUCCESS)
601 ACE_ASSERT (type == REG_DWORD);
604 tmp = 0;
605 sz = sizeof(tmp);
606 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("Timeout"), 0, &type,
607 (LPBYTE) &tmp, &sz);
608 if (err == ERROR_SUCCESS)
610 ACE_ASSERT (type == REG_DWORD);
611 this->startup_timeout_.sec (tmp);
614 tmp = 0;
615 sz = sizeof(tmp);
616 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("Multicast"), 0, &type,
617 (LPBYTE) &tmp, &sz);
618 if (err == ERROR_SUCCESS)
620 ACE_ASSERT (type == REG_DWORD);
621 this->multicast_ = tmp != 0;
624 sz = sizeof(tmpstr);
625 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("PersistFile"), 0, &type,
626 (LPBYTE) tmpstr, &sz);
627 if (err == ERROR_SUCCESS)
629 ACE_ASSERT (type == REG_SZ);
630 tmpstr[sz - 1] = '\0';
631 this->persist_file_name_ = tmpstr;
634 sz = sizeof(imr_type_);
635 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("ImrType"), 0, &type,
636 (LPBYTE) &this->imr_type_ , &sz);
637 if (err == ERROR_SUCCESS)
639 ACE_ASSERT (type == REG_DWORD);
642 sz = sizeof(tmpstr);
643 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("FtEndpoint"), 0, &type,
644 (LPBYTE) tmpstr, &sz);
645 if (err == ERROR_SUCCESS)
647 ACE_ASSERT (type == REG_SZ);
648 tmpstr[sz - 1] = '\0';
649 this->ft_endpoint_ = ACE_TEXT_ALWAYS_CHAR (tmpstr);
652 tmp = 0;
653 sz = sizeof(tmp);
654 err = ACE_TEXT_RegQueryValueEx (key, ACE_TEXT ("FtUpdateDelay"), 0, &type,
655 (LPBYTE) &tmp, &sz);
656 if (err == ERROR_SUCCESS)
658 ACE_ASSERT (type == REG_DWORD);
659 ft_update_delay_.msec (static_cast<long> (tmp));
662 err = ::RegCloseKey (key);
663 ACE_ASSERT (err == ERROR_SUCCESS);
664 #endif
665 return 0;
668 bool
669 Options::service () const
671 return this->service_;
674 unsigned int
675 Options::debug () const
677 return this->debug_;
680 const ACE_TString&
681 Options::ior_filename () const
683 return this->ior_output_file_;
686 bool
687 Options::multicast () const
689 return this->multicast_;
692 Options::SERVICE_COMMAND
693 Options::service_command() const
695 return this->service_command_;
698 const char*
699 Options::cmdline() const {
700 return this->cmdline_.c_str ();
703 const ACE_TString&
704 Options::persist_file_name() const {
705 return this->persist_file_name_;
708 ACE_Time_Value
709 Options::startup_timeout () const
711 return this->startup_timeout_;
714 bool
715 Options::ping_external () const
717 return this->ping_external_;
720 ACE_Time_Value
721 Options::ping_interval () const
723 return this->ping_interval_;
726 ACE_Time_Value
727 Options::ping_timeout () const
729 return this->ping_timeout_;
732 LiveCheck *
733 Options::pinger () const
735 return this->pinger_;
738 void
739 Options::pinger (LiveCheck *p)
741 this->pinger_ = p;
744 Options::RepoMode
745 Options::repository_mode () const
747 return this->repo_mode_;
750 bool
751 Options::repository_erase () const
753 return this->erase_repo_;
756 bool
757 Options::readonly () const
759 return this->readonly_;
762 bool
763 Options::unregister_if_address_reused () const
765 return this->unregister_if_address_reused_;
768 bool
769 Options::lockout () const
771 return this->lockout_;
774 bool
775 Options::throw_shutdown_exceptions () const
777 return this->throw_shutdown_exceptions_;
780 Options::ImrType
781 Options::imr_type () const
783 return this->imr_type_;
786 const ACE_CString &
787 Options::ft_endpoint () const
789 return this->ft_endpoint_;
792 ACE_Time_Value
793 Options::ft_update_delay () const
795 return this->ft_update_delay_;