+static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ const char *termz_org,
+ oid_value attributeSet,
+ NMEM stream,
+ int reg_type, int complete_flag,
+ const char *rank_type,
+ const char *xpath_use,
+ int num_bases, char **basenames,
+ NMEM rset_nmem,
+ RSET *rset,
+ struct rset_key_control *kc)
+{
+ RSET *result_sets = 0;
+ int num_result_sets = 0;
+ int i;
+ ZEBRA_RES res =
+ term_list_trunc(zh, zapt, termz_org, attributeSet,
+ stream, reg_type, complete_flag,
+ rank_type, xpath_use,
+ num_bases, basenames,
+ rset_nmem,
+ &result_sets, &num_result_sets, kc);
+ if (res != ZEBRA_OK)
+ return res;
+
+ for (i = 0; i<num_result_sets; i++)
+ {
+ RSET first_set = 0;
+ res = rpn_search_APT_position(zh, zapt, attributeSet,
+ reg_type,
+ num_bases, basenames,
+ rset_nmem, &first_set,
+ kc);
+ if (res != ZEBRA_OK)
+ {
+ for (i = 0; i<num_result_sets; i++)
+ rset_delete(result_sets[i]);
+ return res;
+ }
+
+ if (first_set)
+ {
+ RSET tmp_set[2];
+
+ tmp_set[0] = first_set;
+ tmp_set[1] = result_sets[i];
+
+ result_sets[i] = rset_create_prox(
+ rset_nmem, kc, kc->scope,
+ 2, tmp_set,
+ 1 /* ordered */, 0 /* exclusion */,
+ 3 /* relation */, 1 /* distance */);
+ }
+ }
+ if (num_result_sets == 0)
+ *rset = rset_create_null(rset_nmem, kc, 0);
+ else if (num_result_sets == 1)
+ *rset = result_sets[0];
+ else
+ *rset = rset_create_or(rset_nmem, kc, kc->scope, 0 /* termid */,
+ num_result_sets, result_sets);
+ if (!*rset)
+ return ZEBRA_FAIL;
+ return ZEBRA_OK;
+}
+
+static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ const char *termz_org,
+ oid_value attributeSet,
+ NMEM stream,
+ int reg_type, int complete_flag,
+ const char *rank_type,
+ const char *xpath_use,
+ int num_bases, char **basenames,
+ NMEM rset_nmem,
+ RSET *rset,
+ struct rset_key_control *kc)
+{
+ RSET *result_sets = 0;
+ int num_result_sets = 0;
+ int i;
+ ZEBRA_RES res =
+ term_list_trunc(zh, zapt, termz_org, attributeSet,
+ stream, reg_type, complete_flag,
+ rank_type, xpath_use,
+ num_bases, basenames,
+ rset_nmem,
+ &result_sets, &num_result_sets,
+ kc);
+ if (res != ZEBRA_OK)
+ return res;
+ for (i = 0; i<num_result_sets; i++)
+ {
+ RSET first_set = 0;
+ res = rpn_search_APT_position(zh, zapt, attributeSet,
+ reg_type,
+ num_bases, basenames,
+ rset_nmem, &first_set,
+ kc);
+ if (res != ZEBRA_OK)
+ {
+ for (i = 0; i<num_result_sets; i++)
+ rset_delete(result_sets[i]);
+ return res;
+ }
+
+ if (first_set)
+ {
+ RSET tmp_set[2];
+
+ tmp_set[0] = first_set;
+ tmp_set[1] = result_sets[i];
+
+ result_sets[i] = rset_create_prox(
+ rset_nmem, kc, kc->scope,
+ 2, tmp_set,
+ 1 /* ordered */, 0 /* exclusion */,
+ 3 /* relation */, 1 /* distance */);
+ }
+ }
+
+
+ if (num_result_sets == 0)
+ *rset = rset_create_null(rset_nmem, kc, 0);
+ else if (num_result_sets == 1)
+ *rset = result_sets[0];
+ else
+ *rset = rset_create_and(rset_nmem, kc, kc->scope,
+ num_result_sets, result_sets);
+ if (!*rset)
+ return ZEBRA_FAIL;
+ return ZEBRA_OK;
+}
+
+static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
+ const char **term_sub,
+ char *term_dict,
+ oid_value attributeSet,
+ struct grep_info *grep_info,
+ int *max_pos,
+ int reg_type,
+ char *term_dst,
+ int *error_code)