本文整理汇总了C++中config_read函数的典型用法代码示例。如果您正苦于以下问题:C++ config_read函数的具体用法?C++ config_read怎么用?C++ config_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_read函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例5: setup
void setup(void)
{
config_get_file();
config_read(configFile);
configure_debug(NULL,255,0);
GetDBParams();
db_connect();
}
示例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);
}
示例7: setup
void setup(void)
{
configure_debug(255,0);
config_read(configFile);
GetDBParams();
db_connect();
g_mime_init(0);
}
示例8: setup
void setup(void)
{
config_get_file();
config_read(configFile);
configure_debug(NULL,255,31);
pool = mempool_open();
A = Capa_new(pool);
}
示例9: setup
void setup(void)
{
configure_debug(255,0);
config_read(configFile);
GetDBParams();
db_connect();
auth_connect();
}
示例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 */
}
示例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");
}
示例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");
}
示例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;
}
示例14: setup
void setup(void)
{
configure_debug(511,0);
config_read(configFile);
GetDBParams();
db_connect();
auth_connect();
g_mime_init(0);
init_testuser1();
}
示例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);
}