]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add interface to assign configuration variable from the command line
authorCedric Le Goater <clg@fr.ibm.com>
Thu, 14 Jan 2010 06:43:17 +0000 (07:43 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 14 Jan 2010 06:43:17 +0000 (07:43 +0100)
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 <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/confile.c
src/lxc/confile.h

index 1fa9bc1b17004d52f8a80fec854ad265414b81ee..af663e098c2ca52483b32e836c9cdf904af9af8b 100644 (file)
@@ -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;
+}
index f88e55ff1dd1b230411f5af931e97a4cf51aa0f0..cfe96e52b8d72af83eb9dad81bfefb7dc5f5787c 100644 (file)
  */
 
 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);