Dictionary now public. Private header dict-p.h added.
Block File now public. Private headers mfile.h moved to away from include.
-## $Id: Makefile.am,v 1.3 2004-08-24 10:37:18 adam Exp $ Copyright (C) 1994-1998, Index Data ApS
+## $Id: Makefile.am,v 1.4 2004-12-08 12:23:08 adam Exp $ Copyright (C) 1994-1998, Index Data ApS
lib_LTLIBRARIES = libidzebra-bfile.la
AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC)
-libidzebra_bfile_la_SOURCES = bfile.c mfile.c cfile.c commit.c cfile.h
+libidzebra_bfile_la_SOURCES = bfile.c mfile.c cfile.c commit.c cfile.h mfile.h
-/* $Id: bfile.c,v 1.37 2004-11-19 10:26:53 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: bfile.c,v 1.38 2004-12-08 12:23:08 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
#include <zebrautl.h>
-#include <bfile.h>
-
+#include <idzebra/bfile.h>
+#include "mfile.h"
#include "cfile.h"
+struct BFile_struct
+{
+ MFile mf;
+ Zebra_lock_rdwr rdwr_lock;
+ struct CFile_struct *cf;
+};
+
struct BFiles_struct {
MFile_area commit_area;
MFile_area_struct *register_area;
BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag)
{
- BFile tmp = (BFile) xmalloc(sizeof(BFile_struct));
+ BFile tmp = (BFile) xmalloc(sizeof(struct BFile_struct));
if (bfs->commit_area)
{
-/* $Id: cfile.c,v 1.31 2004-11-19 10:26:53 heikki Exp $
+/* $Id: cfile.c,v 1.32 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
02111-1307, USA.
*/
-
-
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <zebrautl.h>
-#include <mfile.h>
+#include "mfile.h"
#include "cfile.h"
static int write_head (CFile cf)
-/* $Id: commit.c,v 1.21 2004-11-19 10:26:53 heikki Exp $
+/* $Id: commit.c,v 1.22 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
*/
-
#include <assert.h>
#include <stdlib.h>
#include <zebrautl.h>
-#include <mfile.h>
+#include "mfile.h"
#include "cfile.h"
#define CF_OPTIMIZE_COMMIT 0
-/* $Id: mfile.c,v 1.56 2004-11-19 10:26:53 heikki Exp $
+/* $Id: mfile.c,v 1.57 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
#include <zebra-lock.h>
#include <zebrautl.h>
-#include <mfile.h>
+#include "mfile.h"
static int scan_areadef(MFile_area ma, const char *ad, const char *base)
{
--- /dev/null
+/* $Id: mfile.h,v 1.1 2004-12-08 12:23:08 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+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.
+*/
+
+
+
+#ifndef MFILE_H
+#define MFILE_H
+
+#include <stdio.h>
+#include <yaz/yconfig.h>
+#include <idzebra/version.h>
+
+#ifdef WIN32
+
+/* 64-bit access .. */
+typedef __int64 mfile_off_t;
+#define mfile_seek _lseeki64
+
+#else
+#include <sys/types.h>
+typedef off_t mfile_off_t;
+#define mfile_seek lseek
+#endif
+
+#ifndef FILENAME_MAX
+#include <sys/param.h>
+#define FILENAME_MAX MAXPATHLEN
+#endif
+
+#include <zebra-lock.h>
+
+YAZ_BEGIN_CDECL
+
+#define MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */
+#define MF_MAX_PARTS 28 /* max # of part-files per metafile */
+
+#define mf_blocksize(mf) ((mf)->blocksize)
+
+
+typedef struct mf_dir
+{
+ char name[FILENAME_MAX+1];
+ mfile_off_t max_bytes; /* allocated bytes in this dir. */
+ mfile_off_t avail_bytes; /* bytes left */
+ struct mf_dir *next;
+} mf_dir;
+
+typedef struct part_file
+{
+ zint number;
+ zint top;
+ zint blocks;
+ mfile_off_t bytes;
+ mf_dir *dir;
+ char *path;
+ int fd;
+} part_file;
+
+struct MFile_area_struct;
+typedef struct MFile_area_struct *MFile_area;
+
+typedef struct meta_file
+{
+ char name[FILENAME_MAX+1];
+ part_file files[MF_MAX_PARTS];
+ 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;
+ int wr;
+ Zebra_mutex mutex;
+
+ struct meta_file *next;
+} *MFile, meta_file;
+
+typedef struct MFile_area_struct
+{
+ char name[FILENAME_MAX+1];
+ mf_dir *dirs;
+ struct meta_file *mfiles;
+ struct MFile_area_struct *next; /* global list of active areas */
+ 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.
+ */
+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.
+ */
+int mf_close(MFile mf);
+
+/*
+ * Read one block from a metafile. Interface mirrors bfile.
+ */
+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);
+
+/*
+ * Unlink the file by name, rather than MFile-handle.
+ */
+int mf_unlink_name(MFile_area, const char *name);
+
+YAZ_END_CDECL
+
+#endif
-## $Id: Makefile.am,v 1.10 2004-12-07 14:57:08 adam Exp $
+## $Id: Makefile.am,v 1.11 2004-12-08 12:23:08 adam Exp $
lib_LTLIBRARIES = libidzebra-dict.la
noinst_PROGRAMS = dicttest dictext
../util/libidzebra-util.la \
$(YAZLALIB)
-libidzebra_dict_la_SOURCES = scan.c dopen.c dclose.c drdwr.c open.c \
- close.c insert.c lookup.c lookupec.c lookgrep.c delete.c dcompact.c
+libidzebra_dict_la_SOURCES = dopen.c dclose.c drdwr.c open.c close.c \
+ insert.c lookup.c lookupec.c lookgrep.c delete.c scan.c dcompact.c \
+ dict-p.h
dicttest_SOURCES = dicttest.c
-/* $Id: close.c,v 1.7 2002-08-02 19:26:55 adam Exp $
+/* $Id: close.c,v 1.8 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
#include <assert.h>
-#include <dict.h>
+#include "dict-p.h"
int dict_close (Dict dict)
{
-/* $Id: dclose.c,v 1.6 2002-08-02 19:26:55 adam Exp $
+/* $Id: dclose.c,v 1.7 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
#include <stdlib.h>
-#include <dict.h>
+#include "dict-p.h"
int dict_bf_close (Dict_BFile dbf)
{
-/* $Id: dcompact.c,v 1.10 2004-11-19 10:26:54 heikki Exp $
+/* $Id: dcompact.c,v 1.11 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
#include <yaz/ylog.h>
-#include <dict.h>
+#include "dict-p.h"
static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map)
{
-/* $Id: delete.c,v 1.9 2003-06-30 15:56:48 adam Exp $
+/* $Id: delete.c,v 1.10 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
#include <stdio.h>
#include <assert.h>
-#include <dict.h>
+#include "dict-p.h"
static void dict_del_subtree (Dict dict, Dict_ptr ptr,
void *client,
--- /dev/null
+/* $Id: dict-p.h,v 1.1 2004-12-08 12:23:08 adam Exp $
+ Copyright (C) 2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+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.
+*/
+
+#ifndef DICT_P_H
+#define DICT_P_H
+
+#include <idzebra/dict.h>
+
+YAZ_BEGIN_CDECL
+
+#define DICT_MAGIC "dict01"
+
+#define DICT_DEFAULT_PAGESIZE 4096
+
+struct Dict_head {
+ char magic_str[8];
+ int page_size;
+ int compact_flag;
+ Dict_ptr root, last, freelist;
+};
+
+struct Dict_file_block
+{
+ struct Dict_file_block *h_next, **h_prev;
+ struct Dict_file_block *lru_next, *lru_prev;
+ void *data;
+ int dirty;
+ int no;
+ int nbytes;
+};
+
+typedef struct Dict_file_struct
+{
+ int cache;
+ BFile bf;
+
+ struct Dict_file_block *all_blocks;
+ struct Dict_file_block *free_list;
+ struct Dict_file_block **hash_array;
+
+ struct Dict_file_block *lru_back, *lru_front;
+ int hash_size;
+ void *all_data;
+
+ int block_size;
+ int hits;
+ int misses;
+ int compact_flag;
+} *Dict_BFile;
+
+struct Dict_struct {
+ int rw;
+ Dict_BFile dbf;
+ const char **(*grep_cmap)(void *vp, const char **from, int len);
+ void *grep_cmap_data;
+ struct Dict_head head;
+};
+
+int dict_bf_readp (Dict_BFile bf, int no, void **bufp);
+int dict_bf_newp (Dict_BFile bf, int no, void **bufp, int nbytes);
+int dict_bf_touch (Dict_BFile bf, int no);
+void dict_bf_flush_blocks (Dict_BFile bf, int no_to_flush);
+Dict_BFile dict_bf_open (BFiles bfs, const char *name, int block_size,
+ int cache, int rw);
+int dict_bf_close (Dict_BFile dbf);
+void dict_bf_compact (Dict_BFile dbf);
+
+#define DICT_EOS 0
+#define DICT_type(x) 0[(Dict_ptr*) x]
+#define DICT_backptr(x) 1[(Dict_ptr*) x]
+#define DICT_bsize(x) 2[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
+#define DICT_nodir(x) 0[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
+#define DICT_size(x) 1[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
+#define DICT_infoffset (2*sizeof(Dict_ptr)+3*sizeof(short))
+#define DICT_xxxxpagesize(x) ((x)->head.page_size)
+
+#define DICT_to_str(x) sizeof(Dict_info)+sizeof(Dict_ptr)
+
+/*
+ type type of page
+ backptr pointer to parent
+ nextptr pointer to next page (if any)
+ nodir no of words
+ size size of strings,info,ptr entries
+
+ dir[0..nodir-1]
+ ptr,info,string
+ */
+
+YAZ_END_CDECL
+
+#endif
-/* $Id: dicttest.c,v 1.30 2004-11-19 10:26:55 heikki Exp $
+/* $Id: dicttest.c,v 1.31 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
02111-1307, USA.
*/
-
-
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
-#include <dict.h>
+#include <idzebra/dict.h>
#include <zebrautl.h>
char *prog;
-/* $Id: dopen.c,v 1.9 2002-08-02 19:26:55 adam Exp $
+/* $Id: dopen.c,v 1.10 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
#include <stdlib.h>
-#include <dict.h>
+#include "dict-p.h"
static void common_init (Dict_BFile bf, int block_size, int cache)
{
-/* $Id: drdwr.c,v 1.14 2004-11-19 10:26:55 heikki Exp $
+/* $Id: drdwr.c,v 1.15 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdlib.h>
#include <assert.h>
-#include <dict.h>
+#include "dict-p.h"
void dict_pr_lru (Dict_BFile bf)
{
-/* $Id: insert.c,v 1.23 2004-11-19 10:26:55 heikki Exp $
+/* $Id: insert.c,v 1.24 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
#include <assert.h>
-#include <dict.h>
+#include "dict-p.h"
#define CHECK 0
-/* $Id: lookgrep.c,v 1.27 2004-11-19 10:26:55 heikki Exp $
+/* $Id: lookgrep.c,v 1.28 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <assert.h>
#include <dfa.h>
-#include <dict.h>
+#include "dict-p.h"
typedef unsigned MatchWord;
#define WORD_BITS 32
-/* $Id: lookup.c,v 1.11 2002-08-02 19:26:55 adam Exp $
+/* $Id: lookup.c,v 1.12 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
#include <assert.h>
-#include <dict.h>
+#include "dict-p.h"
static char *dict_look (Dict dict, const Dict_char *str, Dict_ptr ptr)
{
-/* $Id: lookupec.c,v 1.10 2002-08-02 19:26:55 adam Exp $
+/* $Id: lookupec.c,v 1.11 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
#include <assert.h>
-#include <dict.h>
+#include "dict-p.h"
typedef unsigned MatchWord;
-/* $Id: open.c,v 1.21 2004-11-19 10:26:55 heikki Exp $
+/* $Id: open.c,v 1.22 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include <string.h>
#include <stdio.h>
-#include <dict.h>
+#include "dict-p.h"
Dict dict_open (BFiles bfs, const char *name, int cache, int rw,
int compact_flag, int page_size)
-/* $Id: scan.c,v 1.17 2004-12-07 20:04:39 adam Exp $
+/* $Id: scan.c,v 1.18 2004-12-08 12:23:08 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
#include <assert.h>
-#include <dict.h>
+#include "dict-p.h"
int dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str,
int start, int *count, void *client,
-/* $Id: scantest.c,v 1.1 2004-12-07 14:57:08 adam Exp $
+/* $Id: scantest.c,v 1.2 2004-12-08 12:23:08 adam Exp $
Copyright (C) 2003,2004
Index Data Aps
#include <string.h>
#include <yaz/options.h>
-#include <dict.h>
+#include <idzebra/dict.h>
struct handle_info {
int b;
-# $Id: Makefile.am,v 1.17 2004-09-28 12:39:54 adam Exp $
-noinst_HEADERS = bfile.h bset.h charmap.h \
-dict.h direntz.h isam-codec.h isamb.h isamc.h isamg.h \
-isams.h mfile.h passwddb.h dfa.h zebra_xpath.h d1_absyn.h \
+# $Id: Makefile.am,v 1.18 2004-12-08 12:23:08 adam Exp $
+noinst_HEADERS = bset.h charmap.h \
+direntz.h isam-codec.h isamb.h isamc.h isamg.h \
+isams.h passwddb.h dfa.h zebra_xpath.h d1_absyn.h \
rset.h set.h sortidx.h str.h zebra-lock.h zebrautl.h
SUBDIRS = idzebra
+++ /dev/null
-/* $Id: bfile.h,v 1.22 2004-08-04 08:35:23 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
- Index Data Aps
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-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.
-*/
-
-#ifndef BFILE_H
-#define BFILE_H
-
-#include <mfile.h>
-
-YAZ_BEGIN_CDECL
-
-#define bf_blocksize(bf) mf_blocksize(bf->mf)
-
-typedef struct BFiles_struct *BFiles;
-
-BFiles bfs_create (const char *spec, const char *base);
-void bfs_destroy (BFiles bfiles);
-
-typedef struct BFile_struct
-{
- MFile mf;
- Zebra_lock_rdwr rdwr_lock;
- struct CFile_struct *cf;
-} *BFile, BFile_struct;
-
-/* bf_close: closes bfile.
- returns 0 if successful; non-zero otherwise
- */
-int bf_close (BFile);
-
-/* bf_open: opens bfile.
- opens bfile with name 'name' and with 'block_size' as block size.
- returns bfile handle is successful; NULL otherwise
- */
-BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag);
-
-/* bf_read: reads bytes from bfile 'bf'.
- reads 'nbytes' bytes (or whole block if 0) from offset 'offset' from
- block 'no'. stores contents in buffer 'buf'.
- returns 1 if whole block could be read; 0 otherwise.
- */
-int bf_read (BFile bf, zint no, int offset, int nbytes, void *buf);
-
-/* bf_write: writes bytes to bfile 'bf'.
- writes 'nbytes' bytes (or whole block if 0) at offset 'offset' to
- block 'no'. retrieves contents from buffer 'buf'.
- returns 0 if successful; non-zero otherwise.
- */
-int bf_write (BFile bf, zint no, int offset, int nbytes, const void *buf);
-
-/* bf_cache: enables bfile cache if spec is not NULL */
-void bf_cache (BFiles bfs, const char *spec);
-
-/* bf_commitExists: returns 1 if commit is pending; 0 otherwise */
-int bf_commitExists (BFiles bfs);
-
-/* bf_commitExec: executes commit */
-void bf_commitExec (BFiles bfs);
-
-/* bf_commitClean: cleans commit files, etc */
-void bf_commitClean (BFiles bfs, const char *spec);
-
-/* bf_reset: delete register and shadow completely */
-void bf_reset (BFiles bfs);
-
-YAZ_END_CDECL
-
-#endif
+++ /dev/null
-/* $Id: dict.h,v 1.34 2004-11-19 10:26:55 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
- Index Data Aps
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-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.
-*/
-
-
-
-#ifndef DICT_H
-#define DICT_H
-
-#include <bfile.h>
-#include <yaz/ylog.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef unsigned Dict_ptr;
-typedef unsigned char Dict_char;
-
-struct Dict_head {
- char magic_str[8];
- int page_size;
- int compact_flag;
- Dict_ptr root, last, freelist;
-};
-
-struct Dict_file_block
-{
- struct Dict_file_block *h_next, **h_prev;
- struct Dict_file_block *lru_next, *lru_prev;
- void *data;
- int dirty;
- int no;
- int nbytes;
-};
-
-typedef struct Dict_file_struct
-{
- int cache;
- BFile bf;
-
- struct Dict_file_block *all_blocks;
- struct Dict_file_block *free_list;
- struct Dict_file_block **hash_array;
-
- struct Dict_file_block *lru_back, *lru_front;
- int hash_size;
- void *all_data;
-
- int block_size;
- int hits;
- int misses;
- int compact_flag;
-} *Dict_BFile;
-
-typedef struct Dict_struct {
- int rw;
- Dict_BFile dbf;
- const char **(*grep_cmap)(void *vp, const char **from, int len);
- void *grep_cmap_data;
- struct Dict_head head;
-} *Dict;
-
-#define DICT_MAGIC "dict01"
-
-#define DICT_DEFAULT_PAGESIZE 4096
-
-int dict_bf_readp (Dict_BFile bf, int no, void **bufp);
-int dict_bf_newp (Dict_BFile bf, int no, void **bufp, int nbytes);
-int dict_bf_touch (Dict_BFile bf, int no);
-void dict_bf_flush_blocks (Dict_BFile bf, int no_to_flush);
-Dict_BFile dict_bf_open (BFiles bfs, const char *name, int block_size,
- int cache, int rw);
-int dict_bf_close (Dict_BFile dbf);
-void dict_bf_compact (Dict_BFile dbf);
-
-Dict dict_open (BFiles bfs, const char *name, int cache, int rw,
- int compact_flag, int page_size);
-int dict_close (Dict dict);
-int dict_insert (Dict dict, const char *p, int userlen, void *userinfo);
-int dict_delete (Dict dict, const char *p);
-int dict_delete_subtree (Dict dict, const char *p, void *client,
- int (*f)(const char *info, void *client));
-char *dict_lookup (Dict dict, const char *p);
-int dict_lookup_ec (Dict dict, char *p, int range,
- int (*f)(char *name));
-int dict_lookup_grep (Dict dict, const char *p, int range, void *client,
- int *max_pos, int init_pos,
- int (*f)(char *name, const char *info,
- void *client));
-int dict_strcmp (const Dict_char *s1, const Dict_char *s2);
-int dict_strncmp (const Dict_char *s1, const Dict_char *s2, size_t n);
-int dict_strlen (const Dict_char *s);
-int dict_scan (Dict dict, char *str,
- int *before, int *after, void *client,
- int (*f)(char *name, const char *info, int pos,
- void *client));
-
-void dict_grep_cmap (Dict dict, void *vp,
- const char **(*cmap)(void *vp,
- const char **from, int len));
-int dict_copy_compact (BFiles bfs, const char *from, const char *to);
-
-
-#define DICT_EOS 0
-#define DICT_type(x) 0[(Dict_ptr*) x]
-#define DICT_backptr(x) 1[(Dict_ptr*) x]
-#define DICT_bsize(x) 2[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
-#define DICT_nodir(x) 0[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
-#define DICT_size(x) 1[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
-#define DICT_infoffset (2*sizeof(Dict_ptr)+3*sizeof(short))
-#define DICT_xxxxpagesize(x) ((x)->head.page_size)
-
-#define DICT_to_str(x) sizeof(Dict_info)+sizeof(Dict_ptr)
-
-/*
- type type of page
- backptr pointer to parent
- nextptr pointer to next page (if any)
- nodir no of words
- size size of strings,info,ptr entries
-
- dir[0..nodir-1]
- ptr,info,string
- */
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
-# $Id: Makefile.am,v 1.3 2004-09-28 12:39:54 adam Exp $
+# $Id: Makefile.am,v 1.4 2004-12-08 12:23:09 adam Exp $
-pkginclude_HEADERS=api.h version.h res.h recctrl.h data1.h recgrs.h zebramap.h
+pkginclude_HEADERS=api.h version.h res.h recctrl.h data1.h recgrs.h zebramap.h bfile.h dict.h
--- /dev/null
+/* $Id: bfile.h,v 1.1 2004-12-08 12:23:09 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+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.
+*/
+
+#ifndef BFILE_H
+#define BFILE_H
+
+#include <idzebra/version.h>
+
+YAZ_BEGIN_CDECL
+
+typedef struct BFiles_struct *BFiles;
+typedef struct BFile_struct *BFile;
+
+BFiles bfs_create (const char *spec, const char *base);
+void bfs_destroy (BFiles bfiles);
+
+/* bf_close: closes bfile.
+ returns 0 if successful; non-zero otherwise
+ */
+YAZ_EXPORT
+int bf_close (BFile);
+
+/* bf_open: opens bfile.
+ opens bfile with name 'name' and with 'block_size' as block size.
+ returns bfile handle is successful; NULL otherwise
+ */
+YAZ_EXPORT
+BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag);
+
+/* bf_read: reads bytes from bfile 'bf'.
+ reads 'nbytes' bytes (or whole block if 0) from offset 'offset' from
+ block 'no'. stores contents in buffer 'buf'.
+ returns 1 if whole block could be read; 0 otherwise.
+ */
+YAZ_EXPORT
+int bf_read (BFile bf, zint no, int offset, int nbytes, void *buf);
+
+/* bf_write: writes bytes to bfile 'bf'.
+ writes 'nbytes' bytes (or whole block if 0) at offset 'offset' to
+ block 'no'. retrieves contents from buffer 'buf'.
+ returns 0 if successful; non-zero otherwise.
+ */
+YAZ_EXPORT
+int bf_write (BFile bf, zint no, int offset, int nbytes, const void *buf);
+
+/* bf_cache: enables bfile cache if spec is not NULL */
+YAZ_EXPORT
+void bf_cache (BFiles bfs, const char *spec);
+
+/* bf_commitExists: returns 1 if commit is pending; 0 otherwise */
+YAZ_EXPORT
+int bf_commitExists (BFiles bfs);
+
+/* bf_commitExec: executes commit */
+YAZ_EXPORT
+void bf_commitExec (BFiles bfs);
+
+/* bf_commitClean: cleans commit files, etc */
+YAZ_EXPORT
+void bf_commitClean (BFiles bfs, const char *spec);
+
+/* bf_reset: delete register and shadow completely */
+YAZ_EXPORT
+void bf_reset (BFiles bfs);
+
+YAZ_END_CDECL
+
+#endif
--- /dev/null
+/* $Id: dict.h,v 1.1 2004-12-08 12:23:09 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+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.
+*/
+
+#ifndef DICT_H
+#define DICT_H
+
+#include <yaz/ylog.h>
+#include <idzebra/bfile.h>
+
+YAZ_BEGIN_CDECL
+
+typedef struct Dict_struct *Dict;
+
+typedef unsigned Dict_ptr;
+typedef unsigned char Dict_char;
+
+YAZ_EXPORT
+Dict dict_open (BFiles bfs, const char *name, int cache, int rw,
+ int compact_flag, int page_size);
+
+YAZ_EXPORT
+int dict_close (Dict dict);
+
+YAZ_EXPORT
+int dict_insert (Dict dict, const char *p, int userlen, void *userinfo);
+
+YAZ_EXPORT
+int dict_delete (Dict dict, const char *p);
+
+YAZ_EXPORT
+int dict_delete_subtree (Dict dict, const char *p, void *client,
+ int (*f)(const char *info, void *client));
+YAZ_EXPORT
+char *dict_lookup (Dict dict, const char *p);
+
+YAZ_EXPORT
+int dict_lookup_ec (Dict dict, char *p, int range, int (*f)(char *name));
+
+YAZ_EXPORT
+int dict_lookup_grep (Dict dict, const char *p, int range, void *client,
+ int *max_pos, int init_pos,
+ int (*f)(char *name, const char *info, void *client));
+
+YAZ_EXPORT
+int dict_strcmp (const Dict_char *s1, const Dict_char *s2);
+
+YAZ_EXPORT
+int dict_strncmp (const Dict_char *s1, const Dict_char *s2, size_t n);
+
+YAZ_EXPORT
+int dict_strlen (const Dict_char *s);
+
+YAZ_EXPORT
+int dict_scan (Dict dict, char *str,
+ int *before, int *after, void *client,
+ int (*f)(char *name, const char *info, int pos, void *client));
+
+YAZ_EXPORT
+void dict_grep_cmap (Dict dict, void *vp,
+ const char **(*cmap)(void *vp,
+ const char **from, int len));
+
+YAZ_EXPORT
+int dict_copy_compact (BFiles bfs, const char *from, const char *to);
+
+YAZ_END_CDECL
+
+#endif
-/* $Id: isamb.h,v 1.15 2004-09-09 10:08:04 heikki Exp $
+/* $Id: isamb.h,v 1.16 2004-12-08 12:23:09 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#ifndef ISAMB_H
#define ISAMB_H
-#include <bfile.h>
+#include <idzebra/bfile.h>
#include <isamc.h>
YAZ_BEGIN_CDECL
-/* $Id: isamc.h,v 1.13 2004-08-04 08:35:23 adam Exp $
+/* $Id: isamc.h,v 1.14 2004-12-08 12:23:09 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#define ISAMC_H
#include <isam-codec.h>
-#include <bfile.h>
+#include <idzebra/bfile.h>
YAZ_BEGIN_CDECL
-/* $Id: isams.h,v 1.6 2004-08-04 08:35:23 adam Exp $
+/* $Id: isams.h,v 1.7 2004-12-08 12:23:09 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#define ISAMS_H
#include <isam-codec.h>
-#include <bfile.h>
+#include <idzebra/bfile.h>
#include <isamc.h>
#ifdef __cplusplus
+++ /dev/null
-/* $Id: mfile.h,v 1.23 2004-08-25 09:23:35 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
- Index Data Aps
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-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.
-*/
-
-
-
-#ifndef MFILE_H
-#define MFILE_H
-
-#include <stdio.h>
-#include <yaz/yconfig.h>
-#include <idzebra/version.h>
-
-#ifdef WIN32
-
-/* 64-bit access .. */
-typedef __int64 mfile_off_t;
-#define mfile_seek _lseeki64
-
-#else
-#include <sys/types.h>
-typedef off_t mfile_off_t;
-#define mfile_seek lseek
-#endif
-
-#ifndef FILENAME_MAX
-#include <sys/param.h>
-#define FILENAME_MAX MAXPATHLEN
-#endif
-
-#include <zebra-lock.h>
-
-YAZ_BEGIN_CDECL
-
-#define MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */
-#define MF_MAX_PARTS 28 /* max # of part-files per metafile */
-
-#define mf_blocksize(mf) ((mf)->blocksize)
-
-
-typedef struct mf_dir
-{
- char name[FILENAME_MAX+1];
- mfile_off_t max_bytes; /* allocated bytes in this dir. */
- mfile_off_t avail_bytes; /* bytes left */
- struct mf_dir *next;
-} mf_dir;
-
-typedef struct part_file
-{
- zint number;
- zint top;
- zint blocks;
- mfile_off_t bytes;
- mf_dir *dir;
- char *path;
- int fd;
-} part_file;
-
-struct MFile_area_struct;
-typedef struct MFile_area_struct *MFile_area;
-
-typedef struct meta_file
-{
- char name[FILENAME_MAX+1];
- part_file files[MF_MAX_PARTS];
- 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;
- int wr;
- Zebra_mutex mutex;
-
- struct meta_file *next;
-} *MFile, meta_file;
-
-typedef struct MFile_area_struct
-{
- char name[FILENAME_MAX+1];
- mf_dir *dirs;
- struct meta_file *mfiles;
- struct MFile_area_struct *next; /* global list of active areas */
- 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.
- */
-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.
- */
-int mf_close(MFile mf);
-
-/*
- * Read one block from a metafile. Interface mirrors bfile.
- */
-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);
-
-/*
- * Unlink the file by name, rather than MFile-handle.
- */
-int mf_unlink_name(MFile_area, const char *name);
-
-YAZ_END_CDECL
-
-#endif
-/* $Id: sortidx.h,v 1.5 2004-08-25 09:23:36 adam Exp $
+/* $Id: sortidx.h,v 1.6 2004-12-08 12:23:09 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#define SORTIDX_H
#include <idzebra/version.h>
-#include <bfile.h>
+#include <idzebra/bfile.h>
#ifdef __cplusplus
extern "C" {
-/* $Id: index.h,v 1.126 2004-11-29 21:55:25 adam Exp $
+/* $Id: index.h,v 1.127 2004-12-08 12:23:09 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#endif
#include <sys/stat.h>
-#include <dict.h>
+#include <idzebra/dict.h>
#include <isams.h>
#include <isamc.h>
#include <isamb.h>
-/* $Id: recindex.h,v 1.21 2004-08-04 08:35:23 adam Exp $
+/* $Id: recindex.h,v 1.22 2004-12-08 12:23:09 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#define RECINDEX_H
#include <zebrautl.h>
-#include <bfile.h>
+#include <zebra-lock.h>
+#include <idzebra/bfile.h>
YAZ_BEGIN_CDECL
-/* $Id: recindxp.h,v 1.15 2004-08-09 09:06:13 adam Exp $
+/* $Id: recindxp.h,v 1.16 2004-12-08 12:23:09 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include "recindex.h"
-#include <bfile.h>
+#include <idzebra/bfile.h>
YAZ_BEGIN_CDECL
-/* $Id: sortidx.c,v 1.10 2004-11-19 10:27:03 heikki Exp $
+/* $Id: sortidx.c,v 1.11 2004-12-08 12:23:09 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include <string.h>
#include <yaz/ylog.h>
-#include <bfile.h>
+#include <idzebra/bfile.h>
#include <sortidx.h>
#define SORT_IDX_BLOCKSIZE 64
-/* $Id: isamc-p.h,v 1.11 2004-08-06 12:28:23 adam Exp $
+/* $Id: isamc-p.h,v 1.12 2004-12-08 12:23:10 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
-#include <bfile.h>
+#include <idzebra/bfile.h>
#include <isamc.h>
YAZ_BEGIN_CDECL
-; $Id: zebra.nsi,v 1.24 2004-08-25 09:21:43 adam Exp $
+; $Id: zebra.nsi,v 1.25 2004-12-08 12:23:10 adam Exp $
!define VERSION "1.4.0"
File ..\recctrl\*.h
SetOutPath $INSTDIR\dict
File ..\dict\*.c
+ File ..\dict\*.h
SetOutPath $INSTDIR\bfile
File ..\bfile\*.c
File ..\bfile\*.h