• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parse_config函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parse_config函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_config函数的具体用法?C++ parse_config怎么用?C++ parse_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_config函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Acidburn0zzz,项目名称:syslinux-mac,代码行数:21,代码来源:ethersel.c


示例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;
}
开发者ID:GGGO,项目名称:asterisk,代码行数:21,代码来源:codec_speex.c


示例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);
}
开发者ID:HouzuoGuo,项目名称:xl2tpd,代码行数:40,代码来源:file.c


示例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;
}
开发者ID:ChaosCloud,项目名称:lxc,代码行数:40,代码来源:seccomp.c


示例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;
}
开发者ID:stm2,项目名称:server,代码行数:40,代码来源:main.c


示例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();
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:22,代码来源:builder.cpp


示例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);
}
开发者ID:Aconex,项目名称:pcp,代码行数:39,代码来源:config.c


示例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;
}
开发者ID:andrey-malets,项目名称:amtredird,代码行数:22,代码来源:main.c


示例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;
}
开发者ID:bastianh,项目名称:tg,代码行数:39,代码来源:main.c


示例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);
}
开发者ID:alexander-naumov,项目名称:OpenSMTPD,代码行数:22,代码来源:makemap.c


示例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;
}
开发者ID:a5216652166,项目名称:ddd,代码行数:39,代码来源:fio.c


示例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);
}
开发者ID:sib8th,项目名称:php_tracer,代码行数:45,代码来源:slog.c


示例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);
    }
}
开发者ID:TeamElevate,项目名称:edison,代码行数:38,代码来源:bluetooth_rfkill_event.c


示例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);
 }
开发者ID:Luminoth,项目名称:coffeenotif,代码行数:23,代码来源:es_config.cpp


示例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;
}
开发者ID:q3k,项目名称:uhub,代码行数:23,代码来源:mod_auth_simple.c


示例16: main_initialize

void main_initialize(char *arg1, char *arg2) {
    struct stat st; /* buffer for stat */

    ssl_init(); /* initialize SSL library */
    sthreads_init(); /* initialize critical sections & SSL callbacks */
    parse_config(arg1, arg2);
    log_open();
    s_log(LOG_NOTICE, "%s", stunnel_info());

    /* check if certificate exists */
    if(!options.key) /* key file not specified */
        options.key=options.cert;
    if(options.option.cert) {
        if(stat(options.key, &st)) {
            ioerror(options.key);
            exit(1);
        }
#ifndef USE_WIN32
        if(st.st_mode & 7)
            s_log(LOG_WARNING, "Wrong permissions on %s", options.key);
#endif /* defined USE_WIN32 */
    }
}
开发者ID:niubl,项目名称:camera_project,代码行数:23,代码来源:stunnel.c


示例17: traverse_layout

static void traverse_layout(GenerateWebsiteWorkspace *workspace, xmlNodePtr node) {
    CongNodePtr child;

    g_assert(node);

    g_message("traverse_layout <%s>", node->name);

    for (child=node->children; child; child=child->next) {
        if (cong_node_is_element(child, NULL, "config")) {
            parse_config(workspace, child);
        } else if (cong_node_is_element(child, NULL, "copyright")) {
            parse_copyright(workspace, child);
        } else if (cong_node_is_element(child, NULL, "headlink")) {
            parse_headlink(workspace, child);
        } else if (cong_node_is_element(child, NULL, "style")) {
            parse_style(workspace, child);
        } else if (cong_node_is_element(child, NULL, "toc")) {
            parse_toc(workspace, child);
        } else if (cong_node_is_element(child, NULL, "notoc")) {
            parse_notoc(workspace, child);
        }
    }
}
开发者ID:GNOME,项目名称:conglomerate,代码行数:23,代码来源:plugin-website.c


示例18: tmain

int tmain (int argc, char **argv) {
//  signal (SIGSEGV, sig_segv_handler);
//  signal (SIGABRT, sig_abrt_handler);

  log_level = 10;

  args_parse (argc, argv);
  running_for_first_time ();
  parse_config ();


  get_terminal_attributes ();

  #ifdef USE_LUA
  if (lua_file) {
    lua_init (lua_file);
  }
  #endif

  inner_main ();

  return 0;
}
开发者ID:Ken2713,项目名称:sigram,代码行数:23,代码来源:tmain.c


示例19: parse_config

void terrain_builder::add_off_map_rule(const std::string& image)
{
	// Build a config object
	config cfg;

	config &item = cfg.add_child("terrain_graphics");

	config &tile = item.add_child("tile");
	tile["x"] = "0";
	tile["y"] = "0";
	tile["type"] = t_translation::write_terrain_code(t_translation::OFF_MAP_USER);

	config &tile_image = tile.add_child("image");
	tile_image["layer"] = "-1000";
	tile_image["name"] = image;

	item["probability"] = "100";
	item["no_flag"] = "base";
	item["set_flag"] = "base";

	// Parse the object
	parse_config(cfg);
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:23,代码来源:builder.cpp


示例20: main

int main(int argc, char **argv)
{
    int err = 0;
    lua_State *L;
    dictionary *d = 0;
    setup_signal_handler();
    message_handle_missing(MESSAGE_MISSING_REPLACE);
    /* parse arguments again, to override ini file */
    err = parse_args(argc, argv);
    if (err != 0) {
        return (err > 0) ? 0 : err;
    }
    d = parse_config(inifile);
    if (!d) {
        log_error("could not open ini configuration %s\n", inifile);
    }

    locale_init();

    L = lua_init(d);
    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;
    }
    game_done();
    lua_done(L);
    log_close();
    stats_write(stdout, "");
    stats_close();
    if (d) {
        iniparser_freedict(d);
    }
    return 0;
}
开发者ID:ennorehling,项目名称:eressea,代码行数:37,代码来源:main.c



注:本文中的parse_config函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parse_config_file函数代码示例发布时间:2022-05-30
下一篇:
C++ parse_common_args函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap