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

C++ config_read函数代码示例

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

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



在下文中一共展示了config_read函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: read_config_from_file

static void
read_config_from_file (const char *filename)
{
  FILE *fp;

  fp = fopen (filename, "r");
  if (fp != NULL) {
    config_t conf;

    config_init (&conf);

    /*
    if (verbose)
      fprintf (stderr, "%s: reading configuration from %s\n",
               guestfs_int_program_name, filename);
    */

    if (config_read (&conf, fp) == CONFIG_FALSE) {
      fprintf (stderr,
               _("%s: %s: line %d: error parsing configuration file: %s\n"),
               guestfs_int_program_name, filename, config_error_line (&conf),
               config_error_text (&conf));
      exit (EXIT_FAILURE);
    }

    if (fclose (fp) == -1) {
      perror (filename);
      exit (EXIT_FAILURE);
    }

    config_lookup_bool (&conf, "read_only", &read_only);

    config_destroy (&conf);
  }
}
开发者ID:FengYang,项目名称:libguestfs,代码行数:35,代码来源:config.c


示例2: net_beginService

void net_beginService() {
  // initializes the W5100 and the TCP server for the user interface

  config_read(&cfg);
  uint8_t sn[4]={0};
  //Init and config ethernet device w5100
  W5100.init();
  W5100.setMACAddress(cfg.mac);
  W5100.setIPAddress(cfg.ip);
  W5100.setGatewayIp(cfg.gw);
  toSubnetMask(cfg.subnet, sn);
  W5100.setSubnetMask(sn);

	printf_P(PSTR("ip: %u.%u.%u.%u/%u:%u\n\r"), cfg.ip[0], cfg.ip[1], cfg.ip[2], cfg.ip[3], cfg.subnet, cfg.port);
  printf_P(PSTR("subnet %u.%u.%u.%u\n\r"), sn[0], sn[1], sn[2], sn[3]);
	printf_P(PSTR("mac: %x:%x:%x:%x:%x:%x\n\r"), cfg.mac[0], cfg.mac[1], cfg.mac[2], cfg.mac[3], cfg.mac[4], cfg.mac[5]);
	printf_P(PSTR("gw: %u.%u.%u.%u\n\r"), cfg.gw[0], cfg.gw[1], cfg.gw[2], cfg.gw[3]);
	printf_P(PSTR("db: %u.%u.%u.%u:%u/%s\n\r"), cfg.ip_db[0], cfg.ip_db[1], cfg.ip_db[2], cfg.ip_db[3], cfg.port_db, cfg.name_db);
	printf_P(PSTR("cookie: %s\n\r"), cfg.cookie_db);
	printf_P(PSTR("function for inserting into DB: %s/%s\n\r"), cfg.doc_db, cfg.func_db);



  // Create the first server socket
  socket(FIRST_SERVER_SOCK, SnMR::TCP, cfg.port, 0);
  while(!listen(FIRST_SERVER_SOCK)){
    // wait 100ms and try again
    wdt_delay_ms(100);
  }
  // connect to db, if do send to db 
  // Create client to db
  // Port of the client can be arbitary, but it should be different then the port of ui server
  // connect_db(cfg.port+1);
}
开发者ID:nEDM-TUM,项目名称:Temperature-Sensor-System,代码行数:34,代码来源:networking.cpp


示例3: read_config

void FAST_FUNC read_config(const char *file)
{
	parser_t *parser;
	const struct config_keyword *k;
	unsigned i;
	char *token[2];

	for (i = 0; i < KWS_WITH_DEFAULTS; i++)
		keywords[i].handler(keywords[i].def, keywords[i].var);

	parser = config_open(file);
	while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) {
		for (k = keywords, i = 0; i < ARRAY_SIZE(keywords); k++, i++) {
			if (strcasecmp(token[0], k->keyword) == 0) {
				if (!k->handler(token[1], k->var)) {
					bb_error_msg("can't parse line %u in %s",
							parser->lineno, file);
					/* reset back to the default value */
					k->handler(k->def, k->var);
				}
				break;
			}
		}
	}
	config_close(parser);

	server_config.start_ip = ntohl(server_config.start_ip);
	server_config.end_ip = ntohl(server_config.end_ip);
}
开发者ID:losierb,项目名称:android-busybox,代码行数:29,代码来源:files.c


示例4: tcl_loaddb

static int
tcl_loaddb(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
{
    if(argc != 1)
    {
	sprintf(interp->result, WRONG_NUMBER_OF_ARGUMENTS, argv[0]);
	return TCL_OK;
    }
    else
    {
	ya_result return_code;

	config_data *config = NULL;
	/* Initialise configuration file */
	if(FAIL(config_init(S_CONFIGDIR, &config)))
	{
	    return EXIT_FAILURE;
	}

	/* Read configuration file */
	if(FAIL(config_read("main", &config)))
	{
	    return EXIT_FAILURE;
	}

	/* Read configuration file */
	if(FAIL(config_read("zone", &config)))
	{
	    return EXIT_FAILURE;
	}

	if(FAIL(return_code = database_load(&server_context->db_zdb, config->data_path, config->zones)))
	{
	    OSDEBUG(termout, "error: %r\n", return_code);
	    
	    return return_code;
	}

	sprintf(interp->result, "done");

	return TCL_OK;
    }


    return TCL_OK;
}
开发者ID:koodaamo,项目名称:yadifa,代码行数:46,代码来源:tcl_cmd.c


示例5: setup

void setup(void)
{
	config_get_file();
	config_read(configFile);
	configure_debug(NULL,255,0);
	GetDBParams();
	db_connect();
}
开发者ID:Alexander-KI,项目名称:dbmail,代码行数:8,代码来源:check_dbmail_common.c


示例6: config_load

void config_load(const char *file)
{
  FILE *f = config_open(file, config_paths, "r");
  if (!f)
    return;
  config_read(f);
  fclose(f);
}
开发者ID:Hummer12007,项目名称:nav,代码行数:8,代码来源:config.c


示例7: setup

void setup(void)
{
	configure_debug(255,0);
	config_read(configFile);
	GetDBParams();
	db_connect();
	g_mime_init(0);
}
开发者ID:alniaky,项目名称:dbmail,代码行数:8,代码来源:check_dbmail_server.c


示例8: setup

void setup(void)
{
    config_get_file();
    config_read(configFile);
    configure_debug(NULL,255,31);
    pool = mempool_open();
    A = Capa_new(pool);
}
开发者ID:Alexander-KI,项目名称:dbmail,代码行数:8,代码来源:check_dbmail_capa.c


示例9: setup

void setup(void)
{
	configure_debug(255,0);
	config_read(configFile);
	GetDBParams();
	db_connect();
	auth_connect();
}
开发者ID:alniaky,项目名称:dbmail,代码行数:8,代码来源:check_dbmail_mailboxstate.c


示例10: main

/** Reads the configuration file and then starts the main loop */
int main(int argc, char **argv) {

	s_config *config = config_get_config();
	config_init();

	parse_commandline(argc, argv);

	/* Initialize the config */
	config_read(config->configfile);
	config_validate();

	/* Initializes the linked list of connected clients */
	client_list_init();

	/* Init the signals to catch chld/quit/etc */
	init_signals();


	if (restart_orig_pid) {
		/*
		 * We were restarted and our parent is waiting for us to talk to it over the socket
		 */
		get_clients_from_parent();

		/*
		 * At this point the parent will start destroying itself and the firewall. Let it finish it's job before we continue
		 */
		while (kill(restart_orig_pid, 0) != -1) {
			debug(LOG_INFO, "Waiting for parent PID %d to die before continuing loading", restart_orig_pid);
			sleep(1);
		}

		debug(LOG_INFO, "Parent PID %d seems to be dead. Continuing loading.");
	}

	if (config->daemon) {

		debug(LOG_INFO, "Forking into background");

		switch(safe_fork()) {
			case 0: /* child */
				setsid();
				append_x_restartargv();
				main_loop();
				break;

			default: /* parent */
				exit(0);
				break;
		}
	}
	else {
		append_x_restartargv();
		main_loop();
	}

	return(0); /* never reached */
}
开发者ID:GaomingPan,项目名称:wifidog,代码行数:59,代码来源:gateway.c


示例11: sig_sesman_reload_cfg

void DEFAULT_CC
sig_sesman_reload_cfg(int sig)
{
    int error;
    struct config_sesman *cfg;
    char cfg_file[256];

    log_message(LOG_LEVEL_WARNING, "receiving SIGHUP %d", 1);

    if (g_getpid() != g_pid)
    {
        LOG_DBG("g_getpid() [%d] differs from g_pid [%d]", g_getpid(), g_pid);
        return;
    }

    cfg = g_malloc(sizeof(struct config_sesman), 1);

    if (0 == cfg)
    {
        log_message(LOG_LEVEL_ERROR, "error creating new config:  - keeping old cfg");
        return;
    }

    if (config_read(cfg) != 0)
    {
        log_message(LOG_LEVEL_ERROR, "error reading config - keeping old cfg");
        g_free(cfg);
        return;
    }

    /* stop logging subsystem */
    log_end();

    /* replace old config with new readed one */
    g_cfg = cfg;

    g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);

    /* start again logging subsystem */
    error = log_start(cfg_file, "XRDP-sesman");

    if (error != LOG_STARTUP_OK)
    {
        char buf[256];

        switch (error)
        {
            case LOG_ERROR_MALLOC:
                g_printf("error on malloc. cannot restart logging. log stops here, sorry.\n");
                break;
            case LOG_ERROR_FILE_OPEN:
                g_printf("error reopening log file [%s]. log stops here, sorry.\n", getLogFile(buf, 255));
                break;
        }
    }

    log_message(LOG_LEVEL_INFO, "configuration reloaded, log subsystem restarted");
}
开发者ID:340211173,项目名称:xrdp,代码行数:58,代码来源:sig.c


示例12: read_config

static void read_config(void) {
	char *filename = NULL;
	FILE *file = open_config_file(&filename);

	if (config_read(config, file) != CONFIG_TRUE)
		die("%s:%d %s", filename, config_error_line(config), config_error_text(config));

	if (fclose(file) == EOF) perror_die("fclose");
}
开发者ID:eatnumber1,项目名称:macspoof,代码行数:9,代码来源:macspoof.c


示例13: config_read

/* This is the main entry point.  XMMS calls this function to find anything
 * else that it needs to know about this plugin.
 */
VisPlugin *get_vplugin_info(void)
{
	/* Depends on whether we're plotting pcm data or freq data */
	config_read(NULL, NULL);
	blursk_genrender();

	/* return the info */
	return &blursk_vp;
}
开发者ID:PyroOS,项目名称:Pyro,代码行数:12,代码来源:blursk.cpp


示例14: setup

void setup(void)
{
	configure_debug(511,0);
	config_read(configFile);
	GetDBParams();
	db_connect();
	auth_connect();
	g_mime_init(0);
	init_testuser1();
}
开发者ID:jinwon,项目名称:dbmail,代码行数:10,代码来源:check_dbmail_mailbox.c


示例15: setup

/*
 *
 * the test fixtures
 *
 */
void setup(void)
{
	reallyquiet = 1;
	configure_debug(255,0);
	config_read(configFile);
	GetDBParams();
	db_connect();
	auth_connect();
	do_add("testfailuser","testpass","md5-hash",0,0,NULL,NULL);
}
开发者ID:alniaky,项目名称:dbmail,代码行数:15,代码来源:check_dbmail_user.c


示例16: setup

void setup(void)
{
	configure_debug(255,0);
	config_read(configFile);
	GetDBParams();
	db_connect();
	if (! g_thread_supported () ) g_thread_init (NULL);
	auth_connect();
	init_testuser1();
}
开发者ID:alniaky,项目名称:dbmail,代码行数:10,代码来源:check_dbmail_imapd.c


示例17: create_file_names_for_track

int
create_file_names_for_track (_main_data * main_data, int track, char **wfp,
			     char **efp)
{
  static char *buffer;
  int rc;
  char *conv_str = NULL;
  GtkWidget *main_window = main_window_handler(MW_REQUEST_MW, NULL, NULL);

  rc = parse_rx_format_string (&buffer,
			       ((char *) config_read (CONF_CDDB_FORMATSTR)),
			       track, main_data->disc_artist,
			       main_data->disc_title, main_data->disc_year,
			       main_data->track[track].title);
  if (rc < 0)
    {
      err_handler (GTK_WINDOW(main_window), RX_PARSING_ERR,
		   _
		   ("Check if the filename format string contains format characters other than %a %# %v %y or %s."));
      return 0;
    }

  if (buffer[0] == 0)
    strcpy (buffer, main_data->track[track].title);

  conv_str = g_locale_from_utf8 (buffer, -1, NULL, NULL, NULL);

  remove_non_unix_chars (conv_str);
  convert_slashes (conv_str, '-');
  if ((int) config_read (CONF_GNRL_CONVSPC))
    {
      convert_spaces (conv_str, '_');
    }

  if (wfp)
    mk_strcat (wfp, wd, conv_str, wfext, NULL);
  if (efp)
    mk_strcat (efp, ed, conv_str, ecfext, NULL);

  g_free (conv_str);

  return 1;
}
开发者ID:alip2890,项目名称:Rippix,代码行数:43,代码来源:misc_utils.c


示例18: setup

void setup(void)
{
	config_get_file();
	config_read(configFile);
	configure_debug(NULL,255,0);
	GetDBParams();
	db_connect();
	auth_connect();
	init_testuser1();
	queue_pool = mempool_open();
}
开发者ID:Alexander-KI,项目名称:dbmail,代码行数:11,代码来源:check_dbmail_imapd.c


示例19: config_load

void config_load()
{
    memset(&AQCONFIG,0,sizeof(AQCONFIG));
    config_read();
    if ((AQCONFIG.magic!=MAGIC) || (AQCONFIG.version!=VERSION))
    {
        config_defaults();
        config_save();
    }
    
}
开发者ID:aqleds,项目名称:firmware,代码行数:11,代码来源:config.c


示例20: preset_read

/* Read the presets from the "blursk-presets" file */
void preset_read(void)
{
	gchar		*filename;
	static int	did_once = FALSE;
	char		*str;
	preset_t	*item, *scan, *lag;
	FILE		*fp;
	char		linebuf[1024];

	/* if we already did this, then don't do it again */
	if (did_once)
		return;
	did_once = TRUE;

	/* scan the "blursk-presets" file for section names (preset names) */
	filename = g_strconcat(g_get_home_dir(), "/.xmms/blursk-presets", NULL);
	fp = fopen(filename, "r");
	while (fp && fgets(linebuf, sizeof linebuf, fp))
	{
		/* skip if not a section name */
		if (linebuf[0] != '[' || (str = strchr(linebuf, ']')) == NULL)
			continue;
		*str = '\0';

		/* allocate a struct for storing this info */
		item = (preset_t *)malloc(sizeof(preset_t));
		item->title = g_strdup(linebuf + 1);

		/* add this to the list of presets, keeping the
		 * list sorted by title.
		 */
		for (scan = preset_list, lag = NULL;
		     scan && strcasecmp(scan->title, item->title) < 0;
		     lag = scan, scan = scan->next)
		{
		}
		item->next = scan;
		if (lag)
			lag->next = item;
		else
			preset_list = item;

		/* increment the number of presets */
		preset_qty++;
	}
	if (fp)
		fclose(fp);

	/* Read the configuration data for each preset */
	for (item = preset_list; item; item = item->next)
	{
		config_read(item->title, &item->conf);
	}
}
开发者ID:PyroOS,项目名称:Pyro,代码行数:55,代码来源:preset.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ config_read_file函数代码示例发布时间:2022-05-30
下一篇:
C++ config_perror函数代码示例发布时间: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