Minor adjustments
authorSebastian Hammer <quinn@indexdata.com>
Wed, 1 Nov 1995 13:54:12 +0000 (13:54 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Wed, 1 Nov 1995 13:54:12 +0000 (13:54 +0000)
36 files changed:
Makefile
ccl/cclfind.c
ccl/cclqual.c
ccl/ccltoken.c
comstack/tcpip.c
comstack/xmosi.c
include/comstack.h
include/d1_attset.h [new file with mode: 0644]
include/d1_map.h [new file with mode: 0644]
include/data1.h
include/odr.h
include/readconf.h [new file with mode: 0644]
include/yconfig.h
makelib/Makefile
odr/odr.c
odr/odr_mem.c
retrieval/Makefile
retrieval/d1_absyn.c
retrieval/d1_doespec.c
retrieval/d1_grs.c
retrieval/d1_map.c
retrieval/d1_marc.c
retrieval/d1_read.c
retrieval/d1_sutrs.c
retrieval/d1_tagset.c
retrieval/d1_varset.c
rfc1006/rfct.c
server/eventl.c
server/requestq.c
server/seshigh.c
server/statserv.c
util/Makefile
util/marcdump.c
util/readconf.c [new file with mode: 0644]
util/wrbuf.c
util/yaz-ccl.c

index 2c92740..b8c61c5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.25 1995-10-06 08:51:13 quinn Exp $
+# $Id: Makefile,v 1.26 1995-11-01 13:54:12 quinn Exp $
 
 # Uncomment the lines below to enable mOSI communcation.
 ODEFS=-DUSE_XTIMOSI
@@ -13,7 +13,7 @@ CDEFS=$(ODEFS)
 #CC=
 SHELL=/bin/sh
 MAKE=make
-SUBDIR=util odr asn $(RFC1006) ccl comstack client server makelib
+SUBDIR=util odr asn $(RFC1006) ccl comstack retrieval client server makelib
 # Add external libraries to the ELIBS macro
 ELIBS=
 CONTROL=RANLIB="ranlib" ELIBS=$(ELIBS)
index 6c08770..6fe807b 100644 (file)
@@ -2,7 +2,10 @@
  * Europagate, 1995
  *
  * $Log: cclfind.c,v $
- * Revision 1.3  1995-09-29 17:11:59  quinn
+ * Revision 1.4  1995-11-01 13:54:20  quinn
+ * Minor adjustments
+ *
+ * Revision 1.3  1995/09/29  17:11:59  quinn
  * Smallish
  *
  * Revision 1.2  1995/09/27  15:02:44  quinn
@@ -96,7 +99,7 @@ static void strxcat (char *n, const char *src, int len)
 
 static char *copy_token_name (struct ccl_token *tp)
 {
-    char *str = malloc (tp->len + 1);
+    char *str = xmalloc (tp->len + 1);
     assert (str);
     memcpy (str, tp->name, tp->len);
     str[tp->len] = '\0';
@@ -106,7 +109,7 @@ static char *copy_token_name (struct ccl_token *tp)
 static struct ccl_rpn_node *mk_node (enum rpn_node_kind kind)
 {
     struct ccl_rpn_node *p;
-    p = malloc (sizeof(*p));
+    p = xmalloc (sizeof(*p));
     assert (p);
     p->kind = kind;
     return p;
@@ -126,22 +129,22 @@ void ccl_rpn_delete (struct ccl_rpn_node *rpn)
         ccl_rpn_delete (rpn->u.p[1]);
         break;
     case CCL_RPN_TERM:
-        free (rpn->u.t.term);
+        xfree (rpn->u.t.term);
         for (attr = rpn->u.t.attr_list; attr; attr = attr1)
         {
             attr1 = attr->next;
-            free (attr);
+            xfree (attr);
         }
         break;
     case CCL_RPN_SET:
-        free (rpn->u.setname);
+        xfree (rpn->u.setname);
         break;
     case CCL_RPN_PROX:
         ccl_rpn_delete (rpn->u.p[0]);
         ccl_rpn_delete (rpn->u.p[1]);
         break;
     }
-    free (rpn);
+    xfree (rpn);
 }
 
 static struct ccl_rpn_node *find_spec (struct ccl_rpn_attr **qa);
@@ -151,7 +154,7 @@ static void add_attr (struct ccl_rpn_node *p, int type, int value)
 {
     struct ccl_rpn_attr *n;
 
-    n = malloc (sizeof(*n));
+    n = xmalloc (sizeof(*n));
     assert (n);
     n->type = type;
     n->value = value;
@@ -192,7 +195,7 @@ static struct ccl_rpn_node *search_term (struct ccl_rpn_attr **qa)
        lookahead = lookahead->next;
     }
     p = mk_node (CCL_RPN_TERM);
-    p->u.t.term = malloc (len);
+    p->u.t.term = xmalloc (len);
     assert (p->u.t.term);
     p->u.t.attr_list = NULL;
     p->u.t.term[0] = '\0';
@@ -241,7 +244,7 @@ static struct ccl_rpn_node *search_term (struct ccl_rpn_attr **qa)
         {
             ccl_error = CCL_ERR_TRUNC_NOT_BOTH;
             if (qa)
-                free (qa);
+                xfree (qa);
             ccl_rpn_delete (p);
             return NULL;
         }
@@ -253,7 +256,7 @@ static struct ccl_rpn_node *search_term (struct ccl_rpn_attr **qa)
         {
             ccl_error = CCL_ERR_TRUNC_NOT_RIGHT;
             if (qa)
-                free (qa);
+                xfree (qa);
             ccl_rpn_delete (p);
             return NULL;
         }
@@ -265,7 +268,7 @@ static struct ccl_rpn_node *search_term (struct ccl_rpn_attr **qa)
         {
             ccl_error = CCL_ERR_TRUNC_NOT_LEFT;
             if (qa)
-                free (qa);
+                xfree (qa);
             ccl_rpn_delete (p);
             return NULL;
         }
@@ -295,7 +298,7 @@ static struct ccl_rpn_node *qualifiers (struct ccl_token *la,
     }
     for (lookahead = look_token; lookahead != la; lookahead=lookahead->next)
         no++;
-    ap = malloc (no * sizeof(*ap));
+    ap = xmalloc (no * sizeof(*ap));
     assert (ap);
     for (i=0; look_token != la; i++)
     {
@@ -303,7 +306,7 @@ static struct ccl_rpn_node *qualifiers (struct ccl_token *la,
         if (!ap[i])
         {
             ccl_error = CCL_ERR_UNKNOWN_QUAL;
-            free (ap);
+            xfree (ap);
             return NULL;
         }
         ADVANCE;
@@ -319,7 +322,7 @@ static struct ccl_rpn_node *qualifiers (struct ccl_token *la,
         if (KIND != CCL_TOK_EQ)
         {
             ccl_error = CCL_ERR_EQ_EXPECTED;
-            free (ap);
+            xfree (ap);
             return NULL;
         }
         ADVANCE;
@@ -328,21 +331,21 @@ static struct ccl_rpn_node *qualifiers (struct ccl_token *la,
             ADVANCE;
             if (!(p = find_spec (ap)))
             {
-                free (ap);
+                xfree (ap);
                 return NULL;
             }
             if (KIND != CCL_TOK_RP)
             {
                 ccl_error = CCL_ERR_RP_EXPECTED;
                 ccl_rpn_delete (p);
-                free (ap);
+                xfree (ap);
                 return NULL;
             }
             ADVANCE;
         }
         else
             p = search_terms (ap);
-        free (ap);
+        xfree (ap);
         return p;
     }
     rel = 0;
@@ -388,20 +391,20 @@ static struct ccl_rpn_node *qualifiers (struct ccl_token *la,
                     add_attr (p1, CCL_BIB1_REL, 4);
                     p->u.p[1] = p2;
                     add_attr (p2, CCL_BIB1_REL, 2);
-                    free (ap);
+                    xfree (ap);
                     return p;
                 }
                 else                       /* = term -    */
                 {
                     add_attr (p1, CCL_BIB1_REL, 4);
-                    free (ap);
+                    xfree (ap);
                     return p1;
                 }
             }
             else
             {
                 add_attr (p1, CCL_BIB1_REL, rel);
-                free (ap);
+                xfree (ap);
                 return p1;
             }
         }
@@ -410,12 +413,12 @@ static struct ccl_rpn_node *qualifiers (struct ccl_token *la,
             ADVANCE;
             p = search_term (ap);
             add_attr (p, CCL_BIB1_REL, 2);
-            free (ap);
+            xfree (ap);
             return p;
         }
         ccl_error = CCL_ERR_TERM_EXPECTED;
     }
-    free (ap);
+    xfree (ap);
     return NULL;
 }
 
index 3c0a6de..2230b77 100644 (file)
@@ -2,7 +2,10 @@
  * Europagate, 1995
  *
  * $Log: cclqual.c,v $
- * Revision 1.3  1995-09-29 17:12:00  quinn
+ * Revision 1.4  1995-11-01 13:54:21  quinn
+ * Minor adjustments
+ *
+ * Revision 1.3  1995/09/29  17:12:00  quinn
  * Smallish
  *
  * Revision 1.2  1995/09/27  15:02:44  quinn
@@ -52,13 +55,13 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
             break;
     if (!q)
     {
-        struct ccl_qualifier *new_qual = malloc (sizeof(*new_qual));
+        struct ccl_qualifier *new_qual = xmalloc (sizeof(*new_qual));
         assert (new_qual);
         
         new_qual->next = b->list;
         b->list = new_qual;
         
-        new_qual->name = malloc (strlen(name)+1);
+        new_qual->name = xmalloc (strlen(name)+1);
         assert (new_qual->name);
         strcpy (new_qual->name, name);
         attrp = &new_qual->attr_list;
@@ -73,7 +76,7 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
     {
         struct ccl_rpn_attr *attr;
 
-        attr = malloc (sizeof(*attr));
+        attr = xmalloc (sizeof(*attr));
         assert (attr);
         attr->type = *pairs++;
         attr->value = *pairs++;
@@ -85,7 +88,7 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
 
 CCL_bibset ccl_qual_mk (void)
 {
-    CCL_bibset b = malloc (sizeof(*b));
+    CCL_bibset b = xmalloc (sizeof(*b));
     assert (b);
     b->list = NULL;     
     return b;
index db6edd6..14b217d 100644 (file)
@@ -2,7 +2,10 @@
  * Europagate, 1995
  *
  * $Log: ccltoken.c,v $
- * Revision 1.3  1995-09-29 17:12:00  quinn
+ * Revision 1.4  1995-11-01 13:54:22  quinn
+ * Minor adjustments
+ *
+ * Revision 1.3  1995/09/29  17:12:00  quinn
  * Smallish
  *
  * Revision 1.2  1995/09/27  15:02:44  quinn
@@ -65,13 +68,13 @@ struct ccl_token *ccl_tokenize (const char *command)
        }
        if (!first)
        {
-           first = last = malloc (sizeof (*first));
+           first = last = xmalloc (sizeof (*first));
            assert (first);
            last->prev = NULL;
        }
        else
        {
-           last->next = malloc (sizeof(*first));
+           last->next = xmalloc (sizeof(*first));
            assert (last->next);
            last->next->prev = last;
            last = last->next;
index 4e2ab4f..dae32b9 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: tcpip.c,v $
- * Revision 1.7  1995-10-30 12:41:16  quinn
+ * Revision 1.8  1995-11-01 13:54:27  quinn
+ * Minor adjustments
+ *
+ * Revision 1.7  1995/10/30  12:41:16  quinn
  * Added hostname lookup for server.
  *
  * Revision 1.6  1995/09/29  17:12:00  quinn
@@ -129,7 +132,7 @@ static int initialized = 0;
 typedef struct tcpip_state
 {
     char *altbuf; /* alternate buffer for surplus data */
-    int altsize;  /* size as malloced */
+    int altsize;  /* size as xmalloced */
     int altlen;   /* length of data or 0 if none */
 
     int written;  /* -1 if we aren't writing */
@@ -168,9 +171,9 @@ COMSTACK tcpip_type(int blocking, int protocol)
     if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
 #endif
         return 0;
-    if (!(p = malloc(sizeof(struct comstack))))
+    if (!(p = xmalloc(sizeof(struct comstack))))
         return 0;
-    if (!(state = p->private = malloc(sizeof(tcpip_state))))
+    if (!(state = p->private = xmalloc(sizeof(tcpip_state))))
         return 0;
 #ifdef WINDOWS
     if (!(p->blocking = blocking) && ioctlsocket(s, FIONBIO, &tru) < 0)
@@ -347,14 +350,14 @@ COMSTACK tcpip_accept(COMSTACK h)
         h->cerrno = CSOUTSTATE;
         return 0;
     }
-    if (!(new = malloc(sizeof(*new))))
+    if (!(new = xmalloc(sizeof(*new))))
     {
         h->cerrno = CSYSERR;
         return 0;
     }
     memcpy(new, h, sizeof(*h));
     new->iofile = h->newfd;
-    if (!(state = new->private = malloc(sizeof(tcpip_state))))
+    if (!(state = new->private = xmalloc(sizeof(tcpip_state))))
     {
         h->cerrno = CSYSERR;
         return 0;
@@ -404,11 +407,11 @@ int tcpip_get(COMSTACK h, char **buf, int *bufsize)
     {
         if (!*bufsize)
         {
-            if (!(*buf = malloc(*bufsize = CS_TCPIP_BUFCHUNK)))
+            if (!(*buf = xmalloc(*bufsize = CS_TCPIP_BUFCHUNK)))
                 return -1;
         }
         else if (*bufsize - hasread < CS_TCPIP_BUFCHUNK)
-            if (!(*buf = realloc(*buf, *bufsize *= 2)))
+            if (!(*buf =xrealloc(*buf, *bufsize *= 2)))
                 return -1;
         if ((res = recv(h->iofile, *buf + hasread, CS_TCPIP_BUFCHUNK, 0)) < 0)
 #ifdef WINDOWS
@@ -435,10 +438,10 @@ int tcpip_get(COMSTACK h, char **buf, int *bufsize)
             req += CS_TCPIP_BUFCHUNK - rest;
         if (!sp->altbuf)
         {
-            if (!(sp->altbuf = malloc(sp->altsize = req)))
+            if (!(sp->altbuf = xmalloc(sp->altsize = req)))
                 return -1;
         } else if (sp->altsize < req)
-            if (!(sp->altbuf = realloc(sp->altbuf, sp->altsize = req)))
+            if (!(sp->altbuf =xrealloc(sp->altbuf, sp->altsize = req)))
                 return -1;
         TRC(fprintf(stderr, "  Moving %d bytes to altbuf(0x%x)\n", tomove,
             (unsigned) sp->altbuf));
@@ -503,9 +506,9 @@ int tcpip_close(COMSTACK h)
     TRC(fprintf(stderr, "tcpip_close\n"));
     close(h->iofile);
     if (sp->altbuf)
-        free(sp->altbuf);
-    free(sp);
-    free(h);
+        xfree(sp->altbuf);
+    xfree(sp);
+    xfree(h);
     return 0;
 }
 
index 3f6a9c2..4a94c62 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: xmosi.c,v $
- * Revision 1.7  1995-10-30 12:41:17  quinn
+ * Revision 1.8  1995-11-01 13:54:29  quinn
+ * Minor adjustments
+ *
+ * Revision 1.7  1995/10/30  12:41:17  quinn
  * Added hostname lookup for server.
  *
  * Revision 1.6  1995/09/29  17:12:00  quinn
@@ -154,9 +157,9 @@ COMSTACK mosi_type(int blocking, int protocol)
     mosi_state *state;
     int flags = O_RDWR;
 
-    if (!(r = malloc(sizeof(*r))))
+    if (!(r = xmalloc(sizeof(*r))))
        return 0;
-    if (!(state = r->private = malloc(sizeof(*state))))
+    if (!(state = r->private = xmalloc(sizeof(*state))))
        return 0;
 
     state->call = 0;
@@ -209,9 +212,9 @@ int hex2oct(char *hex, char *oct)
  */
 struct netbuf MDF *mosi_strtoaddr(const char *str)
 {
-    struct netbuf *ret = malloc(sizeof(struct netbuf));
-    struct sockaddr_in *add = malloc(sizeof(struct sockaddr_in));
-    struct t_mosiaddr *mosiaddr = malloc(sizeof(struct t_mosiaddr));
+    struct netbuf *ret = xmalloc(sizeof(struct netbuf));
+    struct sockaddr_in *add = xmalloc(sizeof(struct sockaddr_in));
+    struct t_mosiaddr *mosiaddr = xmalloc(sizeof(struct t_mosiaddr));
     struct hostent *hp;
     char *p, *b, buf[512], *nsap;
     short int port = 102;
@@ -388,10 +391,10 @@ COMSTACK mosi_accept(COMSTACK h)
        h->cerrno = CSOUTSTATE;
        return 0;
     }
-    if (!(new = malloc(sizeof(*new))))
+    if (!(new = xmalloc(sizeof(*new))))
        return 0;
     *new = *h;
-    if (!(new->private = ns = malloc(sizeof(*ns))))
+    if (!(new->private = ns = xmalloc(sizeof(*ns))))
        return 0;
     *ns = *st;
     if (!h->blocking)
@@ -423,11 +426,11 @@ int mosi_get(COMSTACK h, char **buf, int *bufsize)
     {
        if (!*bufsize)
        {
-           if (!(*buf = malloc(*bufsize = CS_MOSI_BUFCHUNK)))
+           if (!(*buf = xmalloc(*bufsize = CS_MOSI_BUFCHUNK)))
                return -1;
        }
        else if (*bufsize - ct->hasread < CS_MOSI_BUFCHUNK)
-           if (!(*buf = realloc(*buf, *bufsize *= 2)))
+           if (!(*buf =xrealloc(*buf, *bufsize *= 2)))
                return -1;
 
        if ((res = u_rcv(h->iofile, *buf + ct->hasread, CS_MOSI_BUFCHUNK,
@@ -469,10 +472,10 @@ int mosi_put(COMSTACK h, char *buf, int size)
 
 int mosi_close(COMSTACK h)
 {
-    free(h->private);
+    xfree(h->private);
     if (h->iofile >= 0)
        u_close(h->iofile);
-    free(h);
+   xfree(h);
     return 0;
 }    
 
index eabbdf1..8e619cb 100644 (file)
  * OF THIS SOFTWARE.
  *
  * $Log: comstack.h,v $
- * Revision 1.12  1995-10-30 12:41:27  quinn
+ * Revision 1.13  1995-11-01 13:54:33  quinn
+ * Minor adjustments
+ *
+ * Revision 1.12  1995/10/30  12:41:27  quinn
  * Added hostname lookup for server.
  *
  * Revision 1.11  1995/09/29  17:12:01  quinn
 
 #include <yconfig.h>
 #include <oid.h>
-#include <dmalloc.h>
+#include <xmalloc.h>
 
 #define COMSTACK_DEFAULT_TIMEOUT -1  /* not used yet */
 
diff --git a/include/d1_attset.h b/include/d1_attset.h
new file mode 100644 (file)
index 0000000..42bf4b4
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1995, Index Data.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation, in whole or in part, for any purpose, is hereby granted,
+ * provided that:
+ *
+ * 1. This copyright and permission notice appear in all copies of the
+ * software and its documentation. Notices of copyright or attribution
+ * which appear at the beginning of any file must remain unchanged.
+ *
+ * 2. The names of Index Data or the individual authors may not be used to
+ * endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
+ * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ *
+ */
+
+#ifndef D1_ATTSET_H
+#define D1_ATTSET_H
+
+#include <oid.h>
+
+/*
+ * This structure describes a attset, perhaps made up by inclusion
+ * (supersetting) of other attribute sets. When indexing and searching,
+ * we perform a normalisation, where we associate a given tag with
+ * the set that originally defined it, rather than the superset. This
+ * allows the most flexible access. Eg, the tags common to GILS and BIB-1
+ * should be searchable by both names.
+ */
+
+struct data1_attset;
+
+typedef struct data1_att
+{
+    struct data1_attset *parent;   /* attribute set */
+    char *name;                    /* symbolic name of this tag */
+    int value;                     /* tag value */
+    int local;                     /* local index value */
+    struct data1_att *next;
+} data1_att;
+
+typedef struct data1_attset
+{
+    char *name;          /* symbolic name */
+    oid_value reference;   /* external ID of attset */
+    int ordinal;           /* attset identification in index */
+    data1_att *atts;          /* attributes */
+    struct data1_attset *children;  /* included attset */
+    struct data1_attset *next;       /* sibling */
+} data1_attset;
+
+data1_att *data1_getattbyname(data1_attset *s, char *name);
+data1_attset *data1_read_attset(char *file);
+
+#endif
diff --git a/include/d1_map.h b/include/d1_map.h
new file mode 100644 (file)
index 0000000..37dfe87
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1995, Index Data.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation, in whole or in part, for any purpose, is hereby granted,
+ * provided that:
+ *
+ * 1. This copyright and permission notice appear in all copies of the
+ * software and its documentation. Notices of copyright or attribution
+ * which appear at the beginning of any file must remain unchanged.
+ *
+ * 2. The names of Index Data or the individual authors may not be used to
+ * endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
+ * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ *
+ */
+
+#ifndef D1_MAP_H
+#define D1_MAP_H
+
+typedef struct data1_maptag
+{
+    int new_field;
+    int type;
+    enum 
+    {
+       D1_MAPTAG_numeric,
+       D1_MAPTAG_string
+    } which;
+    union
+    {
+       int numeric;
+       char *string;
+    } value;
+    struct data1_maptag *next;
+} data1_maptag;
+
+typedef struct data1_mapunit
+{
+    int no_data;
+    char *source_element_name;
+    data1_maptag *target_path;
+    struct data1_mapunit *next;
+} data1_mapunit;
+
+typedef struct data1_maptab
+{
+    char *name;
+    oid_value target_absyn_ref;
+    char *target_absyn_name;
+    data1_mapunit *map;
+    struct data1_maptab *next;
+} data1_maptab;
+
+#endif
index 65cc658..bd0747d 100644 (file)
@@ -1,10 +1,33 @@
 /*
- * Copyright (C) 1994, Index Data I/S 
- * All rights reserved.
- * Sebastian Hammer, Adam Dickmeiss
+ * Copyright (c) 1995, Index Data.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation, in whole or in part, for any purpose, is hereby granted,
+ * provided that:
+ *
+ * 1. This copyright and permission notice appear in all copies of the
+ * software and its documentation. Notices of copyright or attribution
+ * which appear at the beginning of any file must remain unchanged.
+ *
+ * 2. The names of Index Data or the individual authors may not be used to
+ * endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
+ * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
  *
  * $Log: data1.h,v $
- * Revision 1.1  1995-11-01 13:07:18  quinn
+ * Revision 1.2  1995-11-01 13:54:35  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  13:07:18  quinn
  * Data1 module now lives in YAZ.
  *
  * Revision 1.13  1995/10/25  16:00:49  quinn
@@ -58,7 +81,7 @@
 #include <proto.h>
 
 #include <d1_attset.h>
-#include "d1_map.h"
+#include <d1_map.h>
 
 #define DATA1_MAX_SYMBOL 31
 
index 8bfc445..f9d55d7 100644 (file)
  * OF THIS SOFTWARE.
  *
  * $Log: odr.h,v $
- * Revision 1.15  1995-10-18 16:12:36  quinn
+ * Revision 1.16  1995-11-01 13:54:36  quinn
+ * Minor adjustments
+ *
+ * Revision 1.15  1995/10/18  16:12:36  quinn
  * Better diagnostics.
  *
  * Revision 1.14  1995/09/29  17:12:04  quinn
@@ -356,6 +359,6 @@ void odr_release_mem(ODR_MEM p);
 #define ODR_MAXNAME 256
 
 #include <prt.h>
-#include <dmalloc.h>
+#include <xmalloc.h>
 
 #endif
diff --git a/include/readconf.h b/include/readconf.h
new file mode 100644 (file)
index 0000000..a494586
--- /dev/null
@@ -0,0 +1,12 @@
+
+#ifndef READCONF_H
+#define READCONF_H
+
+#include <stdio.h>
+
+int readconf(char *name, void *private,
+    int (*fun)(char *name, void *private, int argc, char *argv[]));
+
+int readconf_line(FILE *f, char *line, int len, char *argv[], int num);
+
+#endif
index 879943b..78550c8 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef YCONFIG_H
 #define YCONFIG_H
 
-#include <dmalloc.h>
+#include <xmalloc.h>
 
 #ifdef WINDOWS
 #define MDF
index 3769731..d97e4cf 100644 (file)
@@ -1,14 +1,14 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.6 1995-04-10 10:22:57 quinn Exp $
+# $Id: Makefile,v 1.7 1995-11-01 13:54:38 quinn Exp $
 
 #CC=
 SHELL=/bin/sh
 MAKE=make
 LIBDIR=../lib
 LIBS=$(LIBDIR)/libodr.a $(LIBDIR)/libasn.a $(LIBDIR)/libcomstack.a \
-       $(LIBDIR)/libserver.a $(LIBDIR)/libutil.a
+       $(LIBDIR)/libserver.a $(LIBDIR)/libutil.a $(LIBDIR)/libret.a
 LIB=$(LIBDIR)/libyaz.a
 
 all: $(LIB)
index cc94ef8..b44078a 100644 (file)
--- a/odr/odr.c
+++ b/odr/odr.c
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr.c,v $
- * Revision 1.18  1995-09-29 17:12:22  quinn
+ * Revision 1.19  1995-11-01 13:54:41  quinn
+ * Minor adjustments
+ *
+ * Revision 1.18  1995/09/29  17:12:22  quinn
  * Smallish
  *
  * Revision 1.17  1995/09/29  17:01:50  quinn
@@ -65,7 +68,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <dmalloc.h>
+#include <xmalloc.h>
 #include <odr.h>
 
 Odr_null *ODR_NULLVAL = "NULL";  /* the presence of a null value */
@@ -109,7 +112,7 @@ ODR odr_createmem(int direction)
 {
     struct odr *r;
 
-    if (!(r = malloc(sizeof(*r))))
+    if (!(r = xmalloc(sizeof(*r))))
         return 0;
     r->direction = direction;
     r->print = stderr;
@@ -143,10 +146,10 @@ void odr_destroy(ODR o)
 {
     odr_release_mem(o->mem);
     if (o->ecb.buf && o->ecb.can_grow)
-        free(o->ecb.buf);
+       xfree(o->ecb.buf);
     if (o->print != stderr)
         fclose(o->print);
-    free(o);
+   xfree(o);
 }
 
 void odr_setbuf(ODR o, char *buf, int len, int can_grow)
index 185b581..3894907 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_mem.c,v $
- * Revision 1.10  1995-10-25 16:58:19  quinn
+ * Revision 1.11  1995-11-01 13:54:43  quinn
+ * Minor adjustments
+ *
+ * Revision 1.10  1995/10/25  16:58:19  quinn
  * Stupid bug in odr_malloc
  *
  * Revision 1.9  1995/10/13  16:08:08  quinn
@@ -40,7 +43,7 @@
 
 #include <stdlib.h>
 #include <odr.h>
-#include <dmalloc.h>
+#include <xmalloc.h>
 
 /* ------------------------ NIBBLE MEMORY ---------------------- */
 
@@ -84,9 +87,9 @@ static odr_memblock *get_block(int size)
 
        if (get < size)
            get = size;
-       if (!(r = malloc(sizeof(*r))))
+       if (!(r = xmalloc(sizeof(*r))))
            abort();
-       if (!(r->buf = malloc(r->size = get)))
+       if (!(r->buf = xmalloc(r->size = get)))
            abort();
     }
     r->top = 0;
@@ -127,7 +130,7 @@ void *odr_malloc(ODR o, int size)
 
     if (!o)
     {
-       if (!(r = malloc(size)))
+       if (!(r = xmalloc(size)))
            abort();
        return r;
     }
@@ -169,9 +172,9 @@ int odr_grow_block(odr_ecblock *b, int min_bytes)
        togrow = b->size;
     if (togrow < min_bytes)
        togrow = min_bytes;
-    if (b->size && !(b->buf = realloc(b->buf, b->size += togrow)))
+    if (b->size && !(b->buf =xrealloc(b->buf, b->size += togrow)))
        abort();
-    else if (!b->size && !(b->buf = malloc(b->size = togrow)))
+    else if (!b->size && !(b->buf = xmalloc(b->size = togrow)))
        abort();
 #ifdef ODR_DEBUG
     fprintf(stderr, "New size for encode_buffer: %d\n", b->size);
index 84f90a6..c817557 100644 (file)
@@ -1,13 +1,13 @@
-# $Id: Makefile,v 1.1 1995-11-01 11:56:06 quinn Exp $
+# $Id: Makefile,v 1.2 1995-11-01 13:54:43 quinn Exp $
 
 SHELL=/bin/sh
 RANLIB=ranlib
 INCLUDE=-I../include -I.
 CFLAGS=-g -Wall -pedantic -ansi
 DEFS=$(INCLUDE)
-LIB=../lib/data1.a
-PO = d1_read.o d1_attset.o d1_tagset.o d1_absyn.o d1_grs.o d1_grs_key.o \
-       attribute.o d1_matchstr.o d1_sutrs.o d1_varset.o d1_espec.o \
+LIB=../lib/libret.a
+PO = d1_read.o d1_attset.o d1_tagset.o d1_absyn.o d1_grs.o \
+       d1_matchstr.o d1_sutrs.o d1_varset.o d1_espec.o \
        d1_doespec.o d1_map.o d1_marc.o
 CPP=$(CC) -E
 
index f93d39b..1322132 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_absyn.c,v $
- * Revision 1.1  1995-11-01 11:56:06  quinn
+ * Revision 1.2  1995-11-01 13:54:44  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:06  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -20,7 +23,7 @@
 #include <oid.h>
 #include <log.h>
 
-#include "data1.h"
+#include <data1.h>
 
 #define D1_MAX_NESTING  128
 #define DATA1_MAX_SYNTAXES 30 /* max no of syntaxes to handle in one session */
index bc16d07..538d567 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_doespec.c,v $
- * Revision 1.1  1995-11-01 11:56:07  quinn
+ * Revision 1.2  1995-11-01 13:54:45  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:07  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -14,7 +17,7 @@
 #include <assert.h>
 #include <log.h>
 #include <proto.h>
-#include "data1.h"
+#include <data1.h>
 
 static int match_children(data1_node *n, Z_ETagUnit **t, int num);
 
index 650f9c7..a3ea519 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_grs.c,v $
- * Revision 1.1  1995-11-01 11:56:07  quinn
+ * Revision 1.2  1995-11-01 13:54:46  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:07  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -16,7 +19,7 @@
 #include <proto.h>
 #include <log.h>
 
-#include "data1.h"
+#include <data1.h>
 
 #define D1_VARIANTARRAY 20 /* fixed max length on sup'd variant-list. Lazy me */
 
index cbc2e7c..cec007e 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_map.c,v $
- * Revision 1.1  1995-11-01 11:56:08  quinn
+ * Revision 1.2  1995-11-01 13:54:46  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:08  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -19,7 +22,7 @@
 #include <log.h>
 #include <readconf.h>
 
-#include "data1.h"
+#include <data1.h>
 #include "d1_map.h"
 
 data1_maptab *data1_read_maptab(char *file)
index 2ac1842..786f2da 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_marc.c,v $
- * Revision 1.1  1995-11-01 11:56:08  quinn
+ * Revision 1.2  1995-11-01 13:54:48  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:08  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -19,7 +22,7 @@
 #include <log.h>
 #include <readconf.h>
 #include <xmalloc.h>
-#include "data1.h"
+#include <data1.h>
 
 #define ISO2709_RS 035
 #define ISO2709_FS 036
index c951c97..633ed62 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_read.c,v $
- * Revision 1.1  1995-11-01 11:56:09  quinn
+ * Revision 1.2  1995-11-01 13:54:48  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:09  quinn
  * Added Retrieval (data management) functions en masse.
  *
  * Revision 1.14  1995/10/30  12:40:55  quinn
@@ -58,7 +61,7 @@
 
 #include <xmalloc.h>
 #include <log.h>
-#include "data1.h"
+#include <data1.h>
 
 static data1_node *freelist = 0;
 
@@ -414,7 +417,7 @@ data1_node *data1_read_record(int (*rf)(int, char *, size_t), int fd)
        abort();
     for (;;)
     {
-       if (rd + 4096 > size && !(buf = realloc(buf, size *= 2)))
+       if (rd + 4096 > size && !(buf =xrealloc(buf, size *= 2)))
            abort();
        if ((res = (*rf)(fd, buf + rd, 4096)) <= 0)
        {
index 0411616..be255a2 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_sutrs.c,v $
- * Revision 1.1  1995-11-01 11:56:09  quinn
+ * Revision 1.2  1995-11-01 13:54:49  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:09  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -14,7 +17,7 @@
 
 #include <wrbuf.h>
 
-#include "data1.h"
+#include <data1.h>
 
 #define NTOBUF_INDENT   2
 #define NTOBUF_MARGIN 75
index 794315e..a8e4570 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_tagset.c,v $
- * Revision 1.1  1995-11-01 11:56:09  quinn
+ * Revision 1.2  1995-11-01 13:54:49  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:09  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -18,7 +21,7 @@
 #include <xmalloc.h>
 #include <log.h>
 
-#include "data1.h"
+#include <data1.h>
 
 /*
  * We'll probably want to add some sort of hashed index to these lookup-
index 2d20727..bbea607 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_varset.c,v $
- * Revision 1.1  1995-11-01 11:56:09  quinn
+ * Revision 1.2  1995-11-01 13:54:50  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/11/01  11:56:09  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
 
 #include <readconf.h>
 #include <oid.h>
-#include <alexutil.h>
 #include <log.h>
 
-#include "data1.h"
+#include <data1.h>
 
 data1_vartype *data1_getvartypebyct(data1_varset *set, char *class, char *type)
 {
index b7d8fae..b1222ec 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rfct.c,v $
- * Revision 1.7  1995-06-16 10:46:48  quinn
+ * Revision 1.8  1995-11-01 13:54:52  quinn
+ * Minor adjustments
+ *
+ * Revision 1.7  1995/06/16  10:46:48  quinn
  * *** empty log message ***
  *
  * Revision 1.6  1995/06/15  07:45:11  quinn
 #ifdef __linux__
 #include <linux/limits.h>
 #endif
-#include <dmalloc.h>  /* project memory debugging - delete if you don't have it */
 
 #ifdef TRACE_TRANSPORT
 #define TRC(x) x
index f15a54f..1ffd053 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: eventl.c,v $
- * Revision 1.15  1995-09-15 14:44:15  quinn
+ * Revision 1.16  1995-11-01 13:54:56  quinn
+ * Minor adjustments
+ *
+ * Revision 1.15  1995/09/15  14:44:15  quinn
  * *** empty log message ***
  *
  * Revision 1.14  1995/08/29  14:44:50  quinn
@@ -66,7 +69,7 @@
 
 #include <eventl.h>
 
-#include <dmalloc.h>
+#include <xmalloc.h>
 
 static IOCHAN iochans = 0;
 
@@ -79,7 +82,7 @@ IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags)
 {
     IOCHAN new;
 
-    if (!(new = malloc(sizeof(*new))))
+    if (!(new = xmalloc(sizeof(*new))))
        return 0;
     new->destroyed = 0;
     new->fd = fd;
@@ -178,7 +181,7 @@ int event_loop()
                }
                if (nextp == p)
                    nextp = p->next;
-               free(tmp);
+               xfree(tmp);
            }
        }
     }
index cfae569..d9a3a34 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: requestq.c,v $
- * Revision 1.1  1995-05-15 12:12:22  quinn
+ * Revision 1.2  1995-11-01 13:54:57  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/05/15  12:12:22  quinn
  * Request queue.
  *
  *
  * Simple queue management.
  *
  * We also use the request-freelist to store encoding buffers, rather than
- * freeing and malloc'ing them on each cycle.
+ * freeing and xmalloc'ing them on each cycle.
  */
 
 #include <stdlib.h>
 
-#include <dmalloc.h>
+#include <xmalloc.h>
 #include <session.h>
 
 static request *request_list = 0;  /* global freelist for requests */
@@ -66,7 +69,7 @@ request *request_get(void)
        request_list = r->next;
     else
     {
-       if (!(r = malloc(sizeof(*r))))
+       if (!(r = xmalloc(sizeof(*r))))
            abort();
        r->response = 0;
        r->size_response = 0;
index 9c89f0d..3ebb06f 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: seshigh.c,v $
- * Revision 1.52  1995-11-01 12:19:13  quinn
+ * Revision 1.53  1995-11-01 13:54:58  quinn
+ * Minor adjustments
+ *
+ * Revision 1.52  1995/11/01  12:19:13  quinn
  * Second attempt to fix same bug.
  *
  * Revision 1.50  1995/10/25  16:58:32  quinn
 #include <assert.h>
 #include <sys/time.h>
 
-#include <dmalloc.h>
+#include <xmalloc.h>
 #include <comstack.h>
 #include <eventl.h>
 #include <session.h>
@@ -235,7 +238,7 @@ association *create_association(IOCHAN channel, COMSTACK link)
 
     if (!control_block)
        control_block = statserv_getcontrol();
-    if (!(new = malloc(sizeof(*new))))
+    if (!(new = xmalloc(sizeof(*new))))
        return 0;
     new->client_chan = channel;
     new->client_link = link;
@@ -301,12 +304,12 @@ void destroy_association(association *h)
     if (h->print)
        odr_destroy(h->print);
     if (h->input_buffer)
-       free(h->input_buffer);
+    xfree(h->input_buffer);
     if (h->backend)
        bend_close(h->backend);
     while (request_deq(&h->incoming));
     while (request_deq(&h->outgoing));
-    free(h);
+   xfree(h);
 }
 
 static void do_close(association *a, int reason, char *message)
@@ -570,7 +573,7 @@ static int process_response(association *assoc, request *req, Z_APDU *res)
     }
     req->response = odr_getbuf(assoc->encode, &req->len_response,
        &req->size_response);
-    odr_setbuf(assoc->encode, 0, 0, 0); /* don't free if we abort later */
+    odr_setbuf(assoc->encode, 0, 0, 0); /* don'txfree if we abort later */
     odr_reset(assoc->encode);
     if (assoc->print && !z_APDU(assoc->print, &res, 0))
     {
index fe72e45..3c35cfb 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: statserv.c,v $
- * Revision 1.29  1995-10-30 12:41:29  quinn
+ * Revision 1.30  1995-11-01 13:54:59  quinn
+ * Minor adjustments
+ *
+ * Revision 1.29  1995/10/30  12:41:29  quinn
  * Added hostname lookup for server.
  *
  * Revision 1.28  1995/09/29  17:12:30  quinn
 #ifdef USE_XTIMOSI
 #include <xmosi.h>
 #endif
-#include <dmalloc.h>
 #include <log.h>
 #include <statserv.h>
 
index bd077ed..00b5723 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.14 1995-10-06 08:51:24 quinn Exp $
+# $Id: Makefile,v 1.15 1995-11-01 13:55:04 quinn Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
@@ -11,7 +11,8 @@ LIBINCLUDE=-L$(LIBDIR)
 DEFS=$(INCLUDE)
 LIB=$(LIBDIR)/libutil.a
 LIBS=
-PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o # dmalloc.o
+PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o \
+       xmalloc.o readconf.o # dmalloc.o
 CPP=$(CC) -E
 RANLIB=ranlib
 
index 2eddc42..e1e9e9a 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: marcdump.c,v $
- * Revision 1.3  1995-05-16 08:51:12  quinn
+ * Revision 1.4  1995-11-01 13:55:05  quinn
+ * Minor adjustments
+ *
+ * Revision 1.3  1995/05/16  08:51:12  quinn
  * License, documentation, and memory fixes
  *
  * Revision 1.2  1995/05/15  11:56:56  quinn
@@ -19,7 +22,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <marcdisp.h>
-#include <dmalloc.h>
+#include <xmalloc.h>
 
 #ifndef SEEK_SET
 #define SEEK_SET 0
@@ -60,10 +63,10 @@ int main (int argc, char **argv)
                 *argv, argv[1], strerror (errno));
         exit (1);
     }
-    buf = malloc (file_size);
+    buf = xmalloc (file_size);
     if (!buf)
     {
-        fprintf (stderr, "%s: cannot malloc: %s\n",
+        fprintf (stderr, "%s: cannot xmalloc: %s\n",
                 *argv, strerror (errno));
         exit (1);
     }
diff --git a/util/readconf.c b/util/readconf.c
new file mode 100644 (file)
index 0000000..a890e08
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 1994, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: readconf.c,v $
+ * Revision 1.1  1995-11-01 13:55:06  quinn
+ * Minor adjustments
+ *
+ * Revision 1.2  1995/10/30  13:54:27  quinn
+ * iRemoved fclose().
+ *
+ * Revision 1.1  1995/10/10  16:28:18  quinn
+ * Initial revision
+ *
+ *
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include <log.h>
+
+int readconf_line(FILE *f, char *line, int len, char *argv[], int num)
+{
+    char *p;
+    int argc;
+
+    while ((p = fgets(line, len, f)))
+    {
+       while (*p && isspace(*p))
+           p++;
+       if (*p && *p != '#')
+           break;
+    }
+    if (!p)
+       return 0;
+
+    for (argc = 0; *p ; argc++)
+    {
+       if (*p == '#')  /* trailing comment */
+           break;
+       argv[argc] = p;
+       while (*p && !isspace(*p))
+           p++;
+       if (*p)
+       {
+           *(p++) = '\0';
+           while (*p && isspace(*p))
+               p++;
+       }
+    }
+    return argc;
+}
+
+/*
+ * Read lines of a configuration file.
+ */
+int readconf(char *name, void *private,
+    int (*fun)(char *name, void *private, int argc, char *argv[]))
+{
+    FILE *f;
+    char line[512], *m_argv[50];
+    int m_argc;
+
+    if (!(f = fopen(name, "r")))
+    {
+       logf(LOG_WARN|LOG_ERRNO, "readconf: %s", name);
+       return -1;
+    }
+    for (;;)
+    {
+       int res;
+
+       if (!(m_argc = readconf_line(f, line, 512, m_argv, 50)))
+       {
+           fclose(f);
+           return 0;
+       }
+
+       if ((res = (*fun)(name, private, m_argc, m_argv)))
+       {
+           fclose(f);
+           return res;
+       }
+    }
+}
index 446b6d5..62ba1a5 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: wrbuf.c,v $
- * Revision 1.1  1995-10-06 08:51:25  quinn
+ * Revision 1.2  1995-11-01 13:55:06  quinn
+ * Minor adjustments
+ *
+ * Revision 1.1  1995/10/06  08:51:25  quinn
  * Added Write-buffer.
  *
  *
@@ -22,7 +25,7 @@ WRBUF wrbuf_alloc(void)
 {
     WRBUF n;
 
-    if (!(n = malloc(sizeof(*n))))
+    if (!(n = xmalloc(sizeof(*n))))
        abort();
     n->buf = 0;
     n->size = 0;
@@ -33,8 +36,8 @@ WRBUF wrbuf_alloc(void)
 void wrbuf_free(WRBUF b, int free_buf)
 {
     if (free_buf && b->buf)
-       free(b->buf);
-    free(b);
+       xfree(b->buf);
+    xfree(b);
 }
 
 void wrbuf_rewind(WRBUF b)
@@ -52,9 +55,9 @@ int wrbuf_grow(WRBUF b, int minsize)
        togrow = b->size;
     if (togrow < minsize)
        togrow = minsize;
-    if (b->size && !(b->buf = realloc(b->buf, b->size += togrow)))
+    if (b->size && !(b->buf =xrealloc(b->buf, b->size += togrow)))
        abort();
-    else if (!b->size && !(b->buf = malloc(b->size = togrow)))
+    else if (!b->size && !(b->buf = xmalloc(b->size = togrow)))
        abort();
     return 0;
 }
index a801874..55de4de 100644 (file)
@@ -15,13 +15,13 @@ static Z_AttributesPlusTerm *ccl_rpn_term (struct ccl_rpn_node *p)
     Odr_oct *term_octet;
     Z_Term *term;
 
-    zapt = malloc (sizeof(*zapt));
+    zapt = xmalloc (sizeof(*zapt));
     assert (zapt);
 
-    term_octet = malloc (sizeof(*term_octet));
+    term_octet = xmalloc (sizeof(*term_octet));
     assert (term_octet);
 
-    term = malloc(sizeof(*term));
+    term = xmalloc(sizeof(*term));
     assert(term);
 
     for (attr = p->u.t.attr_list; attr; attr = attr->next)
@@ -30,11 +30,11 @@ static Z_AttributesPlusTerm *ccl_rpn_term (struct ccl_rpn_node *p)
     if (num)
     {
         int i = 0;
-        zapt->attributeList = malloc (num*sizeof(*zapt->attributeList));
+        zapt->attributeList = xmalloc (num*sizeof(*zapt->attributeList));
         assert (zapt->attributeList);
         for (attr = p->u.t.attr_list; attr; attr = attr->next, i++)
         {
-            zapt->attributeList[i] = malloc (sizeof(**zapt->attributeList));
+            zapt->attributeList[i] = xmalloc (sizeof(**zapt->attributeList));
             assert (zapt->attributeList[i]);
             zapt->attributeList[i]->attributeType =
                 &attr->type;
@@ -63,7 +63,7 @@ static Z_Operand *ccl_rpn_simple (struct ccl_rpn_node *p)
 {
     Z_Operand *zo;
 
-    zo = malloc (sizeof(*zo));
+    zo = xmalloc (sizeof(*zo));
     assert (zo);
 
     switch (p->kind)
@@ -87,9 +87,9 @@ static Z_Complex *ccl_rpn_complex (struct ccl_rpn_node *p)
     Z_Complex *zc;
     Z_Operator *zo;
 
-    zc = malloc (sizeof(*zc));
+    zc = xmalloc (sizeof(*zc));
     assert (zc);
-    zo = malloc (sizeof(*zo));
+    zo = xmalloc (sizeof(*zo));
     assert (zo);
 
     zc->operator = zo;
@@ -119,7 +119,7 @@ static Z_RPNStructure *ccl_rpn_structure (struct ccl_rpn_node *p)
 {
     Z_RPNStructure *zs;
 
-    zs = malloc (sizeof(*zs));
+    zs = xmalloc (sizeof(*zs));
     assert (zs);
     switch (p->kind)
     {
@@ -145,7 +145,7 @@ Z_RPNQuery *ccl_rpn_query (struct ccl_rpn_node *p)
 {
     Z_RPNQuery *zq;
 
-    zq = malloc (sizeof(*zq));
+    zq = xmalloc (sizeof(*zq));
     assert (zq);
     zq->attributeSetId = NULL;
     zq->RPNStructure = ccl_rpn_structure (p);