2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-11-16 17:00:55 adam
8 * Better logging of rpn query.
17 static char *attrStr (int type, int value, enum oid_value ast)
29 sprintf (str, "use=%d", value);
32 sprintf (str, "relation=%d", value);
35 sprintf (str, "position=%d", value);
38 sprintf (str, "structure=%d", value);
41 sprintf (str, "truncation=%d", value);
44 sprintf (str, "completeness=%d", value);
51 sprintf (str, "%d=%d", type, value);
56 * zlog_attributes: print attributes of term
58 static void zlog_attributes (Z_AttributesPlusTerm *t, int level,
62 for (of = 0; of < t->num_attributes; of++)
64 Z_AttributeElement *element;
65 element = t->attributeList[of];
67 switch (element->which)
69 case Z_AttributeValue_numeric:
70 logf (LOG_LOG, "%*.s %s", level, "",
71 attrStr (*element->attributeType, *element->value.numeric, ast));
73 case Z_AttributeValue_complex:
74 logf (LOG_LOG, "%*.s attributeType=%d complex", level, "",
75 *element->attributeType);
76 for (i = 0; i<element->value.complex->num_list; i++)
78 if (element->value.complex->list[i]->which ==
79 Z_StringOrNumeric_string)
80 logf (LOG_LOG, "%*.s string: '%s'", level, "",
81 element->value.complex->list[i]->u.string);
82 else if (element->value.complex->list[i]->which ==
83 Z_StringOrNumeric_numeric)
84 logf (LOG_LOG, "%*.s numeric: '%d'", level, "",
85 *element->value.complex->list[i]->u.numeric);
89 logf (LOG_LOG, "%.*s attribute unknown", level, "");
94 static void zlog_structure (Z_RPNStructure *zs, int level, enum oid_value ast)
96 if (zs->which == Z_RPNStructure_complex)
98 switch (zs->u.complex->operator->which)
101 logf (LOG_LOG, "%*.s and", level, "");
104 logf (LOG_LOG, "%*.s or", level, "");
106 case Z_Operator_and_not:
107 logf (LOG_LOG, "%*.s and", level, "");
110 logf (LOG_LOG, "%*.s unknown complex", level, "");
113 zlog_structure (zs->u.complex->s1, level+2, ast);
114 zlog_structure (zs->u.complex->s2, level+2, ast);
116 else if (zs->which == Z_RPNStructure_simple)
118 if (zs->u.simple->which == Z_Operand_APT)
120 Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm;
122 if (zapt->term->which == Z_Term_general)
124 logf (LOG_LOG, "%*.s term '%.*s' (general)", level, "",
125 zapt->term->u.general->len, zapt->term->u.general->buf);
129 logf (LOG_LOG, "%*.s term (not general)", level, "");
131 zlog_attributes (zapt, level+2, ast);
133 else if (zs->u.simple->which == Z_Operand_resultSetId)
135 logf (LOG_LOG, "%*.s set '%s'", level, "",
136 zs->u.simple->u.resultSetId);
139 logf (LOG_LOG, "%*.s unknown simple structure", level, "");
142 logf (LOG_LOG, "%*.s unknown structure", level, "");
145 void zlog_rpn (Z_RPNQuery *rpn)
147 oident *attrset = oid_getentbyoid (rpn->attributeSetId);
150 ast = attrset->value;
151 logf (LOG_LOG, "RPN query. Type: %s", attrset->desc);
152 zlog_structure (rpn->RPNStructure, 0, ast);