Various cleanup. YAZ util used instead.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 4 Sep 1995 12:33:21 +0000 (12:33 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 4 Sep 1995 12:33:21 +0000 (12:33 +0000)
42 files changed:
bfile/Makefile
bfile/bfile.c
bfile/mfile.c
dfa/Makefile
dfa/agrep.c
dfa/bset.c
dfa/dfa.c
dfa/grepper.c
dfa/imalloc.c
dfa/lexer.c
dfa/readfile.c
dfa/set.c
dfa/states.c
dict/Makefile
dict/dictext.c
dict/dicttest.c
dict/insert.c
dict/open.c
include/bfile.h
include/mfile.h
index/Makefile
index/dir.c
index/extract.c
index/index.h
index/kdump.c
index/kinput.c
index/main.c
index/trav.c
index/zrpn.c
index/zserver.c
isam/Makefile
isam/isam.c
isam/isutil.c
isam/memory.c
isam/physical.c
isam/rootblk.c
rset/Makefile
rset/rset.c
rset/rsisam.c
util/Makefile
util/res-test.c
util/res.c

index 52fff4d..2c5f980 100644 (file)
@@ -1,5 +1,15 @@
+# Copyright (C) 1994, Index Data I/S 
+# All rights reserved.
+# Sebastian Hammer, Adam Dickmeiss
+# $Id: Makefile,v 1.12 1995-09-04 12:33:21 adam Exp $
+
 SHELL=/bin/sh
-INCLUDE=-I../include
+RANLIB=ranlib
+YAZ=../../yaz
+YAZLIB=$(YAZ)/lib/libyaz.a
+INCLUDE=-I../include -I$(YAZ)/include
+#CFLAGS=-g -Wall -pedantic -ansi
+DEFS=$(INCLUDE)
 TPROG=btest
 CFLAGS=-g -Wall -pedantic -ansi
 DEFS=$(INCLUDE)
@@ -9,13 +19,13 @@ CPP=cc -E
 
 all: $(LIB)
 
-$(TPROG): $(TPROG).o $(LIB) 
-       $(CC) -o $(TPROG) $(TPROG).o $(LIB)
+$(TPROG): $(TPROG).o $(LIB) $(YAZLIB)
+       $(CC) -o $(TPROG) $(TPROG).o $(LIB) $(YAZLIB)
 
 $(LIB): $(PO)
        rm -f $(LIB)
        ar qc $(LIB) $(PO)
-       ranlib $(LIB)
+       $(RANLIB) $(LIB)
 
 .c.o:
        $(CC) -c $(DEFS) $(CFLAGS) $<
@@ -23,16 +33,16 @@ $(LIB): $(PO)
 clean:
        rm -f *.[oa] $(TPROG) core mon.out gmon.out errlist
 
+
 depend: depend2
 
 depend1:
-       mv Makefile Makefile.tmp
-       sed '/^#Depend/q' <Makefile.tmp >Makefile
-       $(CPP) $(INCLUDE) -M *.c >>Makefile
-       -rm Makefile.tmp
+       sed '/^#Depend/q' <Makefile >Makefile.tmp
+       $(CPP) $(DEFS) -M *.c >>Makefile.tmp
+       mv -f Makefile.tmp Makefile
 
 depend2:
-       $(CPP) $(INCLUDE) -M *.c >.depend       
+       $(CPP) $(DEFS) -M *.c >.depend  
 
 ifeq (.depend,$(wildcard .depend))
 include .depend
index 9f045aa..7b65809 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: bfile.c,v $
- * Revision 1.10  1994-08-25 10:15:54  quinn
+ * Revision 1.11  1995-09-04 12:33:21  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.10  1994/08/25  10:15:54  quinn
  * Trivial
  *
  * Revision 1.9  1994/08/24  08:45:48  quinn
  *
  */
 
-#include <util.h>
-#include <bfile.h>
+#include <stdio.h>
 #include <sys/types.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
 
+#include <alexutil.h>
+#include <bfile.h>
+
 int bf_close (BFile bf)
 {
     mf_close(bf->mf);
@@ -53,7 +58,7 @@ BFile bf_open (const char *name, int block_size, int wflag)
 
     if (!(tmp->mf = mf_open(0, name, block_size, wflag)))
     {
-        log(LOG_FATAL, "Mfopen failed for %s", name); 
+        logf (LOG_FATAL, "Mfopen failed for %s", name); 
        return(0);
     }
     return(tmp);
index 9ad5943..3340a9f 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: mfile.c,v $
- * Revision 1.9  1994-11-04 14:26:39  quinn
+ * Revision 1.10  1995-09-04 12:33:22  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.9  1994/11/04  14:26:39  quinn
  * bug-fix.
  *
  * Revision 1.8  1994/10/05  16:56:42  quinn
 #include <unistd.h>
 #include <dirent.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <assert.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <mfile.h>
 
 static MFile_area_struct *open_areas = 0;
@@ -61,7 +65,7 @@ static int scan_areadef(MFile_area ma, const char *name)
 
     if (!ad)
     {
-       log(LOG_FATAL, "Could not find resource '%s'", name);
+       logf (LOG_FATAL, "Could not find resource '%s'", name);
        return -1;
     }
     for (;;)
@@ -71,7 +75,7 @@ static int scan_areadef(MFile_area ma, const char *name)
            break;
         if (rs != 3)
         {
-           log(LOG_FATAL, "Illegal directory description: %s", ad + offset);
+           logf (LOG_FATAL, "Illegal directory description: %s", ad + offset);
            return -1;
        }
        switch (unit)
@@ -80,7 +84,7 @@ static int scan_areadef(MFile_area ma, const char *name)
            case 'K': case 'k': multi = 1024; break;
            case 'M': case 'm': multi = 1048576; break;
            default:
-               log(LOG_FATAL, "Illegal unit: %c in %s", unit, ad + offset);
+               logf (LOG_FATAL, "Illegal unit: %c in %s", unit, ad + offset);
                return -1;
        }
        *dp = dir = xmalloc(sizeof(mf_dir));
@@ -113,13 +117,13 @@ static int file_position(MFile mf, int pos, int offset)
     if (mf->files[c].fd < 0 && (mf->files[c].fd = open(mf->files[c].path,
        mf->wr ? O_RDWR|O_CREAT : O_RDONLY, 0666)) < 0)
     {
-       log(LOG_FATAL|LOG_ERRNO, "Failed to open %s", mf->files[c].path);
+       logf (LOG_FATAL|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)
     {
-       log(LOG_FATAL|LOG_ERRNO, "Failed to seek in %s", mf->files[c].path);
+       logf (LOG_FATAL|LOG_ERRNO, "Failed to seek in %s", mf->files[c].path);
        return -1;
     }
     mf->cur_file = c;
@@ -146,7 +150,7 @@ MFile_area mf_init(const char *name)
     int fd, number;
     char metaname[FILENAME_MAX+1], tmpnam[FILENAME_MAX+1];
 
-    log(LOG_DEBUG, "mf_init(%s)", name);
+    logf (LOG_DEBUG, "mf_init(%s)", name);
     for (mp = open_areas; mp; mp = mp->next)
        if (!strcmp(name, mp->name))
            abort();
@@ -157,7 +161,7 @@ MFile_area mf_init(const char *name)
     ma->dirs = 0;
     if (scan_areadef(ma, name) < 0)
     {
-       log(LOG_FATAL, "Failed to access description of '%s'", name);
+       logf (LOG_FATAL, "Failed to access description of '%s'", name);
        return 0;
     }
     /* look at each directory */
@@ -165,7 +169,7 @@ MFile_area mf_init(const char *name)
     {
        if (!(dd = opendir(dirp->name)))
        {
-           log(LOG_FATAL|LOG_ERRNO, "Failed to open %s", dirp->name);
+           logf (LOG_FATAL|LOG_ERRNO, "Failed to open %s", dirp->name);
            return 0;
        }
        /* look at each file */
@@ -175,7 +179,8 @@ MFile_area mf_init(const char *name)
                continue;
            if (sscanf(dent->d_name, "%[^.].%d", metaname, &number) != 2)
            {
-               log(LOG_FATAL, "Failed to resolve part-name %s", dent->d_name);
+               logf (LOG_FATAL, "Failed to resolve part-name %s",
+                      dent->d_name);
                return 0;
            }
            for (meta_f = ma->mfiles; meta_f; meta_f = meta_f->next)
@@ -208,12 +213,14 @@ MFile_area mf_init(const char *name)
            /* get size */
            if ((fd = open(part_f->path, O_RDONLY)) < 0)
            {
-               log(LOG_FATAL|LOG_ERRNO, "Failed to access %s", dent->d_name);
+               logf (LOG_FATAL|LOG_ERRNO, "Failed to access %s",
+                      dent->d_name);
                return 0;
            }
            if ((part_f->bytes = lseek(fd, 0, SEEK_END)) < 0)
            {
-               log(LOG_FATAL|LOG_ERRNO, "Failed to seek in %s", dent->d_name);
+               logf (LOG_FATAL|LOG_ERRNO, "Failed to seek in %s",
+                      dent->d_name);
                return 0;
            }
            close(fd);
@@ -223,10 +230,10 @@ MFile_area mf_init(const char *name)
     }
     for (meta_f = ma->mfiles; meta_f; meta_f = meta_f->next)
     {
-       log(LOG_DEBUG, "mf_init: %s consists of %d part(s)", meta_f->name,
-           meta_f->no_files);
+       logf (LOG_DEBUG, "mf_init: %s consists of %d part(s)", meta_f->name,
+              meta_f->no_files);
        qsort(meta_f->files, meta_f->no_files, sizeof(part_file),
-           cmp_part_file);
+              cmp_part_file);
     }
     return ma;
 }
@@ -242,13 +249,13 @@ MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag)
     char tmp[FILENAME_MAX+1];
     mf_dir *dp;
 
-    log(LOG_LOG, "mf_open(%s bs=%d, %s)", name, block_size,
-       wflag ? "RW" : "RDONLY");
+    logf(LOG_LOG, "mf_open(%s bs=%d, %s)", name, block_size,
+         wflag ? "RW" : "RDONLY");
     if (!ma)
     {
         if (!default_area && !(default_area = mf_init(MF_DEFAULT_AREA)))
         {
-            log(LOG_FATAL, "Failed to open default area.");
+            logf (LOG_FATAL, "Failed to open default area.");
             return 0;
        }
        ma = default_area;
@@ -274,7 +281,7 @@ MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag)
            dp = dp->next);
        if (!dp)
        {
-           log(LOG_FATAL, "Insufficient space for new mfile.");
+           logf (LOG_FATAL, "Insufficient space for new mfile.");
            return 0;
        }
        new->files[0].dir = dp;
@@ -318,7 +325,7 @@ int mf_close(MFile mf)
 {
     int i;
 
-    log(LOG_DEBUG, "mf_close(%s)", mf->name);
+    logf (LOG_DEBUG, "mf_close(%s)", mf->name);
     assert(mf->open);
     for (i = 0; i < mf->no_files; i++)
        if (mf->files[i].fd >= 0)
@@ -342,8 +349,8 @@ int mf_read(MFile mf, int no, int offset, int num, void *buf)
     toread = num ? num : mf->blocksize;
     if ((rd = read(mf->files[mf->cur_file].fd, buf, toread)) < 0)
     {
-       log(LOG_FATAL|LOG_ERRNO, "mf_read: Read failed (%s)",
-               mf->files[mf->cur_file].path);
+       logf (LOG_FATAL|LOG_ERRNO, "mf_read: Read failed (%s)",
+              mf->files[mf->cur_file].path);
        exit(1);
     }
     else if (rd < toread)
@@ -367,7 +374,7 @@ int mf_write(MFile mf, int no, int offset, int num, const void *buf)
     /* file needs to grow */
     while (ps >= mf->files[mf->cur_file].blocks)
     {
-       log(LOG_DEBUG, "File grows");
+       logf (LOG_DEBUG, "File grows");
        /* file overflow - allocate new file */
        if ((ps - mf->files[mf->cur_file].blocks + 1) * mf->blocksize >
            mf->files[mf->cur_file].dir->avail_bytes)
@@ -376,7 +383,7 @@ int mf_write(MFile mf, int no, int offset, int num, const void *buf)
            if ((nblocks = mf->files[mf->cur_file].dir->avail_bytes /
                mf->blocksize) > 0)
            {
-               log(LOG_DEBUG, "Capping off file %s at pos %d",
+               logf (LOG_DEBUG, "Capping off file %s at pos %d",
                    mf->files[mf->cur_file].path, nblocks);
                if ((ps = file_position(mf,
                    (mf->cur_file ? mf->files[mf->cur_file-1].top : 0) +
@@ -384,7 +391,7 @@ int mf_write(MFile mf, int no, int offset, int num, const void *buf)
                        exit(1);
                if (write(mf->files[mf->cur_file].fd, &dummych, 1) < 1)
                {
-                   log(LOG_ERRNO|LOG_FATAL, "write dummy");
+                   logf (LOG_ERRNO|LOG_FATAL, "write dummy");
                    exit(1);
                }
                mf->files[mf->cur_file].blocks += nblocks;
@@ -393,12 +400,13 @@ int mf_write(MFile mf, int no, int offset, int num, const void *buf)
                    mf->blocksize;
            }
            /* get other bit */
-           log(LOG_DEBUG, "Creating new file.");
+           logf (LOG_DEBUG, "Creating new file.");
            for (dp = mf->ma->dirs; dp && dp->avail_bytes < mf->min_bytes_creat;
                dp = dp->next);
            if (!dp)
            {
-               log(LOG_FATAL, "Cannot allocate more space for %s", mf->name);
+               logf (LOG_FATAL, "Cannot allocate more space for %s",
+                      mf->name);
                exit(1);
            }
            mf->files[mf->cur_file].top = (mf->cur_file ?
@@ -430,7 +438,7 @@ int mf_write(MFile mf, int no, int offset, int num, const void *buf)
     towrite = num ? num : mf->blocksize;
     if (write(mf->files[mf->cur_file].fd, buf, towrite) < towrite)
     {
-       log(LOG_FATAL|LOG_ERRNO, "Write failed");
+       logf (LOG_FATAL|LOG_ERRNO, "Write failed");
        exit(1);
     }
     return 0;
index a83a74b..f033443 100644 (file)
@@ -1,14 +1,17 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.7 1995-02-06 10:12:55 adam Exp $
+# $Id: Makefile,v 1.8 1995-09-04 12:33:25 adam Exp $
 
 SHELL=/bin/sh
-INCLUDE=-I../include
+RANLIB=ranlib
+YAZ=../../yaz
+YAZLIB=$(YAZ)/lib/libyaz.a
+INCLUDE=-I../include -I$(YAZ)/include
 TPROG1=agrep
 TPROG2=lexer
 TPROG3=grepper
-CFLAGS=-g -Wall -pedantic -ansi
+#CFLAGS=-g -Wall -pedantic -ansi
 DEFS=$(INCLUDE) -DYACC -DYYDEBUG=1 -DMEMDEBUG=1
 LIB=../lib/dfa.a 
 PO = dfa.o imalloc.o states.o set.o bset.o
@@ -19,19 +22,22 @@ all: $(LIB)
 
 alll: $(LIB) $(TPROG1) $(TPROG2) $(TPROG3)
 
-$(TPROG1): $(TPROG1).o $(LIB) ../lib/util.a
-       $(CC) $(CFLAGS) -o $(TPROG1) $(TPROG1).o $(LIB) ../lib/util.a
+$(TPROG1): $(TPROG1).o $(LIB) ../lib/alexutil.a $(YAZLIB)
+       $(CC) $(CFLAGS) -o $(TPROG1) $(TPROG1).o $(LIB) \
+               ../lib/alexutil.a $(YAZLIB)
 
-$(TPROG2): $(TPROG2).o readfile.o $(LIB) ../lib/util.a
-       $(CC) $(CFLAGS) -o $(TPROG2) $(TPROG2).o readfile.o $(LIB) ../lib/util.a
+$(TPROG2): $(TPROG2).o readfile.o $(LIB) ../lib/alexutil.a $(YAZLIB)
+       $(CC) $(CFLAGS) -o $(TPROG2) $(TPROG2).o readfile.o $(LIB) \
+               ../lib/alexutil.a $(YAZLIB)
 
-$(TPROG3): $(TPROG3).o $(LIB) 
-       $(CC) $(CFLAGS) -o $(TPROG3) $(TPROG3).o $(LIB) ../lib/util.a
+$(TPROG3): $(TPROG3).o $(LIB) ../lib/alexutil.a $(YAZLIB)
+       $(CC) $(CFLAGS) -o $(TPROG3) $(TPROG3).o $(LIB) $(YAZLIB) \
+               ../lib/alexutil.a $(YAZLIB)
 
 $(LIB): $(PO)
        rm -f $(LIB)
        ar qc $(LIB) $(PO)
-       ranlib $(LIB)
+       $(RANLIB) $(LIB)
 
 .c.o:
        $(CC) -c $(DEFS) $(CFLAGS) $<
@@ -47,12 +53,12 @@ clean:
 depend: depend2
 
 depend1:
-       mv Makefile Makefile.tmp
        $(YACC) $(YFLAGS) regexp.y
        mv y.tab.c regexp.c
-       sed '/^#Depend/q' <Makefile.tmp >Makefile
-       $(CPP) -M $(DEFS) *.c |sed 's/regexp\.c/regexp.y/g' >>Makefile
-       rm -f Makefile.tmp regexp.c
+       sed '/^#Depend/q' <Makefile >Makefile.tmp
+       $(CPP) -M $(DEFS) *.c |sed 's/regexp\.c/regexp.y/g' >>Makefile.tmp
+       mv -f Makefile.tmp Makefile
+       rm -f regexp.c
 
 depend2:
        $(YACC) $(YFLAGS) regexp.y
index 81f608c..1f23dc5 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: agrep.c,v $
- * Revision 1.4  1995-01-24 16:00:21  adam
+ * Revision 1.5  1995-09-04 12:33:25  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.4  1995/01/24  16:00:21  adam
  * Added -ansi to CFLAGS.
  * Some changes to the dfa module.
  *
@@ -31,7 +34,7 @@
 #include <unistd.h>
 
 
-#include <util.h>
+#include <alexutil.h>
 #include <dfa.h>
 #include "imalloc.h"
 
index 1bd65e8..e514b4f 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: bset.c,v $
- * Revision 1.2  1995-01-24 16:00:21  adam
+ * Revision 1.3  1995-09-04 12:33:25  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.2  1995/01/24  16:00:21  adam
  * Added -ansi to CFLAGS.
  * Some changes to the dfa module.
  *
@@ -19,7 +22,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <bset.h>
 #include "imalloc.h"
 
index 0104852..9ce116b 100644 (file)
--- a/dfa/dfa.c
+++ b/dfa/dfa.c
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: dfa.c,v $
- * Revision 1.2  1995-01-25 11:30:50  adam
+ * Revision 1.3  1995-09-04 12:33:26  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.2  1995/01/25  11:30:50  adam
  * Simple error reporting when parsing regular expressions.
  * Memory usage reduced.
  *
@@ -20,7 +23,7 @@
 #include <string.h>
 #include <ctype.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "dfap.h"
 #include "imalloc.h"
 
index 1c51554..14bd7e9 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: grepper.c,v $
- * Revision 1.4  1995-01-24 16:00:21  adam
+ * Revision 1.5  1995-09-04 12:33:26  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.4  1995/01/24  16:00:21  adam
  * Added -ansi to CFLAGS.
  * Some changes to the dfa module.
  *
@@ -24,7 +27,7 @@
 #include <ctype.h>
 #include <assert.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <dfa.h>
 #include "imalloc.h"
 
@@ -326,7 +329,7 @@ static int grep_file (struct DFA *dfa, const char *fname, int range)
         inf = fopen (fname, "r");
         if (!inf)
         {
-            log (LOG_FATAL|LOG_ERRNO, "cannot open `%s'", fname);
+            logf (LOG_FATAL|LOG_ERRNO, "cannot open `%s'", fname);
             exit (1);
         }
     }
@@ -398,7 +401,7 @@ int main (int argc, char **argv)
         }
         else
         {
-            log (LOG_FATAL, "Unknown option '-%s'", arg);
+            logf (LOG_FATAL, "Unknown option '-%s'", arg);
             exit (1);
         }
     }
index a0a98f1..8c15b7e 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: imalloc.c,v $
- * Revision 1.3  1994-09-27 16:31:19  adam
+ * Revision 1.4  1995-09-04 12:33:26  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.3  1994/09/27  16:31:19  adam
  * First version of grepper: grep with error correction.
  *
  * Revision 1.2  1994/09/26  16:30:56  adam
@@ -19,7 +22,7 @@
 #include <assert.h>
 #include <stdlib.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "imalloc.h"
 
 #ifdef MEMDEBUG
@@ -39,7 +42,7 @@ void *imalloc (size_t size)
     size_t words = (4*sizeof(unsigned) -1 + size)/sizeof(unsigned);
     char *p = (char *)xmalloc( words*sizeof(unsigned) );
     if( !p )
-        log (LOG_FATAL, "No memory: imalloc(%u); c/f %d/%d; %ld/%ld",
+        logf (LOG_FATAL, "No memory: imalloc(%u); c/f %d/%d; %ld/%ld",
            size, alloc_calls, free_calls, alloc, max_alloc );
     *((unsigned *)p) = size;
     ((unsigned *)p)[1] = MAG1;
@@ -53,7 +56,7 @@ void *imalloc (size_t size)
 #else
     void *p = (void *)xmalloc( size );
     if( !p )
-        log (LOG_FATAL, "Out of memory (imalloc)" );
+        logf (LOG_FATAL, "Out of memory (imalloc)" );
     return p;
 #endif
 }
@@ -64,7 +67,7 @@ void *icalloc (size_t size)
     unsigned words = (4*sizeof(unsigned) -1 + size)/sizeof(unsigned);
     char *p = (char *) xcalloc( words*sizeof(unsigned), 1 );
     if( !p )
-        log (LOG_FATAL, "No memory: icalloc(%u); c/f %d/%d; %ld/%ld",
+        logf (LOG_FATAL, "No memory: icalloc(%u); c/f %d/%d; %ld/%ld",
            size, alloc_calls, free_calls, alloc, max_alloc );
     ((unsigned *)p)[0] = size;
     ((unsigned *)p)[1] = MAG1;
@@ -78,7 +81,7 @@ void *icalloc (size_t size)
 #else
     void *p = (void) xcalloc( size, 1 );
     if( !p )
-        log (LOG_FATAL, "Out of memory (icalloc)" );
+        logf (LOG_FATAL, "Out of memory (icalloc)" );
     return p;
 #endif
 }
@@ -92,14 +95,14 @@ void i_free (void *p)
     ++free_calls;
     size = (-2)[(unsigned *) p];
     if( (-1)[(unsigned *) p] != MAG1 )
-        log (LOG_FATAL,"Internal: ifree(%u) magic 1 corrupted", size );
+        logf (LOG_FATAL,"Internal: ifree(%u) magic 1 corrupted", size );
     if( size[(unsigned char *) p] != MAG2 )
-        log (LOG_FATAL,"Internal: ifree(%u) magic 2 corrupted", size );
+        logf (LOG_FATAL,"Internal: ifree(%u) magic 2 corrupted", size );
     if( (size+1)[(unsigned char *) p] != MAG3 )
-        log (LOG_FATAL,"Internal: ifree(%u) magic 3 corrupted", size );
+        logf (LOG_FATAL,"Internal: ifree(%u) magic 3 corrupted", size );
     alloc -= size;
     if( alloc < 0L )
-        log (LOG_FATAL,"Internal: ifree(%u) negative alloc.", size );
+        logf (LOG_FATAL,"Internal: ifree(%u) negative alloc.", size );
     xfree( (unsigned *) p-2 );
 }
 #else
index 85fa2e5..24bf871 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: lexer.c,v $
- * Revision 1.6  1995-01-25 11:30:51  adam
+ * Revision 1.7  1995-09-04 12:33:27  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.6  1995/01/25  11:30:51  adam
  * Simple error reporting when parsing regular expressions.
  * Memory usage reduced.
  *
@@ -36,7 +39,7 @@
 #include <string.h>
 #include <stdarg.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <dfa.h>
 #include "imalloc.h"
 #include "lexer.h"
index 7983ca6..d28bbd2 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: readfile.c,v $
- * Revision 1.4  1995-01-25 11:30:51  adam
+ * Revision 1.5  1995-09-04 12:33:27  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.4  1995/01/25  11:30:51  adam
  * Simple error reporting when parsing regular expressions.
  * Memory usage reduced.
  *
@@ -27,7 +30,7 @@
 #include <string.h>
 #include <ctype.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <dfa.h>
 #include "lexer.h"
 
index 3af74d7..3c3f832 100644 (file)
--- a/dfa/set.c
+++ b/dfa/set.c
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: set.c,v $
- * Revision 1.3  1995-02-06 10:12:55  adam
+ * Revision 1.4  1995-09-04 12:33:27  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.3  1995/02/06  10:12:55  adam
  * Unused static function rm_SetElement was removed.
  *
  * Revision 1.2  1995/01/24  16:00:22  adam
@@ -22,7 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <set.h>
 #include "imalloc.h"
 
index a3f6532..5af1da6 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: states.c,v $
- * Revision 1.3  1995-01-25 11:30:51  adam
+ * Revision 1.4  1995-09-04 12:33:28  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.3  1995/01/25  11:30:51  adam
  * Simple error reporting when parsing regular expressions.
  * Memory usage reduced.
  *
@@ -23,7 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "dfap.h"
 #include "imalloc.h"
 
index aa1a93b..ee9f629 100644 (file)
@@ -1,13 +1,16 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.14 1995-02-06 10:13:17 adam Exp $
+# $Id: Makefile,v 1.15 1995-09-04 12:33:31 adam Exp $
 
 SHELL=/bin/sh
-INCLUDE=-I../include
+RANLIB=ranlib
+YAZ=../../yaz
+YAZLIB=$(YAZ)/lib/libyaz.a
+INCLUDE=-I../include -I$(YAZ)/include
 TPROG1=dicttest
 TPROG2=dictext
-CFLAGS=-g -Wall -pedantic -ansi
+#CFLAGS=-g -Wall -pedantic -ansi
 DEFS=$(INCLUDE)
 LIB=../lib/dict.a 
 PO = dopen.o dclose.o drdwr.o open.o close.o insert.o lookup.o \
@@ -18,16 +21,17 @@ all: $(LIB)
 
 alll: $(LIB) $(TPROG1) $(TPROG2)
 
-$(TPROG1): $(TPROG1).o $(LIB) ../lib/bfile.a ../lib/util.a ../lib/dfa.a
-       $(CC) $(CFLAGS) -o $(TPROG1) $(TPROG1).o $(LIB) ../lib/bfile.a ../lib/dfa.a ../lib/util.a 
+$(TPROG1): $(TPROG1).o $(LIB) ../lib/bfile.a ../lib/alexutil.a ../lib/dfa.a
+       $(CC) $(CFLAGS) -o $(TPROG1) $(TPROG1).o $(LIB) \
+               ../lib/bfile.a ../lib/dfa.a ../lib/alexutil.a $(YAZLIB)
 
-$(TPROG2): $(TPROG2).o $(LIB) ../lib/util.a
-       $(CC) $(CFLAGS) -o $(TPROG2) $(TPROG2).o ../lib/util.a
+$(TPROG2): $(TPROG2).o $(LIB) ../lib/alexutil.a $(YAZLIB)
+       $(CC) $(CFLAGS) -o $(TPROG2) $(TPROG2).o ../lib/alexutil.a $(YAZLIB)
 
 $(LIB): $(PO)
        rm -f $(LIB)
        ar qc $(LIB) $(PO)
-       ranlib $(LIB)
+       $(RANLIB) $(LIB)
 
 .c.o:
        $(CC) -c $(DEFS) $(CFLAGS) $<
@@ -38,13 +42,12 @@ clean:
 depend: depend2
 
 depend1:
-       mv Makefile Makefile.tmp
-       sed '/^#Depend/q' <Makefile.tmp >Makefile
-       $(CPP) $(INCLUDE) -M *.c >>Makefile
-       -rm Makefile.tmp
+       sed '/^#Depend/q' <Makefile >Makefile.tmp
+       $(CPP) $(DEFS) -M *.c >>Makefile.tmp
+       mv -f Makefile.tmp Makefile
 
 depend2:
-       $(CPP) $(INCLUDE) -M *.c >.depend       
+       $(CPP) $(DEFS) -M *.c >.depend  
 
 ifeq (.depend,$(wildcard .depend))
 include .depend
index ebace7a..8554a7a 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: dictext.c,v $
- * Revision 1.3  1994-10-04 17:46:54  adam
+ * Revision 1.4  1995-09-04 12:33:31  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.3  1994/10/04  17:46:54  adam
  * Function options now returns arg with error option.
  *
  * Revision 1.2  1994/09/28  13:07:08  adam
@@ -21,7 +24,7 @@
 #include <assert.h>
 #include <ctype.h>
 
-#include <util.h>
+#include <alexutil.h>
 
 char *prog;
 
@@ -42,7 +45,7 @@ int main (int argc, char **argv)
                 inputfile = arg;
             else
             {
-                log (LOG_FATAL, "too many files specified\n");
+                logf (LOG_FATAL, "too many files specified\n");
                 exit (1);
             }
         }
@@ -58,7 +61,7 @@ int main (int argc, char **argv)
         }
         else
         {
-            log (LOG_FATAL, "Unknown option '-%s'", arg);
+            logf (LOG_FATAL, "Unknown option '-%s'", arg);
             exit (1);
         }
     }
@@ -67,7 +70,7 @@ int main (int argc, char **argv)
         ipf = fopen (inputfile, "r");
         if (!ipf)
         {
-            log (LOG_FATAL|LOG_ERRNO, "cannot open '%s'", inputfile);
+            logf (LOG_FATAL|LOG_ERRNO, "cannot open '%s'", inputfile);
             exit (1);
         }
     }
index 1ba36b7..70dd138 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: dicttest.c,v $
- * Revision 1.14  1994-10-04 17:46:55  adam
+ * Revision 1.15  1995-09-04 12:33:31  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.14  1994/10/04  17:46:55  adam
  * Function options now returns arg with error option.
  *
  * Revision 1.13  1994/10/04  12:08:05  adam
@@ -109,7 +112,7 @@ int main (int argc, char **argv)
                 name = arg;
             else
             {
-                log (LOG_FATAL, "too many files specified\n");
+                logf (LOG_FATAL, "too many files specified\n");
                 exit (1);
             }
         }
@@ -145,25 +148,25 @@ int main (int argc, char **argv)
         }
         else
         {
-            log (LOG_FATAL, "Unknown option '-%s'", arg);
+            logf (LOG_FATAL, "Unknown option '-%s'", arg);
             exit (1);
         }
     }
     if (!base || !name)
     {
-        log (LOG_FATAL, "no base and/or dictionary specified");
+        logf (LOG_FATAL, "no base and/or dictionary specified");
         exit (1);
     }
     common_resource = res_open (base);
     if (!common_resource)
     {
-        log (LOG_FATAL, "cannot open resource `%s'", base);
+        logf (LOG_FATAL, "cannot open resource `%s'", base);
         exit (1);
     }
     dict = dict_open (name, cache, rw);
     if (!dict)
     {
-        log (LOG_FATAL, "dict_open fail of `%s'", name);
+        logf (LOG_FATAL, "dict_open fail of `%s'", name);
         exit (1);
     }
     if (inputfile)
@@ -176,7 +179,7 @@ int main (int argc, char **argv)
 
         if (!(ipf = fopen(inputfile, "r")))
         {
-            log (LOG_FATAL|LOG_ERRNO, "cannot open %s", inputfile);
+            logf (LOG_FATAL|LOG_ERRNO, "cannot open %s", inputfile);
             exit (1);
         }
         
@@ -205,11 +208,11 @@ int main (int argc, char **argv)
                         case 1:
                             no_of_change++;
                         if (unique)
-                            log (LOG_LOG, "%s change\n", ipf_ptr);
+                            logf (LOG_LOG, "%s change\n", ipf_ptr);
                             break;
                         case 2:
                             if (unique)
-                                log (LOG_LOG, "%s duplicate\n", ipf_ptr);
+                                logf (LOG_LOG, "%s duplicate\n", ipf_ptr);
                             no_of_same++;
                             break;
                         }
