Commit b8856a12 authored by Nils Goroll's avatar Nils Goroll Committed by Dridi Boukelmoune

Add PAN_dump_oneline()

adds a variant of PAN_dump_struct() which does not start another
indentation level on a new line.
parent c13c71f8
......@@ -848,9 +848,12 @@ Tlen(const txt t)
*/
#define W_TIM_real(w) ((w)->lastused = VTIM_real())
int PAN_dump_struct2(struct vsb *vsb, const void *ptr,
int PAN_dump_struct2(struct vsb *vsb, int block, const void *ptr,
const char *smagic, unsigned magic, const char *fmt, ...)
v_printflike_(5,6);
v_printflike_(6,7);
#define PAN_dump_struct(vsb, ptr, magic, ...) \
PAN_dump_struct2(vsb, ptr, #magic, magic, __VA_ARGS__)
PAN_dump_struct2(vsb, 1, ptr, #magic, magic, __VA_ARGS__)
#define PAN_dump_oneline(vsb, ptr, magic, ...) \
PAN_dump_struct2(vsb, 0, ptr, #magic, magic, __VA_ARGS__)
......@@ -110,7 +110,7 @@ static const void *already_list[N_ALREADY];
static int already_idx;
int
PAN_dump_struct2(struct vsb *vsb, const void *ptr,
PAN_dump_struct2(struct vsb *vsb, int block, const void *ptr,
const char *smagic, unsigned magic, const char *fmt, ...)
{
va_list ap;
......@@ -125,10 +125,14 @@ PAN_dump_struct2(struct vsb *vsb, const void *ptr,
VSB_printf(vsb, " = NULL\n");
return (-1);
}
VSB_printf(vsb, " = %p {\n", ptr);
VSB_printf(vsb, " = %p {", ptr);
if (block)
VSB_putc(vsb, '\n');
for (i = 0; i < already_idx; i++) {
if (already_list[i] == ptr) {
VSB_cat(vsb, " [Already dumped, see above]\n");
VSB_cat(vsb, " [Already dumped, see above]");
if (block)
VSB_putc(vsb, '\n');
VSB_cat(vsb, "},\n");
return (-2);
}
......@@ -138,10 +142,13 @@ PAN_dump_struct2(struct vsb *vsb, const void *ptr,
uptr = ptr;
if (*uptr != magic) {
VSB_printf(vsb, " .magic = 0x%08x", *uptr);
VSB_printf(vsb, " EXPECTED: %s=0x%08x\n", smagic, magic);
VSB_printf(vsb, " EXPECTED: %s=0x%08x", smagic, magic);
if (block)
VSB_putc(vsb, '\n');
VSB_printf(vsb, "}\n");
return (-3);
}
if (block)
VSB_indent(vsb, 2);
return (0);
}
......
......@@ -71,18 +71,19 @@ pan_privs(struct vsb *vsb, const struct vrt_privs *privs)
VSB_printf(vsb, "privs = %p {\n", privs);
VSB_indent(vsb, 2);
VRBT_FOREACH(vp, vrt_privs, privs) {
if (PAN_dump_struct(vsb, vp, VRT_PRIV_MAGIC, "priv"))
if (PAN_dump_oneline(vsb, vp, VRT_PRIV_MAGIC, "priv"))
continue;
p = vp->priv;
//lint -e{774}
if (p == NULL) {
// should never happen
VSB_printf(vsb, "NULL vmod %jx\n",
VSB_printf(vsb, "NULL vmod %jx},\n",
(uintmax_t)vp->vmod_id);
} else {
continue;
}
m = p->methods;
VSB_printf(vsb,
"{p %p l %ld m %p t \"%s\"} vmod %jx\n",
"{p %p l %ld m %p t \"%s\"} vmod %jx},\n",
p->priv, p->len, m,
m != NULL ? m->type : "",
(uintmax_t)vp->vmod_id
......@@ -90,9 +91,6 @@ pan_privs(struct vsb *vsb, const struct vrt_privs *privs)
}
VSB_indent(vsb, -2);
VSB_cat(vsb, "},\n");
}
VSB_indent(vsb, -2);
VSB_cat(vsb, "},\n");
}
/*--------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment