+ close_block(pp->isamb, pp->block[i]);
+ xfree(pp->block);
+ xfree(pp);
+}
+
+int isamb_block_info(ISAMB isamb, int cat)
+{
+ if (cat >= 0 && cat < isamb->no_cat)
+ return isamb->file[cat].head.block_size;
+ return -1;
+}
+
+void isamb_pp_close(ISAMB_PP pp)
+{
+ isamb_pp_close_x(pp, 0, 0);
+}
+
+/* simple recursive dumper .. */
+static void isamb_dump_r(ISAMB b, ISAM_P pos, void (*pr)(const char *str),
+ int level)
+{
+ char buf[1024];
+ char prefix_str[1024];
+ if (pos)
+ {
+ struct ISAMB_block *p = open_block(b, pos);
+ sprintf(prefix_str, "%*s " ZINT_FORMAT " cat=%d size=%d max=%d items="
+ ZINT_FORMAT, level*2, "",
+ pos, p->cat, p->size, b->file[p->cat].head.block_max,
+ p->no_items);
+ (*pr)(prefix_str);
+ sprintf(prefix_str, "%*s " ZINT_FORMAT, level*2, "", pos);
+ if (p->leaf)
+ {
+ while (p->offset < p->size)
+ {
+ const char *src = p->bytes + p->offset;
+ char *dst = buf;
+ (*b->method->codec.decode)(p->decodeClientData, &dst, &src);
+ (*b->method->log_item)(YLOG_DEBUG, buf, prefix_str);
+ p->offset = src - (char*) p->bytes;
+ }
+ assert(p->offset == p->size);
+ }
+ else
+ {
+ const char *src = p->bytes + p->offset;
+ ISAM_P sub;
+
+ decode_ptr(&src, &sub);
+ p->offset = src - (char*) p->bytes;
+
+ isamb_dump_r(b, sub, pr, level+1);
+
+ while (p->offset < p->size)
+ {
+#if INT_ENCODE
+ char file_item_buf[DST_ITEM_MAX];
+ char *file_item = file_item_buf;
+ void *c1 = (*b->method->codec.start)();
+ (*b->method->codec.decode)(c1, &file_item, &src);
+ (*b->method->codec.stop)(c1);
+ (*b->method->log_item)(YLOG_DEBUG, file_item_buf, prefix_str);
+#else
+ zint item_len;
+ decode_item_len(&src, &item_len);
+ (*b->method->log_item)(YLOG_DEBUG, src, prefix_str);
+ src += item_len;
+#endif
+ decode_ptr(&src, &sub);
+
+ p->offset = src - (char*) p->bytes;
+
+ isamb_dump_r(b, sub, pr, level+1);
+ }
+ }
+ close_block(b, p);
+ }
+}
+
+void isamb_dump(ISAMB b, ISAM_P pos, void (*pr)(const char *str))
+{
+ isamb_dump_r(b, pos, pr, 0);
+}
+
+int isamb_pp_read(ISAMB_PP pp, void *buf)
+{
+ return isamb_pp_forward(pp, buf, 0);
+}
+
+
+void isamb_pp_pos(ISAMB_PP pp, double *current, double *total)
+{ /* return an estimate of the current position and of the total number of */
+ /* occureences in the isam tree, based on the current leaf */
+ assert(total);
+ assert(current);
+
+ /* if end-of-stream PP may not be leaf */
+
+ *total = (double) (pp->block[0]->no_items);
+ *current = (double) pp->returned_numbers;
+#if ISAMB_DEBUG
+ yaz_log(YLOG_LOG, "isamb_pp_pos returning: cur= %0.1f tot=%0.1f rn="
+ ZINT_FORMAT, *current, *total, pp->returned_numbers);
+#endif