diff options
author | NeilBrown <neilb@suse.de> | 2013-07-02 10:17:51 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-07-02 10:17:51 +1000 |
commit | d0c017a663b58645f93094457b5493c8348bc122 (patch) | |
tree | ef09f34589165ba3ea0abd103bcccbd1c252056c /lib.c | |
parent | b76dc299752f01d03ac4013f4e68cf9ee439c879 (diff) |
Move conf_line and free_line from conf.c to lib.c
As they are uses for mdstat as well as mdadm.conf, they don't really
belong in conf.c
This removes a dependency between mdmon and conf.c
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -23,6 +23,7 @@ */ #include "mdadm.h" +#include "dlink.h" #include <ctype.h> /* This fill contains various 'library' style function. They @@ -407,3 +408,42 @@ unsigned long GCD(unsigned long a, unsigned long b) } return a; } + +/* + * conf_line reads one logical line from the conffile or mdstat. + * It skips comments and continues until it finds a line that starts + * with a non blank/comment. This character is pushed back for the next call + * A doubly linked list of words is returned. + * the first word will be a keyword. Other words will have had quotes removed. + */ + +char *conf_line(FILE *file) +{ + char *w; + char *list; + + w = conf_word(file, 1); + if (w == NULL) return NULL; + + list = dl_strdup(w); + free(w); + dl_init(list); + + while ((w = conf_word(file,0))){ + char *w2 = dl_strdup(w); + free(w); + dl_add(list, w2); + } +/* printf("got a line\n");*/ + return list; +} + +void free_line(char *line) +{ + char *w; + for (w=dl_next(line); w != line; w=dl_next(line)) { + dl_del(w); + dl_free(w); + } + dl_free(line); +} |