Lines Matching +full:static +full:- +full:config
1 /*-
36 #include "config.h"
41 static void enable_cache(struct configuration *,const char *, int);
42 static struct configuration_entry *find_create_entry(struct configuration *,
44 static int get_number(const char *, int, int);
45 static enum cache_policy_t get_policy(const char *);
46 static int get_yesno(const char *);
47 static int check_cachename(const char *);
48 static void check_files(struct configuration *, const char *, int);
49 static void set_keep_hot_count(struct configuration *, const char *, int);
50 static void set_negative_policy(struct configuration *, const char *,
52 static void set_negative_time_to_live(struct configuration *,
54 static void set_positive_policy(struct configuration *, const char *,
56 static void set_perform_actual_lookups(struct configuration *, const char *,
58 static void set_positive_time_to_live(struct configuration *,
60 static void set_suggested_size(struct configuration *, const char *,
62 static void set_threads_num(struct configuration *, int);
63 static int strbreak(char *, char **, int);
65 static int
90 static struct configuration_entry *
91 find_create_entry(struct configuration *config,
98 entry = configuration_find_entry(config, entry_name);
102 res = add_configuration_entry(config, entry);
114 static void
115 enable_cache(struct configuration *config, const char *entry_name, int flag)
120 entry = find_create_entry(config, entry_name);
121 entry->enabled = flag;
125 static void
126 set_positive_time_to_live(struct configuration *config,
138 entry = find_create_entry(config, entry_name);
139 memcpy(&entry->positive_cache_params.max_lifetime,
141 memcpy(&entry->mp_cache_params.max_lifetime,
147 static void
148 set_negative_time_to_live(struct configuration *config,
160 entry = find_create_entry(config, entry_name);
162 memcpy(&entry->negative_cache_params.max_lifetime,
168 static void
169 set_positive_confidence_threshold(struct configuration *config,
178 entry = find_create_entry(config, entry_name);
180 entry->positive_cache_params.confidence_threshold = conf_thresh;
185 static void
186 set_negative_confidence_threshold(struct configuration *config,
194 entry = find_create_entry(config, entry_name);
196 entry->negative_cache_params.confidence_threshold = conf_thresh;
203 static void
204 set_keep_hot_count(struct configuration *config,
213 entry = find_create_entry(config, entry_name);
215 entry->positive_cache_params.max_elemsize = count;
217 entry = find_create_entry(config, entry_name);
219 entry->negative_cache_params.max_elemsize = count;
224 static void
225 set_positive_policy(struct configuration *config,
233 entry = find_create_entry(config, entry_name);
235 entry->positive_cache_params.policy = policy;
240 static void
241 set_negative_policy(struct configuration *config,
249 entry = find_create_entry(config, entry_name);
251 entry->negative_cache_params.policy = policy;
256 static void
257 set_perform_actual_lookups(struct configuration *config,
265 entry = find_create_entry(config, entry_name);
267 entry->perform_actual_lookups = flag;
272 static void
273 set_suggested_size(struct configuration *config,
279 assert(config != NULL);
283 entry = find_create_entry(config, entry_name);
285 entry->positive_cache_params.cache_entries_size = size;
286 entry->negative_cache_params.cache_entries_size = size;
291 static void
292 check_files(struct configuration *config, const char *entry_name, int flag)
300 static int
309 return (-1);
312 static int
320 return (-1);
324 return (-1);
326 if (((res >= low) || (low == -1)) &&
327 ((res <= max) || (max == -1)))
330 return (-2);
333 static enum cache_policy_t
344 return (-1);
347 static int
352 return ((strlen(str) > 0) ? 0 : -1);
355 static void
356 set_threads_num(struct configuration *config, int value)
359 assert(config != NULL);
360 config->threads_num = value;
368 parse_config_file(struct configuration *config,
379 assert(config != NULL);
385 return (-1);
392 while ((res == 0) && (fgets(buffer, sizeof(buffer) - 1, fin) != NULL)) {
405 (strcmp(fields[0], "enable-cache") == 0) &&
407 ((value = get_yesno(fields[2])) != -1)) {
408 enable_cache(config, fields[1], value);
414 (strcmp(fields[0], "debug-level") == 0) &&
415 ((value = get_number(fields[1], 0, 10)) != -1)) {
421 (strcmp(fields[0], "positive-time-to-live") == 0) &&
423 ((value = get_number(fields[2], 0, -1)) != -1)) {
428 set_positive_time_to_live(config,
432 (strcmp(fields[0], "positive-confidence-threshold") == 0) &&
433 ((value = get_number(fields[2], 1, -1)) != -1)) {
438 set_positive_confidence_threshold(config,
442 (strcmp(fields[0], "positive-policy") == 0) &&
444 ((value = get_policy(fields[2])) != -1)) {
445 set_positive_policy(config, fields[1], value);
448 (strcmp(fields[0], "perform-actual-lookups") == 0) &&
450 ((value = get_yesno(fields[2])) != -1)) {
451 set_perform_actual_lookups(config, fields[1],
458 (strcmp(fields[0], "negative-time-to-live") == 0) &&
460 ((value = get_number(fields[2], 0, -1)) != -1)) {
465 set_negative_time_to_live(config,
469 (strcmp(fields[0], "negative-confidence-threshold") == 0) &&
470 ((value = get_number(fields[2], 1, -1)) != -1)) {
475 set_negative_confidence_threshold(config,
479 (strcmp(fields[0], "negative-policy") == 0) &&
481 ((value = get_policy(fields[2])) != -1)) {
482 set_negative_policy(config,
489 (strcmp(fields[0], "suggested-size") == 0) &&
491 ((value = get_number(fields[2], 1, -1)) != -1)) {
496 set_suggested_size(config, fields[1], value);
503 ((value = get_number(fields[1], 1, -1)) != -1)) {
504 set_threads_num(config, value);
510 (strcmp(fields[0], "keep-hot-count") == 0) &&
512 ((value = get_number(fields[2], 0, -1)) != -1)) {
517 set_keep_hot_count(config,
524 (strcmp(fields[0], "check-files") == 0) &&
526 ((value = get_yesno(fields[2])) != -1)) {
527 check_files(config,
542 LOG_ERR_2("config file parser", "error in file "
547 res = -1;