2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.26 1995-10-12 12:40:54 adam
8 * Bug fixes in rpn_prox.
10 * Revision 1.25 1995/10/10 13:59:24 adam
11 * Function rset_open changed its wflag parameter to general flags.
13 * Revision 1.24 1995/10/09 16:18:37 adam
14 * Function dict_lookup_grep got extra client data parameter.
16 * Revision 1.23 1995/10/06 16:33:37 adam
17 * Use attribute mappings.
19 * Revision 1.22 1995/10/06 15:07:39 adam
20 * Structure 'local-number' handled.
22 * Revision 1.21 1995/10/06 13:52:06 adam
23 * Bug fixes. Handler may abort further scanning.
25 * Revision 1.20 1995/10/06 11:06:33 adam
26 * Scan entries include 'occurrences' now.
28 * Revision 1.19 1995/10/06 10:43:56 adam
29 * Scan added. 'occurrences' in scan entries not set yet.
31 * Revision 1.18 1995/10/04 16:57:20 adam
32 * Key input and merge sort in one pass.
34 * Revision 1.17 1995/10/04 12:55:17 adam
35 * Bug fix in ranked search. Use=Any keys inserted.
37 * Revision 1.16 1995/10/02 16:24:40 adam
38 * Use attribute actually used in search requests.
40 * Revision 1.15 1995/10/02 15:18:52 adam
41 * New member in recRetrieveCtrl: diagnostic.
43 * Revision 1.14 1995/09/28 12:10:32 adam
44 * Bug fixes. Field prefix used in queries.
46 * Revision 1.13 1995/09/18 14:17:50 adam
49 * Revision 1.12 1995/09/15 14:45:21 adam
53 * Revision 1.11 1995/09/14 11:53:27 adam
54 * First work on regular expressions/truncations.
56 * Revision 1.10 1995/09/11 15:23:26 adam
57 * More work on relevance search.
59 * Revision 1.9 1995/09/11 13:09:35 adam
60 * More work on relevance feedback.
62 * Revision 1.8 1995/09/08 14:52:27 adam
63 * Minor changes. Dictionary is lower case now.
65 * Revision 1.7 1995/09/07 13:58:36 adam
66 * New parameter: result-set file descriptor (RSFD) to support multiple
67 * positions within the same result-set.
68 * Boolean operators: and, or, not implemented.
69 * Result-set references.
71 * Revision 1.6 1995/09/06 16:11:18 adam
72 * Option: only one word key per file.
74 * Revision 1.5 1995/09/06 10:33:04 adam
75 * More work on present. Some log messages removed.
77 * Revision 1.4 1995/09/05 15:28:40 adam
78 * More work on search engine.
80 * Revision 1.3 1995/09/04 15:20:22 adam
83 * Revision 1.2 1995/09/04 12:33:43 adam
84 * Various cleanup. YAZ util used instead.
86 * Revision 1.1 1995/09/04 09:10:40 adam
87 * More work on index add/del/update.
88 * Merge sort implemented.
89 * Initial work on z39 server.
97 #include <attribute.h>
105 int index_word_prefix_map (char *string, oid_value attrSet, int attrUse)
109 logf (LOG_DEBUG, "oid_value attrSet = %d, attrUse = %d", attrSet, attrUse);
110 attp = att_getentbyatt (attrSet, attrUse);
113 logf (LOG_DEBUG, "ord=%d", attp->attset_ordinal);
114 return index_word_prefix (string, attp->attset_ordinal,
115 attp->local_attribute);
119 * attr_print: log attributes
121 static void attr_print (Z_AttributesPlusTerm *t)
124 for (of = 0; of < t->num_attributes; of++)
126 Z_AttributeElement *element;
127 element = t->attributeList[of];
129 switch (element->which)
131 case Z_AttributeValue_numeric:
132 logf (LOG_DEBUG, "attributeType=%d value=%d",
133 *element->attributeType,
134 *element->value.numeric);
136 case Z_AttributeValue_complex:
137 logf (LOG_DEBUG, "attributeType=%d complex",
138 *element->attributeType);
139 for (i = 0; i<element->value.complex->num_list; i++)
141 if (element->value.complex->list[i]->which ==
142 Z_StringOrNumeric_string)
143 logf (LOG_DEBUG, " string: '%s'",
144 element->value.complex->list[i]->u.string);
145 else if (element->value.complex->list[i]->which ==
146 Z_StringOrNumeric_numeric)
147 logf (LOG_DEBUG, " numeric: '%d'",
148 *element->value.complex->list[i]->u.numeric);
161 Z_AttributesPlusTerm *zapt;
164 static int attr_find (AttrType *src, oid_value *attributeSetP)
166 while (src->major < src->zapt->num_attributes)
168 Z_AttributeElement *element;
170 element = src->zapt->attributeList[src->major];
171 if (src->type == *element->attributeType)
173 switch (element->which)
175 case Z_AttributeValue_numeric:
177 if (element->attributeSet && attributeSetP)
181 attrset = oid_getentbyoid (element->attributeSet);
182 *attributeSetP = attrset->value;
184 return *element->value.numeric;
186 case Z_AttributeValue_complex:
187 if (src->minor >= element->value.complex->num_list ||
188 element->value.complex->list[src->minor]->which !=
189 Z_StringOrNumeric_numeric)
192 if (element->attributeSet && attributeSetP)
196 attrset = oid_getentbyoid (element->attributeSet);
197 *attributeSetP = attrset->value;
199 return *element->value.complex->list[src->minor-1]->u.numeric;
209 static void attr_init (AttrType *src, Z_AttributesPlusTerm *zapt,
222 int (*cmp)(const void *p1, const void *p2);
229 static void heap_swap (struct trunc_info *ti, int i1, int i2)
233 memcpy (ti->swapbuf, ti->heap[i1], ti->keysize);
234 memcpy (ti->heap[i1], ti->heap[i2], ti->keysize);
235 memcpy (ti->heap[i2], ti->swapbuf, ti->keysize);
238 ti->indx[i1] = ti->indx[i2];
242 static void heap_delete (struct trunc_info *ti)
244 int cur = 1, child = 2;
246 assert (ti->heapnum > 0);
247 memcpy (ti->heap[1], ti->heap[ti->heapnum], ti->keysize);
248 ti->indx[1] = ti->indx[ti->heapnum--];
249 while (child <= ti->heapnum) {
250 if (child < ti->heapnum &&
251 (*ti->cmp)(ti->heap[child], ti->heap[1+child]) > 0)
253 if ((*ti->cmp)(ti->heap[cur], ti->heap[child]) > 0)
255 heap_swap (ti, cur, child);
264 static void heap_insert (struct trunc_info *ti, const char *buf, int indx)
268 cur = ++(ti->heapnum);
269 memcpy (ti->heap[cur], buf, ti->keysize);
270 ti->indx[cur] = indx;
272 while (parent && (*ti->cmp)(ti->heap[parent], ti->heap[cur]) > 0)
274 heap_swap (ti, cur, parent);
281 struct trunc_info *heap_init (int size, int key_size,
282 int (*cmp)(const void *p1, const void *p2))
284 struct trunc_info *ti = xmalloc (sizeof(*ti));
289 ti->keysize = key_size;
291 ti->indx = xmalloc (size * sizeof(*ti->indx));
292 ti->heap = xmalloc (size * sizeof(*ti->heap));
293 ti->swapbuf = xmalloc (ti->keysize);
294 ti->tmpbuf = xmalloc (ti->keysize);
295 ti->buf = xmalloc (size * ti->keysize);
296 for (i = size; --i >= 0; )
297 ti->heap[i] = ti->buf + ti->keysize * i;
301 static void heap_close (struct trunc_info *ti)
310 static RSET rset_trunc (ISAM isam, ISAM_P *isam_p, int from, int to,
313 logf (LOG_DEBUG, "rset_trunc, range=%d-%d", from, to-1);
314 if (to - from > merge_chunk)
322 struct trunc_info *ti;
325 rset_temp_parms parms;
327 ispt = xmalloc (sizeof(*ispt) * (to-from));
328 parms.key_size = sizeof (struct it_key);
329 result = rset_create (rset_kind_temp, &parms);
330 rsfd = rset_open (result, RSETF_WRITE|RSETF_SORT_SYSNO);
332 ti = heap_init (to-from, sizeof(struct it_key),
334 for (i = to-from; --i >= 0; )
336 ispt[i] = is_position (isam, isam_p[from+i]);
337 if (is_readkey (ispt[i], ti->tmpbuf))
338 heap_insert (ti, ti->tmpbuf, i);
344 rset_write (result, rsfd, ti->heap[1]);
346 if (is_readkey (ispt[n], ti->tmpbuf))
347 heap_insert (ti, ti->tmpbuf, n);
349 for (i = to-from; --i >= 0; )
350 is_pt_free (ispt[i]);
351 rset_close (result, rsfd);
364 static void add_isam_p (const char *info, struct grep_info *p)
366 if (p->isam_p_indx == p->isam_p_size)
368 ISAM_P *new_isam_p_buf;
370 p->isam_p_size = 2*p->isam_p_size + 100;
371 new_isam_p_buf = xmalloc (sizeof(*new_isam_p_buf) *
375 memcpy (new_isam_p_buf, p->isam_p_buf,
376 p->isam_p_indx * sizeof(*p->isam_p_buf));
377 xfree (p->isam_p_buf);
379 p->isam_p_buf = new_isam_p_buf;
381 assert (*info == sizeof(*p->isam_p_buf));
382 memcpy (p->isam_p_buf + p->isam_p_indx, info+1, sizeof(*p->isam_p_buf));
386 static int grep_handle (Dict_char *name, const char *info, void *p)
388 logf (LOG_DEBUG, "dict name: %s", name);
389 add_isam_p (info, p);
393 static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
394 const char *term_sub,
395 oid_value attributeSet, struct grep_info *grep_info)
397 char term_dict[2*IT_MAX_WORD+2];
401 int truncation_value;
404 oid_value curAttributeSet = attributeSet;
406 attr_init (&use, zapt, 1);
407 use_value = attr_find (&use, &curAttributeSet);
408 logf (LOG_DEBUG, "use value %d", use_value);
409 attr_init (&truncation, zapt, 5);
410 truncation_value = attr_find (&truncation, NULL);
411 logf (LOG_DEBUG, "truncation value %d", truncation_value);
415 i = index_word_prefix_map (term_dict, curAttributeSet, use_value);
422 switch (truncation_value)
424 case -1: /* not specified */
425 case 100: /* do not truncate */
426 strcat (term_dict, term_sub);
427 logf (LOG_DEBUG, "dict_lookup: %s", term_dict);
428 if ((info = dict_lookup (zi->wordDict, term_dict)))
429 add_isam_p (info, grep_info);
431 case 1: /* right truncation */
432 strcat (term_dict, term_sub);
433 strcat (term_dict, ".*");
434 dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, grep_handle);
436 case 2: /* left truncation */
437 case 3: /* left&right truncation */
440 case 101: /* process # in term */
441 for (j = strlen(term_dict), i = 0; term_sub[i] && i < 2; i++)
442 term_dict[j++] = term_sub[i];
443 for (; term_sub[i]; i++)
444 if (term_sub[i] == '#')
446 term_dict[j++] = '.';
447 term_dict[j++] = '*';
450 term_dict[j++] = term_sub[i];
452 dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, grep_handle);
454 case 102: /* regular expression */
455 strcat (term_dict, term_sub);
456 dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, grep_handle);
459 logf (LOG_DEBUG, "%d positions", grep_info->isam_p_indx);
463 static void trans_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
467 Z_Term *term = zapt->term;
469 sizez = term->u.general->len;
470 if (sizez > IT_MAX_WORD)
472 for (i = 0; i < sizez; i++)
473 termz[i] = index_char_cvt (term->u.general->buf[i]);
477 static RSET rpn_search_APT_relevance (ZServerInfo *zi,
478 Z_AttributesPlusTerm *zapt,
479 oid_value attributeSet)
481 rset_relevance_parms parms;
482 char termz[IT_MAX_WORD+1];
483 char term_sub[IT_MAX_WORD+1];
484 struct grep_info grep_info;
485 char *p0 = termz, *p1 = NULL;
488 parms.key_size = sizeof(struct it_key);
490 parms.cmp = key_compare;
491 parms.is = zi->wordIsam;
493 if (zapt->term->which != Z_Term_general)
498 trans_term (zi, zapt, termz);
499 grep_info.isam_p_indx = 0;
500 grep_info.isam_p_size = 0;
501 grep_info.isam_p_buf = NULL;
504 if ((p1 = strchr (p0, ' ')))
506 memcpy (term_sub, p0, p1-p0);
507 term_sub[p1-p0] = '\0';
510 strcpy (term_sub, p0);
511 if (trunc_term (zi, zapt, term_sub, attributeSet, &grep_info))
519 parms.isam_positions = grep_info.isam_p_buf;
520 parms.no_isam_positions = grep_info.isam_p_indx;
521 if (grep_info.isam_p_indx > 0)
522 result = rset_create (rset_kind_relevance, &parms);
524 result = rset_create (rset_kind_null, NULL);
525 xfree (grep_info.isam_p_buf);
529 static RSET rpn_search_APT_word (ZServerInfo *zi,
530 Z_AttributesPlusTerm *zapt,
531 oid_value attributeSet)
533 rset_isam_parms parms;
534 char termz[IT_MAX_WORD+1];
535 struct grep_info grep_info;
538 if (zapt->term->which != Z_Term_general)
543 trans_term (zi, zapt, termz);
545 grep_info.isam_p_indx = 0;
546 grep_info.isam_p_size = 0;
547 grep_info.isam_p_buf = NULL;
549 if (trunc_term (zi, zapt, termz, attributeSet, &grep_info))
551 if (grep_info.isam_p_indx < 1)
552 result = rset_create (rset_kind_null, NULL);
553 else if (grep_info.isam_p_indx == 1)
555 parms.is = zi->wordIsam;
556 parms.pos = *grep_info.isam_p_buf;
557 result = rset_create (rset_kind_isam, &parms);
560 result = rset_trunc (zi->wordIsam, grep_info.isam_p_buf, 0,
561 grep_info.isam_p_indx, 400);
562 xfree (grep_info.isam_p_buf);
566 static RSET rpn_prox (RSET *rset, int rset_no)
574 rset_temp_parms parms;
576 rsfd = xmalloc (sizeof(*rsfd)*rset_no);
577 more = xmalloc (sizeof(*more)*rset_no);
578 buf = xmalloc (sizeof(*buf)*rset_no);
580 for (i = 0; i<rset_no; i++)
582 buf[i] = xmalloc (sizeof(**buf));
583 rsfd[i] = rset_open (rset[i], RSETF_READ|RSETF_SORT_SYSNO);
584 if (!(more[i] = rset_read (rset[i], rsfd[i], buf[i])))
588 rset_close (rset[i], rsfd[i]);
595 return rset_create (rset_kind_null, NULL);
598 parms.key_size = sizeof (struct it_key);
599 result = rset_create (rset_kind_temp, &parms);
600 rsfd_result = rset_open (result, RSETF_WRITE|RSETF_SORT_SYSNO);
604 for (i = 1; i<rset_no; i++)
613 cmp = key_compare (buf[i], buf[i-1]);
616 more[i-1] = rset_read (rset[i-1], rsfd[i-1], buf[i-1]);
621 if (buf[i-1]->seqno+1 != buf[i]->seqno)
623 more[i-1] = rset_read (rset[i-1], rsfd[i-1], buf[i-1]);
629 more[i] = rset_read (rset[i], rsfd[i], buf[i]);
635 rset_write (result, rsfd_result, buf[0]);
636 more[0] = rset_read (*rset, *rsfd, *buf);
640 for (i = 0; i<rset_no; i++)
642 rset_close (rset[i], rsfd[i]);
645 rset_close (result, rsfd_result);
652 static RSET rpn_search_APT_phrase (ZServerInfo *zi,
653 Z_AttributesPlusTerm *zapt,
654 oid_value attributeSet)
656 char termz[IT_MAX_WORD+1];
657 char term_sub[IT_MAX_WORD+1];
658 char *p0 = termz, *p1 = NULL;
659 RSET rset[60], result;
661 struct grep_info grep_info;
663 if (zapt->term->which != Z_Term_general)
668 trans_term (zi, zapt, termz);
670 grep_info.isam_p_size = 0;
671 grep_info.isam_p_buf = NULL;
675 if ((p1 = strchr (p0, ' ')))
677 memcpy (term_sub, p0, p1-p0);
678 term_sub[p1-p0] = '\0';
681 strcpy (term_sub, p0);
683 grep_info.isam_p_indx = 0;
684 if (trunc_term (zi, zapt, term_sub, attributeSet, &grep_info))
686 if (grep_info.isam_p_indx == 0)
687 rset[rset_no] = rset_create (rset_kind_null, NULL);
688 else if (grep_info.isam_p_indx > 1)
689 rset[rset_no] = rset_trunc (zi->wordIsam,
690 grep_info.isam_p_buf, 0,
691 grep_info.isam_p_indx, 400);
694 rset_isam_parms parms;
696 parms.is = zi->wordIsam;
697 parms.pos = *grep_info.isam_p_buf;
698 rset[rset_no] = rset_create (rset_kind_isam, &parms);
700 assert (rset[rset_no]);
701 if (++rset_no >= sizeof(rset)/sizeof(*rset))
709 xfree (grep_info.isam_p_buf);
711 return rset_create (rset_kind_null, NULL);
712 else if (rset_no == 1)
715 result = rpn_prox (rset, rset_no);
716 for (i = 0; i<rset_no; i++)
717 rset_delete (rset[i]);
721 static RSET rpn_search_APT_local (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
722 oid_value attributeSet)
727 rset_temp_parms parms;
728 char termz[IT_MAX_WORD+1];
730 if (zapt->term->which != Z_Term_general)
735 parms.key_size = sizeof (struct it_key);
736 result = rset_create (rset_kind_temp, &parms);
737 rsfd = rset_open (result, RSETF_WRITE|RSETF_SORT_SYSNO);
739 trans_term (zi, zapt, termz);
740 key.sysno = atoi (termz);
743 rset_write (result, rsfd, &key);
744 rset_close (result, rsfd);
749 static RSET rpn_search_APT (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
750 oid_value attributeSet)
754 int relation_value, structure_value;
756 attr_init (&relation, zapt, 2);
757 attr_init (&structure, zapt, 4);
759 relation_value = attr_find (&relation, NULL);
760 structure_value = attr_find (&structure, NULL);
761 switch (structure_value)
764 if (relation_value == 102) /* relevance relation */
765 return rpn_search_APT_relevance (zi, zapt, attributeSet);
766 return rpn_search_APT_phrase (zi, zapt, attributeSet);
768 if (relation_value == 102) /* relevance relation */
769 return rpn_search_APT_relevance (zi, zapt, attributeSet);
770 return rpn_search_APT_phrase (zi, zapt, attributeSet);
773 if (relation_value == 102) /* relevance relation */
774 return rpn_search_APT_relevance (zi, zapt, attributeSet);
775 return rpn_search_APT_word (zi, zapt, attributeSet);
780 case 5: /* date - normalized */
782 case 6: /* word list */
783 return rpn_search_APT_relevance (zi, zapt, attributeSet);
784 case 100: /* date - un-normalized */
786 case 101: /* name - normalized */
788 case 102: /* date - un-normalized */
790 case 103: /* structure */
794 case 105: /* free-form-text */
795 return rpn_search_APT_relevance (zi, zapt, attributeSet);
796 case 106: /* document-text */
797 return rpn_search_APT_relevance (zi, zapt, attributeSet);
798 case 107: /* local-number */
799 return rpn_search_APT_local (zi, zapt, attributeSet);
800 case 108: /* string */
801 return rpn_search_APT_word (zi, zapt, attributeSet);
802 case 109: /* numeric string */
809 static RSET rpn_search_ref (ZServerInfo *zi, Z_ResultSetId *resultSetId)
813 if (!(s = resultSetGet (zi, resultSetId)))
814 return rset_create (rset_kind_null, NULL);
818 static RSET rpn_search_structure (ZServerInfo *zi, Z_RPNStructure *zs,
819 oid_value attributeSet)
822 if (zs->which == Z_RPNStructure_complex)
824 rset_bool_parms bool_parms;
826 bool_parms.rset_l = rpn_search_structure (zi, zs->u.complex->s1,
828 if (bool_parms.rset_l == NULL)
830 bool_parms.rset_r = rpn_search_structure (zi, zs->u.complex->s2,
832 if (bool_parms.rset_r == NULL)
834 rset_delete (bool_parms.rset_l);
837 bool_parms.key_size = sizeof(struct it_key);
838 bool_parms.cmp = key_compare;
840 switch (zs->u.complex->operator->which)
843 r = rset_create (rset_kind_and, &bool_parms);
846 r = rset_create (rset_kind_or, &bool_parms);
848 case Z_Operator_and_not:
849 r = rset_create (rset_kind_not, &bool_parms);
855 else if (zs->which == Z_RPNStructure_simple)
857 if (zs->u.simple->which == Z_Operand_APT)
859 logf (LOG_DEBUG, "rpn_search_APT");
860 r = rpn_search_APT (zi, zs->u.simple->u.attributesPlusTerm,
863 else if (zs->u.simple->which == Z_Operand_resultSetId)
865 logf (LOG_DEBUG, "rpn_search_ref");
866 r = rpn_search_ref (zi, zs->u.simple->u.resultSetId);
880 static void count_set (RSET r, int *count)
886 logf (LOG_DEBUG, "rpn_save_set");
888 rfd = rset_open (r, RSETF_READ|RSETF_SORT_SYSNO);
889 while (rset_read (r, rfd, &key))
891 if (key.sysno != psysno)
898 logf (LOG_DEBUG, "%d distinct sysnos", *count);
901 int rpn_search (ZServerInfo *zi,
902 Z_RPNQuery *rpn, int num_bases, char **basenames,
903 const char *setname, int *hits)
907 oid_value attributeSet;
910 zi->errString = NULL;
912 attrset = oid_getentbyoid (rpn->attributeSetId);
913 attributeSet = attrset->value;
915 rset = rpn_search_structure (zi, rpn->RPNStructure, attributeSet);
918 count_set (rset, hits);
919 resultSetAdd (zi, setname, 1, rset);
921 logf (LOG_DEBUG, "search error: %d", zi->errCode);
926 struct scan_entry *list;
933 static int scan_handle (Dict_char *name, const char *info, int pos,
939 struct scan_info *scan_info = client;
941 rset_isam_parms parms;
943 len_prefix = strlen(scan_info->prefix);
944 if (memcmp (name, scan_info->prefix, len_prefix))
947 idx = scan_info->after - pos + scan_info->before;
950 scan_info->list[idx].term = odr_malloc (scan_info->odr,
951 strlen(name + len_prefix)+1);
952 strcpy (scan_info->list[idx].term, name + len_prefix);
953 assert (*info == sizeof(isam_p));
954 memcpy (&isam_p, info+1, sizeof(isam_p));
955 parms.is = scan_info->isam;
958 rset = rset_create (rset_kind_isam, &parms);
959 count_set (rset, &scan_info->list[idx].occurrences);
962 scan_info->list[idx].occurrences = 1;
964 logf (LOG_DEBUG, "pos=%3d idx=%3d name=%s", pos, idx, name);
968 int rpn_scan (ZServerInfo *zi, ODR odr, Z_AttributesPlusTerm *zapt,
969 int *position, int *num_entries, struct scan_entry **list,
974 int num = *num_entries;
977 char termz[IT_MAX_WORD+20];
980 Z_Term *term = zapt->term;
981 struct scan_info scan_info;
983 logf (LOG_DEBUG, "scan, position = %d, num = %d", pos, num);
984 scan_info.before = before = pos-1;
985 scan_info.after = after = 1+num-pos;
988 logf (LOG_DEBUG, "scan, before = %d, after = %d", before, after);
990 scan_info.isam = zi->wordIsam;
991 scan_info.list = odr_malloc (odr, (before+after)*sizeof(*scan_info.list));
992 for (j = 0; j<before+after; j++)
993 scan_info.list[j].term = NULL;
994 attr_init (&use, zapt, 1);
995 use_value = attr_find (&use, NULL);
996 logf (LOG_DEBUG, "use value %d", use_value);
1000 i = index_word_prefix (termz, 1, use_value);
1001 strcpy (scan_info.prefix, termz);
1002 sizez = term->u.general->len;
1003 if (sizez > IT_MAX_WORD)
1004 sizez = IT_MAX_WORD;
1005 for (j = 0; j<sizez; j++)
1006 termz[j+i] = index_char_cvt (term->u.general->buf[j]);
1009 dict_scan (zi->wordDict, termz, &before, &after, &scan_info, scan_handle);
1011 *status = BEND_SCAN_SUCCESS;
1013 for (i = 0; i<scan_info.after; i++)
1014 if (scan_info.list[scan_info.before+scan_info.after-i-1].term)
1018 *status = BEND_SCAN_PARTIAL;
1020 for (i = 0; i<scan_info.before; i++)
1021 if (scan_info.list[i].term)
1024 *status = BEND_SCAN_PARTIAL;
1028 *list = scan_info.list+i; /* list is set to first 'real' entry */
1030 if (*num_entries == 0) /* signal 'unsupported use-attribute' */
1031 zi->errCode = 114; /* if no entries was found */
1032 logf (LOG_DEBUG, "position = %d, num_entries = %d",
1033 *position, *num_entries);
1035 logf (LOG_DEBUG, "scan error: %d", zi->errCode);