Diff

Differences From Artifact [de1fe284bf]:

To Artifact [9a2b349279]:


809
810
811
812
813
814
815
816
817
818
819
820
821
822

823
824
825
826
827
828
829
 *   global variables.  It may cause the program to abort with a failure
 *   if the configuration is unreadable or unparsable.  Due to this fact,
 *   it should only be called during start-up and not from the main loop.
 *
 */
void parse_config(void) {

	config_t *config = NULL;
	config_setting_t *config_setting = NULL;
	struct ce *config_entry = NULL;
	int result = 0;
	int i = 0;
	const char *facstr = NULL;
	

	config_init(config);
	result = config_read_file(config, "test.config");
	if (result == CONFIG_FALSE) {
		if (config_error_type(config) == CONFIG_ERR_PARSE) {
			fprintf (stderr, "Error parsing config file %s, line %d: %s\n",
				config_error_file(config),
				config_error_line(config),







|






>







809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
 *   global variables.  It may cause the program to abort with a failure
 *   if the configuration is unreadable or unparsable.  Due to this fact,
 *   it should only be called during start-up and not from the main loop.
 *
 */
void parse_config(void) {

	config_t cf, *config;
	config_setting_t *config_setting = NULL;
	struct ce *config_entry = NULL;
	int result = 0;
	int i = 0;
	const char *facstr = NULL;
	
	config = &cf;
	config_init(config);
	result = config_read_file(config, "test.config");
	if (result == CONFIG_FALSE) {
		if (config_error_type(config) == CONFIG_ERR_PARSE) {
			fprintf (stderr, "Error parsing config file %s, line %d: %s\n",
				config_error_file(config),
				config_error_line(config),
856
857
858
859
860
861
862
863
864

865
866
867
868
869
870

871
872
873
874
875
876
877
878
879
880
881

882

883

884

885

886

887

888
889
890
891
892
893
894
895
896

	if (packet_cache_len < 0) {
		packet_cache_len = USE_CACHE_DEF_LEN;
		fprintf(stderr, "config size TTL negative - using default");
	}
#endif

	config_lookup_string(config, "log.facility", &facstr);
	i = 0;

	while (&facenum[i] != NULL) {
		if (strcasecmp(facenum[i].string, facstr) == 0) {
			conf.log_facility = facenum[i].num;
			break;
		} else {
			i++;

		}
	}
	
	config_lookup_int(config, "config.queueno", &conf.queueno);
	
	if (conf.queueno < 0) {
		conf.queueno = 1;
		fprintf(stderr, "queueno negative - using default");
	}

	config_setting = config_lookup(config, "blacklistbl");

	parse_config_bl_list(config_setting, 1);

	config_setting = config_lookup(config, "whitelistbl");

	parse_config_bl_list(config_setting, 2);

	config_setting = config_lookup(config, "blacklist");

	parse_config_bl_list(config_setting, 3);

	config_setting = config_lookup(config, "whitelist");

	parse_config_bl_list(config_setting, 4);
	
}

parse_config_bl_list(config_setting_t *c, int type) {

	struct config_entry *ce, *tmp;
	int i = 0, len = 0;
	char *setting;







|

>
|
|
|
|
|
|
>











>
|
>

>
|
>

>
|
>

>
|
|







857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906

	if (packet_cache_len < 0) {
		packet_cache_len = USE_CACHE_DEF_LEN;
		fprintf(stderr, "config size TTL negative - using default");
	}
#endif

	result = config_lookup_string(config, "log.facility", &facstr);
	i = 0;
	if (result == CONFIG_TRUE) {
		while (&facenum[i] != NULL) {
			if (strcasecmp(facenum[i].string, facstr) == 0) {
				conf.log_facility = facenum[i].num;
				break;
			} else {
				i++;
			}
		}
	}
	
	config_lookup_int(config, "config.queueno", &conf.queueno);
	
	if (conf.queueno < 0) {
		conf.queueno = 1;
		fprintf(stderr, "queueno negative - using default");
	}

	config_setting = config_lookup(config, "blacklistbl");
	if (config_setting != NULL) {
		parse_config_bl_list(config_setting, 1);
	}
	config_setting = config_lookup(config, "whitelistbl");
	if (config_setting != NULL) {
		parse_config_bl_list(config_setting, 2);
	}
	config_setting = config_lookup(config, "blacklist");
	if (config_setting != NULL) {
		parse_config_bl_list(config_setting, 3);
	}
	config_setting = config_lookup(config, "whitelist");
	if (config_setting != NULL) {
		parse_config_bl_list(config_setting, 4);
	}
}

parse_config_bl_list(config_setting_t *c, int type) {

	struct config_entry *ce, *tmp;
	int i = 0, len = 0;
	char *setting;