FACT++  1.0
int main ( int  argc,
const char *  argv[] 
)

Definition at line 606 of file dclient5.cc.

References Configuration::Get(), Configuration::Has(), Configuration::HasHelp(), Configuration::HasPrint(), Configuration::HasVersion(), Configuration::Parse(), PrintHelp(), PrintUsage(), PrintVersion(), Configuration::SetPrintUsage(), and SetupConfiguration().

607 {
608  Configuration conf(argv[0]);
609  conf.SetPrintUsage(PrintUsage);
610  SetupConfiguration(conf);
611 
612  po::variables_map vm;
613  try
614  {
615  vm = conf.Parse(argc, argv);
616  }
617  catch (std::exception &e)
618  {
619 #if BOOST_VERSION > 104000
620  po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e);
621  if (MO)
622  cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl;
623  else
624 #endif
625  cout << "Error: " << e.what() << endl;
626  cout << endl;
627 
628  return -1;
629  }
630 
631  if (conf.HasPrint())
632  return -1;
633 
634  if (conf.HasVersion())
635  {
636  PrintVersion(argv[0]);
637  return -1;
638  }
639 
640  if (conf.HasHelp())
641  {
642  PrintHelp();
643  return -1;
644  }
645 
646  // To allow overwriting of DIM_DNS_NODE set 0 to 1
647  setenv("DIM_DNS_NODE", conf.Get<string>("dns").c_str(), 1);
648 
649  try
650  {
651  // No console access at all
652  if (!conf.Has("console"))
653  {
654  if (conf.Get<bool>("no-dim"))
655  return RunDim<StateMachine>(conf);
656  else
657  return RunDim<StateMachineDim>(conf);
658  }
659  // Cosole access w/ and w/o Dim
660  if (conf.Get<bool>("no-dim"))
661  {
662  if (conf.Get<int>("console")==0)
663  return RunShell<LocalShell, StateMachine>(conf);
664  else
665  return RunShell<LocalConsole, StateMachine>(conf);
666  }
667  else
668  {
669  if (conf.Get<int>("console")==0)
670  return RunShell<LocalShell, StateMachineDim>(conf);
671  else
672  return RunShell<LocalConsole, StateMachineDim>(conf);
673  }
674  }
675  catch (std::exception& e)
676  {
677  std::cerr << "Exception: " << e.what() << "\n";
678  }
679 
680  return 0;
681 }
void PrintVersion(const char *name)
Definition: dclient5.cc:573
void PrintHelp()
Definition: dclient5.cc:531
Commandline parsing, resource file parsing and database access.
Definition: Configuration.h:9
void SetupConfiguration(Configuration &conf)
Definition: dclient5.cc:589
void PrintUsage()
Definition: dclient5.cc:513

+ Here is the call graph for this function: