本文整理汇总了C++中config_setting_lookup_string函数的典型用法代码示例。如果您正苦于以下问题:C++ config_setting_lookup_string函数的具体用法?C++ config_setting_lookup_string怎么用?C++ config_setting_lookup_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_setting_lookup_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_ue_sim_param
bool parse_ue_sim_param(config_setting_t *ue_setting, int user_id, usim_data_conf_t *u) {
int rc = true;
config_setting_t *ue_param_setting = NULL;
ue_param_setting = config_setting_get_member(ue_setting, SIM);
if (ue_param_setting == NULL) {
printf("Check SIM section for UE%d. EXITING...\n", user_id);
return false;
}
rc = config_setting_lookup_string(ue_param_setting, MSIN, &u->msin);
if (rc != 1 || strlen(u->msin) > 10 || strlen(u->msin) < 9) {
printf("Check SIM MSIN section for UE%d. Exiting\n", user_id);
return false;
}
rc = config_setting_lookup_string(ue_param_setting, USIM_API_K,
&u->usim_api_k);
if (rc != 1) {
printf("Check SIM USIM_API_K section for UE%d. Exiting\n", user_id);
return false;
}
rc = config_setting_lookup_string(ue_param_setting, OPC, &u->opc);
if (rc != 1) {
printf("Check SIM OPC section for UE%d. Exiting\n", user_id);
return false;
}
rc = config_setting_lookup_string(ue_param_setting, MSISDN, &u->msisdn);
if (rc != 1) {
printf("Check SIM MSISDN section for UE%d. Exiting\n", user_id);
return false;
}
return true;
}
示例2: configure_cgi_handlers
void configure_cgi_handlers(spade_server* server, config_t* configuration) {
config_setting_t* handler_settings = config_lookup(configuration,
"cgi.handlers");
int cgi_handler_count = config_setting_length(handler_settings);
for (int n = 0; n < cgi_handler_count; n++) {
config_setting_t* handler_setting = config_setting_get_elem(
handler_settings, n);
const char* handler = NULL;
config_setting_lookup_string(handler_setting, "handler", &handler);
const char* url = NULL;
config_setting_lookup_string(handler_setting, "url", &url);
if(!register_cgi_handler(server, url, handler)) {
log4c_category_log(log4c_category_get("spade"), LOG4C_PRIORITY_INFO,
"Registered CGI handler '%s' for URL prefix '%s'",
handler, url);
}
}
if (server->cgi_handler_count == 0) {
log4c_category_log(log4c_category_get("spade"), LOG4C_PRIORITY_INFO,
"No CGI handlers registered");
} else {
log4c_category_log(log4c_category_get("spade"), LOG4C_PRIORITY_INFO,
"Registered a total of %d CGI handlers",
server->cgi_handler_count);
}
}
示例3: read_pairs_setting
/*! \brief read pair setting */
static int read_pairs_setting(config_setting_t * setting, add_pair_mapping add, void * data)
{
int i;
config_setting_t * pair;
for (i = 0; (pair = config_setting_get_elem(setting, i)) != NULL; ++i)
{
int rv;
const char * local;
const char * remote;
rv = config_setting_lookup_string(pair, "local", &local);
if (rv != CONFIG_TRUE)
{
message(LOG_ERROR, FACILITY_CONFIG, "Failed to read local key from pairs in shared config.\n");
return CONFIG_FALSE;
}
rv = config_setting_lookup_string(pair, "remote", &remote);
if (rv != CONFIG_TRUE)
{
message(LOG_ERROR, FACILITY_CONFIG, "Failed to read remote key from pairs in shared config.\n");
return CONFIG_FALSE;
}
add(data, local, remote);
}
return CONFIG_TRUE;
}
示例4: configure_clay_handlers
void configure_clay_handlers(spade_server* server, config_t* configuration) {
config_setting_t* handler_settings = config_lookup(configuration,
"clay.handlers");
if (!handler_settings) {
log4c_category_log(log4c_category_get("spade"), LOG4C_PRIORITY_INFO,
"No Clay handlers registered");
return;
}
int clay_handler_count = config_setting_length(handler_settings);
for (int n = 0; n < clay_handler_count; n++) {
config_setting_t* handler_setting = config_setting_get_elem(
handler_settings, n);
const char* endpoint = NULL;
config_setting_lookup_string(handler_setting, "endpoint", &endpoint);
const char* url = NULL;
config_setting_lookup_string(handler_setting, "url", &url);
if(!register_clay_handler(server, url, endpoint)) {
log4c_category_log(log4c_category_get("spade"), LOG4C_PRIORITY_INFO,
"Registered Clay handler for URL prefix '%s' at endpoint %s",
url, endpoint);
}
}
if (server->clay_handler_count == 0) {
log4c_category_log(log4c_category_get("spade"), LOG4C_PRIORITY_INFO,
"No Clay handlers registered");
} else {
log4c_category_log(log4c_category_get("spade"), LOG4C_PRIORITY_INFO,
"Registered a total of %d Clay handlers",
server->clay_handler_count);
}
}
示例5: read_dokan_config
/*! \brief read dokan config from local config */
static int read_dokan_config(config_t * config)
{
config_setting_t * dokan_setting = config_lookup(config, "dokan");
if (dokan_setting == NULL)
{
message(LOG_INFO, FACILITY_CONFIG, "No dokan section was found in local config.\n");
return CONFIG_TRUE;
}
int rv;
const char * volume_name;
/* dokan::volume_name */
rv = config_setting_lookup_string(dokan_setting, "volume_name", &volume_name);
if (rv == CONFIG_TRUE)
{
xmkstring(&(zfs_config.dokan.volume_name), volume_name);
}
const char * file_system_name;
/* dokan::filesystem_name */
rv = config_setting_lookup_string(dokan_setting, "file_system_name", &file_system_name);
if (rv == CONFIG_TRUE)
{
xmkstring(&(zfs_config.dokan.file_system_name), file_system_name);
}
return CONFIG_TRUE;
}
示例6: load_mods
static int
load_mods(config_t *config, config_setting_t *setting)
{
int err;
unsigned int mod_count;
int i;
const char* mod_name;
const char* mod_so;
const char* mod_ident;
config_setting_t *mod_setting;
err = 0;
fprintf(stderr, "load mods from config\n");
setting = config_lookup(config, "mods");
if (setting != NULL) {
mod_count = config_setting_length(setting);
for (i = 0; i < mod_count; ++i) {
mod_setting = config_setting_get_elem(setting, i);
if (mod_setting) {
if (!config_setting_lookup_string(mod_setting,
"name",
&mod_name) ||
!config_setting_lookup_string(mod_setting,
"so",
&mod_so)) {
continue;
}
if (!config_setting_lookup_string(mod_setting,
"ident",
&mod_ident)) {
mod_ident = NULL;
}
fprintf(stderr, "load module %s - %s - [%s]\n",
mod_name, mod_so, mod_ident);
module_t *mod = module_open(mod_name,
mod_ident,
mod_so,
RTLD_NOW);
if (!mod) {
err = 1;
break;
}
if (module_map_insert(&g_config.module_root, mod) == NULL) {
err = 1;
module_close(mod);
break;
}
if (module_call_init_func(mod, &g_config)) {
fprintf(stderr, "ERROR %s returned not 0\n", mod->name);
err = 1;
module_close(mod);
break;
}
}
}
}
return err;
}
示例7: thermal_constructor
static GtkWidget *
thermal_constructor(LXPanel *panel, config_setting_t *settings)
{
thermal *th;
GtkWidget *p;
const char *tmp;
ENTER;
th = g_new0(thermal, 1);
th->panel = panel;
th->settings = settings;
p = gtk_event_box_new();
lxpanel_plugin_set_data(p, th, thermal_destructor);
gtk_widget_set_has_window(p, FALSE);
gtk_container_set_border_width( GTK_CONTAINER(p), 2 );
th->namew = gtk_label_new("ww");
gtk_container_add(GTK_CONTAINER(p), th->namew);
th->tip = g_string_new(NULL);
/* By default, use automatic, that is, "not custom" temperature levels. If
* we were using custom levels, they would be 0°C at startup, so we would
* display in warning colors by default. */
th->not_custom_levels = TRUE;
if (config_setting_lookup_string(settings, "NormalColor", &tmp))
th->str_cl_normal = g_strdup(tmp);
if (config_setting_lookup_string(settings, "Warning1Color", &tmp))
th->str_cl_warning1 = g_strdup(tmp);
if (config_setting_lookup_string(settings, "Warning2Color", &tmp))
th->str_cl_warning2 = g_strdup(tmp);
config_setting_lookup_int(settings, "AutomaticSensor", &th->auto_sensor);
/* backward compatibility for wrong variable */
config_setting_lookup_int(settings, "CustomLevels", &th->not_custom_levels);
config_setting_lookup_int(settings, "AutomaticLevels", &th->not_custom_levels);
if (config_setting_lookup_string(settings, "Sensor", &tmp))
th->sensor = g_strdup(tmp);
config_setting_lookup_int(settings, "Warning1Temp", &th->warning1);
config_setting_lookup_int(settings, "Warning2Temp", &th->warning2);
if(!th->str_cl_normal)
th->str_cl_normal = g_strdup("#00ff00");
if(!th->str_cl_warning1)
th->str_cl_warning1 = g_strdup("#fff000");
if(!th->str_cl_warning2)
th->str_cl_warning2 = g_strdup("#ff0000");
applyConfig(p);
gtk_widget_show(th->namew);
update_display(th);
th->timer = g_timeout_add_seconds(3, (GSourceFunc) update_display_timeout, (gpointer)th);
RET(p);
}
示例8: channel_read_sub
/**
* Attempt to create a global channel from the channel config
* @param chan: Channel list
* @param tmp_chan: Temporary channel data
* @param i: Index
* @return True on success or false on failure
*/
bool channel_read_sub(config_setting_t *chan, struct Channel *tmp_chan, uint8 i) {
config_setting_t *group_list = NULL;
int delay = 1000, autojoin = 0, leave = 1, chat = 1, color_override = 0,
self_notif = 1, join_notif = 0, leave_notif = 0;
int type = CHAN_TYPE_PUBLIC, group_count = 0;
const char *name = NULL, *password = NULL, *alias = NULL, *color_str = "Default", *type_str = NULL;
if (tmp_chan == NULL)
return false;
if (!config_setting_lookup_string(chan, "name", &name)) {
ShowError("Please input channel 'name' at '%s' line '%d'! Skipping...\n", chan->file, chan->line);
return false;
}
if (config_setting_lookup_string(chan, "type", &type_str) && !script_get_constant(type_str, &type)) {
ShowError("Invalid channel type %s at '%s' line '%d'! Skipping...\n", type_str, chan->file, chan->line);
return false;
}
config_setting_lookup_string(chan, "password", &password);
config_setting_lookup_string(chan, "alias", &alias);
config_setting_lookup_string(chan, "color", &color_str);
config_setting_lookup_int(chan, "delay", &delay);
config_setting_lookup_bool(chan, "autojoin", &autojoin);
config_setting_lookup_bool(chan, "leave", &leave);
config_setting_lookup_bool(chan, "chat", &chat);
config_setting_lookup_bool(chan, "color_override", &color_override);
config_setting_lookup_bool(chan, "self_notif", &self_notif);
config_setting_lookup_bool(chan, "join_notif", &join_notif);
config_setting_lookup_bool(chan, "leave_notif", &leave_notif);
safestrncpy(tmp_chan->name,name+1,sizeof(tmp_chan->name));
if (password)
safestrncpy(tmp_chan->pass,password,sizeof(tmp_chan->pass));
else
tmp_chan->pass[0] = '\0';
safestrncpy(tmp_chan->alias,alias?alias:name,sizeof(tmp_chan->alias));
tmp_chan->msg_delay = delay;
tmp_chan->type = (enum Channel_Type)type;
tmp_chan->color = channel_getColor(color_str);
tmp_chan->opt = (autojoin ? CHAN_OPT_AUTOJOIN : 0) |
(leave ? CHAN_OPT_CAN_LEAVE : 0) |
(chat ? CHAN_OPT_CAN_CHAT : 0) |
(color_override ? CHAN_OPT_COLOR_OVERRIDE : 0) |
(self_notif ? CHAN_OPT_ANNOUNCE_SELF : 0) |
(join_notif ? CHAN_OPT_ANNOUNCE_JOIN : 0) |
(leave_notif ? CHAN_OPT_ANNOUNCE_LEAVE : 0);
if ((group_list = config_setting_get_member(chan, "groupid")) && (group_count = config_setting_length(group_list)) > 0) {
int j;
CREATE(tmp_chan->groups, unsigned short, group_count);
tmp_chan->group_count = group_count;
for (j = 0; j < group_count; j++) {
int groupid = config_setting_get_int_elem(group_list, j);
tmp_chan->groups[j] = groupid;
}
}
示例9: read_node_list_shared_config
int read_node_list_shared_config(config_t * config)
{
config_setting_t * node_list = config_lookup(config, "node:list");
if (node_list == NULL)
{
message(LOG_ERROR, FACILITY_CONFIG, "No node list section in shared config was found.\n");
return CONFIG_FALSE;
}
config_setting_t * node_entry;
int i;
for (i = 0; (node_entry = config_setting_get_elem(node_list, i)) != NULL; ++i)
{
uint64_t id;
const char * name;
const char * address;
int rv;
rv = config_setting_lookup_uint64_t(node_entry, "id", &id);
if (rv != CONFIG_TRUE)
{
message(LOG_ERROR, FACILITY_CONFIG, "Id config key is wrong type or is missing in shared config.\n");
return CONFIG_FALSE;
}
rv = config_setting_lookup_string(node_entry, "name", &name);
if (rv != CONFIG_TRUE)
{
message(LOG_ERROR, FACILITY_CONFIG, "Name config key is wrong type or is missing in shared config.\n");
return CONFIG_FALSE;
}
rv = config_setting_lookup_string(node_entry, "address", &address);
if (rv != CONFIG_TRUE)
{
message(LOG_ERROR, FACILITY_CONFIG, "Addres config key is wrong type or is missing in shared config.\n");
return CONFIG_FALSE;
}
string str_name;
string str_address;
xmkstring(&str_name, name);
xmkstring(&str_address, address);
node nod = try_create_node(id, &str_name, &str_name, read_tcp_port_setting(node_entry));
if (nod)
zfsd_mutex_unlock(&nod->mutex);
}
return CONFIG_TRUE;
}
示例10: volume_entry_read
/*! \brief reads volume entry from shared config */
static int volume_entry_read(config_setting_t * volume_setting, volume_entry * ve)
{
int rv;
uint64_t id;
rv = config_setting_lookup_uint64_t(volume_setting, "id", &id);
if (rv != CONFIG_TRUE)
{
message (LOG_ERROR, FACILITY_CONFIG, "Id confg key is missing or is wrong type in volume list.\n");
return CONFIG_FALSE;
}
const char * volume_name;
rv = config_setting_lookup_string(volume_setting, "name", &volume_name);
if (rv != CONFIG_TRUE)
{
message(LOG_ERROR, FACILITY_CONFIG, "Name config key is missing or is wrong type in volume list.\n");
return CONFIG_FALSE;
}
const char * volume_mountpoint;
rv = config_setting_lookup_string(volume_setting, "mountpoint", &volume_mountpoint);
if (rv != CONFIG_TRUE)
{
message(LOG_ERROR, FACILITY_CONFIG, "Mountpoint config key is missing or is wrong type in volume list.\n");
return CONFIG_FALSE;
}
if (is_valid_volume_id(id) == false)
{
message(LOG_ERROR, FACILITY_CONFIG, "Volume id is invalid.\n");
return CONFIG_FALSE;
}
if (is_valid_volume_name(volume_name) == false)
{
message(LOG_ERROR, FACILITY_CONFIG, "Volume name is invalid.\n");
return CONFIG_FALSE;
}
if (is_valid_local_path(volume_mountpoint) == false)
{
message(LOG_ERROR, FACILITY_CONFIG, "Volume mountpoint is invalid.\n");
return CONFIG_FALSE;
}
//id, name mountpoint
ve->id = id;
xmkstring(&ve->name, volume_name);
xmkstring(&ve->mountpoint, volume_mountpoint);
return CONFIG_TRUE;
}
示例11: monitors_constructor
static GtkWidget *
monitors_constructor(LXPanel *panel, config_setting_t *settings)
{
ENTER;
int i;
MonitorsPlugin *mp;
GtkWidget *p;
const char *tmp;
mp = g_new0(MonitorsPlugin, 1);
mp->panel = panel;
mp->settings = settings;
p = gtk_hbox_new(TRUE, 2);
lxpanel_plugin_set_data(p, mp, monitors_destructor);
/* First time we use this plugin : only display CPU usage */
mp->displayed_monitors[CPU_POSITION] = 1;
/* Apply options */
config_setting_lookup_int(settings, "DisplayCPU",
&mp->displayed_monitors[CPU_POSITION]);
config_setting_lookup_int(settings, "DisplayRAM",
&mp->displayed_monitors[MEM_POSITION]);
if (config_setting_lookup_string(settings, "Action", &tmp))
mp->action = g_strdup(tmp);
if (config_setting_lookup_string(settings, "CPUColor", &tmp))
colors[CPU_POSITION] = g_strndup(tmp, COLOR_SIZE-1);
if (config_setting_lookup_string(settings, "RAMColor", &tmp))
colors[MEM_POSITION] = g_strndup(tmp, COLOR_SIZE-1);
/* Initializing monitors */
for (i = 0; i < N_MONITORS; i++)
{
if (!colors[i])
colors[i] = g_strndup(default_colors[i], COLOR_SIZE-1);
if (mp->displayed_monitors[i])
{
mp->monitors[i] = monitors_add_monitor(p, mp,
update_functions[i],
tooltip_update[i],
colors[i]);
}
}
/* Adding a timer : monitors will be updated every UPDATE_PERIOD
* seconds */
mp->timer = g_timeout_add_seconds(UPDATE_PERIOD, (GSourceFunc) monitors_update,
(gpointer) mp);
RET(p);
}
示例12: zcfg_load_interfaces
/**
* Load interfaces section.
* @param[in] option Option name.
* @param[in,out] array Resulting array.
* @return <0 - error. 0 - success. >0 - not found.
*/
int zcfg_load_interfaces(const config_setting_t *option, UT_array *array)
{
utarray_init(array, &ut_zif_pair_icd);
if (!option) {
return 1;
}
if (CONFIG_TYPE_LIST != option->type) {
return -1;
}
u_int count = (u_int) config_setting_length(option);
for (u_int i = 0; i < count; i++) {
zifpair_t if_pair;
const char *str;
config_setting_t *entry = config_setting_get_elem(option, i);
if (!config_setting_lookup_string(entry, ZCFG_LAN, &str)) {
ZLOG(LOG_ERR, "config:%s:%s: invalid or missing 'lan' property", option->parent->name, option->name);
goto fail;
}
strncpy(if_pair.lan, str, sizeof(if_pair.lan));
if (!config_setting_lookup_string(entry, ZCFG_WAN, &str)) {
ZLOG(LOG_ERR, "config:%s:%s: invalid or missing 'wan' property", option->parent->name, option->name);
goto fail;
}
strncpy(if_pair.wan, str, sizeof(if_pair.wan));
int affinity = 0;
if (!config_setting_lookup_int(entry, ZCFG_AFFINITY, &affinity)) {
ZLOG(LOG_ERR, "config:%s:%s: invalid or missing 'affinity' property", option->parent->name, option->name);
goto fail;
}
if ((affinity < 0) || affinity >= UINT16_MAX) {
ZLOG(LOG_ERR, "config:%s:%s: invalid 'affinity' value", option->parent->name, option->name);
goto fail;
}
if_pair.affinity = (uint16_t) affinity;
utarray_push_back(array, &if_pair);
}
return 0;
fail:
utarray_done(array);
return -1;
}
示例13: setup
static void setup(config_setting_t *settings)
{
if (settings != NULL) {
config_setting_lookup_string(settings, "apikey", &apikey);
config_setting_lookup_string(settings, "email", &email);
unsigned char *md5bytes = MD5((unsigned char *)email, strlen(email), NULL);
int i;
for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
sprintf(&md5email[i*2], "%02x", md5bytes[i]);
}
}
}
示例14: g_new0
/* Plugin constructor. */
static GtkWidget *wincmd_constructor(LXPanel *panel, config_setting_t *settings)
{
/* Allocate plugin context and set into Plugin private data pointer. */
WinCmdPlugin * wc = g_new0(WinCmdPlugin, 1);
GtkWidget * p;
const char *str;
int tmp_int;
/* Initialize to defaults. */
wc->button_1_command = WC_ICONIFY;
wc->button_2_command = WC_SHADE;
/* Load parameters from the configuration file. */
if (config_setting_lookup_string(settings, "Button1", &str))
{
if (g_ascii_strcasecmp(str, "shade") == 0)
wc->button_1_command = WC_SHADE;
else if (g_ascii_strcasecmp(str, "none") == 0)
wc->button_1_command = WC_NONE;
/* default is WC_ICONIFY */
}
if (config_setting_lookup_string(settings, "Button2", &str))
{
if (g_ascii_strcasecmp(str, "iconify") == 0)
wc->button_2_command = WC_ICONIFY;
else if (g_ascii_strcasecmp(str, "none") == 0)
wc->button_2_command = WC_NONE;
}
if (config_setting_lookup_string(settings, "image", &str))
wc->image = expand_tilda(str);
if (config_setting_lookup_int(settings, "Toggle", &tmp_int))
wc->toggle_preference = tmp_int != 0;
/* Default the image if unspecified. */
if (wc->image == NULL)
wc->image = g_strdup("window-manager");
/* Save construction pointers */
wc->settings = settings;
/* Allocate top level widget and set into Plugin widget pointer. */
p = lxpanel_button_new_for_icon(panel, wc->image, NULL, NULL);
lxpanel_plugin_set_data(p, wc, wincmd_destructor);
gtk_container_set_border_width(GTK_CONTAINER(p), 0);
gtk_widget_set_tooltip_text(p, _("Left click to iconify all windows. Middle click to shade them."));
/* Show the widget and return. */
return p;
}
示例15: print_layouts
void print_layouts(int num_frame)
{
config_setting_t *category_list, *category, *layout_list, *layout;
config_t layout_config;
int layout_length, i;
const char* ascii_image;
config_init(&layout_config);
config_read_file(&layout_config, "./layout.cfg");
category_list = config_lookup(&layout_config, "application.layout_group");
category = config_setting_get_elem(category_list, num_frame - MIN_NUM_FRAME);
layout_list = config_setting_get_member(category, "layout");
layout_length = config_setting_length(layout_list);
for(i = 0; i < layout_length; i++)
{
layout = config_setting_get_elem(layout_list, i);
config_setting_lookup_string(layout, "image", &ascii_image);
printf(" %c)\n", 'a' + i);
printf("%s\n", ascii_image);
}
config_destroy(&layout_config);
}