Change APDU dump printing to avoid long leading blanks
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 May 2012 12:49:08 +0000 (14:49 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 May 2012 12:49:08 +0000 (14:49 +0200)
For levels 16 or larger the level is shown and the indentation is
truncated but recursed with modula 8. This makes it still reasonable
easy to read - even for nested BER dumps.

src/odr_util.c

index 22a6691..644c3c3 100644 (file)
 
 void odr_prname(ODR o, const char *name)
 {
-    if (name)
-        odr_printf(o, "%*s%s ", o->op->indent*4, "", name);
+    if (o->op->indent < 16)
+        odr_printf(o, "%*s", o->op->indent * 2, "");
     else
-        odr_printf(o, "%*s", o->op->indent*4, "");
+        odr_printf(o, "level=%-7d%*s", o->op->indent, 
+                   2 * (o->op->indent % 8) , "");
+    if (name)
+        odr_printf(o, "%s ", name);
 }
 
 int odp_more_chunks(ODR o, const unsigned char *base, int len)