]> mj.ucw.cz Git - libucw.git/commitdiff
the init-hook of the main section inserts a few nodes into the link-list
authorRobert Spalek <robert@ucw.cz>
Thu, 20 Apr 2006 17:31:55 +0000 (19:31 +0200)
committerRobert Spalek <robert@ucw.cz>
Thu, 20 Apr 2006 17:31:55 +0000 (19:31 +0200)
lib/conf2-test.c

index fdeb0d1856330b614671159789a9375c389a3c06..3baa440dd3f3eeab055683a3529f7c04c0610a50 100644 (file)
@@ -12,6 +12,7 @@
 #include <time.h>
 
 struct sub_sect_1 {
+  struct cnode n;
   byte *name;
   byte *level;
   int confidence[2];
@@ -58,10 +59,23 @@ static byte *str1 = "no worries";
 static byte **str2 = DYN_ALLOC(byte *, 2, "Alice", "Bob");
 static u64 u1 = 0xCafeBeefDeadC00ll;
 static double d1 = -1.1;
-static struct sub_sect_1 sec1 = { "Charlie", "WBAFC", { 0, -1} };
+static struct sub_sect_1 sec1 = { {}, "Charlie", "WBAFC", { 0, -1} };
 static struct clist secs;
 static time_t t1, t2;
 
+static byte *
+init_top(void *ptr UNUSED)
+{
+  for (uns i=0; i<5; i++)
+  {
+    struct sub_sect_1 *s = cf_malloc(sizeof(struct sub_sect_1));
+    cf_init_section("slaves", &cf_sec_1, s);
+    s->confidence[1] = i;
+    clist_add_tail(&secs, &s->n);
+  }
+  return NULL;
+}
+
 static byte *
 commit_top(void *ptr UNUSED)
 {
@@ -78,6 +92,7 @@ time_parser(uns number, byte **pars, time_t *ptr)
 }
 
 static struct cf_section cf_top UNUSED = {
+  CF_COMMIT(init_top),
   CF_COMMIT(commit_top),
   CF_ITEMS {
     CF_INT("nr1", &nr1),