本文整理汇总了C++中parse_config函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_config函数的具体用法?C++ parse_config怎么用?C++ parse_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
struct match *list, *match;
struct pci_domain *pci_domain;
openconsole(&dev_null_r, &dev_stdcon_w);
pci_domain = pci_scan();
if (pci_domain) {
list = parse_config(argc < 2 ? NULL : argv[1]);
match = find_pci_device(pci_domain, list);
if (match)
syslinux_run_command(match->filename);
}
/* On error, return to the command line */
fputs("Error: no recognized network card found!\n", stderr);
return 1;
}
示例2: load_module
static int load_module(void)
{
int res = 0;
if (parse_config(0))
return AST_MODULE_LOAD_DECLINE;
res |= ast_register_translator(&speextolin);
res |= ast_register_translator(&lintospeex);
res |= ast_register_translator(&speexwbtolin16);
res |= ast_register_translator(&lin16tospeexwb);
res |= ast_register_translator(&speexuwbtolin32);
res |= ast_register_translator(&lin32tospeexuwb);
if (res) {
unload_module();
return res;
}
return res;
}
示例3: init_config
int init_config ()
{
FILE *f;
int returnedValue;
gconfig.port = UDP_LISTEN_PORT;
gconfig.sarefnum = IP_IPSEC_REFINFO; /* default use the latest we know */
gconfig.listenaddr = htonl(INADDR_ANY); /* Default is to bind (listen) to all interfaces */
gconfig.debug_avp = 0;
gconfig.debug_network = 0;
gconfig.packet_dump = 0;
gconfig.debug_tunnel = 0;
gconfig.debug_state = 0;
lnslist = NULL;
laclist = NULL;
deflac = (struct lac *) calloc (1, sizeof (struct lac));
f = fopen (gconfig.configfile, "r");
if (!f)
{
f = fopen (gconfig.altconfigfile, "r");
if (f)
{
l2tp_log (LOG_WARNING, "%s: Using old style config files %s and %s\n",
__FUNCTION__, gconfig.altconfigfile, gconfig.altauthfile);
strncpy (gconfig.authfile, gconfig.altauthfile,
sizeof (gconfig.authfile));
}
else
{
l2tp_log (LOG_CRIT, "%s: Unable to open config file %s or %s\n",
__FUNCTION__, gconfig.configfile, gconfig.altconfigfile);
return -1;
}
}
returnedValue = parse_config (f);
fclose (f);
return (returnedValue);
}
示例4: lxc_read_seccomp_config
int lxc_read_seccomp_config(struct lxc_conf *conf)
{
FILE *f;
int ret;
if (!conf->seccomp)
return 0;
#if HAVE_SCMP_FILTER_CTX
/* XXX for debug, pass in SCMP_ACT_TRAP */
conf->seccomp_ctx = seccomp_init(SCMP_ACT_ERRNO(31));
ret = !conf->seccomp_ctx;
#else
ret = seccomp_init(SCMP_ACT_ERRNO(31)) < 0;
#endif
if (ret) {
ERROR("failed initializing seccomp");
return -1;
}
/* turn of no-new-privs. We don't want it in lxc, and it breaks
* with apparmor */
if (seccomp_attr_set(
#if HAVE_SCMP_FILTER_CTX
conf->seccomp_ctx,
#endif
SCMP_FLTATR_CTL_NNP, 0)) {
ERROR("failed to turn off n-new-privs\n");
return -1;
}
f = fopen(conf->seccomp, "r");
if (!f) {
SYSERROR("failed to open seccomp policy file %s\n", conf->seccomp);
return -1;
}
ret = parse_config(f, conf);
fclose(f);
return ret;
}
示例5: main
int main(int argc, char **argv)
{
int err = 0;
lua_State *L;
setup_signal_handler();
/* ini file sets defaults for arguments*/
parse_config(inifile);
if (!global.inifile) {
log_error("could not open ini configuration %s\n", inifile);
}
/* parse arguments again, to override ini file */
parse_args(argc, argv, &err);
log_open(logfile);
locale_init();
#ifdef CRTDBG
init_crtdbg();
#endif
L = lua_init();
game_init();
bind_monsters(L);
err = eressea_run(L, luafile);
if (err) {
log_error("script %s failed with code %d\n", luafile, err);
return err;
}
#ifdef MSPACES
malloc_stats();
#endif
game_done();
lua_done(L);
log_close();
if (global.inifile) {
iniparser_freedict(global.inifile);
}
return 0;
}
示例6: map_
terrain_builder::terrain_builder(const config& level,
const gamemap* m, const std::string& offmap_image) :
map_(m),
tile_map_(map().w(), map().h()),
terrain_by_type_()
{
image::precache_file_existence("terrain/");
if(building_rules_.empty() && rules_cfg_){
// parse global terrain rules
parse_global_config(*rules_cfg_);
} else {
// use cached global rules but clear local rules
flush_local_rules();
}
// parse local rules
parse_config(level);
add_off_map_rule(offmap_image);
build_terrains();
}
示例7: read_config
void
read_config(FILE *conf)
{
struct stat stat_buf;
long size;
int sts;
size_t nread;
/* get length of file */
sts = fstat(fileno(conf), &stat_buf);
if (sts < 0) {
(void)fprintf(stderr, "%s: Failure to stat configuration file \"%s\": %s\n",
pmProgname, configfile, osstrerror());
exit(1);
}
size = (long)stat_buf.st_size;
/* create buffer */
conf_buffer = (char*)malloc(size+1*sizeof(char));
if (conf_buffer == NULL) {
(void)fprintf(stderr, "%s: Failure to create buffer for configuration file \"%s\"\n",
pmProgname, configfile);
exit(1);
}
conf_buffer_ptr = conf_buffer;
/* read whole file into buffer */
nread = fread(conf_buffer, sizeof(char), size, conf);
if (nread != size) {
(void)fprintf(stderr, "%s: Failure to read configuration file \"%s\" into buffer\n",
pmProgname, configfile);
exit(1);
}
conf_buffer[size] = '\0'; /* terminate the buffer */
if (parse_config(&the_tree) != 0)
exit(1);
}
示例8: main
int main(int ac, char *av[]) {
int rv = 0;
int sfd = setup_signalfd();
struct config *config = parse_config("amtredird.ini");
if (config && validate_config(config)) {
if (init_amt(config)) {
if (sfd != -1) {
rv = (run_server(config, sfd) == 0);
} else {
rv = 1;
}
teardown_amt(config);
}
} else {
rv = 1;
}
close(sfd);
free_config(config);
return rv;
}
示例9: main
int main (int argc, char **argv) {
signal (SIGSEGV, sig_segv_handler);
signal (SIGABRT, sig_abrt_handler);
log_level = 10;
args_parse (argc, argv);
printf (
"Telegram-client version " TG_VERSION ", Copyright (C) 2013 Vitaly Valtman\n"
"Telegram-client comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.\n"
"This is free software, and you are welcome to redistribute it\n"
"under certain conditions; type `show_license' for details.\n"
);
running_for_first_time ();
parse_config ();
get_terminal_attributes ();
#ifdef USE_LUA
if (lua_file) {
lua_init (lua_file);
}
#endif
#ifdef USE_PYTHON
if (python_file) {
python_init(python_file);
}
#endif
inner_main ();
#ifdef USE_PYTHON
if (python_file) {
python_finalize();
}
#endif
return 0;
}
示例10: conf_aliases
char *
conf_aliases(char *cfgpath)
{
struct table *table;
char *path;
char *p;
if (parse_config(env, cfgpath, 0))
exit(1);
table = table_find("aliases", NULL);
if (table == NULL)
return (PATH_ALIASES);
path = xstrdup(table->t_config, "conf_aliases");
p = strstr(path, ".db");
if (p == NULL || strcmp(p, ".db") != 0) {
return (path);
}
*p = '\0';
return (path);
}
示例11: main
int main(int argc, char **argv)
{
if (argc < 2)
{
printf("argc < 2\n");
return 0;
}
if (0 != parse_config(argv[1]))
return 0;
//fio_register_handler(FIO_CBF_SINGLE_THREAD, single_mode_handle);
//fio_register_handler(IPPROTO_UDP, handle_audp);
switch (sysconfig.single_thread)
{
case FIO_MODE_1_SND_OR_RCV /*2*/:
fio_register_handler(T_FIO_PKT_INTD, handle_dns_resp);
break;
case FIO_MODE_2CARDS /*3*/:
fio_register_handler(T_FIO_PKT_INTD, handle_udps_2cards);
break;
case FIO_MODE_N_BRG_OUT /*4*/:
fio_register_handler(T_FIO_PKT_INTD, handle_udps);
break;
default:
fio_register_handler(T_FIO_PKT_INTD, handle_udps_in);
break;
}
if (0 != fio_init() || 0 != fio_start())
return 0;
signal(SIGINT, fio_sigint_h);
fio_start_statistics();
fio_wait();
fio_shutdown();
return 0;
}
示例12: slog_init
/*
* Initialize slog library. Function parses config file and reads log
* level and save to file flag from config. First argument is file name
* where log will be saved and second argument conf is config file path
* to be parsedand third argument lvl is log level for this message.
*/
void slog_init(const char* fname, const char* conf, int lvl, int flvl, int t_safe)
{
int status = 0;
/* Set up default values */
slg.level = lvl;
slg.file_level = flvl;
slg.to_file = 0;
slg.pretty = 0;
slg.filestamp = 1;
slg.td_safe = t_safe;
/* Init mutex sync */
if (t_safe)
{
/* Init mutex attribute */
pthread_mutexattr_t m_attr;
if (pthread_mutexattr_init(&m_attr) ||
pthread_mutexattr_settype(&m_attr, PTHREAD_MUTEX_RECURSIVE) ||
pthread_mutex_init(&slog_mutex, &m_attr) ||
pthread_mutexattr_destroy(&m_attr))
{
printf("<%s:%d> %s: [ERROR] Can not initialize mutex: %d\n",
__FILE__, __LINE__, __FUNCTION__, errno);
slg.td_safe = 0;
}
}
/* Parse config file */
if (conf != NULL)
{
slg.fname = fname;
status = parse_config(conf);
}
/* Handle config parser status */
if (!status) slog(0, SLOG_INFO, "Initializing logger values without config");
else slog(0, SLOG_INFO, "Loading logger config from: %s", conf);
}
示例13: read_config
void read_config(char* file)
{
GKeyFile *config;
char *cur = hciattach_options;
const char *end = hciattach_options + sizeof(hciattach_options);
/* set first default values and then load configured ones */
init_config();
config = load_config(file);
parse_config(config);
load_bd_add();
/* set always configured options: use same configured baud-rate also for download, and ignore first 2 bytes (needed by bcm43341 and more recent brcm bt chip) */
cur += snprintf(cur, end-cur, "%s", "--use_baudrate_for_download --no2bytes");
/* concatenate configured options */
if ((cur < end) && (main_opts.enable_fork)) {
cur += snprintf(cur, end-cur," %s", "--enable_fork");
}
if ((cur < end) && (main_opts.enable_lpm)) {
cur += snprintf(cur, end-cur," %s", "--enable_lpm");
}
if ((cur < end) && (main_opts.enable_hci)) {
cur += snprintf(cur, end-cur," %s", "--enable_hci");
}
if ((cur < end) && (main_opts.set_baud_rate)) {
cur += snprintf(cur, end-cur," --baudrate %d", main_opts.baud_rate);
}
if ((cur < end) && (main_opts.dl_patch)) {
cur += snprintf(cur, end-cur," --patchram %s", main_opts.fw_patch);
}
if ((cur < end) && (main_opts.set_bd)) {
cur += snprintf(cur, end-cur," --bd_addr %s", main_opts.bd_add);
}
if ((cur < end) && (main_opts.set_scopcm)) {
cur += snprintf(cur, end-cur," --scopcm %s", main_opts.scopcm);
}
}
示例14: while
bool Config::read_from_sd()
{
Serial.print("Reading config from '");
Serial.print(CONFIG_FILE);
Serial.println("'...");
File configFile = SD.open(CONFIG_FILE);
if(!configFile) {
Serial.print("Unable to open config file '");
Serial.print(CONFIG_FILE);
Serial.println("'!");
return false;
}
String config;
while(configFile.available()) {
config += configFile.readString();
}
configFile.close();
return parse_config(config);
}
示例15: load_acl
static struct acl_data* load_acl(const char* config, struct plugin_handle* handle)
{
struct acl_data* data = parse_config(config);
if (!data)
return 0;
if (!data->file || !*data->file)
{
free_acl(data); data = 0;
set_error_message(handle, "No configuration file given, missing \"file=<filename>\" configuration option.");
return 0;
}
if (file_read_lines(data->file, data->users, &parse_line) == -1)
{
fprintf(stderr, "Unable to load %s\n", data->file);
set_error_message(handle, "Unable to load file");
}
return data;
}