+static ZEBRA_RES term_limits_APT(ZebraHandle zh,
+ Z_AttributesPlusTerm *zapt,
+ zint *hits_limit_value,
+ const char **term_ref_id_str)
+{
+ AttrType term_ref_id_attr;
+ AttrType hits_limit_attr;
+
+ attr_init(&hits_limit_attr, zapt, 9);
+ *hits_limit_value = attr_find(&hits_limit_attr, NULL);
+
+ attr_init(&term_ref_id_attr, zapt, 10);
+ attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str);
+
+ /* 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_LOG, "term_limits_APT ref_id=%s limit=" ZINT_FORMAT,
+ *term_ref_id_str ? *term_ref_id_str : "none",
+ *hits_limit_value);
+ return ZEBRA_OK;
+}
+