本文整理汇总了C++中cfg_getstr函数的典型用法代码示例。如果您正苦于以下问题:C++ cfg_getstr函数的具体用法?C++ cfg_getstr怎么用?C++ cfg_getstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cfg_getstr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:cheliequan,项目名称:idning-paper,代码行数:38,代码来源:oc_serv.c
示例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));
}
开发者ID:noushi,项目名称:bmon,代码行数:23,代码来源:bmon.c
示例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;
}
开发者ID:xdave,项目名称:xbps,代码行数:15,代码来源:initend.c
示例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;
}
开发者ID:NickCharsley,项目名称:lvmts,代码行数:15,代码来源:config.c
示例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);
}
}
开发者ID:ioan-chera,项目名称:eternity,代码行数:27,代码来源:e_weapons.cpp
示例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"";
}
开发者ID:stromnet,项目名称:telldus,代码行数:16,代码来源:SettingsConfuse.cpp
示例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;
}
开发者ID:NickCharsley,项目名称:lvmts,代码行数:16,代码来源:config.c
示例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);
}
开发者ID:jacklicn,项目名称:moosefs,代码行数:17,代码来源:masterconn.c
示例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));
}
开发者ID:noushi,项目名称:bmon,代码行数:17,代码来源:bmon.c
示例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;
}
开发者ID:DavidEGrayson,项目名称:libconfuse,代码行数:17,代码来源:cfgtest.c
示例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;
}
开发者ID:linux-vserver,项目名称:vcd,代码行数:19,代码来源:vcd_hostinfo.c
示例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;
}
开发者ID:linfengWu,项目名称:shadow-mfs,代码行数:18,代码来源:state.c
示例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);
}
}
开发者ID:noushi,项目名称:bmon,代码行数:43,代码来源:conf.c
示例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;
}
开发者ID:DavidEGrayson,项目名称:libconfuse,代码行数:20,代码来源:env.c
示例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;
}
开发者ID:CristopherLeal,项目名称:SVMClassifier,代码行数:39,代码来源:config.c
示例16: parse_family
int parse_family(char *filename, family_ent_t * family) {
cfg_t *pcfg;
memset(family, 0, sizeof(family_ent_t));
pcfg = cfg_init(family_opts, CFGF_NONE);
if (cfg_parse(pcfg, filename) == CFG_PARSE_ERROR)
return -1;
strcpy(family->name, cfg_getstr(pcfg, "name"));
family->fam_id = cfg_getint(pcfg, "fam_id");
family->fam_type = cfg_getint(pcfg, "fam_type");
family->search_prio = cfg_getint(pcfg, "search_prio");
family->prg_entry_script = get_script_by_name(cfg_getstr(pcfg, "prg_entry_script"));
family->prg_exit_script = get_script_by_name(cfg_getstr(pcfg, "prg_exit_script"));
family->rd_devid_script = get_script_by_name(cfg_getstr(pcfg, "rd_devid_script"));
/* family->devid_mask = cfg_getint(pcfg, "devid_mask"); */
/* family->blank_value = cfg_getint(pcfg, "blank_value"); */
family->devid_mask = strtoul(cfg_getstr(pcfg, "devid_mask"), NULL, 16);
family->blank_value = strtoul(cfg_getstr(pcfg, "blank_value"), NULL, 16);
family->bytes_per_loc = cfg_getint(pcfg, "bytes_per_loc");
family->addr_inc = cfg_getint(pcfg, "addr_inc");
family->b_detect = cfg_getint(pcfg, "b_detect");
family->prg_entry_vpp_script = get_script_by_name(cfg_getstr(pcfg, "prg_entry_vpp_script"));
family->ee_bytes_per_word = cfg_getint(pcfg, "ee_bytes_per_word");
family->ee_addr_inc = cfg_getint(pcfg, "ee_addr_inc");
family->user_id_hex_bytes = cfg_getint(pcfg, "user_id_hex_bytes");
family->user_id_bytes = cfg_getint(pcfg, "user_id_bytes");
family->prog_mem_hex_bytes = cfg_getint(pcfg, "prog_mem_hex_bytes");
family->ee_mem_hex_bytes = cfg_getint(pcfg, "ee_mem_hex_bytes");
family->prg_mem_shift = cfg_getint(pcfg, "prg_mem_shift");
family->test_memory_start = cfg_getint(pcfg, "test_memory_start");
family->test_memory_length = cfg_getint(pcfg, "test_memory_length");
family->vpp = cfg_getfloat(pcfg, "vpp");
cfg_free(pcfg);
return 0;
}
开发者ID:GBert,项目名称:misc,代码行数:41,代码来源:pk2dft.c
示例17: configfile_read_element_cfg
static void configfile_read_element_cfg(void)
{
int i, nelement;
nelement = cfg_size(cfg, "element");
for (i = 0; i < nelement; i++) {
struct element_cfg *ec;
cfg_t *element;
const char *name, *description;
long max;
if (!(element = cfg_getnsec(cfg, "element", i)))
BUG();
if (!(name = cfg_title(element)))
BUG();
ec = element_cfg_alloc(name);
if ((description = cfg_getstr(element, "description")))
ec->ec_description = strdup(description);
if ((max = cfg_getint(element, "max")))
ec->ec_rxmax = ec->ec_txmax = max;
if ((max = cfg_getint(element, "rxmax")))
ec->ec_rxmax = max;
if ((max = cfg_getint(element, "txmax")))
ec->ec_txmax = max;
if (cfg_getbool(element, "show"))
ec->ec_flags |= ELEMENT_CFG_SHOW;
else
ec->ec_flags |= ELEMENT_CFG_HIDE;
}
}
开发者ID:noushi,项目名称:bmon,代码行数:38,代码来源:conf.c
示例18: src_init
void src_init(cfg_t *source_cfg) {
char *stream = cfg_getstr(source_cfg, "stream");
if (!stream) return;
crcInit();
if (!strncmp("udp://", stream, 6)) {
double chunk_duration = cfg_getfloat(source_cfg,"chunk_duration");
info("Initializing SOURCE mode: tuning to stream %s, sampling rate is "
"%.2lf Hz", stream, (double)1.0/chunk_duration);
init_source_ul(stream, chunk_duration);
} else if (!strncmp("http://", stream, 7)) {
char addr[128];
int port,i;
if (sscanf(stream, "http://%127[^:]:%i", addr, &port) != 2)
fatal("Unable to parse source specification %s", stream);
if (ulChunkReceiverSetup(addr, port))
fatal("Unable to start the HTTP receiver to http://%s:%d",
addr, port);
} else fatal("Unable to parse stream specification %s", stream);
napaSchedulePeriodic(NULL, 1/60.0, periodicPublishSrcLag, NULL);
}
开发者ID:cskiraly,项目名称:NAPA-BASELIBS,代码行数:23,代码来源:source.c
示例19: topology_reload
void topology_reload(void) {
int fd;
if (TopologyFileName) {
free(TopologyFileName);
}
if (!cfg_isdefined("TOPOLOGY_FILENAME")) {
TopologyFileName = strdup(ETC_PATH "/mfs/mfstopology.cfg");
passert(TopologyFileName);
if ((fd = open(TopologyFileName,O_RDONLY))<0 && errno==ENOENT) {
free(TopologyFileName);
TopologyFileName = strdup(ETC_PATH "/mfstopology.cfg");
if ((fd = open(TopologyFileName,O_RDONLY))>=0) {
mfs_syslog(LOG_WARNING,"default sysconf path has changed - please move mfstopology.cfg from "ETC_PATH"/ to "ETC_PATH"/mfs/");
}
}
if (fd>=0) {
close(fd);
}
} else {
TopologyFileName = cfg_getstr("TOPOLOGY_FILENAME",ETC_PATH "/mfs/mfstopology.cfg");
}
topology_load();
}
开发者ID:alexmiao,项目名称:moosefs,代码行数:23,代码来源:topology.c
示例20: build_params_dict
static PyObject* build_params_dict(cfg_t *pymodule)
{
int k;
PyObject *params_dict = PyDict_New();
if (pymodule && params_dict) {
for (k = 0; k < cfg_size(pymodule, "param"); k++) {
cfg_t *param;
char *name, *value;
PyObject *pyvalue;
param = cfg_getnsec(pymodule, "param", k);
name = apr_pstrdup(pool, param->title);
value = apr_pstrdup(pool, cfg_getstr(param, "value"));
pyvalue = PyString_FromString(value);
if (name && pyvalue) {
PyDict_SetItemString(params_dict, name, pyvalue);
Py_DECREF(pyvalue);
}
}
}
return params_dict;
}
开发者ID:AsherBond,项目名称:monitor-core,代码行数:23,代码来源:mod_python.c
注:本文中的cfg_getstr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论