本文整理汇总了C++中AmConfigReader::loadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ AmConfigReader::loadFile方法的具体用法?C++ AmConfigReader::loadFile怎么用?C++ AmConfigReader::loadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmConfigReader
的用法示例。
在下文中一共展示了AmConfigReader::loadFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: onLoad
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;
};
示例7: 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;
}
示例8: 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;
}
示例9: onLoad
int RegistrationAgentFactory::onLoad()
{
AmConfigReader cfg;
if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
return -1;
// get application specific global parameters
configureModule(cfg);
// stay backwards compatible
RegInfo ri;
ri.domain = cfg.getParameter("domain","");
ri.user = cfg.getParameter("user","");
ri.display_name = cfg.getParameter("display_name","");
ri.auth_user = cfg.getParameter("auth_user","");
ri.passwd = cfg.getParameter("pwd","");
if (!ri.domain.length() ||
!ri.user.length() ||
!ri.display_name.length() ||
!ri.auth_user.length() ||
!ri.passwd.length()) {
ERROR("Account for registration not correctly configured.\n");
ERROR("RegistrationAgent will not register any accounts.\n");
return 0;
}
DBG("Adding registration #%d (%s %s %s %s)\n", 0,
ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), ri.auth_user.c_str());
dialer.add_reg(ri);
unsigned int ri_index = 1;
while (ri_index < 100) {
RegInfo ri;
ri.domain = cfg.getParameter("domain"+int2str(ri_index),"");
ri.user = cfg.getParameter("user"+int2str(ri_index),"");
ri.display_name = cfg.getParameter("display_name"+int2str(ri_index),"");
ri.auth_user = cfg.getParameter("auth_user"+int2str(ri_index),"");
ri.passwd = cfg.getParameter("pwd"+int2str(ri_index),"");
if (!ri.domain.length() ||
!ri.user.length() ||
!ri.display_name.length() ||
!ri.auth_user.length() ||
!ri.passwd.length())
break;
DBG("Adding registration #%d (%s %s %s %s)\n", ri_index,
ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), ri.auth_user.c_str());
dialer.add_reg(ri);
ri_index++;
}
dialer.start();
return 0;
}
示例10: onLoad
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;
}
示例11: 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;
}
示例12: DBG
int XMLRPC2DI::load() {
if (configured) // load only once
return 0;
configured = true;
AmConfigReader cfg;
if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
return -1;
ServerRetryAfter = cfg.getParameterInt("server_retry_after", 10);
DBG("retrying failed server after %u seconds\n", ServerRetryAfter);
string run_server = cfg.getParameter("run_server","yes");
if (run_server != "yes") {
DBG("XMLRPC server will not be started.\n");
return 0;
}
string conf_xmlrpc_port = cfg.getParameter("xmlrpc_port",XMLRPC_PORT);
if (conf_xmlrpc_port.empty()) {
ERROR("configuration: xmlrpc_port must be defined!\n");
return -1;
}
if (str2i(conf_xmlrpc_port, XMLRPCPort)) {
ERROR("configuration: unable to decode xmlrpc_port value '%s'!\n",
conf_xmlrpc_port.c_str());
return -1;
}
bool export_di = false;
string direct_export = cfg.getParameter("direct_export","");
if (direct_export.length()) {
DBG("direct_export interfaces: %s\n", direct_export.c_str());
} else {
DBG("No direct_export interfaces.\n");
}
string export_di_s = cfg.getParameter("export_di","yes");
if (export_di_s == "yes") {
export_di = true;
}
DBG("XMLRPC Server: %snabling builtin method 'di'.\n", export_di?"E":"Not e");
server = new XMLRPC2DIServer(XMLRPCPort, export_di, direct_export);
server->start();
return 0;
}
示例13: onLoad
int RegistrationAgentFactory::onLoad()
{
AmConfigReader cfg;
if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
return -1;
// get application specific global parameters
configureModule(cfg);
int i = 0;
string idx_str;
do {
RegInfo ri;
ri.domain = cfg.getParameter(CFG_PARAM_DOMAIN+idx_str,"");
ri.user = cfg.getParameter(CFG_PARAM_USER+idx_str,"");
ri.display_name = cfg.getParameter(CFG_PARAM_DISPLAY+idx_str,"");
ri.auth_user = cfg.getParameter(CFG_PARAM_AUTH+idx_str,"");
ri.passwd = cfg.getParameter(CFG_PARAM_PASS+idx_str,"");
ri.proxy = cfg.getParameter(CFG_PARAM_PROXY+idx_str,"");
if (!ri.domain.length() || !ri.user.length()) {
// not including the passwd: might be IP based registration
// not including the display name: allow user to skip it
DBG("no mandatory config parameters '" CFG_PARAM_DOMAIN "' and '"
CFG_PARAM_USER "' provided for entry #%d; configuration halted.\n", i);
break;
}
if (!ri.auth_user.length()) // easier to config
ri.auth_user = ri.user;
dialer.add_reg(ri);
DBG("Adding registration account #%d (%s %s %s %s %s)\n", i,
ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(),
ri.auth_user.c_str(), ri.proxy.c_str());
i ++;
idx_str = int2str(i);
} while (i < MAX_ACCOUNTS);
if (i <= 0) {
ERROR("no complete account provided: '" MOD_NAME "' module remains "
"inactive, which might not be what you want!\n");
} else {
dialer.start();
}
return 0;
}
示例14: 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;
}
示例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;
}