- if ((r=att_getentbyatt (zh, &attp, curAttributeSet, use_value)))
- {
- logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
- curAttributeSet, use_value, r);
- if (r == -1)
- {
- /* set was found, but value wasn't defined */
- char val_str[32];
- sprintf (val_str, "%d (1)", use_value);
- zh->errCode = 114;
- zh->errString = nmem_strdup (stream, val_str);
- }
- else
- {
- int oid[OID_SIZE];
- struct oident oident;
-
- oident.proto = PROTO_Z3950;
- oident.oclass = CLASS_ATTSET;
- oident.value = curAttributeSet;
- oid_ent_to_oid (&oident, oid);
-
- zh->errCode = 121;
- zh->errString = nmem_strdup (stream, oident.desc);
- }
- return -1;
- }
- }
- for (local_attr = attp.local_attributes; local_attr;
- local_attr = local_attr->next)
- {
- int ord;
- char ord_buf[32];
- int i, ord_len;
-
- ord = zebraExplain_lookupSU (zh->reg->zei, attp.attset_ordinal,
- local_attr->local);
- if (ord < 0)
- continue;
- if (prefix_len)
- term_dict[prefix_len++] = '|';
- else
- term_dict[prefix_len++] = '(';
-
- ord_len = key_SU_encode (ord, ord_buf);
- for (i = 0; i<ord_len; i++)
- {
- term_dict[prefix_len++] = 1;
- term_dict[prefix_len++] = ord_buf[i];
- }
- }
- if (!prefix_len)
- {
- char val_str[32];
- sprintf (val_str, "%d (2)", use_value);
- zh->errCode = 114;
- zh->errString = nmem_strdup (stream, val_str);
- return -1;
- }
- term_dict[prefix_len++] = ')';
- term_dict[prefix_len++] = 1;
- term_dict[prefix_len++] = reg_type;
- logf (LOG_DEBUG, "reg_type = %d", term_dict[prefix_len-1]);
- term_dict[prefix_len] = '\0';
- j = prefix_len;
- switch (truncation_value)
- {
- case -1: /* not specified */
- case 100: /* do not truncate */
- if (!string_relation (zh, zapt, &termp, term_dict,
- attributeSet,
- reg_type, space_split, term_dst))
- return 0;
- logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict+prefix_len);
- r = dict_lookup_grep (zh->reg->dict, term_dict, 0,
- grep_info, &max_pos, 0, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep fail, rel=gt: %d", r);
- break;
- case 1: /* right truncation */
- term_dict[j++] = '(';
- if (!term_100 (zh->reg->zebra_maps, reg_type,
- &termp, term_dict + j, space_split, term_dst))
- return 0;
- strcat (term_dict, ".*)");
- dict_lookup_grep (zh->reg->dict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- break;
- case 2: /* keft truncation */
- term_dict[j++] = '('; term_dict[j++] = '.'; term_dict[j++] = '*';
- if (!term_100 (zh->reg->zebra_maps, reg_type,
- &termp, term_dict + j, space_split, term_dst))
- return 0;
- strcat (term_dict, ")");
- dict_lookup_grep (zh->reg->dict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- break;
- case 3: /* left&right truncation */
- term_dict[j++] = '('; term_dict[j++] = '.'; term_dict[j++] = '*';
- if (!term_100 (zh->reg->zebra_maps, reg_type,
- &termp, term_dict + j, space_split, term_dst))
- return 0;
- strcat (term_dict, ".*)");
- dict_lookup_grep (zh->reg->dict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- break;
- zh->errCode = 120;
- return -1;
- case 101: /* process # in term */
- term_dict[j++] = '(';
- if (!term_101 (zh->reg->zebra_maps, reg_type,
- &termp, term_dict + j, space_split, term_dst))
- return 0;
- strcat (term_dict, ")");
- r = dict_lookup_grep (zh->reg->dict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=#: %d", r);
- break;
- case 102: /* Regexp-1 */
- term_dict[j++] = '(';
- if (!term_102 (zh->reg->zebra_maps, reg_type,
- &termp, term_dict + j, space_split, term_dst))
- return 0;
- strcat (term_dict, ")");
- logf (LOG_DEBUG, "Regexp-1 tolerance=%d", r);
- r = dict_lookup_grep (zh->reg->dict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=regular: %d",
- r);
- break;
- case 103: /* Regexp-2 */
- r = 1;
- term_dict[j++] = '(';
- if (!term_103 (zh->reg->zebra_maps, reg_type,
- &termp, term_dict + j, &r, space_split, term_dst))
- return 0;
- strcat (term_dict, ")");
- logf (LOG_DEBUG, "Regexp-2 tolerance=%d", r);
- r = dict_lookup_grep (zh->reg->dict, term_dict, r, grep_info,
- &max_pos, 2, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=eregular: %d",
- r);
- break;
- case 104: /* process # and ! in term */
- term_dict[j++] = '(';
- if (!term_104 (zh->reg->zebra_maps, reg_type,
- &termp, term_dict + j, space_split, term_dst))
- return 0;
- strcat (term_dict, ")");
- r = dict_lookup_grep (zh->reg->dict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=#/!: %d", r);
- break;
- case 105: /* process * and ! in term */
- term_dict[j++] = '(';
- if (!term_105 (zh->reg->zebra_maps, reg_type,
- &termp, term_dict + j, space_split, term_dst, 1))
- return 0;
- strcat (term_dict, ")");
- r = dict_lookup_grep (zh->reg->dict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=*/!: %d", r);