FACT++  1.0
int StateMachineDimControl::EvalOptions ( Configuration conf)

Definition at line 556 of file StateMachineDimControl.cc.

References fArgumentsJS, fDebug, fScriptUser, fUser, Configuration::Get(), Configuration::GetName(), Configuration::GetOptions(), Configuration::Has(), and Dim::SendCommand().

Referenced by SetInterruptHandler().

557 {
558  fDebug = conf.Get<bool>("debug");
559  fUser = conf.Get<string>("user");
560  fScriptUser = fUser;
561 
562  // FIXME: Check fUser for quotes!
563 
564  const map<string, string> &js = conf.GetOptions<string>("JavaScript.");
565  for (auto it=js.begin(); it!=js.end(); it++)
566  {
567  string key = it->first;
568  string val = it->second;
569 
570  // Escape key
571  boost::replace_all(key, "\\", "\\\\");
572  boost::replace_all(key, "'", "\\'");
573  boost::replace_all(key, "\"", "\\\"");
574 
575  // Escape value
576  boost::replace_all(val, "\\", "\\\\");
577  boost::replace_all(val, "'", "\\'");
578  boost::replace_all(val, "\"", "\\\"");
579 
580  fArgumentsJS += " '"+key +"'='"+val+"'";
581  }
582 
583  // fVerbosity = 40;
584 
585  // if (conf.Has("verbosity"))
586  // fVerbosity = conf.Get<uint32_t>("verbosity");
587 
588  // if (conf.Get<bool>("quiet"))
589  // fVerbosity = 90;
590 
591 #if BOOST_VERSION < 104600
592  const string fname = boost::filesystem::path(conf.GetName()).filename();
593 #else
594  const string fname = boost::filesystem::path(conf.GetName()).filename().string();
595 #endif
596 
597  if (fname=="dimserver")
598  return -1;
599 
600  if (conf.Get<bool>("stop"))
601  return !Dim::SendCommand("DIM_CONTROL/STOP", fUser);
602 
603  if (conf.Has("interrupt"))
604  return !Dim::SendCommand("DIM_CONTROL/INTERRUPT", conf.Get<string>("interrupt")+"\n"+fUser);
605 
606  if (conf.Has("start"))
607  return !Dim::SendCommand("DIM_CONTROL/START", conf.Get<string>("start")+" user='"+fUser+"'"+fArgumentsJS);
608 
609  if (conf.Has("batch"))
610  return !Dim::SendCommand("DIM_CONTROL/EXECUTE", conf.Get<string>("batch")+" user='"+fUser+"'");
611 
612  if (conf.Has("msg"))
613  return !Dim::SendCommand("CHAT/MSG", fUser+": "+conf.Get<string>("msg"));
614 
615  if (conf.Has("restart"))
616  return !Dim::SendCommand(conf.Get<string>("restart")+"/EXIT", uint32_t(126));
617 
618  return -1;
619 }
T Get(const std::string &var)
const std::map< std::string, T > GetOptions(const std::string &opt)
bool SendCommand(const std::string &command)
Definition: Dim.h:26
bool Has(const std::string &var)
std::string fArgumentsJS
Default arguments provided to very java script.
const std::string & GetName() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function: