Commit 62e46035 by Cedric Le Goater Committed by Daniel Lezcano

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: 's avatarCedric Le Goater <clg@fr.ibm.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 222dcd54
...@@ -671,3 +671,36 @@ int lxc_config_read(const char *file, struct lxc_conf *conf) ...@@ -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, return lxc_file_for_each_line(file, parse_line, buffer,
sizeof(buffer), conf); 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;
}
...@@ -22,8 +22,11 @@ ...@@ -22,8 +22,11 @@
*/ */
struct lxc_conf; struct lxc_conf;
struct lxc_list;
extern int lxc_config_read(const char *file, struct lxc_conf *conf); 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_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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment