Moved zebrautl.h to idzebra/util.h.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 30 Mar 2005 09:25:23 +0000 (09:25 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 30 Mar 2005 09:25:23 +0000 (09:25 +0000)
Implemented bf_xpen, bf_xclose that opens/closes a BFile with magic header
and managed block free list handling. bf_alloc/bf_free performs the
block allocation.

46 files changed:
bfile/Makefile.am
bfile/bfile.c
bfile/cfile.c
bfile/commit.c
bfile/mfile.c
bfile/tstbfile1.c [new file with mode: 0644]
dfa/agrep.c
dfa/bset.c
dfa/dfa.c
dfa/grepper.c
dfa/imalloc.c
dfa/lexer.c
dfa/readfile.c
dict/dictext.c
dict/dicttest.c
include/Makefile.am
include/idzebra/Makefile.am
include/idzebra/bfile.h
include/idzebra/data1.h
include/idzebra/res.h
include/idzebra/util.h [new file with mode: 0644]
include/idzebra/version.h
include/zebrautl.h [deleted file]
index/attribute.c
index/index.h
index/recindex.h
recctrl/recctrl.c
recctrl/rectext.c
recctrl/regxread.c
recctrl/safari.c
rset/rsbetween.c
rset/rsbool.c
rset/rset.c
rset/rsisamb.c
rset/rsisamc.c
rset/rsisams.c
rset/rsmultiandor.c
rset/rsnull.c
rset/rsprox.c
rset/rstemp.c
test/codec/Makefile.am
util/Makefile.am
util/atoi_zn.c
util/res.c
util/zint.c [new file with mode: 0644]
win/makefile

index 05db97f..38d05f3 100644 (file)
@@ -1,7 +1,15 @@
-## $Id: Makefile.am,v 1.4 2004-12-08 12:23:08 adam Exp $ Copyright (C) 1994-1998, Index Data ApS
+## $Id: Makefile.am,v 1.5 2005-03-30 09:25:23 adam Exp $ Copyright (C) 1994-1998, Index Data ApS
 lib_LTLIBRARIES = libidzebra-bfile.la
 
 lib_LTLIBRARIES = libidzebra-bfile.la
 
-AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC)
+check_PROGRAMS = tstbfile1
+
+TESTS = $(check_PROGRAMS)
+
+tstbfile1_SOURCES = tstbfile1.c
+
+AM_CPPFLAGS = -I$(top_srcdir)/include $(YAZINC)
 
 libidzebra_bfile_la_SOURCES = bfile.c mfile.c cfile.c commit.c cfile.h mfile.h
 
 
 libidzebra_bfile_la_SOURCES = bfile.c mfile.c cfile.c commit.c cfile.h mfile.h
 
+LDADD = libidzebra-bfile.la ../util/libidzebra-util.la $(YAZLALIB)
+
index 41b8a62..facec01 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bfile.c,v 1.39 2005-01-15 19:38:17 adam Exp $
+/* $Id: bfile.c,v 1.40 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -30,7 +30,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <unistd.h>
 #endif
 
 #include <unistd.h>
 #endif
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <idzebra/bfile.h>
 #include "mfile.h"
 #include "cfile.h"
 #include <idzebra/bfile.h>
 #include "mfile.h"
 #include "cfile.h"
@@ -40,6 +40,14 @@ struct BFile_struct
     MFile mf;
     Zebra_lock_rdwr rdwr_lock;
     struct CFile_struct *cf;
     MFile mf;
     Zebra_lock_rdwr rdwr_lock;
     struct CFile_struct *cf;
+    char *alloc_buf;
+    int block_size;
+    int alloc_buf_size;
+    zint last_block;
+    zint free_list;
+    zint root_block;
+    char *magic;
+    int header_dirty;
 };
 
 struct BFiles_struct {
 };
 
 struct BFiles_struct {
@@ -116,48 +124,153 @@ int bf_close (BFile bf)
     if (bf->cf)
         cf_close (bf->cf);
     mf_close (bf->mf);
     if (bf->cf)
         cf_close (bf->cf);
     mf_close (bf->mf);
-    xfree (bf);
+    xfree(bf->alloc_buf);
+    xfree(bf->magic);
+    xfree(bf);
     return 0;
 }
 
     return 0;
 }
 
+#define HEADER_SIZE 256
+
+BFile bf_xopen(BFiles bfs, const char *name, int block_size, int wrflag,
+              const char *magic, int *read_version,
+              const char **more_info)
+{
+    char read_magic[40];
+    int l = 0;
+    int i = 0;
+    char *hbuf;
+    zint pos = 0;
+    BFile bf = bf_open(bfs, name, block_size, wrflag);
+
+    if (!bf)
+       return 0;
+     /* HEADER_SIZE is considered enough for our header */
+    if (bf->alloc_buf_size < HEADER_SIZE)
+       bf->alloc_buf_size = HEADER_SIZE;
+    else
+       bf->alloc_buf_size = bf->block_size;
+       
+    hbuf = bf->alloc_buf = xmalloc(bf->alloc_buf_size);
+
+    /* fill-in default values */
+    bf->free_list = 0;
+    bf->root_block = bf->last_block = HEADER_SIZE / bf->block_size + 1;
+    bf->magic = xstrdup(magic);
+
+    if (!bf_read(bf, pos, 0, 0, hbuf + pos * bf->block_size))
+    {
+       if (wrflag)
+           bf->header_dirty = 1;
+       return bf;
+    }
+    while(hbuf[pos * bf->block_size + i] != '\0')
+    {
+       if (i == bf->block_size)
+       {   /* end of block at pos reached .. */
+           if (bf->alloc_buf_size  < (pos+1) * bf->block_size)
+           {
+               /* not room for all in alloc_buf_size */
+               yaz_log(YLOG_WARN, "bad header for %s (3)", magic);
+               bf_close(bf);
+               return 0;
+           }
+           /* read next block in header */
+           pos++;
+           if (!bf_read(bf, pos, 0, 0, hbuf + pos * bf->block_size))
+           {
+               yaz_log(YLOG_WARN, "missing header block %s (4)", magic);
+               bf_close(bf);
+               return 0;
+           }
+           i = 0; /* pos within block is reset */
+       }
+       else
+           i++;
+    }
+    if (sscanf(hbuf, "%39s %d " ZINT_FORMAT " " ZINT_FORMAT "%n",
+              read_magic, read_version, &bf->last_block,
+              &bf->free_list, &l) < 4 && l)  /* if %n is counted, it's 5 */
+    {
+       yaz_log(YLOG_WARN, "bad header for %s (1)", magic);
+       bf_close(bf);
+       return 0;
+    }
+    if (strcmp(read_magic, magic))
+    {
+       yaz_log(YLOG_WARN, "bad header for %s (2)", magic);
+       bf_close(bf);
+       return 0;
+    }
+    if (more_info)
+       *more_info = hbuf + l;
+    return bf;
+}
+
+int bf_xclose (BFile bf, int version, const char *more_info)
+{
+    if (bf->header_dirty)
+    {
+       assert(bf->alloc_buf);
+       zint pos = 0;
+       assert(bf->magic);
+       sprintf(bf->alloc_buf, "%s %d " ZINT_FORMAT " " ZINT_FORMAT " ", 
+               bf->magic, version, bf->last_block, bf->free_list);
+       if (more_info)
+           strcat(bf->alloc_buf, more_info);
+       while (1)
+       {
+           bf_write(bf, pos, 0, 0, bf->alloc_buf + pos * bf->block_size);
+           pos++;
+           if (pos * bf->block_size > strlen(bf->alloc_buf))
+               break;
+       }
+    }
+    return bf_close(bf);
+}
+
 BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag)
 {
 BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag)
 {
-    BFile tmp = (BFile) xmalloc(sizeof(struct BFile_struct));
+    BFile bf = (BFile) xmalloc(sizeof(struct BFile_struct));
 
 
+    bf->alloc_buf = 0;
+    bf->magic = 0;
+    bf->block_size = block_size;
+    bf->header_dirty = 0;
     if (bfs->commit_area)
     {
         int first_time;
 
     if (bfs->commit_area)
     {
         int first_time;
 
-        tmp->mf = mf_open (bfs->register_area, name, block_size, 0);
-        tmp->cf = cf_open (tmp->mf, bfs->commit_area, name, block_size,
+        bf->mf = mf_open (bfs->register_area, name, block_size, 0);
+        bf->cf = cf_open (bf->mf, bfs->commit_area, name, block_size,
                            wflag, &first_time);
         if (first_time)
         {
             FILE *outf;
 
                            wflag, &first_time);
         if (first_time)
         {
             FILE *outf;
 
-            outf = open_cache (bfs, "ab");
+            outf = open_cache(bfs, "ab");
             if (!outf)
             {
             if (!outf)
             {
-                yaz_log (YLOG_FATAL|YLOG_ERRNO, "open %s", bfs->cache_fname);
-                exit (1);
+                yaz_log(YLOG_FATAL|YLOG_ERRNO, "open %s", bfs->cache_fname);
+                exit(1);
             }
             }
-            fprintf (outf, "%s %d\n", name, block_size);
-            fclose (outf);
+            fprintf(outf, "%s %d\n", name, block_size);
+            fclose(outf);
         }
     }
     else
     {
         }
     }
     else
     {
-        tmp->mf = mf_open(bfs->register_area, name, block_size, wflag);
-        tmp->cf = NULL;
+        bf->mf = mf_open(bfs->register_area, name, block_size, wflag);
+        bf->cf = NULL;
     }
     }
-    if (!tmp->mf)
+    if (!bf->mf)
     {
     {
-        yaz_log (YLOG_FATAL, "mf_open failed for %s", name);
-        xfree (tmp);
+        yaz_log(YLOG_FATAL, "mf_open failed for %s", name);
+        xfree(bf);
         return 0;
     }
         return 0;
     }
-    zebra_lock_rdwr_init (&tmp->rdwr_lock);
-    return(tmp);
+    zebra_lock_rdwr_init(&bf->rdwr_lock);
+    return bf;
 }
 
 int bf_read (BFile bf, zint no, int offset, int nbytes, void *buf)
 }
 
 int bf_read (BFile bf, zint no, int offset, int nbytes, void *buf)
@@ -268,3 +381,48 @@ void bf_commitClean (BFiles bfs, const char *spec)
     if (mustDisable)
         bf_cache (bfs, 0);
 }
     if (mustDisable)
         bf_cache (bfs, 0);
 }
+
+int bf_alloc(BFile bf, int no, zint *blocks)
+{
+    int i;
+    assert(bf->alloc_buf);
+    bf->header_dirty = 1;
+    for (i = 0; i < no; i++)
+    {
+       if (!bf->free_list)
+           blocks[i] = bf->last_block++;
+       else
+       {
+           char buf[16];
+           const char *cp = buf;
+           memset(buf, '\0', sizeof(buf));
+
+           blocks[i] = bf->free_list;
+           if (!bf_read(bf, bf->free_list, 0, sizeof(buf), buf))
+           {
+               yaz_log(YLOG_WARN, "Bad freelist entry " ZINT_FORMAT,
+                       bf->free_list);
+               exit(1);
+           }
+           zebra_zint_decode(&cp, &bf->free_list);
+       }
+    }
+    return 0;
+}
+
+int bf_free(BFile bf, int no, const zint *blocks)
+{
+    int i;
+    assert(bf->alloc_buf);
+    bf->header_dirty = 1;
+    for (i = 0; i < no; i++)
+    {
+       char buf[16];
+       char *cp = buf;
+       memset(buf, '\0', sizeof(buf));
+       zebra_zint_encode(&cp, bf->free_list);
+       bf->free_list = blocks[i];
+       bf_write(bf, bf->free_list, 0, sizeof(buf), buf);
+    }
+    return 0;
+}
index 63465d5..d2d1add 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cfile.c,v 1.33 2005-01-15 19:38:17 adam Exp $
+/* $Id: cfile.c,v 1.34 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -24,7 +24,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include "mfile.h"
 #include "cfile.h"
 
 #include "mfile.h"
 #include "cfile.h"
 
index 1715913..2461834 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: commit.c,v 1.23 2005-01-15 19:38:17 adam Exp $
+/* $Id: commit.c,v 1.24 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -24,7 +24,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <assert.h>
 #include <stdlib.h>
 
 #include <assert.h>
 #include <stdlib.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include "mfile.h"
 #include "cfile.h"
 
 #include "mfile.h"
 #include "cfile.h"
 
index 189f202..69a062a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mfile.c,v 1.58 2005-01-15 19:38:17 adam Exp $
+/* $Id: mfile.c,v 1.59 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -43,7 +43,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <errno.h>
 
 #include <zebra-lock.h>
 #include <errno.h>
 
 #include <zebra-lock.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include "mfile.h"
 
 static int scan_areadef(MFile_area ma, const char *ad, const char *base)
 #include "mfile.h"
 
 static int scan_areadef(MFile_area ma, const char *ad, const char *base)
diff --git a/bfile/tstbfile1.c b/bfile/tstbfile1.c
new file mode 100644 (file)
index 0000000..f2a4903
--- /dev/null
@@ -0,0 +1,179 @@
+/* $Id: tstbfile1.c,v 1.1 2005-03-30 09:25:23 adam Exp $
+   Copyright (C) 1995-2005
+   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.
+*/
+
+#include <assert.h>
+#include <stdlib.h>
+#include <idzebra/bfile.h>
+
+void tst1(BFiles bfs)
+{
+    int version = 1;
+    BFile bf;
+
+    bf_reset(bfs);
+    bf = bf_xopen(bfs, "tst", /* block size */ 32, 
+                 /* wr */ 1, "tstmagic",       &version, 0 /* more_info */);
+    
+    bf_xclose(bf, version, 0 /* no more info */);
+    
+    bf = bf_xopen(bfs, "tst", /* block size */ 32, 
+                 /* wr */ 1, "tstmagic",       &version, 0 /* more_info */);
+    
+    bf_xclose(bf, version, 0 /* no more info */);
+}
+
+void tst2(BFiles bfs)
+{
+    int version = 1;
+    int bno, i;
+    zint blocks[1000];
+    BFile bf;
+    bf_reset(bfs);
+
+    bf = bf_xopen(bfs, "tst", /* block size */ 32, 
+                       /* wr */ 1, "tstmagic", &version, 0 /* more_info */);
+
+    bno = 0;
+    for (i = 1; i<30; i++)
+    {
+       int j;
+       for (j = 0; j<i; j++)
+           blocks[bno + j] = 0;
+       if (bf_alloc(bf, i, blocks + bno))
+       {
+           fprintf(stderr, "bf_alloc failed i=%d bno=%d\n", i, bno);
+           exit(1);
+       }
+       for (j = 0; j < i; j++)
+       {
+           if (!blocks[bno + j])
+           {
+               fprintf(stderr, "zero block i=%d bno=%d j=%d\n", i, bno, j);
+               exit(1);
+           }
+       }
+       bno += i;
+    }
+    for (i = 0; i<bno; i++)
+    {
+       if (bf_free(bf, 1, blocks + i))
+       {
+           fprintf(stderr, "bf_freec failed i=%d\n", i);
+           exit(1);
+       }
+    }
+    bf_xclose(bf, version, 0);
+}
+
+#define BLOCKS 100
+
+void tst3(BFiles bfs)
+{
+    int version = 1;
+    int i;
+    zint blocks[BLOCKS];
+    BFile bf;
+    int no_in_use = 0;
+    int pass = 0;
+    bf_reset(bfs);
+
+    for(i = 0; i<BLOCKS; i++)
+       blocks[i] = 0;
+
+    bf = bf_xopen(bfs, "tst", /* block size */ 32, 
+                       /* wr */ 1, "tstmagic", &version, 0 /* more_info */);
+
+    no_in_use = 0;
+    for (pass = 0; pass < 100; pass++)
+    {
+       int r = random() % 9;
+
+       assert (no_in_use >= 0 && no_in_use <= BLOCKS);
+       if (r < 5 && (BLOCKS - no_in_use) > 0)
+       {
+           /* alloc phase */
+           int j = 0;
+           zint tblocks[BLOCKS];
+           int left = BLOCKS - no_in_use;
+           int to_alloc = 1 + (random() % left);
+
+           bf_alloc(bf, to_alloc, tblocks);
+           /* transfer from tblocks to blocks */
+           for (i = 0; i<BLOCKS; i++)
+           {
+               if (blocks[i] == 0)
+               {
+                   blocks[i] = tblocks[j++];
+                   no_in_use++;
+                   if (j == to_alloc)
+                       break;
+               }
+           }
+       }
+       else if (r < 8 && no_in_use > 0)
+       {
+           /* free phase */
+           zint tblocks[BLOCKS];
+           int to_free = 1 + (random() % no_in_use);
+           int start = random() % to_free;
+           int j = 0;
+           for (i = 0; i<BLOCKS; i++)
+           {
+               if (blocks[i])
+               {
+                   if (j >= start && j < to_free)
+                   {
+                       tblocks[j-start] = blocks[i];
+                       blocks[i] = 0;
+                       no_in_use--;
+                   }
+                   j++;
+               }
+           }
+           assert(tblocks[to_free-start-1]);
+           bf_free(bf, to_free - start, tblocks);
+       }
+       else
+       {
+           bf_xclose(bf, version, 0);
+           bf = bf_xopen(bfs, "tst", /* block size */ 32, 
+                         /* wr */ 1, "tstmagic", &version, 0 /* more_info */);
+       }
+    }
+    bf_xclose(bf, version, 0);
+}
+
+int main(int argc, char **argv)
+{
+    BFiles bfs = bfs_create(0, /* register: current dir, no limit */
+                           0  /* base: current dir */
+       );
+    if (!bfs)
+       exit(1);
+
+    tst1(bfs);
+    tst2(bfs);
+    tst3(bfs);
+    bf_reset(bfs);
+    bfs_destroy(bfs);
+    exit(0);
+}
index 9409baa..179a495 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: agrep.c,v 1.14 2005-01-15 19:38:18 adam Exp $
+/* $Id: agrep.c,v 1.15 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -39,7 +39,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <unistd.h>
 #endif
 
 #include <unistd.h>
 #endif
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <dfa.h>
 #include "imalloc.h"
 
 #include <dfa.h>
 #include "imalloc.h"
 
index 8fef050..3634774 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bset.c,v 1.7 2005-01-15 19:38:18 adam Exp $
+/* $Id: bset.c,v 1.8 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -27,7 +27,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <bset.h>
 #include "imalloc.h"
 
 #include <bset.h>
 #include "imalloc.h"
 
index d58b303..5c3d376 100644 (file)
--- a/dfa/dfa.c
+++ b/dfa/dfa.c
@@ -1,4 +1,4 @@
-/* $Id: dfa.c,v 1.33 2005-01-15 21:45:42 adam Exp $
+/* $Id: dfa.c,v 1.34 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,7 +28,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <string.h>
 #include <ctype.h>
 
 #include <string.h>
 #include <ctype.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include "dfap.h"
 #include "imalloc.h"
 
 #include "dfap.h"
 #include "imalloc.h"
 
index 48fa465..03553a6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: grepper.c,v 1.12 2005-01-15 19:38:19 adam Exp $
+/* $Id: grepper.c,v 1.13 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -27,7 +27,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <ctype.h>
 #include <assert.h>
 
 #include <ctype.h>
 #include <assert.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <dfa.h>
 #include "imalloc.h"
 
 #include <dfa.h>
 #include "imalloc.h"
 
index b88967f..0561d89 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: imalloc.c,v 1.11 2005-01-15 19:38:19 adam Exp $
+/* $Id: imalloc.c,v 1.12 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -25,7 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <assert.h>
 #include <stdlib.h>
 
 #include <assert.h>
 #include <stdlib.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include "imalloc.h"
 
 #if MEMDEBUG
 #include "imalloc.h"
 
 #if MEMDEBUG
index e5bbc36..c6e1d85 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lexer.c,v 1.13 2005-01-15 19:38:19 adam Exp $
+/* $Id: lexer.c,v 1.14 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,7 +28,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <string.h>
 #include <stdarg.h>
 
 #include <string.h>
 #include <stdarg.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <dfa.h>
 #include "imalloc.h"
 #include "lexer.h"
 #include <dfa.h>
 #include "imalloc.h"
 #include "lexer.h"
index 40b0bf3..7682ea5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: readfile.c,v 1.10 2005-01-15 19:38:19 adam Exp $
+/* $Id: readfile.c,v 1.11 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,7 +28,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <string.h>
 #include <ctype.h>
 
 #include <string.h>
 #include <ctype.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <dfa.h>
 #include "lexer.h"
 
 #include <dfa.h>
 #include "lexer.h"
 
index b72e83a..124e461 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dictext.c,v 1.11 2005-01-15 19:38:21 adam Exp $
+/* $Id: dictext.c,v 1.12 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,7 +28,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <assert.h>
 #include <ctype.h>
 
 #include <assert.h>
 #include <ctype.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 
 char *prog;
 
 
 char *prog;
 
index 2dce332..e923565 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dicttest.c,v 1.32 2005-01-15 19:38:21 adam Exp $
+/* $Id: dicttest.c,v 1.33 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -26,7 +26,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <ctype.h>
 
 #include <idzebra/dict.h>
 #include <ctype.h>
 
 #include <idzebra/dict.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
+#include <idzebra/res.h>
 
 char *prog;
 static Dict dict;
 
 char *prog;
 static Dict dict;
index f06e009..6bb6f49 100644 (file)
@@ -1,6 +1,6 @@
-# $Id: Makefile.am,v 1.21 2005-01-15 21:45:42 adam Exp $
+# $Id: Makefile.am,v 1.22 2005-03-30 09:25:23 adam Exp $
 noinst_HEADERS = bset.h charmap.h  \
 direntz.h passwddb.h dfa.h zebra_xpath.h d1_absyn.h \
 noinst_HEADERS = bset.h charmap.h  \
 direntz.h passwddb.h dfa.h zebra_xpath.h d1_absyn.h \
-rset.h dfaset.h sortidx.h zebra-lock.h zebrautl.h
+rset.h dfaset.h sortidx.h zebra-lock.h
 
 SUBDIRS = idzebra
 
 SUBDIRS = idzebra
index 52efdff..0c6f616 100644 (file)
@@ -1,5 +1,5 @@
-# $Id: Makefile.am,v 1.5 2004-12-08 14:02:36 adam Exp $
+# $Id: Makefile.am,v 1.6 2005-03-30 09:25:23 adam Exp $
 
 pkginclude_HEADERS=api.h version.h res.h recctrl.h data1.h recgrs.h \
 
 pkginclude_HEADERS=api.h version.h res.h recctrl.h data1.h recgrs.h \
- zebramap.h bfile.h dict.h isam-codec.h isams.h isamc.h isamb.h
+ zebramap.h bfile.h dict.h isam-codec.h isams.h isamc.h isamb.h util.h
 
 
index 4ec3923..d1b25c1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bfile.h,v 1.3 2005-01-15 19:38:24 adam Exp $
+/* $Id: bfile.h,v 1.4 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -24,7 +24,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #define BFILE_H
 
 #include <yaz/yconfig.h>
 #define BFILE_H
 
 #include <yaz/yconfig.h>
-#include <idzebra/version.h>
+#include <idzebra/util.h>
 
 YAZ_BEGIN_CDECL
 
 
 YAZ_BEGIN_CDECL
 
@@ -40,6 +40,9 @@ void bfs_destroy (BFiles bfiles);
 YAZ_EXPORT
 int bf_close (BFile);
 
 YAZ_EXPORT
 int bf_close (BFile);
 
+YAZ_EXPORT
+int bf_xclose (BFile bf, int version, const char *more_info);
+
 /* bf_open: opens bfile.
    opens bfile with name 'name' and with 'block_size' as block size.
    returns bfile handle is successful; NULL otherwise 
 /* bf_open: opens bfile.
    opens bfile with name 'name' and with 'block_size' as block size.
    returns bfile handle is successful; NULL otherwise 
@@ -47,6 +50,11 @@ int bf_close (BFile);
 YAZ_EXPORT
 BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag);
 
 YAZ_EXPORT
 BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag);
 
+YAZ_EXPORT
+BFile bf_xopen(BFiles bfs, const char *name, int block_size, int wrflag,
+              const char *magic, int *read_version,
+              const char **more_info);
+
 /* 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'.
 /* 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'.
@@ -83,6 +91,14 @@ void bf_commitClean (BFiles bfs, const char *spec);
 YAZ_EXPORT
 void bf_reset (BFiles bfs);
 
 YAZ_EXPORT
 void bf_reset (BFiles bfs);
 
+/* bf_alloc: allocate one or more blocks */
+YAZ_EXPORT
+int bf_alloc(BFile bf, int no, zint *blocks);
+
+/* bf_alloc: allocate one or more blocks */
+YAZ_EXPORT
+int bf_free(BFile bf, int no, const zint *blocks);
+
 YAZ_END_CDECL
 
 #endif
 YAZ_END_CDECL
 
 #endif
index dc7c975..705b9e9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: data1.h,v 1.7 2005-01-15 19:38:24 adam Exp $
+/* $Id: data1.h,v 1.8 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,11 +28,10 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <yaz/nmem.h>
 #include <yaz/oid.h>
 #include <yaz/proto.h>
 #include <yaz/nmem.h>
 #include <yaz/oid.h>
 #include <yaz/proto.h>
-
-#include <idzebra/version.h>
-
 #include <yaz/yaz-util.h>
 
 #include <yaz/yaz-util.h>
 
+#include <idzebra/util.h>
+
 #define d1_isspace(c) strchr(" \r\n\t\f", c)
 #define d1_isdigit(c) ((c) <= '9' && (c) >= '0')
 
 #define d1_isspace(c) strchr(" \r\n\t\f", c)
 #define d1_isdigit(c) ((c) <= '9' && (c) >= '0')
 
index 357801e..2a7c296 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: res.h,v 1.3 2005-01-15 19:38:24 adam Exp $
+/* $Id: res.h,v 1.4 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -20,10 +20,10 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 */
 
 02111-1307, USA.
 */
 
-#ifndef RES_H
-#define RES_H
+#ifndef IDZEBRA_RES_H
+#define IDZEBRA_RES_H
 
 
-#include <yaz/yaz-version.h>
+#include <idzebra/util.h>
 
 YAZ_BEGIN_CDECL
 
 
 YAZ_BEGIN_CDECL
 
