本文整理汇总了C++中cfg_get_str函数的典型用法代码示例。如果您正苦于以下问题:C++ cfg_get_str函数的具体用法?C++ cfg_get_str怎么用?C++ cfg_get_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cfg_get_str函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: db_common_sql_build_query
void db_common_sql_build_query(VSTRING *query, CFG_PARSER *parser)
{
const char *myname = "db_common_sql_build_query";
char *table;
char *select_field;
char *where_field;
char *additional_conditions;
/*
* Build "old style" query: "select %s from %s where %s"
*/
if ((table = cfg_get_str(parser, "table", NULL, 1, 0)) == 0)
msg_fatal("%s: 'table' parameter not defined", myname);
if ((select_field = cfg_get_str(parser, "select_field", NULL, 1, 0)) == 0)
msg_fatal("%s: 'select_field' parameter not defined", myname);
if ((where_field = cfg_get_str(parser, "where_field", NULL, 1, 0)) == 0)
msg_fatal("%s: 'where_field' parameter not defined", myname);
additional_conditions = cfg_get_str(parser, "additional_conditions",
"", 0, 0);
vstring_sprintf(query, "SELECT %s FROM %s WHERE %s='%%s' %s",
select_field, table, where_field,
additional_conditions);
myfree(table);
myfree(select_field);
myfree(where_field);
myfree(additional_conditions);
}
开发者ID:ystk,项目名称:debian-postfix,代码行数:32,代码来源:db_common.c
示例2: influxdb_put
void
influxdb_put(const char *id, double value)
{
char url[1024];
cfg_root(root);
const char *urlprefix = cfg_get_str(root, CFG("influxdb", "url"), NULL);
const char *db = cfg_get_str(root, CFG("influxdb", "db"), NULL);
const char *username = cfg_get_str(root, CFG("influxdb", "username"), NULL);
const char *password = cfg_get_str(root, CFG("influxdb", "password"), NULL);
if(urlprefix == NULL || db == NULL || username == NULL || password == NULL)
return;
snprintf(url, sizeof(url), "%s/db/%s/series?u=%s&p=%s",
urlprefix, db, username, password);
htsmsg_t *doc = htsmsg_create_list();
htsmsg_t *item = htsmsg_create_map();
htsmsg_add_str(item, "name", id);
htsmsg_t *columns = htsmsg_create_list();
htsmsg_add_str(columns, NULL, "value");
htsmsg_add_msg(item, "columns", columns);
htsmsg_t *points = htsmsg_create_list();
htsmsg_t *point = htsmsg_create_list();
htsmsg_add_dbl(point, NULL, value);
htsmsg_add_msg(points, NULL, point);
htsmsg_add_msg(item, "points", points);
htsmsg_add_msg(doc, NULL, item);
char *data = htsmsg_json_serialize_to_str(doc, 0);
htsmsg_destroy(doc);
size_t len = strlen(data);
FILE *f = fmemopen(data, len, "r");
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &libsvc_curl_waste_output);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_READDATA, (void *)f);
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)len);
CURLcode result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if(result)
trace(LOG_ERR, "CURL Failed %s error %d", url, result);
fclose(f);
free(data);
}
开发者ID:andoma,项目名称:hapd,代码行数:59,代码来源:influxdb.c
示例3: load_app_locations
void load_app_locations()
{
char buff[256];
char *val;
int i;
for (i=0;i<NUM_APPS;i++)
{
sprintf(buff, "default_application_location_%s", app_names[i]);
if (NULL != (val = cfg_get_str("ApplicationLocations",buff)))
{
if (val[0] == '/' || !strcmp(val, "not available"))
{
app_locations[i] = val;
if (verbose)
printf("%s - \'%s\' loaded\n", buff, val);
}
else
{
printf("Config file Error: %s == \'%s\' not allowed\n", buff, val);
}
}
else
if (verbose)
printf("%s - default \'%s\' loaded\n", buff, app_locations[i]);
}
}
开发者ID:AquaSoftGmbH,项目名称:mjpeg,代码行数:27,代码来源:pipes.c
示例4: hexchat_pluginpref_get_str_real
static int
hexchat_pluginpref_get_str_real (hexchat_plugin *pl, const char *var, char *dest, int dest_len)
{
char *confname, *canon, *cfg, *unescaped_value;
char buf[512];
canon = g_strdup (pl->name);
canonalize_key (canon);
confname = g_strdup_printf ("%s%caddon_%s.conf", get_xdir(), G_DIR_SEPARATOR, canon);
g_free (canon);
if (!g_file_get_contents (confname, &cfg, NULL, NULL))
{
g_free (confname);
return 0;
}
g_free (confname);
if (!cfg_get_str (cfg, var, buf, sizeof(buf)))
{
g_free (cfg);
return 0;
}
unescaped_value = g_strcompress (buf);
g_strlcpy (dest, unescaped_value, dest_len);
g_free (unescaped_value);
g_free (cfg);
return 1;
}
开发者ID:IotaSpencer,项目名称:hexchat,代码行数:31,代码来源:plugin.c
示例5: dotdoozer_parse
static int
dotdoozer_parse(job_t *j, htsmsg_t *target)
{
SHA_CTX ctx;
uint8_t digest[20];
const char *buildenv = htsmsg_get_str(target, "buildenv");
if(buildenv == NULL)
return 0;
cfg_root(root);
const char *source = cfg_get_str(root, CFG("buildenvs", buildenv, "source"),
NULL);
if(source == NULL) {
snprintf(j->errmsg, sizeof(j->errmsg), "Don't know about buildenv: %s",
buildenv);
return DOOZER_PERMANENT_FAIL;
}
// We are going to build in a chroot
j->projectdir_internal = "/project";
j->buildenv_source = tstrdup(source);
// Compute SHA1 of source URL, this is the source ID
SHA1((void *)source, strlen(source), digest);
bin2hex(j->buildenv_source_id, sizeof(j->buildenv_source_id),
digest, sizeof(digest));
// Compute SHA1 of source URL + all build deps, this is the modified ID
SHA1_Init(&ctx);
SHA1_Update(&ctx, source, strlen(source));
htsmsg_t *builddeps = htsmsg_get_list(target, "builddeps");
if(builddeps != NULL) {
htsmsg_field_t *f;
int count = 0;
HTSMSG_FOREACH(f, builddeps) {
if(f->hmf_type != HMF_STR) {
snprintf(j->errmsg, sizeof(j->errmsg),
"Not all builddeps are strings");
return DOOZER_PERMANENT_FAIL;
}
count++;
}
j->num_builddeps = count;
const char **bds = talloc_zalloc(count * sizeof(char *));
count = 0;
HTSMSG_FOREACH(f, builddeps) {
bds[count++] = tstrdup(f->hmf_str);
SHA1_Update(&ctx, f->hmf_str, strlen(f->hmf_str));
}
开发者ID:dreamcat4,项目名称:doozer-agent,代码行数:57,代码来源:dotdoozer.c
示例6: cfg_get_int
int cfg_get_int(FIL * fl, const char * section, const char * label, int def)
{
char buf[16];
if (cfg_get_str(fl, section, label, buf))
return atoi(buf);
else
return def;
}
开发者ID:pculka,项目名称:SkyDrop,代码行数:9,代码来源:cfg.cpp
示例7: cfg_get_int
int
cfg_get_int (char *cfg, char *var)
{
char str[128];
if (!cfg_get_str (cfg, var, str, sizeof (str)))
return 0;
return atoi (str);
}
开发者ID:IshaqAzmi,项目名称:hexchat,代码行数:10,代码来源:cfgfiles.c
示例8: cfg_get_float
float
cfg_get_float(char *sec, char *ent)
{
char *val;
val = cfg_get_str(sec,ent);
if (NULL == val)
return -1;
return atof(val);
}
开发者ID:AquaSoftGmbH,项目名称:mjpeg,代码行数:10,代码来源:parseconfig.c
示例9: create_heaps
static void
create_heaps(void)
{
cfg_root(root);
const char *d;
d = cfg_get_str(root, CFG("projectdir"), NULL);
if(d == NULL) {
trace(LOG_ERR, "No 'projectdir' configured, giving up");
exit(1);
}
project_heap_mgr = create_heap(d);
d = cfg_get_str(root, CFG("buildenvdir"), NULL);
if(d == NULL) {
trace(LOG_ERR, "No 'buildenvdir' configured, giving up");
exit(1);
}
buildenv_heap_mgr = create_heap(d);
}
开发者ID:dreamcat4,项目名称:doozer-agent,代码行数:20,代码来源:main.c
示例10: cfg_get_color
int
cfg_get_color (char *cfg, char *var, int *r, int *g, int *b)
{
char str[128];
if (!cfg_get_str (cfg, var, str, sizeof (str)))
return 0;
sscanf (str, "%04x %04x %04x", r, g, b);
return 1;
}
开发者ID:IshaqAzmi,项目名称:hexchat,代码行数:11,代码来源:cfgfiles.c
示例11: CfgQueryStringExamples
int
CfgQueryStringExamples(int verbose, struct cfg *cfg, char *args[])
{
unsigned char buf[1024], *row[10];
FILE *in;
int ret;
if ((in = fopen(args[0], "r")) == NULL) {
PMNO(errno);
return -1;
}
while ((ret = csv_row_fread(in, buf, 1024, row, 10, ',', CSV_QUOTES | CSV_TRIM)) > 0) {
int success = atoi(row[0]);
tcase_printf(verbose, "%s:\n", row[1]);
cfg_clear(cfg);
if (cfg_load_cgi_query_string(cfg, row[1], row[1] + tcslen(row[1])) == -1) {
if (success) {
ret = -1;
AMSG("");
goto out;
}
} else if (!success) {
ret = -1;
AMSG("Supposed to fail");
goto out;
}
if (verbose) {
iter_t iter;
const tchar *name;
tchar dst[512];
cfg_iterate(cfg, &iter);
while ((name = cfg_next(cfg, &iter))) {
if (cfg_get_str(cfg, dst, 512, NULL, name) == -1) {
errno = ENOENT;
PMNO(errno);
return -1;
}
tcase_printf(verbose, "\t%s=%s\n", name, dst);
}
}
}
out:
fclose(in);
return ret;
}
开发者ID:OpenSharp,项目名称:NDceRpc,代码行数:53,代码来源:CfgQueryStringExamples.c
示例12: ignore_read_next_entry
static char *
ignore_read_next_entry (char *my_cfg, struct ignore *ignore)
{
char tbuf[1024];
/* Casting to char * done below just to satisfy compiler */
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "mask", tbuf, sizeof (tbuf));
if (!my_cfg)
return NULL;
ignore->mask = g_strdup (tbuf);
}
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "type", tbuf, sizeof (tbuf));
ignore->type = atoi (tbuf);
}
return my_cfg;
}
开发者ID:DCBoland,项目名称:hexchat,代码行数:21,代码来源:ignore.c
示例13: get_uid_gid
static void
get_uid_gid(void)
{
cfg_root(root);
const char *user = cfg_get_str(root, CFG("user"), "nobody");
const char *group = cfg_get_str(root, CFG("group"), "nogroup");
const struct passwd *p = getpwnam(user);
if(p == NULL) {
trace(LOG_ERR, "Unable to find UID for user %s. Exiting", user);
exit(1);
}
build_uid = p->pw_uid;
const struct group *g = getgrnam(group);
if(g == NULL) {
trace(LOG_ERR, "Unable to find GID for group %s. Exiting", group);
exit(1);
}
build_gid = g->gr_gid;
}
开发者ID:dreamcat4,项目名称:doozer-agent,代码行数:22,代码来源:main.c
示例14: load_common
/* load the common things */
void load_common()
{
char *val;
int i;
if (NULL != (val = cfg_get_str("Studio","Encode_Input_file")))
sprintf(enc_inputfile, val);
else
sprintf(enc_inputfile, "test.avi");
if (NULL != (val = cfg_get_str("Studio","Encode_Output_file")))
sprintf(enc_outputfile, val);
else
sprintf(enc_outputfile,"%s/output.mpg", getenv("HOME"));
if (NULL != (val = cfg_get_str("Studio","Encode_Audio_file")))
sprintf(enc_audiofile, val);
else
sprintf(enc_audiofile, "/tmp/audio.mp2");
if (NULL != (val = cfg_get_str("Studio","Encode_Video_file")))
sprintf(enc_videofile, val);
else
sprintf(enc_videofile, "/tmp/video.m1v");
if (NULL != (val = cfg_get_str("Studio","Encode_Player_use")))
sprintf(selected_player, val);
else
sprintf(selected_player, "no player selected");
if (NULL != (val = cfg_get_str("Studio","Encode_Video_Preview")))
if ( 0 == strcmp(val,"yes"))
use_yuvplay_pipe = 1;
else
use_yuvplay_pipe = 0;
if (-1 != (i = cfg_get_int("Studio","Encoding_four_pel_motion_compensation")))
fourpelmotion = i;
if (-1 != (i = cfg_get_int("Studio","Encoding_two_pel_motion_compensation")))
twopelmotion = i;
if (NULL != (val = cfg_get_str("Studio","Encode_Bicubic_Scaling")))
if ( 0 == strcmp(val,"yes"))
use_yuvplay_pipe = 1;
else
use_yuvplay_pipe = 0;
if (-1 != (i = cfg_get_int("Studio","Encoding_save_on_exit")))
saveonexit = i;
if (-1 != (i = cfg_get_int("Studio","Encoding_dist_enhanced_settings")))
enhanced_settings = i;
}
开发者ID:AquaSoftGmbH,项目名称:mjpeg,代码行数:55,代码来源:config_encode.c
示例15: hexchat_pluginpref_get_str
int
hexchat_pluginpref_get_str (hexchat_plugin *pl, const char *var, char *dest)
{
int fh;
int l;
char confname[64];
char *canon;
char *cfg;
struct stat st;
canon = g_strdup (pl->name);
canonalize_key (canon);
sprintf (confname, "addon_%s.conf", canon);
g_free (canon);
/* partly borrowed from palette.c */
fh = hexchat_open_file (confname, O_RDONLY, 0, 0);
if (fh == -1)
{
return 0;
}
fstat (fh, &st);
cfg = malloc (st.st_size + 1);
if (!cfg)
{
close (fh);
return 0;
}
cfg[0] = '\0';
l = read (fh, cfg, st.st_size);
if (l >= 0)
{
cfg[l] = '\0';
}
if (!cfg_get_str (cfg, var, dest, 512)) /* dest_len is the same as buffer size in set */
{
free (cfg);
close (fh);
return 0;
}
free (cfg);
close (fh);
return 1;
}
开发者ID:grimreaper,项目名称:hexchat,代码行数:51,代码来源:plugin.c
示例16: cfg_get_int_with_result
int
cfg_get_int_with_result (char *cfg, char *var, int *result)
{
char str[128];
if (!cfg_get_str (cfg, var, str, sizeof (str)))
{
*result = 0;
return 0;
}
*result = 1;
return atoi (str);
}
开发者ID:IshaqAzmi,项目名称:hexchat,代码行数:14,代码来源:cfgfiles.c
示例17: load_config
int
load_config (void)
{
char *cfg, *sp;
int res, val, i;
g_assert(check_config_dir () == 0);
if (!g_file_get_contents (default_file (), &cfg, NULL, NULL))
return -1;
/* If the config is incomplete we have the default values loaded */
load_default_config();
i = 0;
do
{
switch (vars[i].type)
{
case TYPE_STR:
cfg_get_str (cfg, vars[i].name, (char *) &prefs + vars[i].offset,
vars[i].len);
break;
case TYPE_BOOL:
case TYPE_INT:
val = cfg_get_int_with_result (cfg, vars[i].name, &res);
if (res)
*((int *) &prefs + vars[i].offset) = val;
break;
}
i++;
}
while (vars[i].name);
g_free (cfg);
if (prefs.hex_gui_win_height < 138)
prefs.hex_gui_win_height = 138;
if (prefs.hex_gui_win_width < 106)
prefs.hex_gui_win_width = 106;
sp = strchr (prefs.hex_irc_user_name, ' ');
if (sp)
sp[0] = 0; /* spaces in username would break the login */
return 0;
}
开发者ID:brendenbus,项目名称:hexchat,代码行数:47,代码来源:cfgfiles.c
示例18: load_script_data
void load_script_data(void)
{
int i;
char *val;
if ( NULL != (val = cfg_get_str("Scriptdata","Script_name")))
sprintf(script_name, val);
else
sprintf(script_name,"script.sh");
if ( -1 != (i = cfg_get_int("Scriptdata","Script_distributed")))
if ( (i == 0) || (i == 1) )
script_use_distributed = i;
if ( -1 != (i = cfg_get_int("Scriptdata","Script_MPEG1")))
if ( i >= 0 || i <= 8)
script.mpeg1 = i;;
if ( -1 != (i = cfg_get_int("Scriptdata","Script_MPEG2")))
if ( i >= 0 || i <= 8)
script.mpeg2 = i;;
if ( -1 != (i = cfg_get_int("Scriptdata","Script_GENERIC")))
if ( i >= 0 || i <= 8)
script.generic = i;;
if ( -1 != (i = cfg_get_int("Scriptdata","Script_VCD")))
if ( i >= 0 || i <= 8)
script.vcd = i;;
if ( -1 != (i = cfg_get_int("Scriptdata","Script_SVCD")))
if ( i >= 0 || i <= 8)
script.svcd = i;;
if ( -1 != (i = cfg_get_int("Scriptdata","Script_DVD")))
if ( i >= 0 || i <= 8)
script.dvd = i;;
if ( -1 != (i = cfg_get_int("Scriptdata","Script_YUV2LAV")))
if ( i >= 0 || i <= 8)
script.yuv2lav = i;;
}
开发者ID:AquaSoftGmbH,项目名称:mjpeg,代码行数:43,代码来源:config_encode.c
示例19: ignore_read_next_entry
static char *
ignore_read_next_entry (char *my_cfg, struct ignore *ignore)
{
char tbuf[1024];
char mask[256];
/* Casting to char * done below just to satisfy compiler */
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "mask ", mask);
ignore->mask = strdup (mask);
}
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "ctcp ", (char *) tbuf);
ignore->ctcp = atoi ((char *) tbuf);
}
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "private ", (char *) tbuf);
ignore->priv = atoi ((char *) tbuf);
}
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "channel ", (char *) tbuf);
ignore->chan = atoi ((char *) tbuf);
}
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "notice ", (char *) tbuf);
ignore->noti = atoi ((char *) tbuf);
}
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "invite ", (char *) tbuf);
ignore->invi = atoi ((char *) tbuf);
}
if (my_cfg)
{
my_cfg = cfg_get_str (my_cfg, "unignore ", (char *) tbuf);
ignore->unignore = atoi ((char *) tbuf);
}
return my_cfg;
}
开发者ID:UIKit0,项目名称:picogui,代码行数:45,代码来源:ignore.c
示例20: cfg_push_sec
/**\brief 将一个section压入section栈*/
static AM_ErrorCode_t cfg_push_sec (AM_CFG_Parser_t *parser)
{
AM_CFG_SecStack_t *sec;
const char *name;
AM_TRY(cfg_get_str(parser, 0, &name));
sec = AM_MEM_ALLOC_TYPE0(AM_CFG_SecStack_t);
if(!sec)
return AM_CFG_ERR_NO_MEM;
sec->name = AM_MEM_Strdup(name);
if(!sec->name)
return AM_CFG_ERR_NO_MEM;
sec->bottom = parser->sec_stack;
parser->sec_stack = sec;
return AM_SUCCESS;
}
开发者ID:felipemogollon,项目名称:dvb,代码行数:21,代码来源:am_cfg_input.c
注:本文中的cfg_get_str函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论