]> mj.ucw.cz Git - libucw.git/blobdiff - lib/conf-dump.c
few "byte *" -> "char *" conversions
[libucw.git] / lib / conf-dump.c
index fe4a7c24dc2fb03e580e61b68a687a771683a22c..0d4092400f52b0da6632885594de3a38b47afcd3 100644 (file)
@@ -27,16 +27,16 @@ 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;
 {
   switch (type) {
     case CT_INT:       bprintf(fb, "%d ", *(uns*)ptr); break;
-    case CT_U64:       bprintf(fb, "%llu ", *(u64*)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_STRING:
     case CT_DOUBLE:    bprintf(fb, "%lg ", *(double*)ptr); break;
     case CT_IP:                bprintf(fb, "%08x ", *(uns*)ptr); break;
     case CT_STRING:
-      if (*(byte**)ptr)
-       bprintf(fb, "'%s' ", *(byte**)ptr);
+      if (*(char**)ptr)
+       bprintf(fb, "'%s' ", *(char**)ptr);
       else
        bprintf(fb, "NULL ");
       break;
       else
        bprintf(fb, "NULL ");
       break;
-    case CT_LOOKUP:    bprintf(fb, "%s ", *(int*)ptr >= 0 ? u->lookup[ *(int*)ptr ] : (byte*) "???"); break;
+    case CT_LOOKUP:    bprintf(fb, "%s ", *(int*)ptr >= 0 ? u->lookup[ *(int*)ptr ] : "???"); break;
     case CT_USER:
       if (u->utype->dumper)
        u->utype->dumper(fb, ptr);
     case CT_USER:
       if (u->utype->dumper)
        u->utype->dumper(fb, ptr);
@@ -48,13 +48,12 @@ dump_basic(struct fastbuf *fb, void *ptr, enum cf_type type, union cf_union *u)
 
 static void dump_section(struct fastbuf *fb, struct cf_section *sec, int level, void *ptr);
 
 
 static void dump_section(struct fastbuf *fb, struct cf_section *sec, int level, void *ptr);
 
-static byte *class_names[] = { "end", "static", "dynamic", "parser", "section", "list" };
-static byte *type_names[] = { "int", "u64", "double", "ip", "string", "lookup", "user" };
+static char *class_names[] = { "end", "static", "dynamic", "parser", "section", "list", "bitmap" };
 
 static void
 dump_item(struct fastbuf *fb, struct cf_item *item, int level, void *ptr)
 {
 
 static void
 dump_item(struct fastbuf *fb, struct cf_item *item, int level, void *ptr)
 {
-  ptr += (addr_int_t) item->ptr;
+  ptr += (uintptr_t) item->ptr;
   enum cf_type type = item->type;
   uns size = cf_type_size(item->type, item->u.utype);
   int i;
   enum cf_type type = item->type;
   uns size = cf_type_size(item->type, item->u.utype);
   int i;
@@ -64,8 +63,8 @@ dump_item(struct fastbuf *fb, struct cf_item *item, int level, void *ptr)
     bputs(fb, "any ");
   else
     bprintf(fb, "%d ", item->number);
     bputs(fb, "any ");
   else
     bprintf(fb, "%d ", item->number);
-  if (item->cls == CC_STATIC || item->cls == CC_DYNAMIC) {
-    bprintf(fb, "T%s ", type_names[type]);
+  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);
   }
     if (item->type == CT_USER)
       bprintf(fb, "U%s S%d ", item->u.utype->name, size);
   }
@@ -75,12 +74,24 @@ dump_item(struct fastbuf *fb, struct cf_item *item, int level, void *ptr)
   } else if (item->cls == CC_DYNAMIC) {
     ptr = * (void**) ptr;
     if (ptr) {
   } else if (item->cls == CC_DYNAMIC) {
     ptr = * (void**) ptr;
     if (ptr) {
-      int real_nr = * (int*) (ptr - size);
+      int real_nr = DARY_LEN(ptr);
       bprintf(fb, "N%d ", real_nr);
       for (i=0; i<real_nr; i++)
        dump_basic(fb, ptr + i * size, type, &item->u);
     } else
       bprintf(fb, "NULL ");
       bprintf(fb, "N%d ", real_nr);
       for (i=0; i<real_nr; i++)
        dump_basic(fb, ptr + i * size, type, &item->u);
     } else
       bprintf(fb, "NULL ");
+  } else if (item->cls == CC_BITMAP) {
+    u32 mask = * (u32*) ptr;
+    for (i=0; i<32; i++) {
+      if (item->type == CT_LOOKUP && !item->u.lookup[i])
+       break;
+      if (mask & (1<<i)) {
+       if (item->type == CT_INT)
+         bprintf(fb, "%d ", i);
+       else if (item->type == CT_LOOKUP)
+         bprintf(fb, "%s ", item->u.lookup[i]);
+      }
+    }
   }
   bputc(fb, '\n');
   if (item->cls == CC_SECTION)
   }
   bputc(fb, '\n');
   if (item->cls == CC_SECTION)