2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 1996-01-03 16:22:11 quinn
10 * Revision 1.1 1995/11/16 17:00:55 adam
11 * Better logging of rpn query.
20 static char *attrStr (int type, int value, enum oid_value ast)
32 sprintf (str, "use=%d", value);
35 sprintf (str, "relation=%d", value);
38 sprintf (str, "position=%d", value);
41 sprintf (str, "structure=%d", value);
44 sprintf (str, "truncation=%d", value);
47 sprintf (str, "completeness=%d", value);
54 sprintf (str, "%d=%d", type, value);
59 * zlog_attributes: print attributes of term
61 static void zlog_attributes (Z_AttributesPlusTerm *t, int level,
65 for (of = 0; of < t->num_attributes; of++)
67 Z_AttributeElement *element;
68 element = t->attributeList[of];
70 switch (element->which)
72 case Z_AttributeValue_numeric:
73 logf (LOG_LOG, "%*.s %s", level, "",
74 attrStr (*element->attributeType, *element->value.numeric, ast));
76 case Z_AttributeValue_complex:
77 logf (LOG_LOG, "%*.s attributeType=%d complex", level, "",
78 *element->attributeType);
79 for (i = 0; i<element->value.complex->num_list; i++)
81 if (element->value.complex->list[i]->which ==
82 Z_StringOrNumeric_string)
83 logf (LOG_LOG, "%*.s string: '%s'", level, "",
84 element->value.complex->list[i]->u.string);
85 else if (element->value.complex->list[i]->which ==
86 Z_StringOrNumeric_numeric)
87 logf (LOG_LOG, "%*.s numeric: '%d'", level, "",
88 *element->value.complex->list[i]->u.numeric);
92 logf (LOG_LOG, "%.*s attribute unknown", level, "");
97 static void zlog_structure (Z_RPNStructure *zs, int level, enum oid_value ast)
99 if (zs->which == Z_RPNStructure_complex)
101 switch (zs->u.complex->roperator->which)
104 logf (LOG_LOG, "%*.s and", level, "");
107 logf (LOG_LOG, "%*.s or", level, "");
109 case Z_Operator_and_not:
110 logf (LOG_LOG, "%*.s and", level, "");
113 logf (LOG_LOG, "%*.s unknown complex", level, "");
116 zlog_structure (zs->u.complex->s1, level+2, ast);
117 zlog_structure (zs->u.complex->s2, level+2, ast);
119 else if (zs->which == Z_RPNStructure_simple)
121 if (zs->u.simple->which == Z_Operand_APT)
123 Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm;
125 if (zapt->term->which == Z_Term_general)
127 logf (LOG_LOG, "%*.s term '%.*s' (general)", level, "",
128 zapt->term->u.general->len, zapt->term->u.general->buf);
132 logf (LOG_LOG, "%*.s term (not general)", level, "");
134 zlog_attributes (zapt, level+2, ast);
136 else if (zs->u.simple->which == Z_Operand_resultSetId)
138 logf (LOG_LOG, "%*.s set '%s'", level, "",
139 zs->u.simple->u.resultSetId);
142 logf (LOG_LOG, "%*.s unknown simple structure", level, "");
145 logf (LOG_LOG, "%*.s unknown structure", level, "");
148 void zlog_rpn (Z_RPNQuery *rpn)
150 oident *attrset = oid_getentbyoid (rpn->attributeSetId);
153 ast = attrset->value;
154 logf (LOG_LOG, "RPN query. Type: %s", attrset->desc);
155 zlog_structure (rpn->RPNStructure, 0, ast);