+#if ISAMB_DEBUG
+ struct ISAMB_block *p = pp->block[pp->level];
+ assert(p->leaf);
+ logf(LOG_DEBUG,"isamb_pp_forward starting "
+ "at level %d node %d ofs=%d sz=%d u=%p sc=%d",
+ pp->level, p->pos, p->offset, p->size,untilbuf, scope);
+#endif
+ if (untilbuf) {
+ if (isamb_pp_forward_on_leaf( pp, buf, untilbuf)) {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_forward (f) returning (A) "
+ "at level %d node %d ofs=%d sz=%d",
+ pp->level, p->pos, p->offset, p->size);
+#endif
+ return 1;
+ }
+ if (! isamb_pp_climb_desc( pp, untilbuf)) {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_forward (f) returning notfound (B) "
+ "at level %d node %d ofs=%d sz=%d",
+ pp->level, p->pos, p->offset, p->size);
+#endif
+ return 0; /* could not find a leaf */
+ }
+ do{
+ if (isamb_pp_forward_on_leaf( pp, buf, untilbuf)) {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_forward (f) returning (C) "
+ "at level %d node %d ofs=%d sz=%d",
+ pp->level, p->pos, p->offset, p->size);
+#endif
+ return 1;
+ }
+ }while ( isamb_pp_find_next_leaf(pp));
+ return 0; /* could not find at all */
+ }
+ else { /* no untilbuf, a straight read */
+ /* FIXME - this should be moved
+ * directly into the pp_read */
+ /* keeping here now, to keep same
+ * interface as the old fwd */
+ if (isamb_pp_read_on_leaf( pp, buf)) {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_forward (read) returning (D) "
+ "at level %d node %d ofs=%d sz=%d",
+ pp->level, p->pos, p->offset, p->size);
+#endif
+ return 1;
+ }
+ if (isamb_pp_find_next_leaf(pp)) {
+#if ISAMB_DEBUG
+ logf(LOG_DEBUG,"isamb_pp_forward (read) returning (E) "
+ "at level %d node %d ofs=%d sz=%d",
+ pp->level, p->pos, p->offset, p->size);
+#endif
+ return isamb_pp_read_on_leaf(pp, buf);
+ }
+ else
+ return 0;
+ }
+} /* isam_pp_forward (new version) */
+
+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 */
+ struct ISAMB_block *p = pp->block[pp->level];
+ assert(total);
+ assert(current);
+ assert(p->leaf);
+
+ *total = pp->block[0]->no_items;
+ *current = (double) pp->returned_numbers;
+#if ISAMB_DEBUG
+ logf(LOG_LOG, "isamb_pp_pos returning: cur= %0.1f tot=%0.1f rn="
+ ZINT_FORMAT, *current, *total, pp->returned_numbers);
+#endif