Beispiel #1
0
static int init_from_file(char *file, const char *name, int value)
{
	FILE *fp;
	char line[1000];

	fp = fopen(file, "r");
	if (fp == NULL) {
		log_fatal(name, "Unable to open %s file: %s: %s", name, file, strerror(errno));
	}

	while (fgets(line, sizeof(line), fp) != NULL) {
		char *comment = strchr(line, '#');
		if (comment) {
			*comment = '\0';
		}
		char ip[33];
		if ((sscanf(line, "%32s", ip)) == EOF) {
			continue;
		}
		if (init_from_string(ip, value)) {
			log_fatal(name, "unable to parse %s file: %s", name, file);
		}
	}
	fclose(fp);

	return 0;
}
Beispiel #2
0
static void init_from_array(char **cidrs, size_t len, int value)
{
	for (int i=0; i < (int) len; i++) {
		init_from_string(cidrs[i], value);
	}
}
Beispiel #3
0
color color_factory::from_string(std::string const& css_color)
{
    color c;
    init_from_string(c, css_color);
    return c;
}