diff --git a/include/idzebra/util.h b/include/idzebra/util.h
new file mode 100644 (file)
index 0000000..41f356e
--- /dev/null
@@ -0,0 +1,69 @@
+/* $Id: util.h,v 1.1 2005-03-30 09:25:23 adam Exp $
+   Copyright (C) 1995-2005
+   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 ZEBRA_UTIL_H
+#define ZEBRA_UTIL_H
+
+#include <yaz/yaz-util.h>
+
+#include <idzebra/version.h>
+
+/* check that we don't have all too old yaz */
+#ifndef YLOG_ERRNO
+#error Need a modern yaz with YLOG_ defines
+#endif
+
+YAZ_BEGIN_CDECL
+
+#ifdef __GNUC__
+typedef long long int zint;
+#define ZINT_FORMAT "%lld"
+#define ZINT_FORMAT0 "lld"
+#else
+#ifdef WIN32
+typedef __int64 zint;
+#define ZINT_FORMAT "%I64d"
+#define ZINT_FORMAT0 "I64d"
+#else
+typedef long zint;
+#define ZINT_FORMAT "%ld"
+#define ZINT_FORMAT0 "ld"
+#endif
+#endif
+
+typedef zint SYSNO;
+
+YAZ_EXPORT
+zint atoi_zn (const char *buf, zint len);
+
+YAZ_EXPORT
+void zebra_zint_encode(char **dst, zint pos);
+
+YAZ_EXPORT
+void zebra_zint_decode(const char **src, zint *pos);
+
+YAZ_END_CDECL
+
+#define CAST_ZINT_TO_INT(x) (int)(x)
+#define CAST_ZINT_TO_DOUBLE(x) (double)(x)
+
+#endif
index 4053fac..fe80f34 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: version.h,v 1.2 2005-01-15 19:38:24 adam Exp $
+/* $Id: version.h,v 1.3 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -24,24 +24,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #define ZEBRAVER "1.4.0"
 
 
 #define ZEBRAVER "1.4.0"
 
-#define ZEBRADATE "$Date: 2005-01-15 19:38:24 $"
-
-#ifdef __GNUC__
-typedef long long int zint;
-#define ZINT_FORMAT "%lld"
-#define ZINT_FORMAT0 "lld"
-#else
-#ifdef WIN32
-typedef __int64 zint;
-#define ZINT_FORMAT "%I64d"
-#define ZINT_FORMAT0 "I64d"
-#else
-typedef long zint;
-#define ZINT_FORMAT "%ld"
-#define ZINT_FORMAT0 "ld"
-#endif
-#endif
-
-typedef zint SYSNO;
+#define ZEBRADATE "$Date: 2005-03-30 09:25:23 $"
 
 #endif
 
 #endif
diff --git a/include/zebrautl.h b/include/zebrautl.h
deleted file mode 100644 (file)
index ecc5d42..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $Id: zebrautl.h,v 1.14 2005-03-08 14:02:08 adam Exp $
-   Copyright (C) 1995-2005
-   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 ZEBRA_UTIL_H
-#define ZEBRA_UTIL_H
-
-#include <yaz/yaz-util.h>
-
-#include <idzebra/res.h>
-#include <idzebra/version.h>
-
-/* check that we don't have all too old yaz */
-#ifndef YLOG_ERRNO
-#error Need a modern yaz with YLOG_ defines
-#endif
-
-YAZ_BEGIN_CDECL
-zint atoi_zn (const char *buf, zint len);
-YAZ_END_CDECL
-
-#define CAST_ZINT_TO_INT(x) (int)(x)
-#define CAST_ZINT_TO_DOUBLE(x) (double)(x)
-
-#endif
index 4ea12f7..51a5be0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: attribute.c,v 1.19 2005-01-15 19:38:24 adam Exp $
+/* $Id: attribute.c,v 1.20 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -20,13 +20,11 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 */
 
 02111-1307, USA.
 */
 
-
-
 #include <stdio.h>
 
 #include <yaz/log.h>
 #include <idzebra/res.h>
 #include <stdio.h>
 
 #include <yaz/log.h>
 #include <idzebra/res.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include "index.h"
 
 static data1_att *getatt(data1_attset *p, int att, const char *sattr)
 #include "index.h"
 
 static data1_att *getatt(data1_attset *p, int att, const char *sattr)
index 36b1c57..5fdc519 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: index.h,v 1.130 2005-01-16 23:14:57 adam Exp $
+/* $Id: index.h,v 1.131 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -26,7 +26,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <time.h>
 #include <stdlib.h>
 #include <idzebra/version.h>
 #include <time.h>
 #include <stdlib.h>
 #include <idzebra/version.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <sortidx.h>
 
 #if HAVE_SYS_TIMES_H
 #include <sortidx.h>
 
 #if HAVE_SYS_TIMES_H
index d8b5e30..403795d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: recindex.h,v 1.23 2005-01-15 19:38:26 adam Exp $
+/* $Id: recindex.h,v 1.24 2005-03-30 09:25:23 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -23,7 +23,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #ifndef RECINDEX_H
 #define RECINDEX_H
 
 #ifndef RECINDEX_H
 #define RECINDEX_H
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <zebra-lock.h>
 #include <idzebra/bfile.h>
 
 #include <zebra-lock.h>
 #include <idzebra/bfile.h>
 
index d4f6f2b..0acba7d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: recctrl.c,v 1.17 2005-01-15 19:38:32 adam Exp $
+/* $Id: recctrl.c,v 1.18 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -29,7 +29,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #endif
 
 #include <direntz.h>
 #endif
 
 #include <direntz.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <idzebra/recctrl.h>
 
 struct recTypeClass {
 #include <idzebra/recctrl.h>
 
 struct recTypeClass {
index 3b14203..48460d5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rectext.c,v 1.24 2005-03-05 09:19:16 adam Exp $
+/* $Id: rectext.c,v 1.25 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -25,7 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <assert.h>
 #include <ctype.h>
 
 #include <assert.h>
 #include <ctype.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <idzebra/recctrl.h>
 
 struct text_info {
 #include <idzebra/recctrl.h>
 
 struct text_info {
index 3d074a8..db605ad 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: regxread.c,v 1.57 2005-01-16 23:14:57 adam Exp $
+/* $Id: regxread.c,v 1.58 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -27,7 +27,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <ctype.h>
 
 #include <yaz/tpath.h>
 #include <ctype.h>
 
 #include <yaz/tpath.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <dfa.h>
 #include <idzebra/recgrs.h>
 
 #include <dfa.h>
 #include <idzebra/recgrs.h>
 
index 6a1c585..a3a98cb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: safari.c,v 1.5 2005-03-09 13:45:29 adam Exp $
+/* $Id: safari.c,v 1.6 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -25,7 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <assert.h>
 #include <ctype.h>
 
 #include <assert.h>
 #include <ctype.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <idzebra/recctrl.h>
 
 struct safari_info {
 #include <idzebra/recctrl.h>
 
 struct safari_info {
index 486954b..56cc894 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsbetween.c,v 1.35 2005-01-15 20:47:16 adam Exp $
+/* $Id: rsbetween.c,v 1.36 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -36,7 +36,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <string.h>
 #include <assert.h>
 
 #include <string.h>
 #include <assert.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <rset.h>
 
 
 #include <rset.h>
 
 
index 8dab557..04afa12 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsbool.c,v 1.52 2005-01-15 19:38:33 adam Exp $
+/* $Id: rsbool.c,v 1.53 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -25,7 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <string.h>
 #include <assert.h>
 
 #include <string.h>
 #include <assert.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <rset.h>
 
 #ifndef RSET_DEBUG
 #include <rset.h>
 
 #ifndef RSET_DEBUG
index 41d39a7..26ba709 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rset.c,v 1.43 2005-01-17 01:21:44 adam Exp $
+/* $Id: rset.c,v 1.44 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -22,7 +22,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <stdio.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <string.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <assert.h>
 #include <yaz/nmem.h>
 #include <rset.h>
 #include <assert.h>
 #include <yaz/nmem.h>
 #include <rset.h>
index 305a3d8..c07c5a5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsisamb.c,v 1.29 2005-01-15 19:38:34 adam Exp $
+/* $Id: rsisamb.c,v 1.30 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -22,7 +22,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <stdio.h>
 #include <assert.h>
 
 #include <stdio.h>
 #include <assert.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <rset.h>
 #include <string.h>
 
 #include <rset.h>
 #include <string.h>
 
index 09a0c29..7eafe1d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsisamc.c,v 1.35 2005-01-15 19:38:34 adam Exp $
+/* $Id: rsisamc.c,v 1.36 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -26,7 +26,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <stdio.h>
 #include <assert.h>
 #include <string.h>
 #include <stdio.h>
 #include <assert.h>
 #include <string.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <rset.h>
 
 static RSFD r_open (RSET ct, int flag);
 #include <rset.h>
 
 static RSFD r_open (RSET ct, int flag);
index 046d2c4..28bb5e5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsisams.c,v 1.18 2005-01-15 19:38:34 adam Exp $
+/* $Id: rsisams.c,v 1.19 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -24,7 +24,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <stdio.h>
 #include <assert.h>
 
 #include <stdio.h>
 #include <assert.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <rset.h>
 
 static RSFD r_open (RSET ct, int flag);
 #include <rset.h>
 
 static RSFD r_open (RSET ct, int flag);
index 0204cac..aeaffc0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsmultiandor.c,v 1.14 2005-03-08 14:02:15 adam Exp $
+/* $Id: rsmultiandor.c,v 1.15 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -39,7 +39,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <idzebra/isamc.h>
 #include <rset.h>
 
 #include <idzebra/isamc.h>
 #include <rset.h>
 
index f073744..754f771 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsnull.c,v 1.31 2005-01-15 19:38:35 adam Exp $
+/* $Id: rsnull.c,v 1.32 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -24,7 +24,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <stdio.h>
 #include <assert.h>
 
 #include <stdio.h>
 #include <assert.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <rset.h>
 
 
 #include <rset.h>
 
 
index d0746dd..129e521 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsprox.c,v 1.25 2005-03-08 14:02:15 adam Exp $
+/* $Id: rsprox.c,v 1.26 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -25,7 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <string.h>
 #include <assert.h>
 
 #include <string.h>
 #include <assert.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <rset.h>
 
 #ifndef RSET_DEBUG
 #include <rset.h>
 
 #ifndef RSET_DEBUG
index 57e1beb..fa239f3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rstemp.c,v 1.60 2005-01-17 01:21:44 adam Exp $
+/* $Id: rstemp.c,v 1.61 2005-03-30 09:25:24 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -32,7 +32,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #endif
 #include <sys/types.h>
 
 #endif
 #include <sys/types.h>
 
-#include <zebrautl.h>
+#include <idzebra/util.h>
 #include <rset.h>
 
 static RSFD r_open(RSET ct, int flag);
 #include <rset.h>
 
 static RSFD r_open(RSET ct, int flag);
index a74c841..f7ab8e5 100644 (file)
@@ -1,6 +1,8 @@
-# $Id: Makefile.am,v 1.4 2004-09-30 08:16:49 adam Exp $
+# $Id: Makefile.am,v 1.5 2005-03-30 09:25:25 adam Exp $
 
 
-TESTS = tstcodec
+check_PROGRAMS = tstcodec
+
+TESTS = $(check_PROGRAMS)
 
 zebralibs = \
  ../../index/libidzebra-api.la \
 
 zebralibs = \
  ../../index/libidzebra-api.la \
@@ -17,7 +19,6 @@ zebralibs = \
 
 tstcodec_SOURCES = tstcodec.c
 
 
 tstcodec_SOURCES = tstcodec.c
 
-noinst_PROGRAMS = tstcodec
 
 AM_CPPFLAGS = -I$(top_srcdir)/include $(YAZINC)
 
 
 AM_CPPFLAGS = -I$(top_srcdir)/include $(YAZINC)
 
index 7ba1fee..8c9783c 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.12 2004-09-30 08:16:49 adam Exp $
+## $Id: Makefile.am,v 1.13 2005-03-30 09:25:25 adam Exp $
 
 lib_LTLIBRARIES = libidzebra-util.la
 
 
 lib_LTLIBRARIES = libidzebra-util.la
 
@@ -13,7 +13,7 @@ DISTCLEANFILES = idzebra-config
 AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) -DDEFAULT_PROFILE_PATH=\"$(pkgdatadir)/tab\"
 LDADD = libidzebra-util.la $(YAZLALIB)
 
 AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) -DDEFAULT_PROFILE_PATH=\"$(pkgdatadir)/tab\"
 LDADD = libidzebra-util.la $(YAZLALIB)
 
-libidzebra_util_la_SOURCES = res.c charmap.c zebramap.c passwddb.c \
+libidzebra_util_la_SOURCES = zint.c res.c charmap.c zebramap.c passwddb.c \
  zebra-lock.c dirent.c xpath.c atoi_zn.c
 
 passtest_SOURCES = passtest.c
  zebra-lock.c dirent.c xpath.c atoi_zn.c
 
 passtest_SOURCES = passtest.c
index f9561ba..535327e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: atoi_zn.c,v 1.2 2005-01-15 19:38:40 adam Exp $
+/* $Id: atoi_zn.c,v 1.3 2005-03-30 09:25:25 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -22,7 +22,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <string.h>
 #include <ctype.h>
 
 #include <string.h>
 #include <ctype.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
 
 zint atoi_zn (const char *buf, zint len)
 {
 
 zint atoi_zn (const char *buf, zint len)
 {
index 6db1086..952b900 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: res.c,v 1.39 2005-01-15 19:38:42 adam Exp $
+/* $Id: res.c,v 1.40 2005-03-30 09:25:25 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -30,8 +30,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <unistd.h>
 #endif
 
 #include <unistd.h>
 #endif
 
-#include <zebrautl.h>
-#include <yaz/yaz-util.h>
+#include <idzebra/res.h>
 
 struct res_entry {
     char *name;
 
 struct res_entry {
     char *name;
diff --git a/util/zint.c b/util/zint.c
new file mode 100644 (file)
index 0000000..b183a53
--- /dev/null
@@ -0,0 +1,52 @@
+/* $Id: zint.c,v 1.1 2005-03-30 09:25:25 adam Exp $
+   Copyright (C) 1995-2005
+   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.
+*/
+
+#include <idzebra/util.h>
+
+void zebra_zint_encode(char **dst, zint pos)
+{
+    unsigned char *bp = (unsigned char*) *dst;
+
+    while (pos > 127)
+    {
+         *bp++ = (unsigned char) (128 | (pos & 127));
+         pos = pos >> 7;
+    }
+    *bp++ = (unsigned char) pos;
+    *dst = (char *) bp;
+}
+
+void zebra_zint_decode(const char **src, zint *pos)
+{
+    const unsigned char **bp = (const unsigned char **) src;
+    zint d = 0;
+    unsigned char c;
+    unsigned r = 0;
+
+    while (((c = *(*bp)++) & 128))
+    {
+        d += ((zint) (c & 127) << r);
+       r += 7;
+    }
+    d += ((zint) c << r);
+    *pos = d;
+}
index 382212d..2fe6dcb 100644 (file)
@@ -1,5 +1,5 @@
 # Zebra makefile for MS NMAKE
 # Zebra makefile for MS NMAKE
-# $Id: makefile,v 1.33 2005-01-16 00:27:54 adam Exp $
+# $Id: makefile,v 1.34 2005-03-30 09:25:26 adam Exp $
  
 ###########################################################
 ############### Parameters 
  
 ###########################################################
 ############### Parameters 
@@ -292,6 +292,7 @@ ZEBRALIB_OBJS= \
        $(OBJDIR)\trunc.obj \
        $(OBJDIR)\zebraapi.obj \
        $(OBJDIR)\zebramap.obj \
        $(OBJDIR)\trunc.obj \
        $(OBJDIR)\zebraapi.obj \
        $(OBJDIR)\zebramap.obj \
+       $(OBJDIR)\zint.obj \
        $(OBJDIR)\zinfo.obj \
        $(OBJDIR)\zrpn.obj \
        $(OBJDIR)\zsets.obj \
        $(OBJDIR)\zinfo.obj \
        $(OBJDIR)\zrpn.obj \
        $(OBJDIR)\zsets.obj \