@@ -245,21 +248,21 @@ int main (int argc, char **argv)
     {
         if (range < 0)
             range = 0;
-        log (LOG_LOG, "Grepping '%s'", grep_pattern);
+        logf (LOG_LOG, "Grepping '%s'", grep_pattern);
         dict_lookup_grep (dict, grep_pattern, range, grep_handle);
     }
     if (rw)
     {
-        log (LOG_LOG, "Insertions.... %d", no_of_iterations);
-        log (LOG_LOG, "No of new..... %d", no_of_new);
-        log (LOG_LOG, "No of change.. %d", no_of_change);
-        log (LOG_LOG, "No of same.... %d", no_of_same);
+        logf (LOG_LOG, "Insertions.... %d", no_of_iterations);
+        logf (LOG_LOG, "No of new..... %d", no_of_new);
+        logf (LOG_LOG, "No of change.. %d", no_of_change);
+        logf (LOG_LOG, "No of same.... %d", no_of_same);
     }
     else
     {
-        log (LOG_LOG, "Lookups....... %d", no_of_iterations);
-        log (LOG_LOG, "No of hits.... %d", no_of_hits);
-        log (LOG_LOG, "No of misses.. %d", no_of_misses);
+        logf (LOG_LOG, "Lookups....... %d", no_of_iterations);
+        logf (LOG_LOG, "No of hits.... %d", no_of_hits);
+        logf (LOG_LOG, "No of misses.. %d", no_of_misses);
     }
     dict_close (dict);
     res_close (common_resource);
index 70a18b4..214189d 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: insert.c,v $
- * Revision 1.10  1994-10-05 12:16:48  adam
+ * Revision 1.11  1995-09-04 12:33:31  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.10  1994/10/05  12:16:48  adam
  * Pagesize is a resource now.
  *
  * Revision 1.9  1994/09/16  15:39:13  adam
@@ -346,7 +349,7 @@ static int dict_ins (Dict dict, const Dict_char *str,
                         }
                         if (split_page (dict, ptr, p)) 
                         {
-                            log (LOG_FATAL, "Unable to split page %d\n", ptr);
+                            logf (LOG_FATAL, "Unable to split page %d\n", ptr);
                             abort ();
                         }
                         return dict_ins (dict, str-1, ptr, userlen, userinfo);
index e13b38c..e20f2f5 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: open.c,v $
- * Revision 1.6  1994-10-05 12:16:52  adam
+ * Revision 1.7  1995-09-04 12:33:32  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.6  1994/10/05  12:16:52  adam
  * Pagesize is a resource now.
  *
  * Revision 1.5  1994/09/01  17:49:39  adam
@@ -46,7 +49,8 @@ Dict dict_open (const char *name, int cache, int rw)
                                    DICT_DEFAULT_PAGESIZE));
     if (page_size < 1024)
     {
-        log (LOG_WARN, "Resource %s was too small. Set to 1024", resource_str);
+        logf (LOG_WARN, "Resource %s was too small. Set to 1024",
+              resource_str);
         page_size = 1024;
     }
     dict->dbf = dict_bf_open (name, page_size, cache, rw);
@@ -54,7 +58,7 @@ Dict dict_open (const char *name, int cache, int rw)
 
     if(!dict->dbf)
     {
-        log (LOG_WARN, "Cannot open `%s'", name);
+        logf (LOG_WARN, "Cannot open `%s'", name);
         xfree (dict);
         return NULL;
     }
@@ -80,15 +84,15 @@ Dict dict_open (const char *name, int cache, int rw)
         dh = (struct Dict_head *) head_buf;
         if (strcmp (dh->magic_str, DICT_MAGIC))
         {
-            log (LOG_WARN, "Bad magic of `%s'", name);
+            logf (LOG_WARN, "Bad magic of `%s'", name);
             dict_bf_close (dict->dbf);
             xfree (dict);
             return NULL;
         }
         if (dh->page_size != page_size)
         {
-            log (LOG_WARN, "Resource %s is %d and pagesize of `%s' is %d",
-                 resource_str, page_size, name, dh->page_size);
+            logf (LOG_WARN, "Resource %s is %d and pagesize of `%s' is %d",
+                  resource_str, page_size, name, dh->page_size);
             dict_bf_close (dict->dbf);
             xfree (dict);
             return NULL;
index 84b0831..2290fa8 100644 (file)
@@ -4,9 +4,12 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  $Log: bfile.h,v $
- Revision 1.6  1994-09-14 13:10:35  quinn
- Small changes
+ Revision 1.7  1995-09-04 12:33:35  adam
+ Various cleanup. YAZ util used instead.
 
+ * Revision 1.6  1994/09/14  13:10:35  quinn
+ * Small changes
+ *
  * Revision 1.5  1994/08/24  08:45:52  quinn
  * Using mfile.
  *
@@ -21,7 +24,7 @@
 #ifndef BFILE_H
 #define BFILE_H
 
-#include <util.h>
+#include <alexutil.h>
 #include <mfile.h>
 
 #define bf_blocksize(bf) mf_blocksize(bf->mf)
index a2822bc..c99fc50 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: mfile.h,v $
- * Revision 1.2  1994-09-14 13:10:36  quinn
+ * Revision 1.3  1995-09-04 12:33:35  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.2  1994/09/14  13:10:36  quinn
  * Small changes
  *
  * Revision 1.1  1994/08/23  14:41:46  quinn
@@ -17,7 +20,7 @@
 
 #include <stdio.h>
 
-#include <util.h>
+#include <alexutil.h>
 
 #define MF_MIN_BLOCKS_CREAT 1          /* minimum free blocks in new dir */
 #define MF_DEFAULT_AREA "register"      /* Use if no mf_init */
index f7377ae..aa0a2d6 100644 (file)
@@ -1,10 +1,13 @@
 # Copyright (C) 1995, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.4 1995-09-04 09:10:34 adam Exp $
+# $Id: Makefile,v 1.5 1995-09-04 12:33:40 adam Exp $
 
 SHELL=/bin/sh
-INCLUDE=-I../include -I../../yaz/include
+RANLIB=ranlib
+YAZ=../../yaz
+YAZLIB=$(YAZ)/lib/libyaz.a
+INCLUDE=-I../include -I$(YAZ)/include
 TPROG1=index
 TPROG2=kdump
 TPROG3=zserver
@@ -16,34 +19,37 @@ CPP=cc -E
 
 all: $(TPROG1) $(TPROG2) $(TPROG3)
 
-$(TPROG1): $(O1) ../lib/dict.a ../lib/isam.a ../lib/bfile.a ../lib/util.a
-       $(CC) $(CFLAGS) -o $(TPROG1) $(O1) ../lib/dict.a ../lib/isam.a ../lib/bfile.a ../lib/util.a
+$(TPROG1): $(O1) ../lib/dict.a \
+               ../lib/isam.a ../lib/bfile.a ../lib/alexutil.a $(YAZLIB)
+       $(CC) $(CFLAGS) -o $(TPROG1) $(O1) ../lib/dict.a \
+               ../lib/isam.a ../lib/bfile.a ../lib/alexutil.a $(YAZLIB)
 
-$(TPROG2): $(O2) ../lib/util.a
-       $(CC) $(CFLAGS) -o $(TPROG2) $(O2) ../lib/util.a
-
-$(TPROG3): $(O3) ../lib/dict.a ../lib/isam.a ../lib/bfile.a ../lib/rset.a ../lib/util.a
-       $(CC) $(CFLAGS) -o $(TPROG3) $(O3) ../lib/rset.a ../lib/dict.a ../lib/isam.a ../lib/bfile.a ../lib/util.a
+$(TPROG2): $(O2) $(YAZLIB)
+       $(CC) $(CFLAGS) -o $(TPROG2) $(O2) $(YAZLIB)
 
+$(TPROG3): $(O3) ../lib/rset.a \
+               ../lib/dict.a ../lib/isam.a ../lib/bfile.a \
+               ../lib/dfa.a ../lib/alexutil.a $(YAZLIB)
+       $(CC) $(CFLAGS) -o $(TPROG3) $(O3) ../lib/rset.a \
+               ../lib/dict.a ../lib/isam.a ../lib/bfile.a \
+               ../lib/dfa.a ../lib/alexutil.a $(YAZLIB)
 
 .c.o:
        $(CC) -c $(DEFS) $(CFLAGS) $<
 
 clean:
-       rm -f *.[oa] $(TPROG1) $(TPROG2) core mon.out gmon.out errlist
-
-$(O1) $(O2) $(O3): index.h
+       rm -f *.[oa] $(TPROG1) $(TPROG2) $(TPROG3)
+       rm -f core mon.out gmon.out errlist
 
 depend: depend2
 
 depend1:
-       mv Makefile Makefile.tmp
-       sed '/^#Depend/q' <Makefile.tmp >Makefile
-       $(CPP) $(INCLUDE) -M *.c >>Makefile
-       -rm Makefile.tmp
+       sed '/^#Depend/q' <Makefile >Makefile.tmp
+       $(CPP) $(DEFS) -M *.c >>Makefile.tmp
+       mv -f Makefile.tmp Makefile
 
 depend2:
-       $(CPP) $(INCLUDE) -M *.c >.depend       
+       $(CPP) $(DEFS) -M *.c >.depend  
 
 ifeq (.depend,$(wildcard .depend))
 include .depend
index 4228825..6d0e11d 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: dir.c,v $
- * Revision 1.3  1995-09-01 14:06:35  adam
+ * Revision 1.4  1995-09-04 12:33:41  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.3  1995/09/01  14:06:35  adam
  * Split of work into more files.
  *
  * Revision 1.2  1995/09/01  10:57:07  adam
@@ -23,7 +26,7 @@
 #include <fcntl.h>
 #include <ctype.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "index.h"
 
 struct dir_entry *dir_open (const char *rep)
@@ -34,17 +37,17 @@ struct dir_entry *dir_open (const char *rep)
     size_t idx = 0;
     struct dir_entry *entry;
 
-    log (LOG_DEBUG, "dir_open %s", rep);
+    logf (LOG_DEBUG, "dir_open %s", rep);
     if (!(dir = opendir(rep)))
     {
-        log (LOG_WARN|LOG_ERRNO, "opendir %s", rep);
+        logf (LOG_WARN|LOG_ERRNO, "opendir %s", rep);
         if (errno != ENOENT)
             exit (1);
         return NULL;
     }
     if (!(entry = malloc (sizeof(*entry) * entry_max)))
     {
-        log (LOG_FATAL|LOG_ERRNO, "malloc");
+        logf (LOG_FATAL|LOG_ERRNO, "malloc");
         exit (1);
     }    
     while ((dent = readdir (dir)))
@@ -58,7 +61,7 @@ struct dir_entry *dir_open (const char *rep)
 
             if (!(entry_n = malloc (sizeof(*entry) * (entry_max + 100))))
             {
-                log (LOG_FATAL|LOG_ERRNO, "malloc");
+                logf (LOG_FATAL|LOG_ERRNO, "malloc");
                 exit (1);
             }
             memcpy (entry_n, entry, idx * sizeof(*entry));
@@ -68,7 +71,7 @@ struct dir_entry *dir_open (const char *rep)
         }
         if (!(entry[idx].name = malloc (strlen(dent->d_name)+1)))
         {
-            log (LOG_FATAL|LOG_ERRNO, "malloc");
+            logf (LOG_FATAL|LOG_ERRNO, "malloc");
             exit (1);
         }
         strcpy (entry[idx].name, dent->d_name);
index fc170f6..0d905f5 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: extract.c,v $
- * Revision 1.2  1995-09-04 09:10:34  adam
+ * Revision 1.3  1995-09-04 12:33:41  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.2  1995/09/04  09:10:34  adam
  * More work on index add/del/update.
  * Merge sort implemented.
  * Initial work on z39 server.
