#include <stdio.h>
#include <string.h>
#include <elwix.h>
#include <aitcfg.h>
int
main(int argc, char **argv)
{
cfg_root_t cfg;
char *str, *sec, *attr;
array_t *arr;
int i;
struct tagCfg *av;
if (argc < 2) {
printf("Error:: missing config.\n\ntestcfg <config> [section/attribute]\n");
return 1;
} else
str = argv[2];
if (cfgLoadConfig(argv[1], &cfg)) {
ELIBERR(cfg);
return 1;
} else
printf("Opened config\n");
if (str) {
attr = strchr(argv[2], '/');
if (!attr) {
attr = str;
sec = NULL;
} else {
*attr++ = 0;
sec = str;
}
if (sec && !*sec)
sec = NULL;
printf("Section=%s Attribute=%s\n", sec, attr);
if (attr && *attr)
printf("%s = %s\n", attr, cfg_getAttribute(&cfg, sec, attr));
else {
arr = cfg_getSection(&cfg, sec);
if (arr) {
printf("[%s]\n", sec);
for (i = 0; i < array_Size(arr); i++) {
av = array(arr, i, struct tagCfg*);
if (av)
printf("%s = %s\n",
AIT_GET_STR(&av->cfg_attr),
AIT_GET_STR(&av->cfg_val));
}
array_Destroy(&arr);
}
}
} else
cfgWriteConfig(stdout, &cfg, 1);
cfgUnloadConfig(&cfg);
printf("Closed config\n");
printf("Done.\n");
return 0;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>