2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: d1_prtree.c,v $
7 * Revision 1.5 1999-01-25 13:49:47 adam
8 * Made data1_pr_tree make better printing of data1 buffers.
10 * Revision 1.4 1998/05/18 13:07:06 adam
11 * Changed the way attribute sets are handled by the retriaval module.
12 * Extended Explain conversion / schema.
13 * Modified server and client to work with ASN.1 compiled protocol handlers.
15 * Revision 1.3 1998/02/27 14:05:34 adam
16 * Added printing of integer nodes.
18 * Revision 1.2 1997/11/06 11:36:44 adam
19 * Implemented variant match on simple elements -data1 tree and Espec-1.
21 * Revision 1.1 1997/10/27 14:04:07 adam
22 * New debug utility, data1_pr_tree, that dumps a data1 tree.
29 static void pr_string (FILE *out, const char *str, int len)
32 for (i = 0; i<len; i++)
36 fprintf (out, "\\x%02x", c);
42 static void pr_tree (data1_handle dh, data1_node *n, FILE *out, int level)
44 fprintf (out, "%*s", level, "");
48 fprintf (out, "root abstract syntax=%s\n", n->u.root.type);
51 fprintf (out, "tag type=%s\n", n->u.tag.tag);
54 fprintf (out, "data type=");
55 switch (n->u.data.what)
58 fprintf (out, "inctxt\n");
61 fprintf (out, "incbin\n");
64 fprintf (out, "text '");
65 pr_string (out, n->u.data.data, n->u.data.len);
69 fprintf (out, "num '");
70 pr_string (out, n->u.data.data, n->u.data.len);
74 fprintf (out, "oid '");
75 pr_string (out, n->u.data.data, n->u.data.len);
79 fprintf (out, "unknown(%d)\n", n->u.data.what);
84 fprintf (out, "variant\n");
86 if (n->u.variant.type->name)
87 fprintf (out, " class=%s type=%d value=%s\n",
88 n->u.variant.type->name, n->u.variant.type->type,
93 fprintf (out, "unknown(%d)\n", n->which);
96 pr_tree (dh, n->child, out, level+4);
98 pr_tree (dh, n->next, out, level);
102 void data1_pr_tree (data1_handle dh, data1_node *n, FILE *out)
104 pr_tree (dh, n, out, 0);