From 112b5f79028ca870126fe4e3f7a5a4de7f698570 Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Thu, 20 Apr 2006 19:31:55 +0200 Subject: [PATCH] the init-hook of the main section inserts a few nodes into the link-list --- lib/conf2-test.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/conf2-test.c b/lib/conf2-test.c index fdeb0d18..3baa440d 100644 --- a/lib/conf2-test.c +++ b/lib/conf2-test.c @@ -12,6 +12,7 @@ #include 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), -- 2.39.2