Remove isamd. It's not been in use for a long time and isamb is better
[idzebra-moved-to-github.git] / bfile / mfile.c
index 62e298a..a96820a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mfile.c,v 1.51 2003-03-25 23:47:23 adam Exp $
+/* $Id: mfile.c,v 1.53 2004-08-04 08:35:22 adam Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
    Index Data Aps
 
@@ -162,10 +162,13 @@ static int file_position(MFile mf, int pos, int offset)
             return -1;
         }
     }
-    if (mfile_seek(mf->files[c].fd, (ps = pos - off) * mf->blocksize + offset,
+    ps = pos - off;
+    if (mfile_seek(mf->files[c].fd, ps * (mfile_off_t) mf->blocksize + offset,
        SEEK_SET) < 0)
     {
        logf (LOG_WARN|LOG_ERRNO, "Failed to seek in %s", mf->files[c].path);
+        logf(LOG_WARN, "pos=%d off=%d blocksize=%d offset=%d",
+                       pos, off, mf->blocksize, offset);
        return -1;
     }
     mf->cur_file = c;
@@ -448,7 +451,7 @@ int mf_close(MFile mf)
 /*
  * Read one block from a metafile. Interface mirrors bfile.
  */
-int mf_read(MFile mf, int no, int offset, int nbytes, void *buf)
+int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf)
 {
     int rd, toread;
 
@@ -483,7 +486,7 @@ int mf_read(MFile mf, int no, int offset, int nbytes, void *buf)
 /*
  * Write.
  */
-int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf)
+int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf)
 {
     int ps, nblocks, towrite;
     mf_dir *dp;
@@ -551,7 +554,7 @@ int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf)
            mf->files[mf->cur_file].blocks = 0;
            mf->files[mf->cur_file].bytes = 0;
            mf->files[mf->cur_file].fd = -1;
-           sprintf(tmp, "%s/%s-%d.mf", dp->name, mf->name,
+           sprintf(tmp, "%s/%s-" ZINT_FORMAT ".mf", dp->name, mf->name,
                mf->files[mf->cur_file].number);
            mf->files[mf->cur_file].path = xstrdup(tmp);
            mf->no_files++;