当前位置: 首页>>代码示例>>C++>>正文


C++ AmConfigReader类代码示例

本文整理汇总了C++中AmConfigReader的典型用法代码示例。如果您正苦于以下问题:C++ AmConfigReader类的具体用法?C++ AmConfigReader怎么用?C++ AmConfigReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AmConfigReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onLoad

int AnnouncementFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;

  // get application specific global parameters
  configureModule(cfg);

  AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH);
  if( !AnnouncePath.empty() 
      && AnnouncePath[AnnouncePath.length()-1] != '/' )
    AnnouncePath += "/";

  AnnounceFile = cfg.getParameter("default_announce",ANNOUNCE_FILE);

  string announce_file = AnnouncePath + AnnounceFile;
  if(!file_exists(announce_file)){
    ERROR("default file for announcement module does not exist ('%s').\n",
	  announce_file.c_str());
    return -1;
  }

  return 0;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:25,代码来源:Announcement.cpp

示例2: onLoad

int AnnRecorderFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;

  // get application specific global parameters
  configureModule(cfg);

  AnnouncePath = cfg.getParameter("announce_path",ANNOUNCE_PATH);
  if( !AnnouncePath.empty() 
      && AnnouncePath[AnnouncePath.length()-1] != '/' )
    AnnouncePath += "/";
  DefaultAnnounce = cfg.getParameter("default_announce");

  SimpleMode = (cfg.getParameter("simple_mode") == "yes");

  AM_PROMPT_START;
  AM_PROMPT_ADD(WELCOME, ANNREC_ANNOUNCE_PATH WELCOME".wav");
  AM_PROMPT_ADD(YOUR_PROMPT, ANNREC_ANNOUNCE_PATH YOUR_PROMPT".wav");
  AM_PROMPT_ADD(TO_RECORD, ANNREC_ANNOUNCE_PATH TO_RECORD".wav");
  AM_PROMPT_ADD(CONFIRM, ANNREC_ANNOUNCE_PATH CONFIRM".wav");
  AM_PROMPT_ADD(GREETING_SET, ANNREC_ANNOUNCE_PATH GREETING_SET".wav");
  AM_PROMPT_ADD(BYE, ANNREC_ANNOUNCE_PATH BYE".wav");
  AM_PROMPT_ADD(BEEP, ANNREC_ANNOUNCE_PATH BEEP".wav");
  AM_PROMPT_END(prompts, cfg, MOD_NAME);

  message_storage_fact = AmPlugIn::instance()->getFactory4Di("msg_storage");
  if(!message_storage_fact) {
    ERROR("sorry, could not get msg_storage, please load a suitable plug-in\n");
    return -1;
  }

  return 0;
}
开发者ID:Chocolatbuddha,项目名称:sems,代码行数:35,代码来源:AnnRecorder.cpp

示例3: loadPromptSets

bool DSMFactory::loadPromptSets(AmConfigReader& cfg) {
  string prompt_sets_path = cfg.getParameter("prompts_sets_path");

  vector<string> prompt_sets_names = 
    explode(cfg.getParameter("load_prompts_sets"), ",");
  for (vector<string>::iterator it=
	 prompt_sets_names.begin(); it != prompt_sets_names.end(); it++) {
    string fname = prompt_sets_path.empty() ? "": prompt_sets_path + "/";
    fname += *it;
    DBG("loading prompts for '%s' (file '%s')\n", it->c_str(), fname.c_str());
    std::ifstream ifs(fname.c_str());
    string s;
    if (!ifs.good()) {
      WARN("prompts set file '%s' could not be read\n", fname.c_str());
    }
    AmPromptCollection* pc = new AmPromptCollection();
    while (ifs.good() && !ifs.eof()) {
      getline(ifs, s);
      if (s.length() && s.find_first_not_of(" \t")!= string::npos &&
	  s[s.find_first_not_of(" \t")] != '#') {
        vector<string> p=explode(s, "=");
	if (p.size()==2) {
	  pc->setPrompt(p[0], p[1], MOD_NAME);
	  DBG("set '%s' added prompt '%s' as '%s'\n", 
	      it->c_str(), p[0].c_str(), p[1].c_str());
	}
      }
    }
    prompt_sets[*it] = pc;
  }
  return true;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:32,代码来源:DSM.cpp

示例4: ERROR

int MWI::onLoad()
{
  AmDynInvokeFactory* ms_fact = 
    AmPlugIn::instance()->getFactory4Di("msg_storage");

  if(!ms_fact || !(MessageStorage = ms_fact->getInstance())) {
    ERROR("could not load msg_storage. Load a msg_storage implementation module.\n");
    return -1;
  };

  // register the publish method as event sink for msg_storage events
  AmArg es_args,ret;
  es_args.push(this);
  es_args.push("publish");
  MessageStorage->invoke("events_subscribe",es_args,ret);
  
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + "mwi.conf")) {
    ERROR("can not load configuration file\n");
    return -1;
  };
  
  presence_server = cfg.getParameter("presence_server");
  if (presence_server.length())
    DBG("set presence server '%s'\n", presence_server.c_str());
  else {
    ERROR("parameter 'presence_server' did not found in the configuration file\n");
    return -1;
  }                
  
  DBG("MWI module loaded.\n");
  return 0;
};
开发者ID:bjtpartners,项目名称:sems-mysql-routing,代码行数:33,代码来源:mwi.cpp

