+int rset_default_read(RSFD rfd, void *buf, TERMID *term)
+{
+ RSET rset = rfd->rset;
+ int rc = (*rset->control->f_read)(rfd, buf, term);
+ if (rc > 0)
+ {
+ int got_scope;
+ if (rfd->counted_items == 0)
+ got_scope = rset->scope+1;
+ else
+ got_scope = rset->keycontrol->cmp(buf, rfd->counted_buf);
+
+#if 0
+ key_logdump_txt(YLOG_LOG, buf, "rset_default_read");
+ yaz_log(YLOG_LOG, "rset_scope=%d got_scope=%d", rset->scope, got_scope);
+#endif
+ if (got_scope > rset->scope)
+ {
+ memcpy(rfd->counted_buf, buf, rset->keycontrol->key_size);
+ rfd->counted_items++;
+ }
+ }
+ return rc;
+}
+
+int rset_default_forward(RSFD rfd, void *buf, TERMID *term,
+ const void *untilbuf)
+{
+ RSET rset = rfd->rset;
+ int more;
+
+ if (rset->control->f_forward &&
+ rfd->counted_items >= rset->hits_limit)
+ {
+ assert (rset->control->f_forward != rset_default_forward);
+ return rset->control->f_forward(rfd, buf, term, untilbuf);
+ }
+
+ while ((more = rset_read(rfd, buf, term)) > 0)
+ {
+ if ((rfd->rset->keycontrol->cmp)(untilbuf, buf) <= 1)
+ break;
+ }
+ if (log_level)
+ yaz_log (log_level, "rset_default_forward exiting m=%d c=%d",
+ more, rset->scope);
+
+ return more;
+}
+
+void rset_visit(RSET rset, int level)
+{
+ int i;
+ yaz_log(YLOG_LOG, "%*s%c " ZINT_FORMAT, level, "",
+ rset->hits_approx ? '~' : '=',
+ rset->hits_count);
+ for (i = 0; i<rset->no_children; i++)
+ rset_visit(rset->children[i], level+1);
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */