* UCW Library -- Configuration files: dumping
*
* (c) 2001--2006 Robert Spalek <robert@ucw.cz>
- * (c) 2003--2006 Martin Mares <mj@ucw.cz>
+ * (c) 2003--2012 Martin Mares <mj@ucw.cz>
+ * (c) 2014 Pavel Charvat <pchar@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
#include <ucw/conf-internal.h>
#include <ucw/clists.h>
#include <ucw/fastbuf.h>
+#include <ucw/xtypes.h>
static void
-spaces(struct fastbuf *fb, uns nr)
+spaces(struct fastbuf *fb, uint nr)
{
- for (uns i=0; i<nr; i++)
+ for (uint i=0; i<nr; i++)
bputs(fb, " ");
}
dump_basic(struct fastbuf *fb, void *ptr, enum cf_type type, union cf_union *u)
{
switch (type) {
- case CT_INT: bprintf(fb, "%d ", *(uns*)ptr); break;
+ case CT_INT: bprintf(fb, "%d ", *(uint*)ptr); break;
case CT_U64: bprintf(fb, "%llu ", (long long) *(u64*)ptr); break;
case CT_DOUBLE: bprintf(fb, "%lg ", *(double*)ptr); break;
- case CT_IP: bprintf(fb, "%08x ", *(uns*)ptr); break;
+ case CT_IP: bprintf(fb, "%08x ", *(uint*)ptr); break;
case CT_STRING:
if (*(char**)ptr)
bprintf(fb, "'%s' ", *(char**)ptr);
else
bprintf(fb, "??? ");
break;
+ case CT_XTYPE:
+ bprintf(fb, "'%s' ", u->xtype->format(ptr, XTYPE_FMT_DEFAULT, cf_get_pool()));
+ break;
}
}
{
ptr += (uintptr_t) item->ptr;
enum cf_type type = item->type;
- uns size = cf_type_size(item->type, item->u.utype);
+ uint size = cf_type_size(item->type, &item->u);
int i;
spaces(fb, level);
bprintf(fb, "%s: C%s #", item->name, class_names[item->cls]);
else
bprintf(fb, "%d ", item->number);
if (item->cls == CC_STATIC || item->cls == CC_DYNAMIC || item->cls == CC_BITMAP) {
- bprintf(fb, "T%s ", cf_type_names[type]);
if (item->type == CT_USER)
bprintf(fb, "U%s S%d ", item->u.utype->name, size);
+ else if (item->type == CT_XTYPE)
+ bprintf(fb, "X%s S%d ", item->u.xtype->name, size);
+ else
+ bprintf(fb, "T%s ", cf_type_names[type]);
}
if (item->cls == CC_STATIC) {
for (i=0; i<item->number; i++)
} else if (item->cls == CC_DYNAMIC) {
ptr = * (void**) ptr;
if (ptr) {
- int real_nr = DARY_LEN(ptr);
+ int real_nr = GARY_SIZE(ptr);
bprintf(fb, "N%d ", real_nr);
for (i=0; i<real_nr; i++)
dump_basic(fb, ptr + i * size, type, &item->u);
if (item->cls == CC_SECTION)
dump_section(fb, item->u.sec, level+1, ptr);
else if (item->cls == CC_LIST) {
- uns idx = 0;
+ uint idx = 0;
CLIST_FOR_EACH(cnode *, n, * (clist*) ptr) {
spaces(fb, level+1);
bprintf(fb, "item %d\n", ++idx);
void
cf_dump_sections(struct fastbuf *fb)
{
- dump_section(fb, &cf_sections, 0, NULL);
+ struct cf_context *cc = cf_get_context();
+ dump_section(fb, &cc->sections, 0, NULL);
}