2 * Copyright (C) 1995-1998, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.8 1998-04-02 14:35:29 adam
8 * First version of Zebra that works with compiled ASN.1.
10 * Revision 1.7 1998/01/29 13:40:11 adam
11 * Better logging for scan service.
13 * Revision 1.6 1997/09/29 09:06:41 adam
14 * Removed static var to make this module thread safe.
16 * Revision 1.5 1997/04/30 08:56:07 quinn
19 * Revision 1.4 1996/10/08 09:41:25 quinn
22 * Revision 1.3 1996/03/20 09:36:40 adam
23 * Function dict_lookup_grep got extra parameter, init_pos, which marks
24 * from which position in pattern approximate pattern matching should occur.
25 * Approximate pattern matching is used in relevance=re-2.
27 * Revision 1.2 1996/01/03 16:22:11 quinn
30 * Revision 1.1 1995/11/16 17:00:55 adam
31 * Better logging of rpn query.
39 static void attrStr (int type, int value, enum oid_value ast, char *str)
56 sprintf (str, "relation=Less than");
59 sprintf (str, "relation=Less than or equal");
62 sprintf (str, "relation=Equal");
65 sprintf (str, "relation=Greater or equal");
68 sprintf (str, "relation=Greater than");
71 sprintf (str, "relation=Not equal");
74 sprintf (str, "relation=Phonetic");
77 sprintf (str, "relation=Stem");
80 sprintf (str, "relation=Relevance");
83 sprintf (str, "relation=AlwaysMatches");
86 sprintf (str, "relation");
93 sprintf (str, "position=First in field");
96 sprintf (str, "position=First in any subfield");
99 sprintf (str, "position=Any position in field");
102 sprintf (str, "position");
109 sprintf (str, "structure=Phrase");
112 sprintf (str, "structure=Word");
115 sprintf (str, "structure=Key");
118 sprintf (str, "structure=Year");
121 sprintf (str, "structure=Date");
124 sprintf (str, "structure=Word list");
127 sprintf (str, "structure=Date (un)");
130 sprintf (str, "structure=Name (norm)");
133 sprintf (str, "structure=Name (un)");
136 sprintf (str, "structure=Structure");
139 sprintf (str, "structure=urx");
142 sprintf (str, "structure=free-form-text");
145 sprintf (str, "structure=document-text");
148 sprintf (str, "structure=local-number");
151 sprintf (str, "structure=string");
154 sprintf (str, "structure=numeric string");
157 sprintf (str, "structure");
164 sprintf (str, "truncation=Right");
167 sprintf (str, "truncation=Left");
170 sprintf (str, "truncation=Left&right");
173 sprintf (str, "truncation=Do not truncate");
176 sprintf (str, "truncation=Process #");
179 sprintf (str, "truncation=re-1");
182 sprintf (str, "truncation=re-2");
185 sprintf (str, "truncation");
192 sprintf (str, "completeness=Incomplete subfield");
195 sprintf (str, "completeness=Complete subfield");
198 sprintf (str, "completeness=Complete field");
201 sprintf (str, "completeness");
210 sprintf (str + strlen(str), " (%d=%d)", type, value);
212 sprintf (str, "%d=%d", type, value);
216 * zlog_attributes: print attributes of term
218 static void zlog_attributes (Z_AttributesPlusTerm *t, int level,
224 int num_attributes = t->attributes->num_attributes;
226 int num_attributes = t->num_attributes;
229 for (of = 0; of < num_attributes; of++)
231 Z_AttributeElement *element;
233 element = t->attributes->attributes[of];
235 element = t->attributeList[of];
238 switch (element->which)
240 case Z_AttributeValue_numeric:
241 attrStr (*element->attributeType,
242 *element->value.numeric, ast, str);
243 logf (LOG_LOG, "%*.s %s", level, "", str);
245 case Z_AttributeValue_complex:
246 logf (LOG_LOG, "%*.s attributeType=%d complex", level, "",
247 *element->attributeType);
248 for (i = 0; i<element->value.complex->num_list; i++)
250 if (element->value.complex->list[i]->which ==
251 Z_StringOrNumeric_string)
252 logf (LOG_LOG, "%*.s string: '%s'", level, "",
253 element->value.complex->list[i]->u.string);
254 else if (element->value.complex->list[i]->which ==
255 Z_StringOrNumeric_numeric)
256 logf (LOG_LOG, "%*.s numeric: '%d'", level, "",
257 *element->value.complex->list[i]->u.numeric);
261 logf (LOG_LOG, "%.*s attribute unknown", level, "");
266 static void zlog_structure (Z_RPNStructure *zs, int level, enum oid_value ast)
268 if (zs->which == Z_RPNStructure_complex)
270 switch (zs->u.complex->roperator->which)
273 logf (LOG_LOG, "%*.s and", level, "");
276 logf (LOG_LOG, "%*.s or", level, "");
278 case Z_Operator_and_not:
279 logf (LOG_LOG, "%*.s and-not", level, "");
282 logf (LOG_LOG, "%*.s unknown complex", level, "");
285 zlog_structure (zs->u.complex->s1, level+2, ast);
286 zlog_structure (zs->u.complex->s2, level+2, ast);
288 else if (zs->which == Z_RPNStructure_simple)
290 if (zs->u.simple->which == Z_Operand_APT)
292 Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm;
294 if (zapt->term->which == Z_Term_general)
296 logf (LOG_LOG, "%*.s term '%.*s' (general)", level, "",
297 zapt->term->u.general->len, zapt->term->u.general->buf);
301 logf (LOG_LOG, "%*.s term (not general)", level, "");
303 zlog_attributes (zapt, level+2, ast);
305 else if (zs->u.simple->which == Z_Operand_resultSetId)
307 logf (LOG_LOG, "%*.s set '%s'", level, "",
308 zs->u.simple->u.resultSetId);
311 logf (LOG_LOG, "%*.s unknown simple structure", level, "");
314 logf (LOG_LOG, "%*.s unknown structure", level, "");
317 void zlog_rpn (Z_RPNQuery *rpn)
319 oident *attrset = oid_getentbyoid (rpn->attributeSetId);
322 ast = attrset->value;
323 logf (LOG_LOG, "RPN query. Type: %s", attrset->desc);
324 zlog_structure (rpn->RPNStructure, 0, ast);
327 void zlog_scan (Z_AttributesPlusTerm *zapt, oid_value ast)
330 if (zapt->term->which == Z_Term_general)
332 logf (LOG_LOG, "%*.s term '%.*s' (general)", level, "",
333 zapt->term->u.general->len, zapt->term->u.general->buf);
336 logf (LOG_LOG, "%*.s term (not general)", level, "");
337 zlog_attributes (zapt, level+2, ast);