From: Cedric Le Goater Date: Thu, 14 Jan 2010 06:43:17 +0000 (+0100) Subject: add interface to assign configuration variable from the command line X-Git-Tag: lxc-0.6.5~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62e46035481fa000b4d23ba94be4c312b3235e70;p=thirdparty%2Flxc.git add interface to assign configuration variable from the command line lxc_config_define_add() and lxc_config_define_load() define the interface to load a list of KEY=VAL buffers in the configuration Signed-off-by: Cedric Le Goater Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 1fa9bc1b1..af663e098 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -671,3 +671,36 @@ int lxc_config_read(const char *file, struct lxc_conf *conf) return lxc_file_for_each_line(file, parse_line, buffer, sizeof(buffer), conf); } + +int lxc_config_define_add(struct lxc_list *defines, char* arg) +{ + struct lxc_list *dent; + + dent = malloc(sizeof(struct lxc_list)); + if (!dent) + return -1; + + dent->elem = arg; + lxc_list_add_tail(defines, dent); + return 0; +} + +char* lxc_config_define_load(struct lxc_list *defines, + struct lxc_conf *conf) +{ + struct lxc_list *it; + int ret = 0; + + lxc_list_for_each(it, defines) { + ret = lxc_config_readline(it->elem, conf); + if (ret) + break; + } + + lxc_list_for_each(it, defines) { + lxc_list_del(it); + free(it); + } + + return ret; +} diff --git a/src/lxc/confile.h b/src/lxc/confile.h index f88e55ff1..cfe96e52b 100644 --- a/src/lxc/confile.h +++ b/src/lxc/confile.h @@ -22,8 +22,11 @@ */ struct lxc_conf; +struct lxc_list; extern int lxc_config_read(const char *file, struct lxc_conf *conf); extern int lxc_config_readline(char *buffer, struct lxc_conf *conf); - +extern int lxc_config_define_add(struct lxc_list *defines, char* arg); +extern char *lxc_config_define_load(struct lxc_list *defines, + struct lxc_conf *conf);