Esempio n. 1
0
int settings_reread(const char *fname)
{
	CONFIG_REC *tempconfig;
	char *str;

	str = fname == NULL ? NULL : convert_home(fname);
	tempconfig = parse_configfile(str);
        g_free_not_null(str);

	if (tempconfig == NULL) {
		signal_emit("gui dialog", 2, "error", g_strerror(errno));
		return FALSE;
	}

	if (config_last_error(tempconfig) != NULL) {
		str = g_strdup_printf("Errors in configuration file:\n%s",
				      config_last_error(tempconfig));
		signal_emit("gui dialog", 2, "error", str);
		g_free(str);

		config_close(tempconfig);
                return FALSE;
	}

	config_close(mainconfig);
	mainconfig = tempconfig;
	config_last_modifycounter = mainconfig->modifycounter;

	signal_emit("setup changed", 0);
	signal_emit("setup reread", 1, mainconfig->fname);
        return TRUE;
}
PROCESS_THREAD(config_write_test, ev, data) {
    PROCESS_BEGIN();

    config_section_t *sect1, *sect2;

    config_init();
    config_open();

    sect1 = config_cnf_create_section(config_get());
    strcpy(sect1->name, "sect");
    config_section_set_int(sect1, "ololoint", -666);
    config_section_set_uint(sect1, "ololoUint", 1313);
    config_section_set_str(sect1, "ololostr", "znachenie");

    config_save();
    config_close();

    config_init();
    config_open();
////    sect2 = config_cnf_create_section(config_get());
////    strcpy(sect2->name, "sect");
////    config_section_set_int(sect2, "alalaint", -999);
////    config_section_set_uint(sect2, "alalaUint", 3131);
////    config_section_set_str(sect2, "alalastr", "justanother");
    config_save();
    config_close();

    ledd_on(PB5);

    PROCESS_END();
}
Esempio n. 3
0
int settings_reread(const char *fname)
{
	CONFIG_REC *tempconfig;
	char *str;

	if (fname == NULL) fname = "~/.irssi/config";

	str = convert_home(fname);
	tempconfig = parse_configfile(str);
	g_free(str);

	if (tempconfig == NULL) {
		signal_emit("gui dialog", 2, "error", g_strerror(errno));
		return FALSE;
	}

	if (config_last_error(tempconfig) != NULL) {
		str = g_strdup_printf(_("Errors in configuration file:\n%s"),
				      config_last_error(tempconfig));
		signal_emit("gui dialog", 2, "error", str);
		g_free(str);

		config_close(tempconfig);
                return FALSE;
	}

	config_close(mainconfig);
	mainconfig = tempconfig;

	signal_emit("setup changed", 0);
	signal_emit("setup reread", 0);
        return TRUE;
}
Esempio n. 4
0
static int theme_read(THEME_REC *theme, const char *path, const char *data)
{
	CONFIG_REC *config;
	THEME_READ_REC rec;
        char *str;

	config = config_open(data == NULL ? path : NULL, -1) ;
	if (config == NULL) {
		/* didn't exist or no access? */
		str = g_strdup_printf("Error reading theme file %s: %s",
				      path, g_strerror(errno));
		read_error(str);
		g_free(str);
		return FALSE;
	}

	if (data != NULL)
		config_parse_data(config, data, "internal");
        else
		config_parse(config);

	if (config_last_error(config) != NULL) {
		str = g_strdup_printf("Ignored errors in theme %s:\n%s",
				      theme->name, config_last_error(config));
		read_error(str);
                g_free(str);
	}

	theme->default_color =
		config_get_int(config, NULL, "default_color", -1);
	theme->info_eol = config_get_bool(config, NULL, "info_eol", FALSE);

	/* FIXME: remove after 0.7.99 */
	if (theme->default_color == 0 &&
	    config_get_int(config, NULL, "default_real_color", -1) != -1)
                theme->default_color = -1;
	theme_read_replaces(config, theme);

	if (data == NULL) {
		/* get the default abstracts from default theme. */
		CONFIG_REC *default_config;

		default_config = config_open(NULL, -1);
		config_parse_data(default_config, default_theme, "internal");
		theme_read_abstracts(default_config, theme);
		config_close(default_config);
	}
	theme_read_abstracts(config, theme);

	rec.theme = theme;
	rec.config = config;
	g_hash_table_foreach(default_formats,
			     (GHFunc) theme_read_modules, &rec);
	config_close(config);

        return TRUE;
}
Esempio n. 5
0
int parse_main(int argc UNUSED_PARAM, char **argv)
{
	const char *delims = "# \t";
	unsigned flags = PARSE_NORMAL;
	int mintokens = 0, ntokens = 128;

	opt_complementary = "-1:n+:m+:f+";
	getopt32(argv, "n:m:d:f:", &ntokens, &mintokens, &delims, &flags);
	//argc -= optind;
	argv += optind;
	while (*argv) {
		parser_t *p = config_open(*argv);
		if (p) {
			int n;
			char **t = xmalloc(sizeof(char *) * ntokens);
			while ((n = config_read(p, t, ntokens, mintokens, delims, flags)) != 0) {
				for (int i = 0; i < n; ++i)
					printf("[%s]", t[i]);
				puts("");
			}
			config_close(p);
		}
		argv++;
	}
	return EXIT_SUCCESS;
}
static inline bool load_offsets_from_string(struct graphics_offsets *offsets,
		const char *str)
{
	config_t *config;

	if (config_open_string(&config, str) != CONFIG_SUCCESS) {
		return false;
	}

	offsets->d3d8.present =
		(uint32_t)config_get_uint(config, "d3d8", "present");
	offsets->d3d8.reset =
		(uint32_t)config_get_uint(config, "d3d8", "reset");

	offsets->d3d9.present =
		(uint32_t)config_get_uint(config, "d3d9", "present");
	offsets->d3d9.present_ex =
		(uint32_t)config_get_uint(config, "d3d9", "present_ex");
	offsets->d3d9.present_swap =
		(uint32_t)config_get_uint(config, "d3d9", "present_swap");
	offsets->d3d9.reset =
		(uint32_t)config_get_uint(config, "d3d9", "reset");
	offsets->d3d9.reset_ex =
		(uint32_t)config_get_uint(config, "d3d9", "reset_ex");

	offsets->dxgi.present =
		(uint32_t)config_get_uint(config, "dxgi", "present");
	offsets->dxgi.resize =
		(uint32_t)config_get_uint(config, "dxgi", "resize");

	config_close(config);
	return true;
}
Esempio n. 7
0
int load_config(char *config)
{
	char buffer[512];
	int ret;

	if ((ret = config_open(config)) < 0)
	{
		// failed to load
		printf("\x1B[31mFailed to read config %s [%d]\033[0m\n", config, ret);
		return -2;
	}

	// read Router id
	config_get_value("router-id", buffer);
	router_id = atoi(buffer);

	// read Input ports
	config_get_value("input-ports", input_ports);

	// read outputs
	config_get_value("outputs", output_dest);

	// close config file and destroy memory
	config_close();

	return 0;

}
Esempio n. 8
0
int parse_main(int argc UNUSED_PARAM, char **argv)
{
	const char *delims = "# \t";
	char **t;
	unsigned flags = PARSE_NORMAL;
	int mintokens = 0, ntokens = 128;
	unsigned noout;

	opt_complementary = "-1";
	noout = 1 & getopt32(argv, "xn:+m:+d:f:+", &ntokens, &mintokens, &delims, &flags);
	//argc -= optind;
	argv += optind;

	t = xmalloc(sizeof(t[0]) * ntokens);
	while (*argv) {
		int n;
		parser_t *p = config_open(*argv);
		while ((n = config_read(p, t, ntokens, mintokens, delims, flags)) != 0) {
			if (!noout) {
				for (int i = 0; i < n; ++i)
					printf("[%s]", t[i]);
				puts("");
			}
		}
		config_close(p);
		argv++;
	}
	return EXIT_SUCCESS;
}
Esempio n. 9
0
File: session.c Progetto: ahf/irssi
/* SYNTAX: UPGRADE [<irssi binary path>] */
static void cmd_upgrade(const char *data)
{
	CONFIG_REC *session;
	char *session_file, *str;
	char *binary;

	if (*data == '\0')
		data = irssi_binary;

	if ((binary = g_find_program_in_path(data)) == NULL)
		cmd_return_error(CMDERR_PROGRAM_NOT_FOUND);

	/* save the session */
        session_file = g_strdup_printf("%s/session", get_irssi_dir());
	session = config_open(session_file, 0600);
        unlink(session_file);

	signal_emit("session save", 1, session);
        config_write(session, NULL, -1);
        config_close(session);

	/* data may contain some other program as well, like
	   /UPGRADE /usr/bin/screen irssi */
	str = g_strdup_printf("%s --noconnect --session=%s --home=%s --config=%s",
			      binary, session_file, get_irssi_dir(), get_irssi_config());
	g_free(binary);
	g_free(session_file);
        session_args = g_strsplit(str, " ", -1);
        g_free(str);

	signal_emit("gui exit", 0);
}
Esempio n. 10
0
static int nprocessors_onln(void)
{
	char **l = NULL;
	parser_t *p = config_open("/proc/stat");
	int ret = 0;

	if (p) {
		while (config_read(p, &l, 2, 1, " ", 0))
			if (l[0][0] == 'c'
				&& l[0][1] == 'p'
				&& l[0][2] == 'u'
				&& isdigit(l[0][3]))
				++ret;
	} else if ((p = config_open("/proc/cpuinfo"))) {
#if defined __sparc__
		while (config_read(p, &l, 2, 2, "\0:", PARSE_NORMAL))
			if (strncmp("ncpus active", l[0], 12) == 0) {
				ret = atoi(l[1]);
				break;
			}
#else
		while (config_read(p, &l, 2, 2, "\0:\t", PARSE_NORMAL))
			if (strcmp("processor", l[0]) == 0)
				++ret;
#endif
	}
	config_close(p);
	return ret != 0 ? ret : 1;
}
Esempio n. 11
0
static int nprocessors_conf(void)
{
	int ret = 0;
	DIR *dir = opendir("/sys/devices/system/cpu");

	if (dir) {
		struct dirent64 *dp;

		while ((dp = readdir64(dir))) {
			if (dp->d_type == DT_DIR
				&& dp->d_name[0] == 'c'
				&& dp->d_name[1] == 'p'
				&& dp->d_name[2] == 'u'
				&& isdigit(dp->d_name[3]))
				++ret;
		}
		closedir(dir);
	} else
	{
#if defined __sparc__
		char **l = NULL;
		parser_t *p = config_open("/proc/stat");
		while (config_read(p, &l, 2, 2, "\0:", PARSE_NORMAL))
			if (strncmp("ncpus probed", l[0], 13) == 0) {
				ret = atoi(l[1]);
				break;
			}
		config_close(p);
#else
		ret = nprocessors_onln();
#endif
	}
	return ret != 0 ? ret : 1;
}
Esempio n. 12
0
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);
}
Esempio n. 13
0
static void read_config(char **pc, int npc, char **fc, int nfc)
{
	char *buf;
	parser_t *parser;
	int pc_ofs = 0, fc_ofs = 0, section = -1;

	pc[0] = fc[0] = NULL;

	parser = config_open("/etc/sestatus.conf");
	while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) {
		if (strcmp(buf, "[process]") == 0) {
			section = 1;
		} else if (strcmp(buf, "[files]") == 0) {
			section = 2;
		} else {
			if (section == 1 && pc_ofs < npc -1) {
				pc[pc_ofs++] = xstrdup(buf);
				pc[pc_ofs] = NULL;
			} else if (section == 2 && fc_ofs < nfc - 1) {
				fc[fc_ofs++] = xstrdup(buf);
				fc[fc_ofs] = NULL;
			}
		}
	}
	config_close(parser);
}
Esempio n. 14
0
/* Set sysctl's from a conf file. Format example:
 * # Controls IP packet forwarding
 * net.ipv4.ip_forward = 0
 */
