+ /* got header assume "isamb"major minor len can fit in 16 bytes */
+ zint zint_tmp;
+ int major, minor, len, pos = 0;
+ int left;
+ const char *src = 0;
+ if (memcmp(hbuf, "isamb", 5))
+ {
+ yaz_log(YLOG_WARN, "bad isamb header for file %s", fname);
+ isamb_close(isamb);
+ return 0;
+ }
+ if (sscanf(hbuf+5, "%d %d %d", &major, &minor, &len) != 3)
+ {
+ yaz_log(YLOG_WARN, "bad isamb header for file %s", fname);
+ isamb_close(isamb);
+ return 0;
+ }
+ if (major != ISAMB_MAJOR_VERSION)
+ {
+ yaz_log(YLOG_WARN, "bad major version for file %s %d, must be %d",
+ fname, major, ISAMB_MAJOR_VERSION);
+ isamb_close(isamb);
+ return 0;
+ }
+ for (left = len - sizes[i]; left > 0; left = left - sizes[i])
+ {
+ pos++;
+ if (!bf_read(isamb->file[i].bf, pos, 0, 0, hbuf + pos*sizes[i]))
+ {
+ yaz_log(YLOG_WARN, "truncated isamb header for "
+ "file=%s len=%d pos=%d",
+ fname, len, pos);
+ isamb_close(isamb);
+ return 0;
+ }
+ }
+ src = hbuf + 16;
+ decode_ptr(&src, &isamb->file[i].head.first_block);
+ decode_ptr(&src, &isamb->file[i].head.last_block);
+ decode_ptr(&src, &zint_tmp);
+ isamb->file[i].head.block_size = (int) zint_tmp;
+ decode_ptr(&src, &zint_tmp);
+ isamb->file[i].head.block_max = (int) zint_tmp;
+ decode_ptr(&src, &isamb->file[i].head.free_list);
+ if (isamb->minor_version >= ISAMB_MINOR_VERSION_WITH_ROOT)
+ decode_ptr(&src, &isamb->root_ptr);