version 1.1.1.1.2.1, 2013/07/22 01:03:34
|
version 1.1.1.2, 2016/10/18 14:04:50
|
Line 8
|
Line 8
|
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
#include <errno.h> |
#include <errno.h> |
#include <sys/types.h> | #include <stdlib.h> |
|
|
#include "stringmap.h" |
#include "stringmap.h" |
#include "iftop.h" |
#include "iftop.h" |
Line 37 char * config_directives[] = {
|
Line 37 char * config_directives[] = {
|
"log-scale", |
"log-scale", |
"max-bandwidth", |
"max-bandwidth", |
"net-filter", |
"net-filter", |
|
"net-filter6", |
|
"link-local", |
"port-display", |
"port-display", |
|
"timed-output", |
|
"no-curses", |
|
"num-lines", |
NULL |
NULL |
}; |
}; |
|
|
Line 46 stringmap config;
|
Line 51 stringmap config;
|
extern options_t options ; |
extern options_t options ; |
|
|
int is_cfgdirective_valid(const char *s) { |
int is_cfgdirective_valid(const char *s) { |
char **t; | int t; |
for (t = config_directives; *t != NULL; ++t) | for (t = 0; config_directives[t] != NULL; t++) |
if (strcmp(s, *t) == 0) return 1; | if (strcmp(s, config_directives[t]) == 0) return 1; |
return 0; |
return 0; |
} |
} |
|
|
Line 165 int config_get_int(const char *directive, int *value)
|
Line 170 int config_get_int(const char *directive, int *value)
|
* failure, or 0 if no value was found. */ |
* failure, or 0 if no value was found. */ |
int config_get_float(const char *directive, float *value) { |
int config_get_float(const char *directive, float *value) { |
stringmap S; |
stringmap S; |
item *I; |
|
char *s, *t; |
char *s, *t; |
|
|
if (!value) return -1; |
if (!value) return -1; |
Line 231 void config_set_string(const char *directive, const ch
|
Line 235 void config_set_string(const char *directive, const ch
|
stringmap S; |
stringmap S; |
|
|
S = stringmap_find(config, directive); |
S = stringmap_find(config, directive); |
if (S) stringmap_delete_free(S); | if (S) { |
stringmap_insert(config, directive, item_ptr(xstrdup(s))); | xfree(S->d.v); |
| S->d = item_ptr(xstrdup(s)); |
| } |
| else { |
| stringmap_insert(config, directive, item_ptr(xstrdup(s))); |
| } |
} |
} |
|
|
int read_config(char *file, int whinge_on_error) { |
int read_config(char *file, int whinge_on_error) { |
void* o; |
|
|
|
return read_config_file(file, whinge_on_error); |
return read_config_file(file, whinge_on_error); |
} |
} |