1 /* $Id: mfile.h,v 1.23 2004-08-25 09:23:35 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
29 #include <yaz/yconfig.h>
30 #include <idzebra/version.h>
34 /* 64-bit access .. */
35 typedef __int64 mfile_off_t;
36 #define mfile_seek _lseeki64
39 #include <sys/types.h>
40 typedef off_t mfile_off_t;
41 #define mfile_seek lseek
45 #include <sys/param.h>
46 #define FILENAME_MAX MAXPATHLEN
49 #include <zebra-lock.h>
53 #define MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */
54 #define MF_MAX_PARTS 28 /* max # of part-files per metafile */
56 #define mf_blocksize(mf) ((mf)->blocksize)
61 char name[FILENAME_MAX+1];
62 mfile_off_t max_bytes; /* allocated bytes in this dir. */
63 mfile_off_t avail_bytes; /* bytes left */
67 typedef struct part_file
78 struct MFile_area_struct;
79 typedef struct MFile_area_struct *MFile_area;
81 typedef struct meta_file
83 char name[FILENAME_MAX+1];
84 part_file files[MF_MAX_PARTS];
87 int open; /* is this file open? */
90 mfile_off_t min_bytes_creat; /* minimum bytes required to enter directory */
95 struct meta_file *next;
98 typedef struct MFile_area_struct
100 char name[FILENAME_MAX+1];
102 struct meta_file *mfiles;
103 struct MFile_area_struct *next; /* global list of active areas */
108 * Open an area, cotaining metafiles in directories.
110 MFile_area mf_init(const char *name, const char *spec, const char *base);
115 void mf_destroy(MFile_area ma);
120 MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag);
125 int mf_close(MFile mf);
128 * Read one block from a metafile. Interface mirrors bfile.
130 int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf);
135 int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf);
138 * Destroy a metafile, unlinking component files. File must be open.
140 int mf_unlink(MFile mf);
144 * Destroy all metafiles. No files may be opened.
146 void mf_reset(MFile_area ma);
149 * Unlink the file by name, rather than MFile-handle.
151 int mf_unlink_name(MFile_area, const char *name);