2 * Copyright (C) 1995-1998, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.9 1998-10-13 20:36:02 adam
8 * Changed "indent" format string in log messages.
10 * Revision 1.8 1998/04/02 14:35:29 adam
11 * First version of Zebra that works with compiled ASN.1.
13 * Revision 1.7 1998/01/29 13:40:11 adam
14 * Better logging for scan service.
16 * Revision 1.6 1997/09/29 09:06:41 adam
17 * Removed static var to make this module thread safe.
19 * Revision 1.5 1997/04/30 08:56:07 quinn
22 * Revision 1.4 1996/10/08 09:41:25 quinn
25 * Revision 1.3 1996/03/20 09:36:40 adam
26 * Function dict_lookup_grep got extra parameter, init_pos, which marks
27 * from which position in pattern approximate pattern matching should occur.
28 * Approximate pattern matching is used in relevance=re-2.
30 * Revision 1.2 1996/01/03 16:22:11 quinn
33 * Revision 1.1 1995/11/16 17:00:55 adam
34 * Better logging of rpn query.
42 static void attrStr (int type, int value, enum oid_value ast, char *str)
59 sprintf (str, "relation=Less than");
62 sprintf (str, "relation=Less than or equal");
65 sprintf (str, "relation=Equal");
68 sprintf (str, "relation=Greater or equal");
71 sprintf (str, "relation=Greater than");
74 sprintf (str, "relation=Not equal");
77 sprintf (str, "relation=Phonetic");
80 sprintf (str, "relation=Stem");
83 sprintf (str, "relation=Relevance");
86 sprintf (str, "relation=AlwaysMatches");
89 sprintf (str, "relation");
96 sprintf (str, "position=First in field");
99 sprintf (str, "position=First in any subfield");
102 sprintf (str, "position=Any position in field");
105 sprintf (str, "position");
112 sprintf (str, "structure=Phrase");
115 sprintf (str, "structure=Word");
118 sprintf (str, "structure=Key");
121 sprintf (str, "structure=Year");
124 sprintf (str, "structure=Date");
127 sprintf (str, "structure=Word list");
130 sprintf (str, "structure=Date (un)");
133 sprintf (str, "structure=Name (norm)");
136 sprintf (str, "structure=Name (un)");
139 sprintf (str, "structure=Structure");
142 sprintf (str, "structure=urx");
145 sprintf (str, "structure=free-form-text");
148 sprintf (str, "structure=document-text");
151 sprintf (str, "structure=local-number");
154 sprintf (str, "structure=string");
157 sprintf (str, "structure=numeric string");
160 sprintf (str, "structure");
167 sprintf (str, "truncation=Right");
170 sprintf (str, "truncation=Left");
173 sprintf (str, "truncation=Left&right");
176 sprintf (str, "truncation=Do not truncate");
179 sprintf (str, "truncation=Process #");
182 sprintf (str, "truncation=re-1");
185 sprintf (str, "truncation=re-2");
188 sprintf (str, "truncation");
195 sprintf (str, "completeness=Incomplete subfield");
198 sprintf (str, "completeness=Complete subfield");
201 sprintf (str, "completeness=Complete field");
204 sprintf (str, "completeness");
213 sprintf (str + strlen(str), " (%d=%d)", type, value);
215 sprintf (str, "%d=%d", type, value);
219 * zlog_attributes: print attributes of term
221 static void zlog_attributes (Z_AttributesPlusTerm *t, int level,
227 int num_attributes = t->attributes->num_attributes;
229 int num_attributes = t->num_attributes;
232 for (of = 0; of < num_attributes; of++)
234 Z_AttributeElement *element;
236 element = t->attributes->attributes[of];
238 element = t->attributeList[of];
241 switch (element->which)
243 case Z_AttributeValue_numeric:
244 attrStr (*element->attributeType,
245 *element->value.numeric, ast, str);
246 logf (LOG_LOG, "%*.0s %s", level, "", str);
248 case Z_AttributeValue_complex:
249 logf (LOG_LOG, "%*.0s attributeType=%d complex", level, "",
250 *element->attributeType);
251 for (i = 0; i<element->value.complex->num_list; i++)
253 if (element->value.complex->list[i]->which ==
254 Z_StringOrNumeric_string)
255 logf (LOG_LOG, "%*.0s string: '%s'", level, "",
256 element->value.complex->list[i]->u.string);
257 else if (element->value.complex->list[i]->which ==
258 Z_StringOrNumeric_numeric)
259 logf (LOG_LOG, "%*.0s numeric: '%d'", level, "",
260 *element->value.complex->list[i]->u.numeric);
264 logf (LOG_LOG, "%.*s attribute unknown", level, "");
269 static void zlog_structure (Z_RPNStructure *zs, int level, enum oid_value ast)
271 if (zs->which == Z_RPNStructure_complex)
273 switch (zs->u.complex->roperator->which)
276 logf (LOG_LOG, "%*.0s and", level, "");
279 logf (LOG_LOG, "%*.0s or", level, "");
281 case Z_Operator_and_not:
282 logf (LOG_LOG, "%*.0s and-not", level, "");
285 logf (LOG_LOG, "%*.0s unknown complex", level, "");
288 zlog_structure (zs->u.complex->s1, level+2, ast);
289 zlog_structure (zs->u.complex->s2, level+2, ast);
291 else if (zs->which == Z_RPNStructure_simple)
293 if (zs->u.simple->which == Z_Operand_APT)
295 Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm;
297 if (zapt->term->which == Z_Term_general)
299 logf (LOG_LOG, "%*.0s term '%.*s' (general)", level, "",
300 zapt->term->u.general->len, zapt->term->u.general->buf);
304 logf (LOG_LOG, "%*.0s term (not general)", level, "");
306 zlog_attributes (zapt, level+2, ast);
308 else if (zs->u.simple->which == Z_Operand_resultSetId)
310 logf (LOG_LOG, "%*.0s set '%s'", level, "",
311 zs->u.simple->u.resultSetId);
314 logf (LOG_LOG, "%*.0s unknown simple structure", level, "");
317 logf (LOG_LOG, "%*.0s unknown structure", level, "");
320 void zlog_rpn (Z_RPNQuery *rpn)
325 attrset = oid_getentbyoid (rpn->attributeSetId);
328 ast = attrset->value;
329 logf (LOG_LOG, "RPN query. Type: %s", attrset->desc);
334 logf (LOG_LOG, "RPN query. Unknown type");
336 zlog_structure (rpn->RPNStructure, 0, ast);
339 void zlog_scan (Z_AttributesPlusTerm *zapt, oid_value ast)
342 if (zapt->term->which == Z_Term_general)
344 logf (LOG_LOG, "%*.0s term '%.*s' (general)", level, "",
345 zapt->term->u.general->len, zapt->term->u.general->buf);
348 logf (LOG_LOG, "%*.0s term (not general)", level, "");
349 zlog_attributes (zapt, level+2, ast);