static int sysctl_handle_preload_file(const char *filename)
{
	char *token[2];
	parser_t *parser;

	parser = config_open(filename);
	/* Must do it _after_ config_open(): */
	xchdir("/proc/sys");
	/* xchroot("/proc/sys") - if you are paranoid */

//TODO: ';' is comment char too
//TODO: comment may be only at line start. "var=1 #abc" - "1 #abc" is the value
// (but _whitespace_ from ends should be trimmed first (and we do it right))
//TODO: "var==1" is mishandled (must use "=1" as a value, but uses "1")
// can it be fixed by removing PARSE_COLLAPSE bit?
	while (config_read(parser, token, 2, 2, "# \t=", PARSE_NORMAL)) {
		char *tp;
		sysctl_dots_to_slashes(token[0]);
		tp = xasprintf("%s=%s", token[0], token[1]);
		sysctl_act_recursive(tp);
		free(tp);
	}
	if (ENABLE_FEATURE_CLEAN_UP)
		config_close(parser);
	return 0;
}
Esempio n. 15
0
opencc_t opencc_open(const char* config_file) {
  if (!lib_initialized) {
    lib_initialize();
  }
  OpenccDesc* opencc;
  opencc = (OpenccDesc*)malloc(sizeof(OpenccDesc));
  opencc->dict_chain = NULL;
  opencc->converter = converter_open();
  converter_set_conversion_mode(opencc->converter, OPENCC_CONVERSION_FAST);
  if (config_file == NULL) {
    /* TODO load default */
    assert(0);
  } else {
    /* Load config */
    Config* config = config_open(config_file);
    if (config == (Config*)-1) {
      errnum = OPENCC_ERROR_CONFIG;
      return (opencc_t)-1;
    }
    opencc->dict_chain = config_get_dict_chain(config);
    converter_assign_dictionary(opencc->converter, opencc->dict_chain);
    config_close(config);
  }
  return (opencc_t)opencc;
}
Esempio n. 16
0
opencc_t opencc_open(const char * config_file, const char* home_path)
{
    if (!lib_initialized)
        lib_initialize();

    opencc_desc * opencc;
    opencc = (opencc_desc *) malloc(sizeof(opencc_desc));

    opencc->dictionary_set = NULL;
    opencc->converter = converter_open();
    converter_set_conversion_mode(opencc->converter, OPENCC_CONVERSION_FAST);

    /* 加載默認辭典 */
    int retval;
    if (config_file == NULL)
        retval = 0;
    else
    {
        config_t config = config_open(config_file, home_path);

        if (config == (config_t) -1)
        {
            errnum = OPENCC_ERROR_CONFIG;
            return (opencc_t) -1;
        }

        opencc->dictionary_set = config_get_dictionary_set(config);
        converter_assign_dictionary(opencc->converter, opencc->dictionary_set);

        config_close(config);
    }

    return (opencc_t) opencc;
}
Esempio n. 17
0
File: main.c Progetto: dstenb/tfm
void atexit_handler()
{
	config_close();
	program_close();
	ui_close();
	states_clear();
	dwindow_free(data.win[0]);
	dwindow_free(data.win[1]);
}
Esempio n. 18
0
int main(int argc, char *argv[])
{
    int initialize_flag;
    char config_value[255];
    int i;
    int total_lanes;

    char acqcfgpath[127];

    char command_buffer[255];
    char base_dir[255];
    sprintf(base_dir, "%s/polonator/G.007/acquisition", getenv("HOME"));
    sprintf(log_dir, "%s/logs", base_dir);
    sprintf(command_buffer, "mkdir -p %s", log_dir);
    system(command_buffer);

    if(argc == 3){
        initialize_flag = atoi(argv[2]);
    }
    else{
        initialize_flag = 0;
    }
    fprintf(stdout, "the initialize flag is %d\n", initialize_flag);

    /* Open config file */
    strcpy(acqcfgpath, getenv("POLONATOR_PATH"));
    strcat(acqcfgpath, "/config_files/polonator-acq.cfg");
    config_open(acqcfgpath);
    if(!config_getvalue("stagealign_wells_per_fc", config_value)){
        p_log("ERROR:\tPolonator-stagealign: config_getval(key stagealign_wells_per_fc) returned no value");
        exit(0);
    }
    total_lanes = atoi(config_value);
    if(!config_getvalue("stagealign_outputdir", config_value)){
        p_log("ERROR:\tPolonator-stagealign: config_getval(key stagealign_outputdir) returned no value");
        exit(0);
    }
    strcpy(output_directory, base_dir);
    strcat(output_directory, "/");
    strcat(output_directory, config_value);
    config_close();

    fprintf(stdout, "=%s=\n", output_directory);

    /* Make sure stagealign output directory exists */
    mkdir(output_directory, S_IRWXU);
    sprintf(log_string, "Create new directory %s :", output_directory);
    p_log_simple(log_string);


    for(i = 0; i < total_lanes; i++)
    {
        stagealign(atoi(argv[1]), i, initialize_flag);
    }
    return 0;
}
Esempio n. 19
0
File: lwan.c Progetto: diviaki/lwan
static bool setup_from_config(lwan_t *lwan)
{
    config_t conf;
    config_line_t line;
    bool has_listener = false;
    char path_buf[PATH_MAX];
    const char *path;

    path = get_config_path(path_buf);
    lwan_status_info("Loading configuration file: %s", path);

    lwan->url_map_trie = lwan_trie_new(destroy_urlmap);

    if (!config_open(&conf, path))
        return false;

    while (config_read_line(&conf, &line)) {
        switch (line.type) {
        case CONFIG_LINE_TYPE_LINE:
            if (!strcmp(line.line.key, "keep_alive_timeout"))
                lwan->config.keep_alive_timeout = parse_int(line.line.value,
                            default_config.keep_alive_timeout);
            else if (!strcmp(line.line.key, "quiet"))
                lwan->config.quiet = parse_bool(line.line.value,
                            default_config.quiet);
            else if (!strcmp(line.line.key, "reuse_port"))
                lwan->config.reuse_port = parse_bool(line.line.value,
                            default_config.reuse_port);
            else
                config_error(&conf, "Unknown config key: %s", line.line.key);
            break;
        case CONFIG_LINE_TYPE_SECTION:
            if (!has_listener) {
                has_listener = true;
                if (!strcmp(line.section.name, "listener"))
                    parse_listener(&conf, &line, lwan);
                else
                    config_error(&conf, "Unknown section type: %s", line.section.name);
            } else {
                config_error(&conf, "Only one listener supported");
            }
            break;
        case CONFIG_LINE_TYPE_SECTION_END:
            config_error(&conf, "Unexpected section end");
        }
    }

    if (conf.error_message) {
        lwan_status_critical("Error on config file \"%s\", line %d: %s",
              path, conf.line, conf.error_message);
    }

    config_close(&conf);

    return true;
}
Esempio n. 20
0
static CONFIG_NODE *sbar_find_item_with_defaults(const char *statusbar, const char *item,
                                                 gboolean create)
{
	CONFIG_REC *config, *close_config;
	CONFIG_NODE *node;

	close_config = NULL;
	config = mainconfig;
	node = sbar_node(statusbar, FALSE);

	if (node == NULL) {
		/* we are looking up defaults from the internal config */
		close_config = config = config_open(NULL, -1);
		config_parse_data(config, default_config, "internal");
		node = config_sbar_node(config, statusbar, FALSE);
	}

	if (node == NULL) {
		printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, statusbar);
		if (close_config != NULL)
			config_close(close_config);
		return NULL;
	}

	node = config_sbar_items_section(config, node, create);

	if (node == NULL || (!create && config_node_section(config, node, item, -1) == NULL)) {
		printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item);
		if (close_config != NULL)
			config_close(close_config);
		return NULL;
	}

	if (config != mainconfig) {
		/* we need to copy default to user config */
		node = statusbar_copy_config(config, node, sbar_node(statusbar, TRUE));
	}

	if (close_config != NULL)
		config_close(close_config);

	return node;
}
Esempio n. 21
0
void endservent(void)
{
	__UCLIBC_MUTEX_LOCK(mylock);
	if (servp) {
		config_close(servp);
		servp = NULL;
	}
	serv_stayopen = 0;
	__UCLIBC_MUTEX_UNLOCK(mylock);
}
Esempio n. 22
0
void setservent(int stayopen)
{
	__UCLIBC_MUTEX_LOCK(mylock);
	if (servp)
		config_close(servp);
	servp = config_open(_PATH_SERVICES);
	if (stayopen)
		serv_stayopen = 1;
	__UCLIBC_MUTEX_UNLOCK(mylock);
}
Esempio n. 23
0
int main(int argc, char *argv[])
{
  SHORT_PROCESS_NAME = basename_safe(argv[0]);
  PROCESS_NAME = argv[0];

  if (argc != 2)
  {
    printf("Usage: %s <endpoint>\n", argv[0]);
    return -1;
  }

  if (config_init(argv[1]) != 0)
  {
    perror("Creating config");
    return -1;
  }

  unsigned int size;
  const char *everything = config_get_all_values(&size);

  printf("%s\n", everything);

  int ret = config_set("Foo", "Bar", "Win");

  printf("Set = %d\n", ret);

  char *val;

  if (config_get("foo", "bar", &val) != 0)
  {
    printf("Failed to get value\n");
  } else
  {
    printf("Val = %s\n", val);
    g_free(val);
  }

  if (config_get("Somethings", "Missing", &val) != 0)
  {
    printf("Failed to get value\n");
  } else
  {
    if (val == NULL)
    {
      printf("It's not set\n");
    } else
    {
      printf("Value is %s\n", val);
    }
  }

  config_close();

  return 0;
}
Esempio n. 24
0
void settings_deinit(void)
{
        g_source_remove(timeout_tag);
	signal_remove("gui exit", (SIGNAL_FUNC) sig_autosave);

        g_free_not_null(last_error_msg);
	g_hash_table_foreach(settings, (GHFunc) settings_hash_free, NULL);
	g_hash_table_destroy(settings);

	if (mainconfig != NULL) config_close(mainconfig);
}
Esempio n. 25
0
static void theme_read_module(THEME_REC *theme, const char *module)
{
	CONFIG_REC *config;

	config = config_open(theme->path, -1);
	if (config != NULL)
		config_parse(config);

	theme_init_module(theme, module, config);

	if (config != NULL) config_close(config);
}
Esempio n. 26
0
int modinfo_main(int argc UNUSED_PARAM, char **argv)
{
	struct modinfo_env env;
	char name[MODULE_NAME_LEN];
	struct utsname uts;
	parser_t *parser;
	char *colon, *tokens[2];
	unsigned opts;
	unsigned i;

	env.field = NULL;
	opt_complementary = "-1"; /* minimum one param */
	opts = getopt32(argv, "fdalvpF:0", &env.field);
	env.tags = opts & OPT_TAGS ? opts & OPT_TAGS : OPT_TAGS;
	argv += optind;

	uname(&uts);
	parser = config_open2(
		xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, uts.release, CONFIG_DEFAULT_DEPMOD_FILE),
		fopen_for_read
	);
	if (!parser) {
		parser = config_open2(
			xasprintf("%s/%s", CONFIG_DEFAULT_MODULES_DIR, CONFIG_DEFAULT_DEPMOD_FILE),
			xfopen_for_read
		);
	}

	while (config_read(parser, tokens, 2, 1, "# \t", PARSE_NORMAL)) {
		colon = last_char_is(tokens[0], ':');
		if (colon == NULL)
			continue;
		*colon = '\0';
		filename2modname(tokens[0], name);
		for (i = 0; argv[i]; i++) {
			if (fnmatch(argv[i], name, 0) == 0) {
				modinfo(tokens[0], uts.release, &env);
				argv[i] = (char *) "";
			}
		}
	}
	if (ENABLE_FEATURE_CLEAN_UP)
		config_close(parser);

	for (i = 0; argv[i]; i++) {
		if (argv[i][0]) {
			modinfo(argv[i], uts.release, &env);
		}
	}

	return 0;
}
Esempio n. 27
0
void settings_deinit(void)
{
        g_source_remove(timeout_tag);
	signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
	signal_remove("gui exit", (SIGNAL_FUNC) sig_autosave);

	g_slist_foreach(last_invalid_modules, (GFunc) g_free, NULL);
	g_slist_free(last_invalid_modules);

	g_hash_table_foreach(settings, (GHFunc) settings_hash_free, NULL);
	g_hash_table_destroy(settings);

	if (mainconfig != NULL) config_close(mainconfig);
}
Esempio n. 28
0
static int check_securetty(void)
{
    char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */
    parser_t *parser = config_open2("/etc/securetty", fopen_for_read);
    while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) {
        if (strcmp(buf, short_tty) == 0)
            break;
        buf = NULL;
    }
    config_close(parser);
    /* buf != NULL here if config file was not found, empty
     * or line was found which equals short_tty */
    return buf != NULL;
}
Esempio n. 29
0
static gboolean sbar_node_isdefault(const char *name)
{
	CONFIG_REC *config;
	CONFIG_NODE *node;

	/* read the default statusbar settings from internal config */
	config = config_open(NULL, -1);
	config_parse_data(config, default_config, "internal");

	node = config_sbar_node(config, name, FALSE);

	config_close(config);

	return node != NULL ? TRUE : FALSE;
}
Esempio n. 30
0
static void rtnl_tab_initialize(const char *file, const char **tab, int size)
{
	char *token[2];
	parser_t *parser = config_open2(file, fopen_for_read);
	while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) {
		int id = bb_strtou(token[0], NULL, 0);
		if (id < 0 || id > size) {
			bb_error_msg("database %s is corrupted at line %d",
				file, parser->lineno);
			break;
		}
		tab[id] = xstrdup(token[1]);
	}
	config_close(parser);
}