/*
- * Copyright (C) 1994-1999, Index Data
+ * Copyright (C) 1994-2002, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: mfile.c,v $
- * Revision 1.43 2002-04-04 20:50:36 adam
- * Multi register works with record paths and data1 profile path
+ * Revision 1.41.2.1 2002-07-23 12:33:21 adam
+ * Towards 1.1.3
*
- * Revision 1.42 2002/04/04 14:14:13 adam
- * Multiple registers (alpha early)
+ * Revision 1.41.4.1 2002/07/23 09:32:41 adam
+ * 64 bit file access on WIN32
*
* Revision 1.41 2000/11/29 14:24:01 adam
* Script configure uses yaz pthreads options. Added locking for
#include <zebrautl.h>
#include <mfile.h>
-static int scan_areadef(MFile_area ma, const char *ad, const char *base)
+static int scan_areadef(MFile_area ma, const char *name, const char *ad)
{
/*
* If no definition is given, use current directory, unlimited.
mf_dir **dp = &ma->dirs, *dir = *dp;
if (!ad)
- ad = ".:-1b";
+ ad = ".:-1b";
for (;;)
{
const char *ad0 = ad;
int i = 0, fact = 1, multi;
- off_t size = 0;
+ mfile_off_t size = 0;
while (*ad == ' ' || *ad == '\t')
ad++;
if (!*ad)
break;
- if (!yaz_is_abspath(ad) && base)
- {
- strcpy (dirname, base);
- i = strlen(dirname);
- dirname[i++] = '/';
- }
while (*ad)
{
if (*ad == ':' && strchr ("+-0123456789", ad[1]))
logf (LOG_WARN|LOG_ERRNO, "Failed to open %s", mf->files[c].path);
return -1;
}
- if (lseek(mf->files[c].fd, (ps = pos - off) * mf->blocksize + offset,
- SEEK_SET) < 0)
+ if (
+#ifdef WIN32
+ _lseeki64
+#else
+ lseek
+#endif
+ (mf->files[c].fd, (mfile_off_t) (ps = pos-off) * mf->blocksize + offset,
+ SEEK_SET) == (mfile_off_t) (-1))
{
logf (LOG_WARN|LOG_ERRNO, "Failed to seek in %s", mf->files[c].path);
return -1;
* Create a new area, cotaining metafiles in directories.
* Find the part-files in each directory, and inventory the existing metafiles.
*/
-MFile_area mf_init(const char *name, const char *spec, const char *base)
+MFile_area mf_init(const char *name, const char *spec)
{
MFile_area ma = (MFile_area) xmalloc(sizeof(*ma));
mf_dir *dirp;
strcpy(ma->name, name);
ma->mfiles = 0;
ma->dirs = 0;
- if (scan_areadef(ma, spec, base) < 0)
+ if (scan_areadef(ma, name, spec) < 0)
{
logf (LOG_WARN, "Failed to access description of '%s'", name);
return 0;
dent->d_name);
return 0;
}
- if ((part_f->bytes = lseek(fd, 0, SEEK_END)) < 0)
+ if ((part_f->bytes =
+#ifdef WIN32
+ _lseeki64
+#else
+ lseek
+#endif
+ (fd, (mfile_off_t) 0, SEEK_END)) == (mfile_off_t)(-1))
{
logf (LOG_FATAL|LOG_ERRNO, "Failed to seek in %s",
dent->d_name);
mf->files[mf->cur_file].dir = dp;
mf->files[mf->cur_file].number =
mf->files[mf->cur_file-1].number + 1;
- mf->files[mf->cur_file].blocks =
- mf->files[mf->cur_file].bytes = 0;
+ 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,
mf->files[mf->cur_file].number);
-dnl Zebra, Index Data Aps, 1994-2000
-dnl $Id: configure.in,v 1.29.2.1 2002-04-09 14:55:40 adam Exp $
+dnl Zebra, Index Data Aps, 1994-2002
+dnl $Id: configure.in,v 1.29.2.2 2002-07-23 12:33:21 adam Exp $
dnl
AC_INIT(include/zebraver.h)
AC_MSG_CHECKING(for package)
AC_MSG_RESULT([Z'mbol])
PROGPREFIX=zmbol
AC_DEFINE(ZMBOL,1)
- AM_INIT_AUTOMAKE(zmbol,1.1.1)
+ AM_INIT_AUTOMAKE(zmbol,1.1.3)
else
AC_MSG_RESULT([Zebra])
PROGPREFIX=zebra
AC_DEFINE(ZMBOL,0)
- AM_INIT_AUTOMAKE(zebra,1.1.1)
+ AM_INIT_AUTOMAKE(zebra,1.1.3)
if test ! -r ${srcdir}/isam; then
mkdir ${srcdir}/isam
fi
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: mfile.h,v 1.17 2002-04-04 14:14:13 adam Exp $
+ * $Id: mfile.h,v 1.16.2.1 2002-07-23 12:33:22 adam Exp $
*/
#ifndef MFILE_H
#include <yaz/yconfig.h>
#ifdef WIN32
-typedef long off_t;
+typedef __int64 mfile_off_t;
#else
#include <sys/types.h>
+typedef off_t mfile_off_t;
#endif
#ifndef FILENAME_MAX
typedef struct mf_dir
{
char name[FILENAME_MAX+1];
- off_t max_bytes; /* allocated bytes in this dir. */
- off_t avail_bytes; /* bytes left */
+ mfile_off_t max_bytes; /* allocated bytes in this dir. */
+ mfile_off_t avail_bytes; /* bytes left */
struct mf_dir *next;
} mf_dir;
int number;
int top;
int blocks;
- off_t bytes;
+ mfile_off_t bytes;
mf_dir *dir;
char *path;
int fd;
int no_files;
int cur_file;
int open; /* is this file open? */
- off_t blocksize;
- off_t min_bytes_creat; /* minimum bytes required to enter directory */
+ int blocksize;
+ mfile_off_t min_bytes_creat; /* minimum bytes required to enter directory */
MFile_area ma;
int wr;
Zebra_mutex mutex;
/*
* Open an area, cotaining metafiles in directories.
*/
-MFile_area mf_init(const char *name, const char *spec, const char *base);
+MFile_area mf_init(const char *name, const char *spec);
/*
* Release an area.