本文整理汇总了C++中cfg_getstr函数的典型用法代码示例。如果您正苦于以下问题:C++ cfg_getstr函数的具体用法?C++ cfg_getstr怎么用?C++ cfg_getstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cfg_getstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
init_app(argc, argv, "osd");
event_init();
char *hdd_cfg = cfg_getstr("HDD_CONF_FILENAME", "etc/hdd.conf");
hdd_init(hdd_cfg);
char *self_host = cfg_getstr("OSD2CLIENT_LISTEN_HOST", "*");
int self_port = cfg_getint32("OSD2CLIENT_LISTEN_PORT", 9527);
rpc_client_setup(self_host, self_port, MACHINE_OSD);
struct evhttp *httpd;
char *listen_host = cfg_getstr("OSD2CLIENT_LISTEN_HOST", "*");
int port = cfg_getint32("OSD2CLIENT_LISTEN_PORT", 9527);
httpd = evhttp_start(listen_host, port);
if (httpd == NULL) {
logging(LOG_ERROR, "start server error %m");
exit(1);
} else {
printf("Start osd at %s:%d\n", listen_host, port);
}
evhttp_set_cb(httpd, "/shutdown", shutdown_handler, NULL);
evhttp_set_gencb(httpd, gen_handler, NULL);
struct timeval five_seconds = {2,0};
struct event *update_clustermap_event= event_new(NULL, -1, EV_PERSIST, update_clustermap_from_cmgr_on_timer_cb, NULL);
event_add(update_clustermap_event, &five_seconds);
event_dispatch();
evhttp_free(httpd);
return 0;
}
示例2: drop_privs
static void drop_privs(void)
{
struct passwd *uentry = NULL;
struct group *gentry = NULL;
char *gid = cfg_getstr(cfg, "gid");
char *uid = cfg_getstr(cfg, "uid");
if (gid)
gentry = getgrnam(gid);
if (uid)
uentry = getpwnam(uid);
if (gentry)
if (setgid(gentry->gr_gid) < 0)
quit("Unable to set group id %d: %s\n",
gentry->gr_gid, strerror(errno));
if (uentry)
if (setuid(uentry->pw_uid) < 0)
quit("Unable to set user id %d: %s\n",
uentry->pw_uid, strerror(errno));
}
示例3: cb_validate_virtual
static int
cb_validate_virtual(cfg_t *cfg, cfg_opt_t *opt)
{
unsigned int i;
for (i = 0; i < cfg_size(cfg, "virtual-package"); i++) {
cfg_t *sec = cfg_opt_getnsec(opt, i);
if (cfg_getstr(sec, "targets") == 0) {
cfg_error(cfg, "targets must be set for "
"virtual-package %s", cfg_title(sec));
return -1;
}
}
return 0;
}
示例4: get_device_tier
int
get_device_tier(struct program_params *pp, const char *lv_name, const char *dev)
{
cfg_t *tmp = cfg_gettsec(pp->cfg, "volume", lv_name);
assert(tmp);
cfg_t *pv_cfg;
for (size_t i=0; i < cfg_size(tmp, "pv"); i++) {
pv_cfg = cfg_getnsec(tmp, "pv", i);
if (!strcmp(cfg_getstr(pv_cfg, "path"), dev))
return cfg_getint(pv_cfg, "tier");
}
return -1;
}
示例5: E_processDecorateWepStatesRecursive
//
// Process DECORATE-format states
//
static void E_processDecorateWepStatesRecursive(cfg_t *weaponsec, int wnum, bool recursive)
{
cfg_t *displaced;
// 01/02/12: Process displaced sections recursively first.
if((displaced = cfg_displaced(weaponsec)))
E_processDecorateWepStatesRecursive(displaced, wnum, true);
// haleyjd 06/22/10: Process DECORATE state block
if(cfg_size(weaponsec, ITEM_WPN_STATES) > 0)
{
// 01/01/12: allow use of pre-existing reserved states; they must be
// defined consecutively in EDF and should be flagged +decorate in order
// for values inside them to be overridden by the DECORATE state block.
// If this isn't being done, firststate will be null.
const char *firststate = cfg_getstr(weaponsec, ITEM_WPN_FIRSTDECSTATE);
const char *tempstr = cfg_getstr(weaponsec, ITEM_WPN_STATES);
// recursion should process states only if firststate is valid
if(!recursive || firststate)
E_processDecorateWepStateList(weaponinfo[wnum], tempstr, firststate, recursive);
}
}
示例6: locker
std::wstring Settings::getDeviceStateValue( int intDeviceId ) const {
TelldusCore::MutexLocker locker(&mutex);
if (d->var_cfg == 0) {
return L"";
}
cfg_t *cfg_device;
for (int i = 0; i < cfg_size(d->var_cfg, "device"); ++i) {
cfg_device = cfg_getnsec(d->var_cfg, "device", i);
int deviceId = atoi(cfg_title(cfg_device));
if (deviceId == intDeviceId) {
std::string value(cfg_getstr(cfg_device, "stateValue"));
return TelldusCore::charToWstring(value.c_str());
}
}
return L"";
}
示例7: get_tier_device
const char *
get_tier_device(struct program_params *pp, const char *lv_name, int tier)
{
cfg_t *tmp = cfg_gettsec(pp->cfg, "volume", lv_name);
assert(tmp);
cfg_t *pv_cfg;
for (size_t i=0; i < cfg_size(tmp, "pv"); i++) {
pv_cfg = cfg_getnsec(tmp, "pv", i);
if (cfg_getint(pv_cfg, "tier") == tier)
return cfg_getstr(pv_cfg, "path");
}
return NULL;
}
示例8: masterconn_parselabels
void masterconn_parselabels(void) {
char *labelsstr,*p,c;
labelsstr = cfg_getstr("LABELS","");
labelmask = 0;
for (p=labelsstr ; *p ; p++) {
c = *p;
if (c>='A' && c<='Z') {
labelmask |= (1 << (c-'A'));
} else if (c>='a' && c<='z') {
labelmask |= (1 << (c-'a'));
}
}
free(labelsstr);
}
示例9: write_pidfile
static void write_pidfile(void)
{
char *pidfile = cfg_getstr(cfg, "pidfile");
FILE *pf;
if (!pidfile)
return;
pf = fopen(pidfile, "w");
if (pf == NULL)
quit("Can't open pidfile %s: %s\n", pidfile, strerror(errno));
fprintf(pf, "%i\n", getpid());
if (fclose(pf) < 0)
quit("Can't close pidfile %s: %s\n", pidfile, strerror(errno));
}
示例10: cb_validate_bookmark
int cb_validate_bookmark(cfg_t *cfg, cfg_opt_t *opt)
{
/* only validate the last bookmark */
cfg_t *sec = cfg_opt_getnsec(opt, cfg_opt_size(opt) - 1);
if(!sec)
{
cfg_error(cfg, "section is NULL!?");
return -1;
}
if(cfg_getstr(sec, "machine") == 0)
{
cfg_error(cfg, "machine option must be set for bookmark '%s'",
cfg_title(sec));
return -1;
}
return 0;
}
示例11: method_init
/* vcd.hostinfo() */
xmlrpc_value *m_vcd_hostinfo(xmlrpc_env *env, xmlrpc_value *p, void *c)
{
LOG_TRACEME
xmlrpc_value *response = NULL;
method_init(env, p, c, VCD_CAP_INFO, 0);
method_return_if_fault(env);
response = xmlrpc_build_value(env,
"{s:s,s:i,s:i}",
"vbasedir", cfg_getstr(cfg, "vbasedir"),
"cpus", sysconf(_SC_NPROCESSORS_ONLN),
"memnodes", max_mem_node()+1); /* Make both cpus and memnodes here an absolute
* value, not including 0, for consistency */
return response;
}
示例12: state_init
int state_init()
{
int whethermaster = cfg_getuint32("MASTER_STATE", 1);
g_virtual_ip = cfg_getstr("VIRTUAL_IP", "");
int havevip = checkvirtualip();
if( ( whethermaster && !havevip ) || ( !whethermaster && havevip ) ) {
MFSLOG(LOG_ERR, "state : %d and havevip :%d conflict vip:%s\n",
whethermaster, havevip, g_virtual_ip);
return -1;
}
whethermaster ? set_state(MFS_STATE_MASTER) : set_state(MFS_STATE_SLAVE);
main_timeregister(TIMEMODE_RUNALL, 2, 0, state_refresh);
return 0;
}
示例13: configfile_read_history
static void configfile_read_history(void)
{
int i, nhistory;
nhistory = cfg_size(cfg, "history");
for (i = 0; i < nhistory; i++) {
struct history_def *def;
cfg_t *history;
const char *name, *type;
float interval;
int size;
if (!(history = cfg_getnsec(cfg, "history", i)))
BUG();
if (!(name = cfg_title(history)))
BUG();
interval = cfg_getfloat(history, "interval");
size = cfg_getint(history, "size");
type = cfg_getstr(history, "type");
if (interval == 0.0f)
interval = cfg_getfloat(cfg, "read_interval");
def = history_def_alloc(name);
def->hd_interval = interval;
def->hd_size = size;
if (!strcasecmp(type, "8bit"))
def->hd_type = HISTORY_TYPE_8;
else if (!strcasecmp(type, "16bit"))
def->hd_type = HISTORY_TYPE_16;
else if (!strcasecmp(type, "32bit"))
def->hd_type = HISTORY_TYPE_32;
else if (!strcasecmp(type, "64bit"))
def->hd_type = HISTORY_TYPE_64;
else
quit("Invalid type \'%s\', must be \"(8|16|32|64)bit\""
" in history definition #%d\n", type, i+1);
}
}
示例14: testconfig
static int
testconfig(const char *buf, const char *parameter)
{
cfg_t *cfg = cfg_init(opts, CFGF_NONE);
if (!cfg)
return 0;
if (cfg_parse_buf(cfg, buf) != CFG_SUCCESS)
return 0;
char *param = cfg_getstr(cfg, "parameter");
if (!param)
return 0;
if (strcmp(param, parameter) != 0)
return 0;
cfg_free(cfg);
return 1;
}
示例15: get_model_access_list
model_access_list * get_model_access_list(const char * filename){
int i;
cfg_opt_t * opts = get_opt();
cfg_t *cfg;
cfg = cfg_init(opts, CFGF_NONE);
cfg_parse(cfg, filename);
model_access_list * ma_list = (model_access_list*)malloc(sizeof(model_access_list));
char *path, *model_list_item, *query_list_item, *model_label;
path = cfg_getstr(cfg,"model_list_path");
ma_list->path = (char *)malloc(sizeof(char)*strlen(path));
strcpy(ma_list->path,path);
for(i=0;i< cfg_size(cfg,"model_list");i++){
model_list_item = cfg_getnstr(cfg,"model_list",i);
ma_list->model_access_info[i].model_filename =(char*)malloc(sizeof(char)*strlen(model_list_item));
strcpy(ma_list->model_access_info[i].model_filename,model_list_item);
model_label = cfg_getnstr(cfg,"model_label_list",i);
ma_list->model_access_info[i].model_label =(char*)malloc(sizeof(char)*strlen(model_label));
strcpy(ma_list->model_access_info[i].model_label,model_label);
query_list_item=cfg_getnstr(cfg,"query_list",i);
ma_list->model_access_info[i].query =(char*)malloc(sizeof(char)*strlen(query_list_item));
strcpy(ma_list->model_access_info[i].query,query_list_item);
}
ma_list->size=i;
free(cfg);
return ma_list;
}