@@ -19,7 +22,7 @@
 #include <fcntl.h>
 #include <ctype.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "index.h"
 
 #define KEY_BUF_SIZE 100000
@@ -37,19 +40,19 @@ void key_open (const char *fname)
         return;
     if ((key_fd = open (fname, O_RDWR|O_CREAT, 0666)) == -1)
     {
-        log (LOG_FATAL|LOG_ERRNO, "Creat %s", fname);
+        logf (LOG_FATAL|LOG_ERRNO, "Creat %s", fname);
         exit (1);
     }
-    log (LOG_DEBUG, "key_open of %s", fname);
+    logf (LOG_DEBUG, "key_open of %s", fname);
     if (!(key_buf = malloc (KEY_BUF_SIZE)))
     {
-        log (LOG_FATAL|LOG_ERRNO, "malloc");
+        logf (LOG_FATAL|LOG_ERRNO, "malloc");
         exit (1);
     }
     key_offset = 0;
     if (!(file_idx = dict_open ("fileidx", 10, 1)))
     {
-        log (LOG_FATAL, "dict_open fail of %s", "fileidx");
+        logf (LOG_FATAL, "dict_open fail of %s", "fileidx");
         exit (1);
     }
     file_key = dict_lookup (file_idx, ".");
@@ -63,14 +66,14 @@ int key_close (void)
 {
     if (key_fd == -1)
     {
-        log (LOG_DEBUG, "key_close - but no file");
+        logf (LOG_DEBUG, "key_close - but no file");
         return 0;
     }
     close (key_fd);
     dict_insert (file_idx, ".", sizeof(sysno_next), &sysno_next);
     dict_close (file_idx);
     key_fd = -1;
-    log (LOG_DEBUG, "key close - key file exist");
+    logf (LOG_DEBUG, "key close - key file exist");
     return 1;
 }
 
@@ -86,7 +89,7 @@ void key_flush (void)
         w = write (key_fd, key_buf + i, key_offset - i);
         if (w == -1)
         {
-            log (LOG_FATAL|LOG_ERRNO, "Write key fail");
+            logf (LOG_FATAL|LOG_ERRNO, "Write key fail");
             exit (1);
         }
         i += w;
@@ -118,12 +121,12 @@ void text_extract (SYSNO sysno, int cmd, const char *fname)
     int c;
     char w[256];
 
-    log (LOG_DEBUG, "Text extract of %d", sysno);
+    logf (LOG_DEBUG, "Text extract of %d", sysno);
     k.sysno = sysno;
     inf = fopen (fname, "r");
     if (!inf)
     {
-        log (LOG_WARN|LOG_ERRNO, "open %s", fname);
+        logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
         return;
     }
     while ((c=getc (inf)) != EOF)
@@ -157,7 +160,7 @@ void file_extract (int cmd, const char *fname, const char *kname)
     const char *file_type;
     void *file_info;
 
-    log (LOG_DEBUG, "%c %s k=%s", cmd, fname, kname);
+    logf (LOG_DEBUG, "%c %s k=%s", cmd, fname, kname);
     for (i = strlen(fname); --i >= 0; )
         if (fname[i] == '/')
         {
index 84c12c8..6e7144a 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: index.h,v $
- * Revision 1.4  1995-09-04 09:10:35  adam
+ * Revision 1.5  1995-09-04 12:33:42  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.4  1995/09/04  09:10:35  adam
  * More work on index add/del/update.
  * Merge sort implemented.
  * Initial work on z39 server.
@@ -20,7 +23,7 @@
  *
  */
 
-#include <util.h>
+#include <alexutil.h>
 #include <dict.h>
 #include <isam.h>
 
index 8dfe387..b9f9ae0 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: kdump.c,v $
- * Revision 1.1  1995-09-04 09:10:36  adam
+ * Revision 1.2  1995-09-04 12:33:42  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.1  1995/09/04  09:10:36  adam
  * More work on index add/del/update.
  * Merge sort implemented.
  * Initial work on z39 server.
@@ -14,7 +17,7 @@
 #include <assert.h>
 #include <unistd.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "index.h"
 
 char *prog;
@@ -57,7 +60,7 @@ int main (int argc, char **argv)
         }
         else
         {
-            log (LOG_FATAL, "Unknown option '-%s'", arg);
+            logf (LOG_FATAL, "Unknown option '-%s'", arg);
             exit (1);
         }
     }
@@ -68,7 +71,7 @@ int main (int argc, char **argv)
     }
     if (!(inf = fopen (key_fname, "r")))
     {
-        log (LOG_FATAL|LOG_ERRNO, "fopen %s", key_fname);
+        logf (LOG_FATAL|LOG_ERRNO, "fopen %s", key_fname);
         exit (1);
     }
     while (read_one (inf, key_string, key_info))
@@ -80,7 +83,7 @@ int main (int argc, char **argv)
     }
     if (fclose (inf))
     {
-        log (LOG_FATAL|LOG_ERRNO, "fclose %s", key_fname);
+        logf (LOG_FATAL|LOG_ERRNO, "fclose %s", key_fname);
         exit (1);
     }
     
index 40fc309..9e6a773 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: kinput.c,v $
- * Revision 1.1  1995-09-04 09:10:37  adam
+ * Revision 1.2  1995-09-04 12:33:42  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.1  1995/09/04  09:10:37  adam
  * More work on index add/del/update.
  * Merge sort implemented.
  * Initial work on z39 server.
@@ -61,7 +64,7 @@ static int inp (Dict dict, ISAM isam, const char *name)
     key_buf = xmalloc (key_buf_size * (KEY_SIZE));
     if (!(inf = fopen (name, "r")))
     {
-        log (LOG_FATAL|LOG_ERRNO, "cannot open `%s'", name);
+        logf (LOG_FATAL|LOG_ERRNO, "cannot open `%s'", name);
         exit (1);
     }
     read_one (inf, cur_name, key_buf);
@@ -93,7 +96,7 @@ static int inp (Dict dict, ISAM isam, const char *name)
         if ((info = dict_lookup (dict, cur_name)))
         {
             ISAM_P isam_p, isam_p2;
-            log (LOG_DEBUG, "updating %s", cur_name);
+            logf (LOG_DEBUG, "updating %s", cur_name);
             no_updates++;
             memcpy (&isam_p, info+1, sizeof(ISAM_P));
             isam_p2 = is_merge (isam, isam_p, nmemb, key_buf);
@@ -103,7 +106,7 @@ static int inp (Dict dict, ISAM isam, const char *name)
         else
         {
             ISAM_P isam_p;
-            log (LOG_DEBUG, "inserting %s", cur_name);
+            logf (LOG_DEBUG, "inserting %s", cur_name);
             no_insertions++;
             isam_p = is_merge (isam, 0, nmemb, key_buf);
             dict_insert (dict, cur_name, sizeof(ISAM_P), &isam_p);
@@ -124,20 +127,20 @@ void key_input (const char *dict_fname, const char *isam_fname,
     dict = dict_open (dict_fname, cache, 1);
     if (!dict)
     {
-        log (LOG_FATAL, "dict_open fail of `%s'", dict_fname);
+        logf (LOG_FATAL, "dict_open fail of `%s'", dict_fname);
         exit (1);
     }
     isam = is_open (isam_fname, key_compare, 1);
     if (!isam)
     {
-        log (LOG_FATAL, "is_open fail of `%s'", isam_fname);
+        logf (LOG_FATAL, "is_open fail of `%s'", isam_fname);
         exit (1);
     }
     inp (dict, isam, key_fname);
     dict_close (dict);
     is_close (isam);
-    log (LOG_LOG, "Iterations . . .%7d", no_iterations);
-    log (LOG_LOG, "Distinct words .%7d", no_diffs);
-    log (LOG_LOG, "Updates. . . . .%7d", no_updates);
-    log (LOG_LOG, "Insertions . . .%7d", no_insertions);
+    logf (LOG_LOG, "Iterations . . .%7d", no_iterations);
+    logf (LOG_LOG, "Distinct words .%7d", no_diffs);
+    logf (LOG_LOG, "Updates. . . . .%7d", no_updates);
+    logf (LOG_LOG, "Insertions . . .%7d", no_insertions);
 }
index 389585d..753ee50 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: main.c,v $
- * Revision 1.5  1995-09-04 09:10:39  adam
+ * Revision 1.6  1995-09-04 12:33:43  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.5  1995/09/04  09:10:39  adam
  * More work on index add/del/update.
  * Merge sort implemented.
  * Initial work on z39 server.
@@ -26,7 +29,7 @@
 #include <assert.h>
 #include <unistd.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "index.h"
 
 char *prog;
@@ -51,7 +54,7 @@ int main (int argc, char **argv)
                 common_resource = res_open (base_name);
                 if (!common_resource)
                 {
-                    log (LOG_FATAL, "Cannot open resource `%s'", base_name);
+                    logf (LOG_FATAL, "Cannot open resource `%s'", base_name);
                     exit (1);
                 }
             }
@@ -67,7 +70,7 @@ int main (int argc, char **argv)
                 }
                 else
                 {
-                    log (LOG_FATAL, "Unknown command: %s", arg);
+                    logf (LOG_FATAL, "Unknown command: %s", arg);
                     exit (1);
                 }
             }
@@ -89,7 +92,7 @@ int main (int argc, char **argv)
         }
         else
         {
-            log (LOG_FATAL, "Unknown option '-%s'", arg);
+            logf (LOG_FATAL, "Unknown option '-%s'", arg);
             exit (1);
         }
     }
@@ -102,10 +105,10 @@ int main (int argc, char **argv)
     key_flush ();
     if (!key_close ())
         exit (0);
-    log (LOG_DEBUG, "Sorting");
+    logf (LOG_DEBUG, "Sorting");
     if (!key_sort ("keys.tmp", 1000000))
         exit (0);
-    log (LOG_DEBUG, "Input");
+    logf (LOG_DEBUG, "Input");
     key_input ("dictinv", "isaminv", "keys.tmp", 50);
     exit (0);
 }
index 27a803c..4accc88 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: trav.c,v $
- * Revision 1.1  1995-09-01 14:06:36  adam
+ * Revision 1.2  1995-09-04 12:33:43  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.1  1995/09/01  14:06:36  adam
  * Split of work into more files.
  *
  */
@@ -17,7 +20,7 @@
 #include <fcntl.h>
 #include <ctype.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "index.h"
 
 static void repository_extract_r (int cmd, char *rep)
@@ -60,17 +63,17 @@ void copy_file (const char *dst, const char *src)
 
     if (d_fd == -1)
     {
-        log (LOG_FATAL|LOG_ERRNO, "Cannot create %s", dst);
+        logf (LOG_FATAL|LOG_ERRNO, "Cannot create %s", dst);
         exit (1);
     }
     if (s_fd == -1)
     {
-        log (LOG_FATAL|LOG_ERRNO, "Cannot open %s", src);
+        logf (LOG_FATAL|LOG_ERRNO, "Cannot open %s", src);
         exit (1);
     }
     if (!(buf = malloc (4096)))
     {
-        log (LOG_FATAL|LOG_ERRNO, "malloc");
+        logf (LOG_FATAL|LOG_ERRNO, "malloc");
         exit (1);
     }
     while ((r=read (s_fd, buf, 4096))>0)
@@ -79,13 +82,13 @@ void copy_file (const char *dst, const char *src)
             i = write (d_fd, buf + w, r - w);
             if (i == -1)
             {
-                log (LOG_FATAL|LOG_ERRNO, "write");
+                logf (LOG_FATAL|LOG_ERRNO, "write");
                 exit (1);
             }
         }
     if (r)
     {
-        log (LOG_FATAL|LOG_ERRNO, "read");
+        logf (LOG_FATAL|LOG_ERRNO, "read");
         exit (1);
     }
     free (buf);
@@ -100,9 +103,9 @@ void del_file (const char *dst)
 
 void del_dir (const char *dst)
 {
-    log (LOG_DEBUG, "rmdir of %s", dst);
+    logf (LOG_DEBUG, "rmdir of %s", dst);
     if (rmdir (dst) == -1)
-        log (LOG_ERRNO|LOG_WARN, "rmdir");
+        logf (LOG_ERRNO|LOG_WARN, "rmdir");
 }
 
 void repository_update_r (int cmd, char *dst, char *src);
index 08897a4..e82d230 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zrpn.c,v $
- * Revision 1.1  1995-09-04 09:10:40  adam
+ * Revision 1.2  1995-09-04 12:33:43  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.1  1995/09/04  09:10:40  adam
  * More work on index add/del/update.
  * Merge sort implemented.
  * Initial work on z39 server.
@@ -14,7 +17,7 @@
 #include <assert.h>
 #include <unistd.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <dict.h>
 #include <isam.h>
 #include <rsisam.h>
index aa6e84c..ea0eb6e 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zserver.c,v $
- * Revision 1.1  1995-09-04 09:10:41  adam
+ * Revision 1.2  1995-09-04 12:33:43  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.1  1995/09/04  09:10:41  adam
  * More work on index add/del/update.
  * Merge sort implemented.
  * Initial work on z39 server.
@@ -14,7 +17,7 @@
 #include <assert.h>
 #include <unistd.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include "index.h"
 
 char *prog;
@@ -37,7 +40,7 @@ int main (int argc, char **argv)
                 common_resource = res_open (base_name);
                 if (!common_resource)
                 {
-                    log (LOG_FATAL, "Cannot open resource `%s'", base_name);
+                    logf (LOG_FATAL, "Cannot open resource `%s'", base_name);
                     exit (1);
                 }
             }
@@ -48,13 +51,13 @@ int main (int argc, char **argv)
         }
         else
         {
-            log (LOG_FATAL, "Unknown option '-%s'", arg);
+            logf (LOG_FATAL, "Unknown option '-%s'", arg);
             exit (1);
         }
     }
     if (!base_name)
     {
-        fprintf (stderr, "search [-v log] base ...\n");
+        fprintf (stderr, "zserver [-v log] base ...\n");
         exit (1);
     }
     exit (0);
index 51dd3d9..12d6115 100644 (file)
@@ -1,11 +1,14 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.12 1995-01-24 16:01:34 adam Exp $
+# $Id: Makefile,v 1.13 1995-09-04 12:33:46 adam Exp $
 
 SHELL=/bin/sh
-INCLUDE=-I../include
-CFLAGS=-g -Wall -pedantic -ansi
+RANLIB=ranlib
+YAZ=../../yaz
+YAZLIB=$(YAZ)/lib/libyaz.a
+INCLUDE=-I../include -I$(YAZ)/include
+#CFLAGS=-g -Wall -pedantic -ansi
 DEFS=$(INCLUDE)
 LIB=../lib/isam.a
 PO = isam.o isutil.o rootblk.o memory.o physical.o
@@ -17,15 +20,15 @@ alll: $(LIB) isam-test issh
 
 test: test.c $(LIB)
        $(CC) -g -o test -I../include test.c \
-       ../lib/isam.a ../lib/bfile.a ../lib/util.a
+       ../lib/isam.a ../lib/bfile.a ../lib/alexutil.a $(YAZLIB)
 
 isam-test: isam-test.c $(LIB)
        $(CC) -g -o isam-test -I../include isam-test.c \
-       ../lib/isam.a ../lib/bfile.a ../lib/util.a
+       ../lib/isam.a ../lib/bfile.a ../lib/alexutil.a $(YAZLIB)
 
 issh: issh.c $(LIB)
        $(CC) -g -o issh -I../include issh.c \
-       ../lib/isam.a ../lib/bfile.a ../lib/util.a
+       ../lib/isam.a ../lib/bfile.a ../lib/alexutil.a $(YAZLIB)
 
 #$(TPROG): $(TPROG).o $(LIB) 
 #      $(CC) -o $(TPROG) $(TPROG).o $(LIB)
@@ -33,7 +36,7 @@ issh: issh.c $(LIB)
 $(LIB): $(PO)
        rm -f $(LIB)
        ar qc $(LIB) $(PO)
-       ranlib $(LIB)
+       $(RANLIB) $(LIB)
 
 .c.o:
        $(CC) -c $(DEFS) $(CFLAGS) $<
@@ -44,13 +47,12 @@ clean:
 depend: depend2
 
 depend1:
-       mv Makefile Makefile.tmp
-       sed '/^#Depend/q' <Makefile.tmp >Makefile
-       $(CPP) $(INCLUDE) -M *.c >>Makefile
-       -rm Makefile.tmp
+       sed '/^#Depend/q' <Makefile >Makefile.tmp
+       $(CPP) $(DEFS) -M *.c >>Makefile.tmp
+       mv -f Makefile.tmp Makefile
 
 depend2:
-       $(CPP) $(INCLUDE) -M *.c >.depend       
+       $(CPP) $(DEFS) -M *.c >.depend  
 
 ifeq (.depend,$(wildcard .depend))
 include .depend
index 2958f16..42d7acd 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: isam.c,v $
- * Revision 1.10  1994-09-28 16:58:32  quinn
+ * Revision 1.11  1995-09-04 12:33:46  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.10  1994/09/28  16:58:32  quinn
  * Small mod.
  *
  * Revision 1.9  1994/09/28  12:56:15  quinn
  *
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <bfile.h>
 #include <isam.h>
 #include <common.h>
@@ -81,7 +85,7 @@ static int splitargs(const char *s, char *bf[], int max)
        ct++;
        if (ct > max)
        {
-           log(LOG_WARN, "Ignoring extra args to is resource");
+           logf (LOG_WARN, "Ignoring extra args to is resource");
            bf[ct] = '\0';
            return(ct - 1);
        }
@@ -102,7 +106,7 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     int num, size, rs, tmp, i;
     is_type_header th;
 
-    log(LOG_DEBUG, "is_open(%s, %s)", name, writeflag ? "RW" : "RDONLY");
+    logf (LOG_DEBUG, "is_open(%s, %s)", name, writeflag ? "RW" : "RDONLY");
     new = xmalloc(sizeof(*new));
     new->writeflag = writeflag;
     for (i = 0; i < IS_MAX_BLOCKTYPES; i++)
@@ -112,7 +116,7 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     if (!(r = res_get(common_resource, nm = strconcat(name, ".",
        "blocktypes", 0))) || !(num = splitargs(r, pp, IS_MAX_BLOCKTYPES)))
     {
-       log(LOG_FATAL, "Failed to locate resource %s", nm);
+       logf (LOG_FATAL, "Failed to locate resource %s", nm);
        return 0;
     }
     new->num_types = num;
@@ -120,7 +124,7 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     {
        if ((rs = sscanf(pp[i], "%d%1[bBkKmM]", &size, m)) < 1)
        {
-           log(LOG_FATAL, "Error in resource %s: %s", r, pp[i]);
+           logf (LOG_FATAL, "Error in resource %s: %s", r, pp[i]);
            return 0;
        }
        if (rs == 1)
@@ -134,7 +138,7 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
                case 'm': case 'M':
                    new->types[i].blocksize = size * 1048576; break;
                default:
-                   log(LOG_FATAL, "Illegal size suffix: %c", *m);
+                   logf (LOG_FATAL, "Illegal size suffix: %c", *m);
                    return 0;
        }
        new->types[i].dbuf = xmalloc(new->types[i].blocksize);
@@ -143,14 +147,14 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
        if (!(new->types[i].bf = bf_open(strconcat(name, m, 0), 
            new->types[i].blocksize, writeflag)))
        {
-           log(LOG_FATAL, "bf_open failed");
+           logf (LOG_FATAL, "bf_open failed");
            return 0;
        }
        if ((rs = is_rb_read(&new->types[i], &th)) > 0)
        {
            if (th.blocksize != new->types[i].blocksize)
            {
-               log(LOG_FATAL, "File blocksize mismatch in %s", name);
+               logf (LOG_FATAL, "File blocksize mismatch in %s", name);
                exit(1);
            }
            new->types[i].freelist = th.freelist;
@@ -160,7 +164,7 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
        {
            if ((rs = is_rb_write(&new->types[i], &th)) <=0)  /* dummy */
            {
-               log(LOG_FATAL, "Failed to write initial superblock.");
+               logf (LOG_FATAL, "Failed to write initial superblock.");
                exit(1);
            }
            new->types[i].freelist = -1;
@@ -171,12 +175,12 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     if (!(r = res_get_def(common_resource, nm = strconcat(name, ".", "keysize",
        0), "4")))
     {
-       log(LOG_FATAL, "Failed to locate resource %s", nm);
+       logf (LOG_FATAL, "Failed to locate resource %s", nm);
        return 0;
     }
     if ((new->keysize = atoi(r)) <= 0)
     {
-       log(LOG_FATAL, "Must specify positive keysize.");
+       logf (LOG_FATAL, "Must specify positive keysize.");
        return 0;
     }
 
@@ -184,7 +188,7 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     if (!(r = res_get_def(common_resource, nm = strconcat(name, ".", "repack",
        0), IS_DEF_REPACK_PERCENT)))
     {
-       log(LOG_FATAL, "Failed to locate resource %s", nm);
+       logf (LOG_FATAL, "Failed to locate resource %s", nm);
        return 0;
     }
     new->repack = atoi(r);
@@ -193,19 +197,19 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     if (!(r = res_get(common_resource, nm = strconcat(name, ".",
        "maxkeys", 0))) || !(num = splitargs(r, pp, IS_MAX_BLOCKTYPES)))
     {
-       log(LOG_FATAL, "Failed to locate resource %s", nm);
+       logf (LOG_FATAL, "Failed to locate resource %s", nm);
        return 0;
     }
     if (num < new->num_types -1)
     {
-       log(LOG_FATAL, "Not enough elements in %s", nm);
+       logf (LOG_FATAL, "Not enough elements in %s", nm);
        return 0;
     }
     for (i = 0; i < num; i++)
     {
        if ((rs = sscanf(pp[i], "%d", &tmp)) < 1)
        {
-           log(LOG_FATAL, "Error in resource %s: %s", r, pp[i]);
+           logf (LOG_FATAL, "Error in resource %s: %s", r, pp[i]);
            return 0;
        }
        new->types[i].max_keys = tmp;
@@ -226,7 +230,7 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
                new->keysize;
        if (new->types[i].max_keys_block0 < 1)
        {
-           log(LOG_FATAL, "Blocksize too small in %s", name);
+           logf (LOG_FATAL, "Blocksize too small in %s", name);
            exit(1);
        }
     }
@@ -235,19 +239,19 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     if (!(r = res_get(common_resource, nm = strconcat(name, ".",
        "nicefill", 0))) || !(num = splitargs(r, pp, IS_MAX_BLOCKTYPES)))
     {
-       log(LOG_FATAL, "Failed to locate resource %s", nm);
+       logf (LOG_FATAL, "Failed to locate resource %s", nm);
        return 0;
     }
     if (num < new->num_types)
     {
-       log(LOG_FATAL, "Not enough elements in %s", nm);
+       logf (LOG_FATAL, "Not enough elements in %s", nm);
        return 0;
     }
     for (i = 0; i < num; i++)
     {
        if ((rs = sscanf(pp[i], "%d", &tmp)) < 1)
        {
-           log(LOG_FATAL, "Error in resource %s: %s", r, pp[i]);
+           logf (LOG_FATAL, "Error in resource %s: %s", r, pp[i]);
            return 0;
        }
        new->types[i].nice_keys_block = (new->types[i].max_keys_block0 * tmp) /
@@ -268,7 +272,7 @@ int is_close(ISAM is)
     int i;
     is_type_header th;
 
-    log(LOG_DEBUG, "is_close()");
+    logf (LOG_DEBUG, "is_close()");
     for (i = 0; i < is->num_types; i++)
     {
        if (is->types[i].bf)
@@ -281,7 +285,7 @@ int is_close(ISAM is)
                th.top = is->types[i].top;
                if (is_rb_write(&is->types[i], &th) < 0)
                {
-                   log(LOG_FATAL, "Failed to write headerblock");
+                   logf (LOG_FATAL, "Failed to write headerblock");
                    exit(1);
                }
            }
@@ -324,7 +328,7 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data)
     if (pos)
        if (is_m_read_full(&tab, tab.data) < 0)
        {
-           log(LOG_FATAL, "read_full failed");
+           logf (LOG_FATAL, "read_full failed");
            exit(1);
        }
     oldnum = tab.num_records;
@@ -344,17 +348,17 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data)
        {
            if (operation == KEYOP_INSERT)
            {
-               log(LOG_DEBUG, "XXInserting new record.");
+               logf (LOG_DEBUG, "XXInserting new record.");
                is_m_write_record(&tab, record);
            }
            else
-               log(LOG_DEBUG, "XXDeletion failed to find match.");
+               logf (LOG_DEBUG, "XXDeletion failed to find match.");
        }
        else /* match found */
        {
            if (operation == KEYOP_INSERT)
            {
-               log(LOG_DEBUG, "XXSkipping insertion - match found.");
+               logf (LOG_DEBUG, "XXSkipping insertion - match found.");
                continue;
            }
            else if (operation == KEYOP_DELETE)
@@ -365,7 +369,7 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data)
                    /* next key is identical insert? - NOOP - skip it */
                    if (!memcmp(record, data + 1, is_keysize(is)))
                    {
-                       log(LOG_DEBUG, "XXNoop delete. skipping.");
+                       logf (LOG_DEBUG, "XXNoop delete. skipping.");
                        data += 1 + is_keysize(is);
                        num--;
                        continue;
@@ -375,14 +379,14 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data)
                    res = (*is->cmp)(data + 1, keybuf);
                    if (res < 0)
                    {
-                       log(LOG_DEBUG, "XXReplacing record.");
+                       logf (LOG_DEBUG, "XXReplacing record.");
                        is_m_replace_record(&tab, data + 1);
                        data += 1 + is_keysize(is);
                        num--;
                        continue;
                    }
                }
-               log(LOG_DEBUG, "Deleting record.");
+               logf (LOG_DEBUG, "Deleting record.");
                is_m_delete_record(&tab);
            }
        }
index aae8c3e..d5aa803 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: isutil.c,v $
- * Revision 1.1  1994-09-12 08:02:13  quinn
+ * Revision 1.2  1995-09-04 12:33:46  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.1  1994/09/12  08:02:13  quinn
  * Not functional yet
  *
  */
@@ -14,6 +17,7 @@
  * may move to util/ along the way.
  */
 
+#include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
 
index 4bbb4d6..034f6d4 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: memory.c,v $
- * Revision 1.5  1994-09-28 16:58:33  quinn
+ * Revision 1.6  1995-09-04 12:33:47  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.5  1994/09/28  16:58:33  quinn
  * Small mod.
  *
  * Revision 1.4  1994/09/27  20:03:52  quinn
@@ -26,8 +29,9 @@
  */
 
 #include <assert.h>
+#include <stdio.h>
 
-#include <util.h>
+#include <alexutil.h>
 #include <isam.h>
 
 int is_mbuf_size[3] = { 0, 1024, 4096 };
@@ -271,7 +275,7 @@ int is_m_write_record(is_mtable *tab, const void *rec)
        mbuf = tab->cur_mblock->cur_mbuf = mbuf->next;
        mbuf->cur_record = 0;
     }
-    log(LOG_DEBUG, "is_m_write_rec(rec == %d)", mbuf->cur_record);
+    logf (LOG_DEBUG, "is_m_write_rec(rec == %d)", mbuf->cur_record);
     memcpy(mbuf->data + mbuf->offset + mbuf->cur_record * is_keysize(tab->is),
        rec, is_keysize(tab->is));
     mbuf->num++;
@@ -387,7 +391,7 @@ int is_m_num_records(is_mtable *tab)
     if (tab->data->state < IS_MBSTATE_PARTIAL)
        if (read_current_full(tab, tab->data) < 0)
        {
-           log(LOG_FATAL, "read full failed");
+           logf (LOG_FATAL, "read full failed");
            exit(1);
        }
     return tab->num_records;
index 312d3e2..e02598e 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: physical.c,v $
- * Revision 1.5  1994-09-28 11:29:33  quinn
+ * Revision 1.6  1995-09-04 12:33:47  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.5  1994/09/28  11:29:33  quinn
  * Added cmp parameter.
  *
  * Revision 1.4  1994/09/27  20:03:53  quinn
@@ -26,6 +29,7 @@
  */
 
 #include <assert.h>
+#include <stdio.h>
 
 #include <isam.h>
 
@@ -39,14 +43,14 @@ static int is_freestore_alloc(ISAM is, int type)
        if (bf_read(is->types[type].bf, tmp, 0, sizeof(tmp),
            &is->types[type].freelist) <=0)
        {
-           log(LOG_FATAL, "Failed to allocate block");
+           logf (LOG_FATAL, "Failed to allocate block");
            exit(1);
        }
     }
     else
        tmp = is->types[type].top++;
 
-    log(LOG_DEBUG, "Allocating block #%d", tmp);
+    logf (LOG_DEBUG, "Allocating block #%d", tmp);
     return tmp;
 }
 
@@ -54,12 +58,12 @@ static void is_freestore_free(ISAM is, int type, int block)
 {
     int tmp;
 
-    log(LOG_DEBUG, "Releasing block #%d", block);
+    logf (LOG_DEBUG, "Releasing block #%d", block);
     tmp = is->types[type].freelist;
     is->types[type].freelist = block;
     if (bf_write(is->types[type].bf, block, 0, sizeof(tmp), &tmp) < 0)
     {
-       log(LOG_FATAL, "Failed to deallocate block.");
+       logf (LOG_FATAL, "Failed to deallocate block.");
        exit(1);
     }
 }
@@ -83,7 +87,7 @@ int is_p_read_partial(is_mtable *tab, is_mblock *block)
     if (bf_read(tab->is->types[tab->pos_type].bf, block->diskpos, 0, toread,
        buf->data) < 0)
     {
-       log(LOG_FATAL, "bfread failed.");
+       logf (LOG_FATAL, "bfread failed.");
        return -1;
     }
     /* extract header info */
@@ -117,7 +121,7 @@ int is_p_read_full(is_mtable *tab, is_mblock *block)
 
     if (block->state == IS_MBSTATE_UNREAD && is_p_read_partial(tab, block) < 0)
     {
-       log(LOG_FATAL, "partial read failed.");
+       logf (LOG_FATAL, "partial read failed.");
        return -1;
     }
     if (block->state == IS_MBSTATE_PARTIAL)
@@ -136,7 +140,7 @@ int is_p_read_full(is_mtable *tab, is_mblock *block)
            if (bf_read(tab->is->types[tab->pos_type].bf, block->diskpos, block->bread, toread *
                is_keysize(tab->is), buf->data) < 0)
            {
-               log(LOG_FATAL, "bfread failed.");
+               logf (LOG_FATAL, "bfread failed.");
                return -1;
            }
            buf->offset = 0;
@@ -145,7 +149,7 @@ int is_p_read_full(is_mtable *tab, is_mblock *block)
            block->bread += toread * is_keysize(tab->is);
        }
     }
-    log(LOG_DEBUG, "R: Block #%d contains %d records.", block->diskpos, block->num_records);
+    logf (LOG_DEBUG, "R: Block #%d contains %d records.", block->diskpos, block->num_records);
     return 0;
 }
 
@@ -198,10 +202,10 @@ void is_p_sync(is_mtable *tab)
        }
        if (bf_write(type->bf, p->diskpos, 0, sum, type->dbuf) < 0)
        {
-           log(LOG_FATAL, "Failed to write block.");
+           logf (LOG_FATAL, "Failed to write block.");
            exit(1);
        }
-       log(LOG_DEBUG, "W: Block #%d contains %d records.", p->diskpos, p->num_records);
+       logf (LOG_DEBUG, "W: Block #%d contains %d records.", p->diskpos, p->num_records);
     }
 }
 
@@ -265,7 +269,7 @@ void is_p_align(is_mtable *tab)
     is_mbuf *mbufs, *mbp;
     int blocks, recsblock;
 
