+ return p->index_fname;
+}
+
+ZEBRA_RES recindex_write_head(recindex_t p, const void *buf, size_t len)
+{
+ int r;
+
+ assert(p);
+
+ assert(p->index_BFile);
+
+ r = bf_write(p->index_BFile, 0, 0, len, buf);
+ if (r)
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "write head of %s", p->index_fname);
+ return ZEBRA_FAIL;
+ }
+ return ZEBRA_OK;
+}
+
+int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize,
+ int ignoreError)
+{
+ int r = 0;
+ if (p->isamb)
+ {
+ if (p->isam_p)
+ {
+ char item[256];
+ char *st = item;
+ char untilbuf[sizeof(zint) + 1];
+
+ ISAMB_PP isam_pp = isamb_pp_open(p->isamb, p->isam_p, 1);
+
+ memcpy(untilbuf, &sysno, sizeof(sysno));
+ untilbuf[sizeof(sysno)] = 0;
+ r = isamb_pp_forward(isam_pp, st, untilbuf);
+
+ isamb_pp_close(isam_pp);
+ if (!r)
+ return 0;
+
+ if (item[sizeof(sysno)] != itemsize)
+ {
+ yaz_log(YLOG_WARN, "unexpected entry size %d != %d",
+ item[sizeof(sysno)], itemsize);
+ return 0;
+ }
+ memcpy(buf, item + sizeof(sysno) + 1, itemsize);
+ }
+ }
+ else
+ {
+ zint pos = (sysno-1)*itemsize;
+ int off = CAST_ZINT_TO_INT(pos%RIDX_CHUNK);
+ int sz1 = RIDX_CHUNK - off; /* sz1 is size of buffer to read.. */
+
+ if (sz1 > itemsize)
+ sz1 = itemsize; /* no more than itemsize bytes */
+
+ r = bf_read(p->index_BFile, 1+pos/RIDX_CHUNK, off, sz1, buf);
+ if (r == 1 && sz1 < itemsize) /* boundary? - must read second part */
+ r = bf_read(p->index_BFile, 2+pos/RIDX_CHUNK, 0, itemsize - sz1,
+ (char*) buf + sz1);
+ if (r != 1 && !ignoreError)
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "read in %s at pos %ld",
+ p->index_fname, (long) pos);
+ }
+ }
+#if 0
+ {
+ struct record_index_entry *ep = buf;
+ yaz_log(YLOG_LOG, "read r=%d sysno=" ZINT_FORMAT " next=" ZINT_FORMAT
+ " sz=%d", r, sysno, ep->next, ep->size);
+ }
+#endif
+ return r;