+static char *set_queryExpression (Z_QueryExpression *qe)
+{
+ char *termz = 0;
+ if (!qe)
+ return 0;
+ if (qe->which == Z_QueryExpression_term)
+ {
+ if (qe->u.term->queryTerm)
+ {
+ Z_Term *term = qe->u.term->queryTerm;
+ if (term->which == Z_Term_general)
+ {
+ termz = xmalloc (term->u.general->len+1);
+ memcpy (termz, term->u.general->buf, term->u.general->len);
+ termz[term->u.general->len] = 0;
+ }
+ }
+ }
+ return termz;
+}
+
+static void set_searchResult (Z_OtherInformation *o,
+ IrTcl_SetObj *setobj)
+{
+ int i;
+ if (!o)
+ return ;
+ for (i = 0; i < o->num_elements; i++)
+ {
+ if (o->list[i]->which == Z_OtherInfo_externallyDefinedInfo)
+ {
+ ODR odr = odr_createmem (ODR_DECODE);
+ Z_External *ext = o->list[i]->information.externallyDefinedInfo;
+ Z_SearchInfoReport *sr = 0;
+
+ if (ext->which == Z_External_single)
+ {
+ odr_setbuf (odr, ext->u.single_ASN1_type->buf,
+ ext->u.single_ASN1_type->len, 0);
+ z_SearchInfoReport (odr, &sr, 0, "searchInfo");
+ }
+ if (ext->which == Z_External_searchResult1)
+ sr = ext->u.searchResult1;
+ if (sr)
+ {
+ int j;
+ reset_searchResult (setobj);
+
+ setobj->searchResult_num = sr->num;
+ setobj->searchResult_terms =
+ xmalloc (sr->num * sizeof(*setobj->searchResult_terms));
+ setobj->searchResult_count =
+ xmalloc (sr->num * sizeof(*setobj->searchResult_count));
+
+ for (j = 0; j < sr->num; j++)
+ {
+ setobj->searchResult_terms[j] =
+ set_queryExpression (
+ sr->elements[j]->subqueryExpression);
+ if (sr->elements[j]->subqueryCount)
+ setobj->searchResult_count[j] =
+ *sr->elements[j]->subqueryCount;
+ else
+ setobj->searchResult_count[j] = 0;
+ }
+ }
+ odr_destroy (odr);
+ }
+ }
+}
+