-    log(LOG_DEBUG, "Realigning table.");
+    logf (LOG_DEBUG, "Realigning table.");
     for (mblock = tab->data; mblock; mblock = next)
     {
         next = mblock->next;
@@ -336,14 +340,14 @@ void is_p_remap(is_mtable *tab)
     is_mblock *blockp, **blockpp;
     int recsblock, blocks;
 
-    log(LOG_DEBUG, "Remapping table.");
+    logf (LOG_DEBUG, "Remapping table.");
     /* collect all data */
     bufpp = &mbufs;
     for (blockp = tab->data; blockp; blockp = blockp->next)
     {
        if (blockp->state < IS_MBSTATE_CLEAN && is_m_read_full(tab, blockp) < 0)
        {
-           log(LOG_FATAL, "Read-full failed in remap.");
+           logf (LOG_FATAL, "Read-full failed in remap.");
            exit(1);
        }
        *bufpp = blockp->data;
index 25c1a82..09aa672 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rootblk.c,v $
- * Revision 1.1  1994-09-26 16:08:00  quinn
+ * Revision 1.2  1995-09-04 12:33:47  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.1  1994/09/26  16:08:00  quinn
  * Most of the functionality in place.
  *
  */
@@ -13,6 +16,7 @@
  * Read and write the blocktype header.
  */
 
+#include <stdio.h>
 #include <isam.h>
 #include "rootblk.h"
 
index d68c3db..a87980c 100644 (file)
@@ -1,27 +1,25 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.3 1995-01-24 16:01:44 adam Exp $
+# $Id: Makefile,v 1.4 1995-09-04 12:33:55 adam Exp $
 
 SHELL=/bin/sh
-INCLUDE=-I../include
-CFLAGS=-g -Wall -pedantic -ansi
+RANLIB=ranlib
+YAZ=../../yaz
+INCLUDE=-I../include -I$(YAZ)/include
+#CFLAGS=-g -Wall -pedantic -ansi
 DEFS=$(INCLUDE)
 LIB=../lib/rset.a
 PROG=
 PO=rset.o rstemp.o rsisam.o
 CPP=cc -E
 
-all: $(PROG) $(LIB)
-
-$(PROG): $(PROG).o
-       $(CC) -o $(PROG) $(INCLUDE) $(CFLAGS) $(PROG).o $(LIB)
-
+all: $(LIB)
 
 $(LIB): $(PO)
        rm -f $(LIB)
        ar qc $(LIB) $(PO)
-       ranlib $(LIB)
+       $(RANLIB) $(LIB)
 
 .c.o:
        $(CC) -c $(DEFS) $(CFLAGS) $<
@@ -32,13 +30,12 @@ clean:
 depend: depend2
 
 depend1:
-       mv Makefile Makefile.tmp
-       sed '/^#Depend/q' <Makefile.tmp >Makefile
-       $(CPP) $(INCLUDE) -M *.c >>Makefile
-       -rm Makefile.tmp
+       sed '/^#Depend/q' <Makefile >Makefile.tmp
+       $(CPP) $(DEFS) -M *.c >>Makefile.tmp
+       mv -f Makefile.tmp Makefile
 
 depend2:
-       $(CPP) $(INCLUDE) -M *.c >.depend       
+       $(CPP) $(DEFS) -M *.c >.depend  
 
 ifeq (.depend,$(wildcard .depend))
 include .depend
index 667bd1d..18b26f7 100644 (file)
@@ -4,14 +4,18 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rset.c,v $
- * Revision 1.1  1994-11-04 13:21:28  quinn
+ * Revision 1.2  1995-09-04 12:33:56  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.1  1994/11/04  13:21:28  quinn
  * Working.
  *
  */
 
 /* TODO: mem management */
 
-#include <util.h>
+#include <stdio.h>
+#include <alexutil.h>
 
 #include <rset.h>
 
index df5ad91..21df0ac 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rsisam.c,v $
- * Revision 1.4  1995-09-04 09:10:55  adam
+ * Revision 1.5  1995-09-04 12:33:56  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.4  1995/09/04  09:10:55  adam
  * Minor changes.
  *
  * Revision 1.3  1994/11/22  13:15:37  quinn
@@ -18,8 +21,9 @@
 /* TODO: Memory management
    LINK DELETE TO CLOSE!  */
 
+#include <stdio.h>
 #include <rsisam.h>
-#include <util.h>
+#include <alexutil.h>
 
 static rset_control *r_create(const struct rset_control *sel, void *parms);
 static int r_open(rset_control *ct, int wflag);
@@ -51,7 +55,7 @@ static rset_control *r_create(const struct rset_control *sel, void *parms)
     rset_control *newct;
     rset_isam_parms *pt = parms;
 
-    log(LOG_DEBUG, "risam_create(%s)", sel->desc);
+    logf (LOG_DEBUG, "risam_create(%s)", sel->desc);
     newct = xmalloc(sizeof(*newct));
     memcpy(newct, sel, sizeof(*sel));
     if (!(newct->buf = (char*) is_position(pt->is, pt->pos)))
@@ -61,10 +65,10 @@ static rset_control *r_create(const struct rset_control *sel, void *parms)
 
 static int r_open(rset_control *ct, int wflag)
 {
-    log(LOG_DEBUG, "risam_open");
+    logf (LOG_DEBUG, "risam_open");
     if (wflag)
     {
-       log(LOG_FATAL, "ISAM set type is read-only");
+       logf (LOG_FATAL, "ISAM set type is read-only");
        return -1;
     }
     r_rewind(ct);
@@ -78,14 +82,14 @@ static void r_close(rset_control *ct)
 
 static void r_delete(rset_control *ct)
 {
-    log(LOG_DEBUG, "risam_delete");
+    logf (LOG_DEBUG, "risam_delete");
     is_pt_free((ISPT) ct->buf);
     xfree(ct);
 }
 
 static void r_rewind(rset_control *ct)
 {
-    log(LOG_DEBUG, "risam_rewind");
+    logf (LOG_DEBUG, "risam_rewind");
     is_rewind((ISPT) ct->buf);
 }
 
@@ -99,6 +103,6 @@ static int r_read(rset_control *ct, void *buf)
 
 static int r_write()
 {
-    log(LOG_FATAL, "ISAM set type is read-only");
+    logf (LOG_FATAL, "ISAM set type is read-only");
     return -1;
 }
index 94db635..15c7e35 100644 (file)
@@ -1,48 +1,47 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.16 1995-01-24 16:01:50 adam Exp $
+# $Id: Makefile,v 1.17 1995-09-04 12:34:05 adam Exp $
 
 SHELL=/bin/sh
-INCLUDE=-I../include
+RANLIB=ranlib
+YAZ=../../yaz
+YAZLIB=$(YAZ)/lib/libyaz.a
+INCLUDE=-I../include -I$(YAZ)/include
 TPROG=opt-test
-CFLAGS=-g -Wall -pedantic -ansi
+#CFLAGS=-g -Wall -pedantic -ansi
 DEFS=$(INCLUDE)
-LIB=../lib/util.a
-PO = options.o xmalloc.o log.o res.o alexpath.o common.o
 CPP=cc -E
+LIB=../lib/alexutil.a
+PO = xmalloc.o res.o alexpath.o common.o
 
 all: $(LIB)
 
-alll: opt-test res-test all
+alll: res-test all
 
-opt-test: opt-test.o $(LIB) 
-       $(CC) -o opt-test opt-test.o $(LIB)
-
-res-test: res-test.o $(LIB)
-       $(CC) -o res-test res-test.o $(LIB)
+res-test: res-test.o $(LIB) $(YAZLIB)
+       $(CC) -o res-test res-test.o $(LIB) $(YAZLIB)
 
 $(LIB): $(PO)
        rm -f $(LIB)
        ar qc $(LIB) $(PO)
-       ranlib $(LIB)
+       $(RANLIB) $(LIB)
 
 .c.o:
        $(CC) -c $(DEFS) $(CFLAGS) $<
 
 clean:
-       rm -f *.[oa] opt-test res-test core mon.out gmon.out errlist
+       rm -f *.[oa] res-test core mon.out gmon.out errlist
 
 depend: depend2
 
 depend1:
-       mv Makefile Makefile.tmp
-       sed '/^#Depend/q' <Makefile.tmp >Makefile
-       $(CPP) $(INCLUDE) -M *.c >>Makefile
-       -rm Makefile.tmp
+       sed '/^#Depend/q' <Makefile >Makefile.tmp
+       $(CPP) $(DEFS) -M *.c >>Makefile.tmp
+       mv -f Makefile.tmp Makefile
 
 depend2:
-       $(CPP) $(INCLUDE) -M *.c >.depend       
+       $(CPP) $(DEFS) -M *.c >.depend  
 
 ifeq (.depend,$(wildcard .depend))
 include .depend
index d947dde..75db5a0 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: res-test.c,v $
- * Revision 1.4  1994-10-04 17:47:11  adam
+ * Revision 1.5  1995-09-04 12:34:05  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.4  1994/10/04  17:47:11  adam
  * Function options now returns arg with error option.
  *
  * Revision 1.3  1994/08/18  11:02:27  adam
  */
 
 #include <stdio.h>
-#include <util.h>
+#include <alexutil.h>
 
 static void res_print (const char *name, const char *value)
 {
-    log (LOG_LOG, "%s=%s", name, value);
+    logf (LOG_LOG, "%s=%s", name, value);
 }
 
 int main(int argc, char **argv)
@@ -48,12 +51,12 @@ int main(int argc, char **argv)
             write_flag = 1;
         else
         {
-            log (LOG_FATAL, "Unknown option '-%s'", arg);
+            logf (LOG_FATAL, "Unknown option '-%s'", arg);
             exit (1);
         }
     if (!resfile)
     {
-        log (LOG_FATAL, "No resource file given.");
+        logf (LOG_FATAL, "No resource file given.");
         exit (1);
     }
     res = res_open (resfile);
index 10891dc..0b2cc75 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: res.c,v $
- * Revision 1.12  1995-01-24 16:40:32  adam
+ * Revision 1.13  1995-09-04 12:34:05  adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.12  1995/01/24  16:40:32  adam
  * Bug fix.
  *
  * Revision 1.11  1994/10/05  16:54:52  adam
@@ -46,7 +49,7 @@
 #include <string.h>
 #include <assert.h>
 #include <unistd.h>
-#include <util.h>
+#include <alexutil.h>
 
 static struct res_entry *add_entry (Res r)
 {
@@ -84,7 +87,7 @@ static void reread (Res r)
     fr = fopen (path, "r");
     if (!fr)
     {
-        log (LOG_FATAL|LOG_ERRNO, "Cannot open %s", path);
+        logf (LOG_FATAL|LOG_ERRNO, "Cannot open %s", path);
         exit (1);
     }
     while (1)
@@ -136,7 +139,7 @@ static void reread (Res r)
                     val_buf[val_size++] = '\0';
                     resp->value = xmalloc (val_size);
                     strcpy (resp->value, val_buf);
-                    log (LOG_DEBUG, "(name=%s,value=%s)",
+                    logf (LOG_DEBUG, "(name=%s,value=%s)",
                          resp->name, resp->value);
                     break;
                 }
@@ -175,7 +178,7 @@ Res res_open (const char *name)
 {
     Res r;
     if (access (name, R_OK))
-        log (LOG_LOG|LOG_ERRNO, "Cannot access `%s'", name);
+        logf (LOG_LOG|LOG_ERRNO, "Cannot access `%s'", name);
     r = xmalloc (sizeof(*r));
     r->init = 0;
     r->first = r->last = NULL;
@@ -221,7 +224,7 @@ char *res_get_def (Res r, const char *name, char *def)
 
     if (!(t = res_get (r, name)))
     {
-       log(LOG_DEBUG, "CAUTION: Using default resource %s:%s", name, def);
+       logf (LOG_DEBUG, "CAUTION: Using default resource %s:%s", name, def);
        return def;
     }
     else
@@ -279,7 +282,7 @@ int res_write (Res r)
     fr = fopen (path, "w");
     if (!fr)
     {
-        log (LOG_FATAL|LOG_ERRNO, "Cannot create %s", path);
+        logf (LOG_FATAL|LOG_ERRNO, "Cannot create %s", path);
         exit (1);
     }