Making data1 look for tables in data1_tabpath
authorSebastian Hammer <quinn@indexdata.com>
Wed, 1 Nov 1995 16:34:52 +0000 (16:34 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Wed, 1 Nov 1995 16:34:52 +0000 (16:34 +0000)
12 files changed:
include/data1.h
include/tpath.h [new file with mode: 0644]
retrieval/d1_absyn.c
retrieval/d1_attset.c
retrieval/d1_espec.c
retrieval/d1_map.c
retrieval/d1_marc.c
retrieval/d1_read.c
retrieval/d1_tagset.c
retrieval/d1_varset.c
util/Makefile
util/tpath.c [new file with mode: 0644]

index bd0747d..51fff44 100644 (file)
  * OF THIS SOFTWARE.
  *
  * $Log: data1.h,v $
- * Revision 1.2  1995-11-01 13:54:35  quinn
+ * Revision 1.3  1995-11-01 16:34:52  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.2  1995/11/01  13:54:35  quinn
  * Minor adjustments
  *
  * Revision 1.1  1995/11/01  13:07:18  quinn
@@ -83,6 +86,8 @@
 #include <d1_attset.h>
 #include <d1_map.h>
 
+extern char *data1_tabpath; /* global path for tables */
+
 #define DATA1_MAX_SYMBOL 31
 
 typedef struct data1_name
diff --git a/include/tpath.h b/include/tpath.h
new file mode 100644 (file)
index 0000000..94c50c9
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ */
+
+FILE *yaz_path_fopen(char *path, char *name, char *mode);
index 1322132..142b998 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_absyn.c,v $
- * Revision 1.2  1995-11-01 13:54:44  quinn
+ * Revision 1.3  1995-11-01 16:34:55  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.2  1995/11/01  13:54:44  quinn
  * Minor adjustments
  *
  * Revision 1.1  1995/11/01  11:56:06  quinn
@@ -22,6 +25,7 @@
 #include <xmalloc.h>
 #include <oid.h>
 #include <log.h>
+#include <tpath.h>
 
 #include <data1.h>
 
@@ -109,7 +113,7 @@ data1_absyn *data1_read_absyn(char *file)
     data1_marctab **marcp;
     int level = 0;
 
-    if (!(f = fopen(file, "r")))
+    if (!(f = yaz_path_fopen(data1_tabpath, file, "r")))
     {
        logf(LOG_WARN|LOG_ERRNO, "%s", file);
        return 0;
index 44dec99..2165004 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_attset.c,v $
- * Revision 1.1  1995-11-01 11:56:07  quinn
+ * Revision 1.2  1995-11-01 16:34:55  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.1  1995/11/01  11:56:07  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -18,6 +21,8 @@
 #include <xmalloc.h>
 #include <log.h>
 #include <d1_attset.h>
+#include <data1.h>
+#include <tpath.h>
 
 data1_att *data1_getattbyname(data1_attset *s, char *name)
 {
@@ -43,7 +48,7 @@ data1_attset *data1_read_attset(char *file)
     data1_att **attp;
     FILE *f;
 
-    if (!(f = fopen(file, "r")))
+    if (!(f = yaz_path_fopen(data1_tabpath, file, "r")))
     {
        logf(LOG_WARN|LOG_ERRNO, "%s", file);
        return 0;
index 181e256..dd27c11 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_espec.c,v $
- * Revision 1.1  1995-11-01 11:56:07  quinn
+ * Revision 1.2  1995-11-01 16:34:56  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.1  1995/11/01  11:56:07  quinn
  * Added Retrieval (data management) functions en masse.
  *
  *
@@ -20,6 +23,8 @@
 #include <proto.h>
 #include <log.h>
 #include <readconf.h>
+#include <tpath.h>
+#include <data1.h>
 
 /*
  * Read an element-set specification from a file. If !o, use xmalloc for
@@ -32,7 +37,7 @@ Z_Espec1 *data1_read_espec1(char *file, ODR o)
     char *argv[50], line[512];
     Z_Espec1 *res = odr_malloc(o, sizeof(*res));
 
-    if (!(f = fopen(file, "r")))
+    if (!(f = yaz_path_fopen(data1_tabpath, file, "r")))
     {
        logf(LOG_WARN|LOG_ERRNO, "%s", file);
        return 0;
index cec007e..d508330 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_map.c,v $
- * Revision 1.2  1995-11-01 13:54:46  quinn
+ * Revision 1.3  1995-11-01 16:34:56  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.2  1995/11/01  13:54:46  quinn
  * Minor adjustments
  *
  * Revision 1.1  1995/11/01  11:56:08  quinn
@@ -22,6 +25,7 @@
 #include <log.h>
 #include <readconf.h>
 
+#include <tpath.h>
 #include <data1.h>
 #include "d1_map.h"
 
@@ -33,7 +37,7 @@ data1_maptab *data1_read_maptab(char *file)
     char *argv[50], line[512];
     data1_mapunit **mapp;
 
-    if (!(f = fopen(file, "r")))
+    if (!(f = yaz_path_fopen(data1_tabpath, file, "r")))
     {
        logf(LOG_WARN|LOG_ERRNO, "%s", file);
        return 0;
index 786f2da..67329ed 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_marc.c,v $
- * Revision 1.2  1995-11-01 13:54:48  quinn
+ * Revision 1.3  1995-11-01 16:34:57  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.2  1995/11/01  13:54:48  quinn
  * Minor adjustments
  *
  * Revision 1.1  1995/11/01  11:56:08  quinn
@@ -23,6 +26,7 @@
 #include <readconf.h>
 #include <xmalloc.h>
 #include <data1.h>
+#include <tpath.h>
 
 #define ISO2709_RS 035
 #define ISO2709_FS 036
@@ -35,7 +39,7 @@ data1_marctab *data1_read_marctab(char *file)
     char line[512], *argv[50];
     int argc;
     
-    if (!(f = fopen(file, "r")))
+    if (!(f = yaz_path_fopen(data1_tabpath, file, "r")))
     {
        logf(LOG_WARN|LOG_ERRNO, "%s", file);
        return 0;
index 633ed62..01b1a09 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_read.c,v $
- * Revision 1.2  1995-11-01 13:54:48  quinn
+ * Revision 1.3  1995-11-01 16:34:57  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.2  1995/11/01  13:54:48  quinn
  * Minor adjustments
  *
  * Revision 1.1  1995/11/01  11:56:09  quinn
 #include <log.h>
 #include <data1.h>
 
+char *data1_tabpath = 0; /* global path for tables */
+
+void data1_set_tabpath(char *p)
+{ data1_tabpath = p; }
+
 static data1_node *freelist = 0;
 
 /*
index a8e4570..b3a8439 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_tagset.c,v $
- * Revision 1.2  1995-11-01 13:54:49  quinn
+ * Revision 1.3  1995-11-01 16:34:58  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.2  1995/11/01  13:54:49  quinn
  * Minor adjustments
  *
  * Revision 1.1  1995/11/01  11:56:09  quinn
@@ -20,6 +23,7 @@
 
 #include <xmalloc.h>
 #include <log.h>
+#include <tpath.h>
 
 #include <data1.h>
 
@@ -102,7 +106,7 @@ data1_tagset *data1_read_tagset(char *file)
     data1_tag **tagp;
     FILE *f;
 
-    if (!(f = fopen(file, "r")))
+    if (!(f = yaz_path_fopen(data1_tabpath, file, "r")))
     {
        logf(LOG_WARN|LOG_ERRNO, "%s", file);
        return 0;
index bbea607..f132610 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_varset.c,v $
- * Revision 1.2  1995-11-01 13:54:50  quinn
+ * Revision 1.3  1995-11-01 16:34:58  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ * Revision 1.2  1995/11/01  13:54:50  quinn
  * Minor adjustments
  *
  * Revision 1.1  1995/11/01  11:56:09  quinn
@@ -20,6 +23,7 @@
 #include <oid.h>
 #include <log.h>
 
+#include <tpath.h>
 #include <data1.h>
 
 data1_vartype *data1_getvartypebyct(data1_varset *set, char *class, char *type)
@@ -53,7 +57,7 @@ data1_varset *data1_read_varset(char *file)
     res->reference = VAL_NONE;
     res->classes = 0;
 
-    if (!(f = fopen(file, "r")))
+    if (!(f = yaz_path_fopen(data1_tabpath, file, "r")))
     {
        logf(LOG_WARN|LOG_ERRNO, "%s", file);
        return 0;
index 00b5723..c096cf5 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.15 1995-11-01 13:55:04 quinn Exp $
+# $Id: Makefile,v 1.16 1995-11-01 16:34:59 quinn Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
@@ -12,7 +12,7 @@ DEFS=$(INCLUDE)
 LIB=$(LIBDIR)/libutil.a
 LIBS=
 PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o \
-       xmalloc.o readconf.o # dmalloc.o
+       xmalloc.o readconf.o tpath.o # dmalloc.o 
 CPP=$(CC) -E
 RANLIB=ranlib
 
diff --git a/util/tpath.c b/util/tpath.c
new file mode 100644 (file)
index 0000000..ec4e981
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 1995, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: tpath.c,v $
+ * Revision 1.1  1995-11-01 16:35:00  quinn
+ * Making data1 look for tables in data1_tabpath
+ *
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+FILE *yaz_path_fopen(char *path, char *name, char *mode)
+{
+    char spath[512] = "";
+
+    if (!path)
+       return fopen(name, mode);
+
+    do
+    {
+       FILE *f;
+
+       if (sscanf(path, "%511[^:]", spath) < 1)
+           return 0;
+       sprintf(spath + strlen(spath), "/%s", name);
+       if ((f = fopen(spath, mode)))
+           return f;
+       if ((path = strchr(path, ':')))
+           path++;
+    }
+    while (path);
+    return 0;
+}