示例5: init

int AmZRTP::init() {
  AmConfigReader cfg;
  string cfgname=add2path(AmConfig::ModConfigPath, 1,  "zrtp.conf");
  if(cfg.loadFile(cfgname)) {
    ERROR("No %s config file present.\n", 
	  cfgname.c_str());
    return -1;
  }
  cache_path = cfg.getParameter("cache_path");
  string zid = cfg.getParameter("zid");
  if (zid.length() != sizeof(zrtp_zid_t)) {
    ERROR("ZID of this instance MUST be set for ZRTP.\n");
    ERROR("ZID needs to be %u characters long.\n", 
	  sizeof(zrtp_zid_t));
    return -1;
  }
  for (int i=0;i<12;i++)
    zrtp_instance_zid[i]=zid[i];

  DBG("initializing ZRTP library with ZID '%s', cache path '%s'.\n",
      zid.c_str(), cache_path.c_str());
  if ( zrtp_status_ok != zrtp_init(&zrtp_global, "zrtp_sems") ) {
    ERROR("Some error during zrtp initialization\n");
    return -1;
  }
  zrtp_add_entropy(&zrtp_global, NULL, 0);
  DBG("ZRTP initialized ok.\n");

  return 0;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:30,代码来源:AmZRTP.cpp

示例6: onLoad

int MsgStorage::onLoad() {

  msg_dir = MSG_DIR;
  
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
    DBG("no configuration could be loaded, assuming defaults.\n");
  } else {
      msg_dir = cfg.getParameter("storage_dir",MSG_DIR);
      DBG("storage_dir set to '%s'.\n", msg_dir.c_str());
  }

  string path = msg_dir;
  int status = mkdir(path.c_str(), 
		     S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  if (status && (errno != EEXIST)) {
    ERROR("creating storage path '%s': %s\n", 
	  path.c_str(),strerror(errno));
    return -1;
  }

  path = msg_dir + "/_test_dir_";
  status = mkdir(path.c_str(), 
		     S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  if (status && (errno != EEXIST)) {
    ERROR("Write permission check failed. Could not create '%s': %s\n", 
	  path.c_str(),strerror(errno));
    return -1;
  }
  rmdir(path.c_str());

  DBG("MsgStorage loaded.\n");
  return 0;
}
开发者ID:Chocolatbuddha,项目名称:sems,代码行数:34,代码来源:MsgStorage.cpp

示例7: loadDiags

bool DSMFactory::loadDiags(AmConfigReader& cfg, DSMStateDiagramCollection* m_diags) {
  string DiagPath = cfg.getParameter("diag_path");
  if (DiagPath.length() && DiagPath[DiagPath.length()-1] != '/')
    DiagPath += '/';

  string ModPath = cfg.getParameter("mod_path");

  string err;
  int res = preloadModules(cfg, err, ModPath);
  if (res<0) {
    ERROR("%s\n", err.c_str());
    return false;
  }

  // todo: pass preloaded mods to chart reader

  string LoadDiags = cfg.getParameter("load_diags");
  vector<string> diags_names = explode(LoadDiags, ",");
  for (vector<string>::iterator it=
	 diags_names.begin(); it != diags_names.end(); it++) {
    if (!m_diags->loadFile(DiagPath+*it+".dsm", *it, ModPath, DebugDSM)) {
      ERROR("loading %s from %s\n", 
	    it->c_str(), (DiagPath+*it+".dsm").c_str());
      return false;
    }
  }

  return true;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:29,代码来源:DSM.cpp

示例8: readFilter

/** @return whether successful */
bool readFilter(AmConfigReader& cfg, const char* cfg_key_filter, const char* cfg_key_list,
		vector<FilterEntry>& filter_list, bool keep_transparent_entry) {
    string filter = cfg.getParameter(cfg_key_filter);
    if (filter.empty())
	return true;

    FilterEntry hf;
    hf.filter_type = String2FilterType(filter.c_str());
    if (Undefined == hf.filter_type) {
	ERROR("invalid %s mode '%s'\n", cfg_key_filter, filter.c_str());
	return false;
    }

    // no transparent filter
    if (!keep_transparent_entry && hf.filter_type==Transparent)
	return true;

    vector<string> elems = explode(cfg.getParameter(cfg_key_list), ",");
    for (vector<string>::iterator it=elems.begin(); it != elems.end(); it++) {
	string c = *it;
	std::transform(c.begin(), c.end(), c.begin(), ::tolower);
	hf.filter_list.insert(c);
    }

    filter_list.push_back(hf);
    return true;
}
开发者ID:Chocolatbuddha,项目名称:sems,代码行数:28,代码来源:HeaderFilter.cpp

示例9: onLoad

int BrpcCtrlInterfaceFactory::onLoad()
{
  AmConfigReader cfg;
  unsigned int ct_to, rx_to, tx_to;

  if (cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
    WARN("failed to read/parse config file `%s' - assuming defaults\n",
      (AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str());
    semsUri = string(LISTEN_ADDR_DEFAULT);
    serUri = string(SER_ADDR_DEFAULT);
  } else {
    semsUri = cfg.getParameter(LISTEN_ADDR_PARAM, LISTEN_ADDR_DEFAULT);
    serUri = cfg.getParameter(SER_ADDR_PARAM, SER_ADDR_DEFAULT);

    if (str2i(cfg.getParameter(CT_TIMEOUT_PARAM, int2str(CT_TIMEOUT)), 
        ct_to)) {
      ERROR("failed to read `%s' param from config file.\n", CT_TIMEOUT_PARAM);
      return -1;
    } else {
      ct_timeout = ct_to * 1000;
    }
    if (str2i(cfg.getParameter(RX_TIMEOUT_PARAM, int2str(RX_TIMEOUT)), 
        rx_to)) {
      ERROR("failed to read `%s' param from config file.\n", RX_TIMEOUT_PARAM);
      return -1;
    } else {
      rx_timeout = rx_to * 1000;
    }
    if (str2i(cfg.getParameter(TX_TIMEOUT_PARAM, int2str(TX_TIMEOUT)), 
        tx_to)) {
      ERROR("failed to read `%s' param from config file.\n", TX_TIMEOUT_PARAM);
      return -1;
    } else {
      tx_timeout = tx_to * 1000;
    }


    if (str2i(cfg.getParameter(RX_WORKERS_PARAM, int2str(RX_WORKERS)), 
        rx_workers)) {
      ERROR("failed to read `%s' param from config file.\n", RX_WORKERS_PARAM);
      return -1;
    }
    if (str2i(cfg.getParameter(TX_WORKERS_PARAM, int2str(TX_WORKERS)), 
        tx_workers)) {
      ERROR("failed to read `%s' param from config file.\n", TX_WORKERS_PARAM);
      return -1;
    }
  }
  INFO(LISTEN_ADDR_PARAM ": %s.\n", semsUri.c_str());
  INFO(SER_ADDR_PARAM ": %s.\n", serUri.c_str());
  INFO(CT_TIMEOUT_PARAM ": %uus.\n", (unsigned)ct_timeout);
  INFO(RX_TIMEOUT_PARAM ": %uus.\n", (unsigned)rx_timeout);
  INFO(TX_TIMEOUT_PARAM ": %uus.\n", (unsigned)tx_timeout);
  INFO(RX_WORKERS_PARAM ": %u.\n", rx_workers);
  INFO(TX_WORKERS_PARAM ": %u.\n", tx_workers);

  return 0;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:58,代码来源:BrpcCtrlInterface.cpp

示例10: onLoad

int DIDialFactory::onLoad(){
  
  AmConfigReader cfg;
  if(!cfg.loadFile(AmConfig::ModConfigPath + string(APP_NAME)+ ".conf")) {

    unsigned int i_pin = 0;
    while (i_pin<100) { // only for safety..
      string dialout_pin = cfg.getParameter("dialout_pin"+int2str(i_pin));
      if (!dialout_pin.length()) 
	break;
      size_t pos = dialout_pin.find_first_of(';');
      if (pos == string::npos)
	break;
      string pin = dialout_pin.substr(0, pos);
      
      size_t pos2 = dialout_pin.find_first_of(';', pos+1);
      if ((pos == string::npos)||(pos2 == string::npos))
	break;
      string userpart = dialout_pin.substr(pos+1, pos2-pos-1);
      pos = pos2;

      pos2 = dialout_pin.find_first_of(';', pos+1);
      if ((pos == string::npos)||(pos2 == string::npos))
	break;
      string user = dialout_pin.substr(pos+1, pos2-pos-1);
      pos = pos2;

      pos2 = dialout_pin.find_first_of(';', pos+1);
      if ((pos == string::npos)||(pos2 == string::npos))
	break;
      string domain = dialout_pin.substr(pos+1, pos2-pos-1);
      pos = pos2;

      pos2 = dialout_pin.find_first_of(';', pos+1);
      if ((pos == string::npos)||(pos2 == string::npos))
	break;
      string pwd = dialout_pin.substr(pos+1, pos2-pos-1);
      pos = pos2;

      dialout_pins[pin] = DIDialoutInfo(userpart, domain, user, pwd);
      DBG("DIDial: added PIN '%s' userpart '%s' domain '%s' user '%s' pwd '<not shown>'\n", 
	  pin.c_str(), userpart.c_str(), domain.c_str(), user.c_str());
      i_pin++;		
    } 
  } else {
    DBG("no configuration for di_dial found. No dialout pins will be set.\n");
  }
  
  DBG("DIDial loaded.\n");
  return 0;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:51,代码来源:DIDial.cpp

示例11: onLoad

int MyCCFactory::onLoad()
{
  AmConfigReader cfg;
  if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
    return -1;
  
  InitialAnnouncement = cfg.getParameter("initial_announcement", "/tmp/hello.wav");
  IncorrectPIN        = cfg.getParameter("incorrect_pin", "/tmp/incorrect_pin.wav");
  OutOfCredit         = cfg.getParameter("out_of_credit", "/tmp/out_of_credit.wav");
  Dialing             = cfg.getParameter("dialing", "/tmp/dialing.wav");
  DialFailed          = cfg.getParameter("dial_failed", "/tmp/dial_failed.wav");
  EnterNumber         = cfg.getParameter("enter_number", "/tmp/enter_number.wav"); 
  ConnectSuffix       = cfg.getParameter("connect_suffix", "@127.0.0.1"); 

  user_timer_fact = AmPlugIn::instance()->getFactory4Di("user_timer");
  if(!user_timer_fact){
    ERROR("could not load user_timer from session_timer plug-in\n");
    return -1;
  }
  cc_acc_fact = AmPlugIn::instance()->getFactory4Di("cc_acc");
  if(!cc_acc_fact){
    ERROR("could not load cc_acc accounting, please provide a module\n");
    return -1;
  }

  return 0;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:27,代码来源:MyCC.cpp

示例12: onLoad

int MyConfigurableAppFactory::onLoad()
{
    AmConfigReader cfg;
    if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
	return -1;

    AnnouncementFile = cfg.getParameter("announcement_file","/tmp/default.wav");

    if(!file_exists(AnnouncementFile)){
	ERROR("announcement file for configurableApp module does not exist ('%s').\n",
	      AnnouncementFile.c_str());
	return -1;
    }

    return 0;
}
开发者ID:Chocolatbuddha,项目名称:sems,代码行数:16,代码来源:MyConfigurableApp.cpp

示例13: INFO

int SipCtrlInterfaceFactory::onLoad()
{
    
    bind_addr = AmConfig::LocalSIPIP;
    bind_port = AmConfig::LocalSIPPort;
  
    INFO("SIP bind_addr: `%s'.\n", bind_addr.c_str());
    INFO("SIP bind_port: `%i'.\n", bind_port);

    if (!AmConfig::OutboundProxy.empty()) {
	sip_uri parsed_uri;
	if (parse_uri(&parsed_uri, (char *)AmConfig::OutboundProxy.c_str(),
		      AmConfig::OutboundProxy.length()) < 0) {
	    ERROR("invalid outbound_proxy specified\n");
	    return -1;
	}
	SipCtrlInterfaceFactory::outbound_host = c2stlstr(parsed_uri.host);
	if (parsed_uri.port) {
	    SipCtrlInterfaceFactory::outbound_port = parsed_uri.port;
	}
    }

    AmConfigReader cfg;
    string cfgfile = AmConfig::ModConfigPath + string(MOD_NAME ".conf");
    if (file_exists(cfgfile) && !cfg.loadFile(cfgfile)) {
	if (cfg.hasParameter("accept_fr_without_totag")) {
	    accept_fr_without_totag = 
		cfg.getParameter("accept_fr_without_totag") == "yes";
	}
	DBG("sipctrl: accept_fr_without_totag = %s\n", 
	    accept_fr_without_totag?"yes":"no");

	if (cfg.hasParameter("log_raw_messages")) {
	    string msglog = cfg.getParameter("log_raw_messages");
	    if (msglog == "no") log_raw_messages = -1;
	    else if (msglog == "error") log_raw_messages = 0;
	    else if (msglog == "warn")  log_raw_messages = 1;
	    else if (msglog == "info")  log_raw_messages = 2;
	    else if (msglog == "debug") log_raw_messages = 3;
	}
	DBG("sipctrl: log_raw_messages level = %d\n", 
	    log_raw_messages);

	if (cfg.hasParameter("log_parsed_messages")) {
	    log_parsed_messages = cfg.getParameter("log_parsed_messages")=="yes";
	}
	DBG("sipctrl: log_parsed_messages = %s\n", 
	    log_parsed_messages?"yes":"no");

    } else {
	DBG("assuming SIP default settings.\n");
    }

    return 0;
    
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:56,代码来源:SipCtrlInterface.cpp

示例14: onLoad

int AnswerMachineFactory::onLoad()
{
    AmConfigReader cfg;
    if(cfg.loadFile(add2path(AmConfig::ModConfigPath,1, MOD_NAME ".conf")))
	return -1;

    // get application specific global parameters
    configureModule(cfg);

    AnnouncePath    = cfg.getParameter("announce_path",ANNOUNCE_PATH);
    DefaultAnnounce = cfg.getParameter("default_announce",DEFAULT_ANNOUNCE);
    MaxRecordTime   = cfg.getParameterInt("max_record_time",DEFAULT_RECORD_TIME);
    RecFileExt      = cfg.getParameter("rec_file_ext",DEFAULT_AUDIO_EXT);

    if(loadEmailTemplates(cfg.getParameter("email_template_path",DEFAULT_MAIL_TMPL_PATH))){
	ERROR("while loading email templates\n");
	return -1;
    }

    AcceptDelay = DEFAULT_ACCEPT_DELAY;

    UserTimer = AmPlugIn::instance()->getFactory4Di("user_timer");
    if(!UserTimer){
	
	ERROR("could not load user_timer from session_timer plug-in\n");
	return -1;
    }

    return 0;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:30,代码来源:AnswerMachine.cpp

示例15: onLoad

int BrpcCtrlInterfaceFactory::onLoad()
{
    AmConfigReader cfg;

    if (cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
        WARN("failed to read/parse config file `%s' - assuming defaults\n",
             (AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str());
        semsUri = string(LISTEN_ADDR_DEFAULT);
        serUri = string(SER_ADDR_DEFAULT);
    } else {
        semsUri = cfg.getParameter(LISTEN_ADDR_PARAM, LISTEN_ADDR_DEFAULT);
        serUri = cfg.getParameter(SER_ADDR_PARAM, SER_ADDR_DEFAULT);
    }
    INFO(LISTEN_ADDR_PARAM ": %s.\n", semsUri.c_str());
    INFO(SER_ADDR_PARAM ": %s.\n", serUri.c_str());

    return 0;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:18,代码来源:BrpcCtrlInterface.cpp


注:本文中的AmConfigReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。