X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=bfile%2Fmfile.h;h=86068bb2fa741fef5524cc8e4acce32741bc8ee7;hb=0f563f23506dabd7c84bdb750d4539b2b6cacf02;hp=dee394f1879700fe193d28c4efb5101bb3d6dedb;hpb=30bb91a2915de98455a8f7a5af5c087239f22203;p=idzebra-moved-to-github.git diff --git a/bfile/mfile.h b/bfile/mfile.h index dee394f..86068bb 100644 --- a/bfile/mfile.h +++ b/bfile/mfile.h @@ -1,5 +1,5 @@ -/* $Id: mfile.h,v 1.4 2006-05-05 09:14:02 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: mfile.h,v 1.12 2007-01-15 20:08:23 adam Exp $ + Copyright (C) 1995-2007 Index Data ApS This file is part of the Zebra server. @@ -15,12 +15,10 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. -*/ - +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #ifndef MFILE_H #define MFILE_H @@ -28,6 +26,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include +#include #ifdef WIN32 @@ -85,7 +84,6 @@ typedef struct meta_file int no_files; int cur_file; int open; /* is this file open? */ - int unlink_flag; int blocksize; mfile_off_t min_bytes_creat; /* minimum bytes required to enter directory */ MFile_area ma; @@ -104,46 +102,68 @@ typedef struct MFile_area_struct Zebra_mutex mutex; } MFile_area_struct; -/* - * Open an area, cotaining metafiles in directories. - */ -MFile_area mf_init(const char *name, const char *spec, const char *base); - -/* - * Release an area. - */ +/** \brief creates a metafile area + \param name of area (does not show up on disk - purely for notation) + \param spec area specification (e.g. "/a:1G dir /b:2000M" + \param base base directory (NULL for no base) + \param only_shadow_files only consider shadow files in area + \returns metafile area handle or NULL if error occurs +*/ +MFile_area mf_init(const char *name, const char *spec, const char *base, + int only_shadow_files) + ZEBRA_GCC_ATTR((warn_unused_result)); + +/** \brief destroys metafile area handle + \param ma metafile area handle +*/ void mf_destroy(MFile_area ma); -/* - * Open a metafile. - */ -MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag); - -/* - * Close a metafile. +/** \brief opens metafile + \param ma metafile area handle + \param name pseudo filename (name*.mf) + \param block_size block size for this file + \param wflag write flag, 0=read, 1=write&read + \returns metafile handle, or NULL for error (could not be opened) */ +MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag) + ZEBRA_GCC_ATTR((warn_unused_result)); + +/** \brief closes metafile + \param mf metafile handle + \retval 0 OK +*/ int mf_close(MFile mf); -/* - * Read one block from a metafile. Interface mirrors bfile. +/** \brief reads block from metafile + \param mf metafile handle + \param no block position + \param offset offset within block + \param nbytes no of bytes to read (0 for whole block) + \param buf content (filled with data if OK) + \retval 0 block partially read + \retval 1 block fully read + \retval -1 block could not be read due to error */ -int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf); - -/* - * Same. - */ -int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf); - -/* - * Destroy a metafile, unlinking component files. File must be open. - */ -int mf_unlink(MFile mf); - - -/* - * Destroy all metafiles. No files may be opened. - */ -void mf_reset(MFile_area ma); +int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf) + ZEBRA_GCC_ATTR((warn_unused_result)); + +/** \brief writes block to metafile + \param mf metafile handle + \param no block position + \param offset offset within block + \param nbytes no of bytes to write (0 for whole block) + \param buf content to be written + \retval 0 block written + \retval -1 error (block not written) +*/ +int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) + ZEBRA_GCC_ATTR((warn_unused_result)); + +/** \brief reset all files in a metafile area (optionally delete them as well) + \param ma metafile area + \param unlink_flag if unlink_flag=1 all files are removed from FS +*/ +void mf_reset(MFile_area ma, int unlink_flag); /* \brief gets statistics about directory in metafile area \param ma the area @@ -165,3 +185,11 @@ int mf_area_directory_stat(MFile_area ma, int no, const char **directory, YAZ_END_CDECL #endif +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +