source: trunk/gsdl/packages/yaz/retrieval/d1_prtree.c@ 1343

Last change on this file since 1343 was 1343, checked in by johnmcp, 24 years ago

Added the YAZ toolkit source to the packages directory (for z39.50 stuff)

  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/*
2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
5 *
6 * $Log$
7 * Revision 1.1 2000/08/03 03:11:34 johnmcp
8 * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
9 *
10 * Revision 1.6 1999/11/30 13:47:12 adam
11 * Improved installation. Moved header files to include/yaz.
12 *
13 * Revision 1.5 1999/01/25 13:49:47 adam
14 * Made data1_pr_tree make better printing of data1 buffers.
15 *
16 * Revision 1.4 1998/05/18 13:07:06 adam
17 * Changed the way attribute sets are handled by the retriaval module.
18 * Extended Explain conversion / schema.
19 * Modified server and client to work with ASN.1 compiled protocol handlers.
20 *
21 * Revision 1.3 1998/02/27 14:05:34 adam
22 * Added printing of integer nodes.
23 *
24 * Revision 1.2 1997/11/06 11:36:44 adam
25 * Implemented variant match on simple elements -data1 tree and Espec-1.
26 *
27 * Revision 1.1 1997/10/27 14:04:07 adam
28 * New debug utility, data1_pr_tree, that dumps a data1 tree.
29 *
30 */
31
32#include <yaz/log.h>
33#include <yaz/data1.h>
34
35static void pr_string (FILE *out, const char *str, int len)
36{
37 int i;
38 for (i = 0; i<len; i++)
39 {
40 int c = str[i];
41 if (c < 32 || c >126)
42 fprintf (out, "\\x%02x", c);
43 else
44 fputc (c, out);
45 }
46}
47
48static void pr_tree (data1_handle dh, data1_node *n, FILE *out, int level)
49{
50 fprintf (out, "%*s", level, "");
51 switch (n->which)
52 {
53 case DATA1N_root:
54 fprintf (out, "root abstract syntax=%s\n", n->u.root.type);
55 break;
56 case DATA1N_tag:
57 fprintf (out, "tag type=%s\n", n->u.tag.tag);
58 break;
59 case DATA1N_data:
60 fprintf (out, "data type=");
61 switch (n->u.data.what)
62 {
63 case DATA1I_inctxt:
64 fprintf (out, "inctxt\n");
65 break;
66 case DATA1I_incbin:
67 fprintf (out, "incbin\n");
68 break;
69 case DATA1I_text:
70 fprintf (out, "text '");
71 pr_string (out, n->u.data.data, n->u.data.len);
72 fprintf (out, "'\n");
73 break;
74 case DATA1I_num:
75 fprintf (out, "num '");
76 pr_string (out, n->u.data.data, n->u.data.len);
77 fprintf (out, "'\n");
78 break;
79 case DATA1I_oid:
80 fprintf (out, "oid '");
81 pr_string (out, n->u.data.data, n->u.data.len);
82 fprintf (out, "'\n");
83 break;
84 default:
85 fprintf (out, "unknown(%d)\n", n->u.data.what);
86 break;
87 }
88 break;
89 case DATA1N_variant:
90 fprintf (out, "variant\n");
91#if 0
92 if (n->u.variant.type->name)
93 fprintf (out, " class=%s type=%d value=%s\n",
94 n->u.variant.type->name, n->u.variant.type->type,
95 n->u.variant.value);
96#endif
97 break;
98 default:
99 fprintf (out, "unknown(%d)\n", n->which);
100 }
101 if (n->child)
102 pr_tree (dh, n->child, out, level+4);
103 if (n->next)
104 pr_tree (dh, n->next, out, level);
105}
106
107
108void data1_pr_tree (data1_handle dh, data1_node *n, FILE *out)
109{
110 pr_tree (dh, n, out, 0);
111}
Note: See TracBrowser for help on using the repository browser.