+ char *term_dst, int xpath_use,
+ struct ord_list **ol);
+
+static ZEBRA_RES term_limits_APT(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ zint *hits_limit_value,
+ const char **term_ref_id_str,
+ NMEM nmem)
+{
+ AttrType term_ref_id_attr;
+ AttrType hits_limit_attr;
+ int term_ref_id_int;
+
+ attr_init(&hits_limit_attr, zapt, 9);
+ *hits_limit_value = attr_find(&hits_limit_attr, NULL);
+
+ attr_init(&term_ref_id_attr, zapt, 10);
+ term_ref_id_int = attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str);
+ if (term_ref_id_int >= 0)
+ {
+ char *res = nmem_malloc(nmem, 20);
+ sprintf(res, "%d", term_ref_id_int);
+ *term_ref_id_str = res;
+ }
+
+ /* no limit given ? */
+ if (*hits_limit_value == -1)
+ {
+ if (*term_ref_id_str)
+ {
+ /* use global if term_ref is present */
+ *hits_limit_value = zh->approx_limit;
+ }
+ else
+ {
+ /* no counting if term_ref is not present */
+ *hits_limit_value = 0;
+ }
+ }
+ else if (*hits_limit_value == 0)
+ {
+ /* 0 is the same as global limit */
+ *hits_limit_value = zh->approx_limit;
+ }
+ yaz_log(YLOG_DEBUG, "term_limits_APT ref_id=%s limit=" ZINT_FORMAT,
+ *term_ref_id_str ? *term_ref_id_str : "none",
+ *hits_limit_value);
+ return ZEBRA_OK;
+}