2 * Insane tester of reading configuration files
4 * (c) 2006 Robert Spalek <robert@ucw.cz>
9 #include "lib/clists.h"
21 init_sec_1(struct sub_sect_1 *s)
30 commit_sec_1(struct sub_sect_1 *s)
32 if (s->confidence < 0 || s->confidence > 10)
33 return "Well, this can't be";
37 static struct cf_section cf_sec_1 = {
38 CF_TYPE(struct sub_sect_1)
40 CF_COMMIT(commit_sec_1)
41 #define F(x) PTR_TO(struct sub_sect_1, x)
43 CF_STRING("name", F(name))
44 CF_STRING("level", F(level))
45 CF_INT("confidence", F(confidence))
51 static int *nrs1 = ARRAY_ALLOC(int, 5, 5, 4, 3, 2, 1);
53 static byte *str1 = "no worries";
54 static byte **str2 = ARRAY_ALLOC(byte *, 2, "Alice", "Bob");
55 static u64 u1 = 0xCafeBeefDeadC00ll;
56 static double d1 = -1.1;
57 static struct sub_sect_1 sec1 = { "Charlie", "WBAFC", 0 };
58 static struct clist secs;
62 commit_top(void *ptr UNUSED)
65 return "Don't touch my variable!";
70 time_parser(uns number, byte **pars, time_t *ptr)
72 *ptr = number ? atoi(pars[0]) : time(NULL);
76 static struct cf_section cf_top = {
80 CF_INT_ARY("nrs1", &nrs1, 5)
81 CF_INT_ARY("nrs2", &nrs2, -1000)
82 CF_STRING("str1", &str1)
83 CF_STRING_ARY("str2", &str2, 2)
86 CF_PARSER("FirstTime", &t1, time_parser, -1)
87 CF_PARSER("SecondTime", &t2, time_parser, 1)
88 CF_SECTION("master", &sec1, &cf_sec_1)
89 CF_LIST("slaves", &secs, &cf_sec_1)