--- XXXXX
-New windows 95/NT port using MSV5.0.
+Added NT Services interface for Z39.50 Server.
+
+Windows 95/NT port using MSV5.0. Project files are included in
+the distribution.
+
+* Defined new 'global' handle for the retrieval (data1) system. The
+new handled, data1_handle, describes the state of the data1 system.
+This handle is passed as first argument to virtually all
+data1 related routines. The functions data1_create and data1_destroy
+creates and destroys a data1 handle respectively.
+
+Added ODR encode stream member to all backend request structures
+init, search, scan etc. This stream should be used to allocate all
+memory used for the response when thread safe operation is needed.
+
+Changed the comstack utility, cs_addstr, to be thread safe. The
+returned hostname string returned by the function is now part the
+COMSTACK instance.
+
+Added comstack utility, cs_straddr, which replaces the tcpip_strtoaddr
+function. The cs_straddr takes a COMSTACK handle as argument, so this
+function must be used after cs_create and before bind/connect.
+This function is thread safe.
Moved test server to 'ztest' directory - generic server code still
in 'server' directory.
# Copyright (C) 1995-1997, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.34 1997-09-05 09:50:55 adam Exp $
+# $Id: Makefile,v 1.35 1997-09-17 12:10:27 adam Exp $
# Uncomment the lines below to enable mOSI communcation.
#ODEFS=-DUSE_XTIMOSI
#LIBMOSI=../../xtimosi/src/libmosi.a ../lib/librfc.a
#XMOSI=xmosi.o
-CDEFS=$(ODEFS)
+CDEFS=$(ODEFS) # -DYAZ_UNICODE=0
#CC=
SHELL=/bin/sh
MAKE=make
all:
for i in $(SUBDIR); do cd $$i; if $(MAKE) $(CONTROL) \
- CFLAGS="$(CFLAGS) $(CDEFS)" LIBMOSI="$(LIBMOSI)" XMOSI="$(XMOSI)";\
+ CFLAGS="$(CFLAGS)" CDEFS="$(CDEFS)" LIBMOSI="$(LIBMOSI)" XMOSI="$(XMOSI)";\
then cd ..; else exit 1; fi; done
dep depend:
- for i in $(SUBDIR); do cd $$i; if $(MAKE) depend; then cd ..; else exit 1; fi; done
+ for i in $(SUBDIR); do cd $$i; if $(MAKE) CDEFS="$(CDEFS)" depend;\
+ then cd ..; else exit 1; fi; done
clean:
for i in $(SUBDIR); do (cd $$i; $(MAKE) clean); done
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
-Compilation and installation
+Compilation and installation for YAZ
The primary output of the source here is the lib/libyaz.a library,
which contains support functions for implementing the server or client
role of Z39.50/SR.
+Windows programmers: refer to the file MSVC.txt which describes
+how to compile the software using Microsoft Visual C++.
+
Two test-programs of interest are generated when you type 'make' at
-the top level. server/ztest and client/client. Ztest is a dummy database
+the top level: ztest/ztest and client/client. Ztest is a dummy database
server which returns canned responses to all queries. It's good for
verifying that the protocol works ok, and ztest.c shows a minimalistic
implementation of the 'backend' interface.
--- /dev/null
+YAZ TODO $Id: TODO,v 1.1 1997-09-17 12:10:27 adam Exp $
+
+NMEM has to be thread safe.
+
+Unicode support.
+
+Complete EXPLAIN support in retrieval module.
+
# Copyright (C) 1994, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.24 1996-10-09 15:54:54 quinn Exp $
+# $Id: Makefile,v 1.25 1997-09-17 12:10:28 adam Exp $
SHELL=/bin/sh
INCLUDE=-I../include -I.
LIBDIR=../lib
LIBINCLUDE=-L$(LIBDIR)
-DEFS=$(INCLUDE)
+DEFS=$(INCLUDE) $(CDEFS)
LIB=$(LIBDIR)/libasn.a
LIBS=-lodr -lasn
PO = proto.o diagbib1.o zget.o prt-rsc.o prt-acc.o prt-exp.o prt-ext.o \
mv -f Makefile.tmp Makefile
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
ifeq (.depend,$(wildcard .depend))
include .depend
# Europagate, 1995
#
# $Log: Makefile,v $
-# Revision 1.7 1997-04-30 08:52:05 quinn
+# Revision 1.8 1997-09-17 12:10:28 adam
+# YAZ version 1.4.
+#
+# Revision 1.7 1997/04/30 08:52:05 quinn
# Null
#
# Revision 1.6 1996/10/11 15:00:24 adam
LIB=../lib/ccl.a
PO=cclfind.o ccltoken.o cclerrms.o cclqual.o cclptree.o cclqfile.o cclstr.o
CPP=$(CC) -E
-DEFS=$(INCLUDE)
+DEFS=$(INCLUDE) $(CDEFS)
all: $(LIB)
# Copyright (C) 1994, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.11 1996-10-07 15:29:01 quinn Exp $
+# $Id: Makefile,v 1.12 1997-09-17 12:10:28 adam Exp $
LIBDIR=../lib
SHELL=/bin/sh
INCLUDE=-I../include -I. -I../../xtimosi/src
LIBINCLUDE=-L$(LIBDIR)
-DEFS=$(INCLUDE) -DCCL2RPN=1
+DEFS=$(INCLUDE) $(CDEFS) -DCCL2RPN=1
LIBS=$(LIBDIR)/libasn.a $(LIBDIR)/libodr.a \
$(LIBDIR)/libcomstack.a ../lib/ccl.a $(LIBMOSI) $(LIBDIR)/libutil.a $(ELIBS)
CPP=$(CC) -E
mv -f Makefile.tmp Makefile
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
ifeq (.depend,$(wildcard .depend))
include .depend
-
/*
- * Copyright (c) 1995-1996, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: client.c,v $
- * Revision 1.49 1997-09-04 13:45:17 adam
+ * Revision 1.50 1997-09-17 12:10:29 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.49 1997/09/04 13:45:17 adam
* Added UNImarc to list of available syntaxes.
*
* Revision 1.48 1997/09/01 08:48:44 adam
fprintf(stderr, "Usage: open (osi|tcp) ':' [tsel '/']host[':'port]\n");
return 0;
}
+ if (!strcmp(type, "tcp"))
+ {
+ t = tcpip_type;
+ protocol = PROTO_Z3950;
+ }
+ else
#ifdef USE_XTIMOSI
if (!strcmp(type, "osi"))
{
- if (!(add = mosi_strtoaddr(addr)))
- {
- perror(arg);
- return 0;
- }
t = mosi_type;
protocol = PROTO_SR;
}
else
#endif
- if (!strcmp(type, "tcp"))
{
- if (!(add = tcpip_strtoaddr(addr)))
- {
- perror(arg);
- return 0;
- }
- t = tcpip_type;
- protocol = PROTO_Z3950;
- }
- else
- {
- fprintf(stderr, "Bad type: %s\n", type);
- return 0;
+ fprintf(stderr, "Bad type: %s\n", type);
+ return 0;
}
if (!(conn = cs_create(t, 1, protocol)))
{
perror("cs_create");
return 0;
}
+ if (!(add = cs_straddr(conn, addr)))
+ {
+ perror(arg);
+ return 0;
+ }
printf("Connecting...");
fflush(stdout);
if (cs_connect(conn, add) < 0)
# Copyright (C) 1994, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.5 1996-05-22 08:35:46 adam Exp $
+# $Id: Makefile,v 1.6 1997-09-17 12:10:30 adam Exp $
LIBDIR=../lib
SHELL=/bin/sh
INCLUDE=-I../include -I. -I../../xtimosi/src
LIBINCLUDE=-L$(LIBDIR) -L../../xtimosi/src
-DEFS=$(INCLUDE) # -DTRACE_TCPIP
+DEFS=$(INCLUDE) $(CDEFS) # -DTRACE_TCPIP
LIB= $(LIBDIR)/libcomstack.a
LIBS=$(LIBDIR)/libasn.a $(LIBDIR)/libodr.a $(LIBDIR)/libcomstack.a \
../lib/ccl.a $(LIBDIR)/libutil.a $(LIBMOSI)
mv -f Makefile.tmp Makefile
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
ifeq (.depend,$(wildcard .depend))
include .depend
/*
- * Copyright (c) 1995, Index Data
+ * Copyright (c) 1995-1997, Index Data
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: tcpip.c,v $
- * Revision 1.16 1997-09-01 08:49:14 adam
+ * Revision 1.17 1997-09-17 12:10:30 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.16 1997/09/01 08:49:14 adam
* New windows NT/95 port using MSV5.0. Minor changes only.
*
* Revision 1.15 1997/05/14 06:53:33 adam
int tcpip_listen(COMSTACK h, char *addrp, int *addrlen);
COMSTACK tcpip_accept(COMSTACK h);
char *tcpip_addrstr(COMSTACK h);
+void *tcpip_straddr(COMSTACK h, const char *str);
/*
* Determine length/completeness of incoming packages
int written; /* -1 if we aren't writing */
int towrite; /* to verify against user input */
int (*complete)(unsigned char *buf, int len); /* length/completeness */
+ struct sockaddr_in addr; /* returned by cs_straddr */
+ char buf[128]; /* returned by cs_addrstr */
} tcpip_state;
#ifdef WINDOWS
p->f_listen = tcpip_listen;
p->f_accept = tcpip_accept;
p->f_addrstr = tcpip_addrstr;
+ p->f_straddr = tcpip_straddr;
p->state = new_socket ? CS_UNBND : CS_IDLE; /* state of line */
p->event = CS_NONE;
return p;
}
-struct sockaddr_in *tcpip_strtoaddr(const char *str)
+static int tcpip_strtoaddr_ex(const char *str, struct sockaddr_in *add)
{
- static struct sockaddr_in add;
struct hostent *hp;
char *p, buf[512];
short int port = 210;
if (!tcpip_init ())
return 0;
TRC(fprintf(stderr, "tcpip_strtoaddress: %s\n", str ? str : "NULL"));
- add.sin_family = AF_INET;
+ add->sin_family = AF_INET;
strcpy(buf, str);
if ((p = strchr(buf, ':')))
{
*p = 0;
port = atoi(p + 1);
}
- add.sin_port = htons(port);
+ add->sin_port = htons(port);
if (!strcmp("@", buf))
- add.sin_addr.s_addr = INADDR_ANY;
+ add->sin_addr.s_addr = INADDR_ANY;
else if ((hp = gethostbyname(buf)))
- memcpy(&add.sin_addr.s_addr, *hp->h_addr_list, sizeof(struct in_addr));
+ memcpy(&add->sin_addr.s_addr, *hp->h_addr_list,
+ sizeof(struct in_addr));
else if ((tmpadd = (unsigned) inet_addr(buf)) != 0)
- memcpy(&add.sin_addr.s_addr, &tmpadd, sizeof(struct in_addr));
+ memcpy(&add->sin_addr.s_addr, &tmpadd, sizeof(struct in_addr));
else
return 0;
+ return 1;
+}
+
+void *tcpip_straddr(COMSTACK h, const char *str)
+{
+ tcpip_state *sp = h->cprivate;
+
+ if (!tcpip_strtoaddr_ex (str, &sp->addr))
+ return 0;
+ return &sp->addr;
+}
+
+struct sockaddr_in *tcpip_strtoaddr(const char *str)
+{
+ static struct sockaddr_in add;
+
+ if (!tcpip_strtoaddr_ex (str, &add))
+ return 0;
return &add;
}
int tcpip_more(COMSTACK h)
{
tcpip_state *sp = h->cprivate;
-
+
return sp->altlen && (*sp->complete)((unsigned char *) sp->altbuf,
sp->altlen);
}
char *tcpip_addrstr(COMSTACK h)
{
struct sockaddr_in addr;
- static char buf[64];
- char *r;
+ tcpip_state *sp = h->cprivate;
+ char *r, *buf = sp->buf;
int len;
struct hostent *host;
-
+
len = sizeof(addr);
if (getpeername(h->iofile, (struct sockaddr*) &addr, &len) < 0)
{
return 0;
}
if ((host = gethostbyaddr((char*)&addr.sin_addr, sizeof(addr.sin_addr),
- AF_INET)))
+ AF_INET)))
r = (char*) host->h_name;
else
r = inet_ntoa(addr.sin_addr);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: xmosi.c,v $
- * Revision 1.15 1997-05-14 06:53:34 adam
+ * Revision 1.16 1997-09-17 12:10:30 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.15 1997/05/14 06:53:34 adam
* C++ support.
*
* Revision 1.14 1996/07/26 12:34:07 quinn
#include <string.h>
#include <assert.h>
-<<<<<<< 1.13
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-=======
#define YNETINCLUDE
#include <yconfig.h>
->>>>>>> /tmp/T4a00144
#include <comstack.h>
#include <xmosi.h>
int mosi_listen(COMSTACK h, char *addrp, int *addrlen);
COMSTACK mosi_accept(COMSTACK h);
char *mosi_addrstr(COMSTACK h);
+void *mosi_straddr(COMSTACK h, const char *str);
typedef struct mosi_state
{
struct t_call *call;
int hasread; /* how many bytes read of current PDU */
int haswrit; /* how many bytes have we written */
+ struct netbuf netbuf;
} mosi_state;
static char *oidtostr(int *o)
r->f_listen = mosi_listen;
r->f_accept = mosi_accept;
r->f_addrstr = mosi_addrstr;
+ r->r_straddr = mosi_straddr;
if (!blocking)
flags |= O_NONBLOCK;
* addressing specific to our hack of OSI transport. A sockaddr_in wrapped
* up in a t_mosiaddr in a netbuf (on a stick).
*/
-struct netbuf MDF *mosi_strtoaddr(const char *str)
+
+int MDF *mosi_strtoaddr_ex(const char *str, struct netbuf *ret)
{
- 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;
ret->buf = (char*)mosiaddr;
ret->len = ret->maxlen = 100 /* sizeof(*mosiaddr) */ ;
+ return 1;
+}
+
+struct netbuf MDF *mosi_strtoaddr(const char *str)
+{
+ struct netbuf *ret = xmalloc(sizeof(struct netbuf));
+
+ if (!mosi_strtoaddr_ex (str, ret))
+ {
+ xfree (ret);
+ return 0;
+ }
+ return ret;
+}
+
+struct netbuf MDF *mosi_straddr(COMSTACK h, const char *str)
+{
+ mosi_state *st = h->cprivate;
+ struct netbuf *ret = &st->netbuf;
+
+ if (!mosi_strtoaddr_ex (str, ret))
+ {
+ xfree (ret);
+ return 0;
+ }
return ret;
}
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, 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,
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
+ * $Log: backend.h,v $
+ * Revision 1.16 1997-09-17 12:10:31 adam
+ * YAZ version 1.4.
+ *
*/
#ifndef BACKEND_H
{
char *configname;
Z_IdAuthentication *auth;
+ ODR stream; /* encoding stream */
} bend_initrequest;
typedef struct bend_initresult
* OF THIS SOFTWARE.
*
* $Log: comstack.h,v $
- * Revision 1.17 1997-09-01 08:49:47 adam
+ * Revision 1.18 1997-09-17 12:10:31 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.17 1997/09/01 08:49:47 adam
* New windows NT/95 port using MSV5.0. To export DLL functions the
* YAZ_EXPORT modifier was added. Defined in yconfig.h.
*
COMSTACK (*f_accept)(COMSTACK handle);
int (*f_close)(COMSTACK handle);
char *(*f_addrstr)(COMSTACK handle);
+ void *(*f_straddr)(COMSTACK handle, const char *str);
};
#define cs_put(handle, buf, size) ((*(handle)->f_put)(handle, buf, size))
#define cs_errno(handle) ((handle)->cerrno)
#define cs_getproto(handle) ((handle)->protocol)
#define cs_addrstr(handle) ((*(handle)->f_addrstr)(handle))
+#define cs_straddr(handle, str) ((*(handle)->f_straddr)(handle, str))
YAZ_EXPORT const char *cs_strerror(COMSTACK h);
YAZ_EXPORT const char *cs_errmsg(int n);
struct data1_attset *next; /* sibling */
} data1_attset;
-YAZ_EXPORT data1_att *data1_getattbyname(data1_attset *s, char *name);
-YAZ_EXPORT data1_attset *data1_read_attset(char *file);
+typedef struct data1_handle_info *data1_handle;
+
+YAZ_EXPORT data1_att *data1_getattbyname(data1_handle dh, data1_attset *s,
+ char *name);
+YAZ_EXPORT data1_attset *data1_read_attset(data1_handle dh, char *file);
#ifdef __cplusplus
}
* OF THIS SOFTWARE.
*
* $Log: data1.h,v $
- * Revision 1.25 1997-09-05 09:50:55 adam
+ * Revision 1.26 1997-09-17 12:10:32 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.25 1997/09/05 09:50:55 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.24 1997/09/01 09:30:39 adam
#include <d1_attset.h>
#include <d1_map.h>
#include <yaz-util.h>
+#include <wrbuf.h>
#ifdef __cplusplus
extern "C" {
struct data1_name *next;
} data1_name;
+typedef struct data1_absyn_cache_info *data1_absyn_cache;
+
typedef enum data1_datatype
{
DATA1K_structured = 1,
struct data1_node *root;
} data1_node;
-YAZ_EXPORT data1_node *get_parent_tag(data1_node *n);
-YAZ_EXPORT data1_node *data1_read_node(char **buf, data1_node *parent,
+YAZ_EXPORT data1_handle data1_create (void);
+YAZ_EXPORT void data1_destroy(data1_handle dh);
+YAZ_EXPORT data1_node *get_parent_tag(data1_handle dh, data1_node *n);
+YAZ_EXPORT data1_node *data1_read_node(data1_handle dh, char **buf,
+ data1_node *parent,
int *line, data1_absyn *absyn, NMEM m);
-YAZ_EXPORT data1_node *data1_read_record(int (*rf)(void *, char *, size_t),
+YAZ_EXPORT data1_node *data1_read_record(data1_handle dh,
+ int (*rf)(void *, char *, size_t),
void *fh, NMEM m);
-YAZ_EXPORT data1_absyn *data1_read_absyn(char *file);
-YAZ_EXPORT data1_tag *data1_gettagbynum(data1_tagset *s, int type, int value);
-YAZ_EXPORT data1_tagset *data1_read_tagset(char *file);
-YAZ_EXPORT data1_element *data1_getelementbytagname(data1_absyn *abs,
+YAZ_EXPORT data1_absyn *data1_read_absyn(data1_handle dh, const char *file);
+YAZ_EXPORT data1_tag *data1_gettagbynum(data1_handle dh, data1_tagset *s,
+ int type, int value);
+YAZ_EXPORT data1_tagset *data1_read_tagset(data1_handle dh, char *file);
+YAZ_EXPORT data1_element *data1_getelementbytagname(data1_handle dh,
+ data1_absyn *abs,
data1_element *parent,
char *tagname);
-YAZ_EXPORT Z_GenericRecord *data1_nodetogr(data1_node *n, int select, ODR o,
+YAZ_EXPORT Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n,
+ int select, ODR o,
int *len);
-YAZ_EXPORT data1_tag *data1_gettagbyname(data1_tagset *s, char *name);
-YAZ_EXPORT void data1_free_tree(data1_node *t);
-YAZ_EXPORT char *data1_nodetobuf(data1_node *n, int select, int *len);
-YAZ_EXPORT data1_node *data1_insert_taggeddata(data1_node *root,
+YAZ_EXPORT data1_tag *data1_gettagbyname(data1_handle dh, data1_tagset *s,
+ char *name);
+YAZ_EXPORT void data1_free_tree(data1_handle dh, data1_node *t);
+YAZ_EXPORT char *data1_nodetobuf(data1_handle dh, data1_node *n,
+ int select, int *len);
+YAZ_EXPORT data1_node *data1_insert_taggeddata(data1_handle dh,
+ data1_node *root,
data1_node *at,
char *tagname, NMEM m);
-YAZ_EXPORT data1_datatype data1_maptype(char *t);
-YAZ_EXPORT data1_varset *data1_read_varset(char *file);
-YAZ_EXPORT data1_vartype *data1_getvartypebyct(data1_varset *set,
+YAZ_EXPORT data1_datatype data1_maptype(data1_handle dh, char *t);
+YAZ_EXPORT data1_varset *data1_read_varset(data1_handle dh, const char *file);
+YAZ_EXPORT data1_vartype *data1_getvartypebyct(data1_handle dh,
+ data1_varset *set,
char *zclass, char *type);
-YAZ_EXPORT Z_Espec1 *data1_read_espec1(char *file, ODR o);
-YAZ_EXPORT int data1_doespec1(data1_node *n, Z_Espec1 *e);
-YAZ_EXPORT data1_esetname *data1_getesetbyname(data1_absyn *a, char *name);
-YAZ_EXPORT data1_element *data1_getelementbyname(data1_absyn *absyn,
+YAZ_EXPORT Z_Espec1 *data1_read_espec1(data1_handle dh, const char *file,
+ ODR o);
+YAZ_EXPORT int data1_doespec1(data1_handle dh, data1_node *n, Z_Espec1 *e);
+YAZ_EXPORT data1_esetname *data1_getesetbyname(data1_handle dh,
+ data1_absyn *a, char *name);
+YAZ_EXPORT data1_element *data1_getelementbyname(data1_handle dh,
+ data1_absyn *absyn,
char *name);
-YAZ_EXPORT data1_node *data1_mk_node(NMEM m);
-YAZ_EXPORT data1_absyn *data1_get_absyn(char *name);
-YAZ_EXPORT data1_maptab *data1_read_maptab(char *file);
-YAZ_EXPORT data1_node *data1_map_record(data1_node *n, data1_maptab *map,
- NMEM m);
-YAZ_EXPORT data1_marctab *data1_read_marctab(char *file);
-YAZ_EXPORT char *data1_nodetomarc(data1_marctab *p, data1_node *n,
- int selected, int *len);
-YAZ_EXPORT char *data1_nodetoidsgml(data1_node *n, int select, int *len);
-YAZ_EXPORT Z_ExplainRecord *data1_nodetoexplain(data1_node *n, int select,
+YAZ_EXPORT data1_node *data1_mk_node(data1_handle dh, NMEM m);
+YAZ_EXPORT data1_absyn *data1_get_absyn(data1_handle dh, char *name);
+YAZ_EXPORT data1_maptab *data1_read_maptab(data1_handle dh, const char *file);
+YAZ_EXPORT data1_node *data1_map_record(data1_handle dh, data1_node *n,
+ data1_maptab *map, NMEM m);
+YAZ_EXPORT data1_marctab *data1_read_marctab (data1_handle dh,
+ const char *file);
+YAZ_EXPORT char *data1_nodetomarc(data1_handle dh, data1_marctab *p,
+ data1_node *n, int selected, int *len);
+YAZ_EXPORT char *data1_nodetoidsgml(data1_handle dh, data1_node *n,
+ int select, int *len);
+YAZ_EXPORT Z_ExplainRecord *data1_nodetoexplain(data1_handle dh,
+ data1_node *n, int select,
ODR o);
-YAZ_EXPORT Z_BriefBib *data1_nodetosummary(data1_node *n, int select,
+YAZ_EXPORT Z_BriefBib *data1_nodetosummary(data1_handle dh,
+ data1_node *n, int select,
ODR o);
-YAZ_EXPORT char *data1_nodetosoif(data1_node *n, int select,
+YAZ_EXPORT char *data1_nodetosoif(data1_handle dh, data1_node *n, int select,
int *len);
-YAZ_EXPORT void data1_set_tabpath(const char *path);
-YAZ_EXPORT const char *data1_get_tabpath(void);
+YAZ_EXPORT void data1_set_tabpath(data1_handle dh, const char *path);
+YAZ_EXPORT const char *data1_get_tabpath(data1_handle dh);
+
+YAZ_EXPORT WRBUF data1_get_wrbuf (data1_handle dp);
+YAZ_EXPORT char **data1_get_read_buf (data1_handle dp, int **lenp);
+YAZ_EXPORT data1_absyn_cache *data1_absyn_cache_get (data1_handle dh);
+YAZ_EXPORT NMEM data1_nmem_get (data1_handle dh);
#ifdef __cplusplus
}
YAZ_EXPORT int nmem_total(NMEM n);
YAZ_EXPORT NMEM nmem_create(void);
YAZ_EXPORT void nmem_destroy(NMEM n);
+YAZ_EXPORT char *nmem_strdup (NMEM mem, const char *src);
#ifdef __cplusplus
}
YAZ_EXPORT int odr_initmember(ODR o, void *p, int size);
YAZ_EXPORT int odr_peektag(ODR o, int *zclass, int *tag, int *cons);
YAZ_EXPORT void odr_setlenlen(ODR o, int len);
-
#ifdef __cplusplus
}
#endif
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, 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,
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
+ * $Log: wrbuf.h,v $
+ * Revision 1.5 1997-09-17 12:10:32 adam
+ * YAZ version 1.4.
+ *
*/
#ifndef WRBUF_H
* Current software version.
*
* $Log: yaz-version.h,v $
- * Revision 1.14 1997-04-30 08:52:09 quinn
+ * Revision 1.15 1997-09-17 12:10:33 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.14 1997/04/30 08:52:09 quinn
* Null
*
* Revision 1.13 1996/10/11 15:06:55 quinn
*/
#ifndef YAZ_VERSION
-#define YAZ_VERSION "1.3"
+#define YAZ_VERSION "1.4"
#endif
# Copyright (C) 1994, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.25 1996-08-12 14:09:54 adam Exp $
+# $Id: Makefile,v 1.26 1997-09-17 12:10:33 adam Exp $
SHELL=/bin/sh
INCLUDE=-I../include -I.
LIBDIR=../lib
LIBINCLUDE=-L$(LIBDIR)
-DEFS=$(INCLUDE) # -DODR_DEBUG
+DEFS=$(INCLUDE) $(CDEFS) # -DODR_DEBUG
LIB=$(LIBDIR)/libodr.a
LIBS=-lodr
PO = odr_bool.o ber_bool.o ber_len.o ber_tag.o odr_util.o odr_null.o \
ber_null.o odr_int.o ber_int.o odr_tag.o odr_cons.o odr_seq.o\
odr_oct.o ber_oct.o odr_bit.o ber_bit.o odr_oid.o ber_oid.o odr_use.o \
- odr_choice.o odr_any.o ber_any.o odr.o odr_mem.o dumpber.o
+ odr_choice.o odr_any.o ber_any.o odr.o odr_mem.o dumpber.o \
+ odr_unicode.o
CPP=$(CC) -E
RANLIB=ranlib
mv -f Makefile.tmp Makefile
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
ifeq (.depend,$(wildcard .depend))
include .depend
/*
- * Copyright (c) 1995, Index Data
+ * Copyright (c) 1995-1997, Index Data
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ber_tag.c,v $
- * Revision 1.15 1997-09-01 08:51:06 adam
+ * Revision 1.16 1997-09-17 12:10:33 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.15 1997/09/01 08:51:06 adam
* New windows NT/95 port using MSV5.0. Had to avoid a few static
* variables used in function ber_tag. These are now part of the
* ODR structure.
* else leave pointer unchanged. Return 0.
*
* Should perhaps be odr_tag?
-*/
+ */
int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt)
{
-#if 0
- static int lclass = -1, ltag, br, lcons; /* save t&c rather than
- decoding twice */
-#endif
Odr_ber_tag *odr_ber_tag = &o->odr_ber_tag;
int rd;
char **pp = p;
-# $Id: Makefile,v 1.8 1996-10-07 15:29:32 quinn Exp $
+# $Id: Makefile,v 1.9 1997-09-17 12:10:34 adam Exp $
SHELL=/bin/sh
RANLIB=ranlib
INCLUDE=-I../include -I.
-DEFS=$(INCLUDE)
+DEFS=$(INCLUDE) $(CDEFS)
LIB=../lib/libret.a
-PO = d1_read.o d1_attset.o d1_tagset.o d1_absyn.o d1_grs.o \
+PO = d1_handle.o d1_read.o d1_attset.o d1_tagset.o d1_absyn.o d1_grs.o \
d1_sutrs.o d1_varset.o d1_espec.o \
d1_doespec.o d1_map.o d1_marc.o d1_write.o d1_expout.o d1_sumout.o \
d1_soif.o
depend1:
mv Makefile Makefile.tmp
sed '/^#Depend/q' <Makefile.tmp >Makefile
- $(CPP) $(INCLUDE) -M *.c >>Makefile
+ $(CPP) $(DEFS) -M *.c >>Makefile
-rm Makefile.tmp
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
ifeq (.depend,$(wildcard .depend))
include .depend
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_absyn.c,v $
- * Revision 1.11 1997-09-05 09:50:55 adam
+ * Revision 1.12 1997-09-17 12:10:34 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.11 1997/09/05 09:50:55 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.10 1997/05/14 06:54:01 adam
#include <stdlib.h>
#include <string.h>
-#include <xmalloc.h>
#include <oid.h>
#include <log.h>
#include <tpath.h>
#include <data1.h>
#define D1_MAX_NESTING 128
-#define DATA1_MAX_SYNTAXES 30 /* max no of syntaxes to handle in one session */
-static struct /* cache of abstract syntaxes */
+struct data1_absyn_cache_info
{
char *name;
data1_absyn *absyn;
-} syntaxes[DATA1_MAX_SYNTAXES] = {{0,0}};
+ data1_absyn_cache next;
+};
-data1_absyn *data1_get_absyn(char *name)
+data1_absyn *data1_absyn_search (data1_handle dh, const char *name)
{
- char fname[512];
- int i;
-
- for (i = 0; syntaxes[i].name; i++)
- if (!strcmp(name, syntaxes[i].name))
- return syntaxes[i].absyn;
+ data1_absyn_cache p = *data1_absyn_cache_get (dh);
- if (i >= DATA1_MAX_SYNTAXES - 1)
+ while (p)
{
- logf(LOG_WARN, "Too many abstract syntaxes loaded");
- return 0;
+ if (!strcmp (name, p->name))
+ return p->absyn;
+ p = p->next;
}
+ return NULL;
+}
+
+data1_absyn *data1_absyn_add (data1_handle dh, const char *name)
+{
+ char fname[512];
+ NMEM mem = data1_nmem_get (dh);
+
+ data1_absyn_cache p = nmem_malloc (mem, sizeof(*p));
+ data1_absyn_cache *pp = data1_absyn_cache_get (dh);
+
sprintf(fname, "%s.abs", name);
- if (!(syntaxes[i].absyn = data1_read_absyn(fname)))
- return 0;
- if (!(syntaxes[i].name = xmalloc(strlen(name)+1)))
- abort();
- strcpy(syntaxes[i].name, name);
- syntaxes[i+1].name = 0;
- return syntaxes[i].absyn;
+ p->absyn = data1_read_absyn (dh, fname);
+ p->name = nmem_strdup (mem, name);
+ p->next = *pp;
+ *pp = p;
+ return p->absyn;
}
-data1_esetname *data1_getesetbyname(data1_absyn *a, char *name)
+data1_absyn *data1_get_absyn (data1_handle dh, char *name)
+{
+ data1_absyn *absyn;
+
+ if (!(absyn = data1_absyn_search (dh, name)))
+ absyn = data1_absyn_add (dh, name);
+ return absyn;
+}
+
+data1_esetname *data1_getesetbyname(data1_handle dh, data1_absyn *a,
+ char *name)
{
data1_esetname *r;
return 0;
}
-data1_element *data1_getelementbytagname(data1_absyn *abs,
- data1_element *parent, char *tagname)
+data1_element *data1_getelementbytagname (data1_handle dh, data1_absyn *abs,
+ data1_element *parent,
+ char *tagname)
{
data1_element *r;
return 0;
}
-data1_element *data1_getelementbyname(data1_absyn *absyn, char *name)
+data1_element *data1_getelementbyname (data1_handle dh, data1_absyn *absyn,
+ char *name)
{
data1_element *r;
return 0;
}
-data1_absyn *data1_read_absyn(char *file)
+data1_absyn *data1_read_absyn (data1_handle dh, const char *file)
{
char line[512], *r, cmd[512], args[512];
data1_absyn *res = 0;
data1_termlist *all = 0;
int level = 0;
- if (!(f = yaz_path_fopen(data1_get_tabpath(), file, "r")))
+ if (!(f = yaz_path_fopen(data1_get_tabpath (dh), file, "r")))
{
logf(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
}
- if (!(res = xmalloc(sizeof(*res))))
- abort();
+ res = nmem_malloc(data1_nmem_get(dh), sizeof(*res));
res->name = 0;
res->reference = VAL_NONE;
res->tagset = 0;
return 0;
}
level = i;
- if (!(new_element = cur[level] = *ppl[level] = xmalloc(sizeof(*new_element))))
- abort;
+ new_element = cur[level] = *ppl[level] =
+ nmem_malloc(data1_nmem_get(dh), sizeof(*new_element));
new_element->next = new_element->children = 0;
new_element->tag = 0;
new_element->termlists = 0;
tp = &new_element->termlists;
ppl[level] = &new_element->next;
ppl[level+1] = &new_element->children;
-
+
/* well-defined tag */
if (sscanf(p, "(%d,%d)", &type, &value) == 2)
{
fclose(f);
return 0;
}
- if (!(new_element->tag = data1_gettagbynum(res->tagset, type, value)))
+ if (!(new_element->tag = data1_gettagbynum (dh, res->tagset,
+ type, value)))
{
logf(LOG_WARN, "Couldn't find tag %s in tagset in %s",
p, file);
/* private tag */
else if (*p)
{
- data1_tag *nt = new_element->tag = xmalloc(sizeof(*new_element->tag));
+ data1_tag *nt =
+ new_element->tag = nmem_malloc(data1_nmem_get (dh),
+ sizeof(*new_element->tag));
nt->which = DATA1T_string;
nt->value.string = xstrdup(p);
- nt->names = xmalloc(sizeof(*new_element->tag->names));
+ nt->names = nmem_malloc(data1_nmem_get(dh),
+ sizeof(*new_element->tag->names));
nt->names->name = nt->value.string;
nt->names->next = 0;
nt->kind = DATA1K_string;
}
if (*attname == '!')
strcpy(attname, name);
- *tp = xmalloc(sizeof(**tp));
- if (!((*tp)->att = data1_getattbyname(res->attset,
- attname)))
+ *tp = nmem_malloc(data1_nmem_get(dh), sizeof(**tp));
+ (*tp)->next = 0;
+ if (!((*tp)->att = data1_getattbyname(dh, res->attset,
+ attname)))
{
logf(LOG_WARN, "Couldn't find att '%s' in attset",
- attname);
+ attname);
fclose(f);
return 0;
}
else if (!data1_matchstr(structure, "p"))
(*tp)->structure = DATA1S_phrase;
- (*tp)->next = 0;
tp = &(*tp)->next;
}
while ((p = strchr(p, ',')) && *(++p));
fclose(f);
return 0;
}
- *tp = xmalloc(sizeof(**tp));
- if (!((*tp)->att = data1_getattbyname(res->attset,
- attname)))
+ *tp = nmem_malloc(data1_nmem_get(dh), sizeof(**tp));
+ if (!((*tp)->att = data1_getattbyname (dh, res->attset,
+ attname)))
{
logf(LOG_WARN, "Couldn't find att '%s' in attset",
- attname);
+ attname);
fclose(f);
return 0;
}
(*tp)->structure = DATA1S_word;
else if (!data1_matchstr(structure, "p"))
(*tp)->structure = DATA1S_phrase;
-
+
(*tp)->next = 0;
tp = &(*tp)->next;
}
fclose(f);
return 0;
}
- if (!(res->name = xmalloc(strlen(args)+1)))
- abort();
- strcpy(res->name, name);
+ res->name = nmem_strdup(data1_nmem_get(dh), args);
}
else if (!strcmp(cmd, "reference"))
{
fclose(f);
return 0;
}
- if (!(res->attset = data1_read_attset(name)))
+ if (!(res->attset = data1_read_attset (dh, name)))
{
logf(LOG_WARN, "Attset failed in %s", file);
fclose(f);
fclose(f);
return 0;
}
- if (!(res->tagset = data1_read_tagset(name)))
+ if (!(res->tagset = data1_read_tagset (dh, name)))
{
logf(LOG_WARN, "Tagset failed in %s", file);
fclose(f);
fclose(f);
return 0;
}
- if (!(res->varset = data1_read_varset(name)))
+ if (!(res->varset = data1_read_varset (dh, name)))
{
logf(LOG_WARN, "Varset failed in %s", file);
fclose(f);
fclose(f);
return 0;
}
- *esetpp = xmalloc(sizeof(**esetpp));
- (*esetpp)->name = xmalloc(strlen(name)+1);
- strcpy((*esetpp)->name, name);
+ *esetpp = nmem_malloc(data1_nmem_get(dh), sizeof(**esetpp));
+ (*esetpp)->name = nmem_strdup(data1_nmem_get(dh), name);
+ (*esetpp)->next = 0;
if (*fname == '@')
(*esetpp)->spec = 0;
- else if (!((*esetpp)->spec = data1_read_espec1(fname, 0)))
+ else if (!((*esetpp)->spec = data1_read_espec1 (dh, fname, 0)))
{
logf(LOG_WARN, "%s: Espec-1 read failed", file);
fclose(f);
return 0;
}
- (*esetpp)->next = 0;
esetpp = &(*esetpp)->next;
}
else if (!strcmp(cmd, "maptab"))
file);
continue;
}
- if (!(*maptabp = data1_read_maptab(name)))
+ if (!(*maptabp = data1_read_maptab (dh, name)))
{
logf(LOG_WARN, "%s: Failed to read maptab.");
continue;
file);
continue;
}
- if (!(*marcp = data1_read_marctab(name)))
+ if (!(*marcp = data1_read_marctab (dh, name)))
{
logf(LOG_WARN, "%s: Failed to read marctab.");
continue;
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_attset.c,v $
- * Revision 1.6 1997-09-05 09:50:56 adam
+ * Revision 1.7 1997-09-17 12:10:34 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.6 1997/09/05 09:50:56 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.5 1996/05/09 07:27:43 quinn
#include <assert.h>
#include <stdlib.h>
-#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)
+data1_att *data1_getattbyname(data1_handle dh, data1_attset *s, char *name)
{
data1_att *r;
if (!data1_matchstr(r->name, name))
return r;
/* scan included sets */
- if (s->children && (r = data1_getattbyname(s->children, name)))
+ if (s->children && (r = data1_getattbyname (dh, s->children, name)))
return r;
}
return 0;
}
-data1_attset *data1_read_attset(char *file)
+data1_attset *data1_read_attset(data1_handle dh, char *file)
{
char line[512], *r, cmd[512], args[512];
data1_attset *res = 0, **childp;
data1_att **attp;
FILE *f;
+ NMEM mem = data1_nmem_get (dh);
- if (!(f = yaz_path_fopen(data1_get_tabpath(), file, "r")))
+ if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
{
logf(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
}
- if (!(res = xmalloc(sizeof(*res))))
- abort();
+ res = nmem_malloc(mem, sizeof(*res));
res->name = 0;
res->reference = VAL_NONE;
res->ordinal = -1;
}
if (rr < 3) /* no local attributes given */
{
- locals = xmalloc(sizeof(*locals));
+ locals = nmem_malloc(mem, sizeof(*locals));
locals->local = num;
locals->next = 0;
}
data1_local_attribute **ap = &locals;
do
{
- *ap = xmalloc(sizeof(**ap));
+ *ap = nmem_malloc(mem, sizeof(**ap));
(*ap)->local = atoi(p);
(*ap)->next = 0;
ap = &(*ap)->next;
}
while ((p = strchr(p, ',')) && *(++p));
}
- if (!(t = *attp = xmalloc(sizeof(*t))))
- abort();
+ t = *attp = nmem_malloc(mem, sizeof(*t));
t->parent = res;
- if (!(t->name = xmalloc(strlen(name)+1)))
- abort();
- strcpy(t->name, name);
+ t->name = nmem_strdup(mem, name);
t->value = num;
t->locals = locals;
t->next = 0;
fclose(f);
return 0;
}
- if (!(res->name = xmalloc(strlen(args)+1)))
- abort();
- strcpy(res->name, name);
+ res->name = nmem_strdup(mem, args);
}
else if (!strcmp(cmd, "reference"))
{
fclose(f);
return 0;
}
- if (!(*childp = data1_read_attset(name)))
+ if (!(*childp = data1_read_attset (dh, name)))
{
logf(LOG_WARN, "Inclusion failed in %s", file);
fclose(f);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_doespec.c,v $
- * Revision 1.8 1997-05-14 06:54:02 adam
+ * Revision 1.9 1997-09-17 12:10:35 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.8 1997/05/14 06:54:02 adam
* C++ support.
*
* Revision 1.7 1997/04/30 08:52:11 quinn
return res;
}
-int data1_doespec1(data1_node *n, Z_Espec1 *e)
+int data1_doespec1 (data1_handle dh, data1_node *n, Z_Espec1 *e)
{
int i;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_espec.c,v $
- * Revision 1.8 1997-09-05 09:50:56 adam
+ * Revision 1.9 1997-09-17 12:10:35 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.8 1997/09/05 09:50:56 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.7 1997/05/14 06:54:02 adam
* Read an element-set specification from a file.
* NOTE: If !o, memory is allocated directly from the heap by odr_malloc().
*/
-Z_Espec1 *data1_read_espec1(char *file, ODR o)
+Z_Espec1 *data1_read_espec1 (data1_handle dh, const char *file, ODR o)
{
FILE *f;
int argc, size_esn = 0;
char *argv[50], line[512];
Z_Espec1 *res = odr_malloc(o, sizeof(*res));
- if (!(f = yaz_path_fopen(data1_get_tabpath(), file, "r")))
+ if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
{
logf(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_expout.c,v $
- * Revision 1.2 1995-12-14 16:28:30 quinn
+ * Revision 1.3 1997-09-17 12:10:36 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.2 1995/12/14 16:28:30 quinn
* More explain stuff.
*
* Revision 1.1 1995/12/14 11:09:51 quinn
{
Z_TargetInfo *res = odr_malloc(o, sizeof(*res));
data1_node *c;
- static bool_t fl = 0;
+ bool_t *fl = odr_malloc(o,sizeof(*fl));
+ *fl = 0;
res->commonInfo = 0;
res->name = 0;
res->recentNews = 0;
res->icon = 0;
- res->namedResultSets = &fl;
- res->multipleDbSearch = &fl;
+ res->namedResultSets = fl;
+ res->multipleDbSearch = fl;
res->maxResultSets = 0;
res->maxResultSize = 0;
res->maxTerms = 0;
{
Z_DatabaseInfo *res = odr_malloc(o, sizeof(*res));
data1_node *c;
- static bool_t fl = 0, tr = 1;
+ bool_t *fl = odr_malloc(o,sizeof(*fl));
+ bool_t *tr = odr_malloc(o,sizeof(*tr));
+ *fl = 0;
+ *tr = 1;
res->commonInfo = 0;
res->name = 0;
res->explainDatabase = 0;
res->num_nicknames = 0;
res->nicknames = 0;
res->icon = 0;
- res->userFee = &fl;
- res->available = &tr;
+ res->userFee = fl;
+ res->available = tr;
res->titleString = 0;
res->num_keywords = 0;
res->keywords = 0;
return res;
}
-Z_ExplainRecord *data1_nodetoexplain(data1_node *n, int select, ODR o)
+Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
+ int select, ODR o)
{
Z_ExplainRecord *res = odr_malloc(o, sizeof(*res));
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_grs.c,v $
- * Revision 1.9 1997-05-14 06:54:03 adam
+ * Revision 1.10 1997-09-17 12:10:36 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.9 1997/05/14 06:54:03 adam
* C++ support.
*
* Revision 1.8 1996/12/05 13:17:49 quinn
#define D1_VARIANTARRAY 20 /* fixed max length on sup'd variant-list. Lazy me */
-Z_GenericRecord *data1_nodetogr(data1_node *n, int select, ODR o, int *len);
-
static Z_ElementMetaData *get_ElementMetaData(ODR o)
{
Z_ElementMetaData *r = odr_malloc(o, sizeof(*r));
return 0;
}
-static Z_ElementData *nodetoelementdata(data1_node *n, int select, int leaf,
- ODR o, int *len)
+static Z_ElementData *nodetoelementdata(data1_handle dh, data1_node *n,
+ int select, int leaf,
+ ODR o, int *len)
{
Z_ElementData *res = odr_malloc(o, sizeof(*res));
else
{
res->which = Z_ElementData_subtree;
- if (!(res->u.subtree = data1_nodetogr(n->parent, select, o, len)))
+ if (!(res->u.subtree = data1_nodetogr (dh, n->parent, select, o, len)))
return 0;
}
return res;
}
-static Z_TaggedElement *nodetotaggedelement(data1_node *n, int select, ODR o,
- int *len)
+static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n,
+ int select, ODR o,
+ int *len)
{
Z_TaggedElement *res = odr_malloc(o, sizeof(*res));
data1_tag *tag = 0;
*/
else if (n->which == DATA1N_data || n->which == DATA1N_variant)
{
- if (!(tag = data1_gettagbyname(n->root->u.root.absyn->tagset,
- "wellKnown")))
+ if (!(tag = data1_gettagbyname (dh, n->root->u.root.absyn->tagset,
+ "wellKnown")))
{
logf(LOG_WARN, "Unable to locate tag for 'wellKnown'");
return 0;
res->content->which = Z_ElementData_noDataRequested;
res->content->u.noDataRequested = ODR_NULLVAL;
}
- else if (!(res->content = nodetoelementdata(data, select, leaf, o, len)))
+ else if (!(res->content = nodetoelementdata (dh, data, select, leaf,
+ o, len)))
return 0;
*len += 10;
return res;
}
-Z_GenericRecord *data1_nodetogr(data1_node *n, int select, ODR o, int *len)
+Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n,
+ int select, ODR o, int *len)
{
Z_GenericRecord *res = odr_malloc(o, sizeof(*res));
data1_node *c;
if (c->which == DATA1N_tag && select && !c->u.tag.node_selected)
continue;
if (!(res->elements[res->num_elements++] =
- nodetotaggedelement(c, select, o, len)))
+ nodetotaggedelement (dh, c, select, o, len)))
return 0;
}
return res;
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_map.c,v $
- * Revision 1.10 1997-09-05 09:50:56 adam
+ * Revision 1.11 1997-09-17 12:10:36 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.10 1997/09/05 09:50:56 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.9 1996/06/10 08:56:02 quinn
#include <ctype.h>
#include <oid.h>
-#include <xmalloc.h>
#include <log.h>
#include <readconf.h>
#include <data1.h>
#include <d1_map.h>
-data1_maptab *data1_read_maptab(char *file)
+data1_maptab *data1_read_maptab (data1_handle dh, const char *file)
{
- data1_maptab *res = xmalloc(sizeof(*res));
+ NMEM mem = data1_nmem_get (dh);
+ data1_maptab *res = nmem_malloc(mem, sizeof(*res));
FILE *f;
int argc;
char *argv[50], line[512];
data1_mapunit **mapp;
int local_numeric = 0;
- if (!(f = yaz_path_fopen(data1_get_tabpath(), file, "r")))
+ if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
{
logf(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
file);
continue;
}
- res->target_absyn_name = xmalloc(strlen(argv[1])+1);
+ res->target_absyn_name = nmem_malloc(mem, strlen(argv[1])+1);
strcpy(res->target_absyn_name, argv[1]);
}
else if (!yaz_matchstr(argv[0], "localnumeric"))
file);
continue;
}
- res->name = xmalloc(strlen(argv[1])+1);
+ res->name = nmem_malloc(mem, strlen(argv[1])+1);
strcpy(res->name, argv[1]);
}
else if (!strcmp(argv[0], "map"))
file);
continue;
}
- *mapp = xmalloc(sizeof(**mapp));
+ *mapp = nmem_malloc(mem, sizeof(**mapp));
(*mapp)->next = 0;
if (argc > 3 && !data1_matchstr(argv[3], "nodata"))
(*mapp)->no_data = 1;
else
(*mapp)->no_data = 0;
- (*mapp)->source_element_name = xmalloc(strlen(argv[1])+1);
+ (*mapp)->source_element_name = nmem_malloc(mem, strlen(argv[1])+1);
strcpy((*mapp)->source_element_name, argv[1]);
mtp = &(*mapp)->target_path;
if (*path == '/')
fclose(f);
return 0;
}
- *mtp = xmalloc(sizeof(**mtp));
+ *mtp = nmem_malloc(mem, sizeof(**mtp));
(*mtp)->next = 0;
(*mtp)->type = type;
if (np > 2 && !data1_matchstr(parm, "new"))
else
{
(*mtp)->which = D1_MAPTAG_string;
- (*mtp)->value.string = xmalloc(strlen(valstr)+1);
+ (*mtp)->value.string = nmem_malloc(mem, strlen(valstr)+1);
strcpy((*mtp)->value.string, valstr);
}
mtp = &(*mtp)->next;
return 1;
}
-static int map_children(data1_node *n, data1_maptab *map, data1_node *res,
- NMEM mem)
+static int map_children(data1_handle dh, data1_node *n, data1_maptab *map,
+ data1_node *res, NMEM mem)
{
data1_node *c;
data1_mapunit *m;
{
if (!cur || mt->new_field || !tagmatch(cur, mt))
{
- cur = data1_mk_node(mem);
+ cur = data1_mk_node (dh, mem);
cur->which = DATA1N_tag;
cur->u.tag.element = 0;
cur->u.tag.tag = mt->value.string;
break;
}
}
- if (map_children(c, map, res, mem) < 0)
+ if (map_children(dh, c, map, res, mem) < 0)
return -1;
}
return 0;
* table. The new copy will refer back to the data of the original record,
* which should not be discarded during the lifetime of the copy.
*/
-data1_node *data1_map_record(data1_node *n, data1_maptab *map, NMEM m)
+data1_node *data1_map_record (data1_handle dh, data1_node *n,
+ data1_maptab *map, NMEM m)
{
- data1_node *res = data1_mk_node(m);
+ data1_node *res = data1_mk_node(dh, m);
res->which = DATA1N_root;
res->u.root.type = map->target_absyn_name;
- if (!(res->u.root.absyn = data1_get_absyn(map->target_absyn_name)))
+ if (!(res->u.root.absyn = data1_get_absyn(dh, map->target_absyn_name)))
{
logf(LOG_WARN, "%s: Failed to load target absyn '%s'",
map->name, map->target_absyn_name);
res->parent = 0;
res->root = res;
- if (map_children(n, map, res, m) < 0)
+ if (map_children(dh, n, map, res, m) < 0)
{
- data1_free_tree(res);
+ data1_free_tree(dh, res);
return 0;
}
return res;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_marc.c,v $
- * Revision 1.7 1997-09-05 09:50:57 adam
+ * Revision 1.8 1997-09-17 12:10:37 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.7 1997/09/05 09:50:57 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.6 1997/09/04 13:51:58 adam
#include <data1.h>
#include <tpath.h>
-data1_marctab *data1_read_marctab(char *file)
+data1_marctab *data1_read_marctab (data1_handle dh, const char *file)
{
FILE *f;
- data1_marctab *res = xmalloc(sizeof(*res));
+ NMEM mem = data1_nmem_get (dh);
+ data1_marctab *res = nmem_malloc(mem, sizeof(*res));
char line[512], *argv[50];
int argc;
- if (!(f = yaz_path_fopen(data1_get_tabpath(), file, "r")))
+ if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
{
logf(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
logf(LOG_WARN, "%s: Bad name directive");
continue;
}
- res->name = xmalloc(strlen(argv[1])+1);
- strcpy(res->name, argv[1]);
+ res->name = nmem_strdup(mem, argv[1]);
}
else if (!strcmp(argv[0], "reference"))
{
static void memint (char *p, int val, int len)
{
- static char buf[9];
+ char buf[10];
if (len == 1)
*p = val + '0';
return len;
}
-char *data1_nodetomarc(data1_marctab *p, data1_node *n, int selected, int *len)
+char *data1_nodetomarc(data1_handle dh, data1_marctab *p, data1_node *n,
+ int selected, int *len)
{
- static char *buf = 0;
- static int size = 0;
+ int *size;
+ char **buf = data1_get_read_buf (dh, &size);
- *len = nodetomarc(p, n, selected, &buf, &size);
- return buf;
+ *len = nodetomarc(p, n, selected, buf, size);
+ return *buf;
}
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_read.c,v $
- * Revision 1.15 1997-09-05 09:50:57 adam
+ * Revision 1.16 1997-09-17 12:10:37 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.15 1997/09/05 09:50:57 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.14 1997/05/14 06:54:04 adam
#include <log.h>
#include <data1.h>
-static char *data1_tabpath = 0; /* global path for tables */
-
-void data1_set_tabpath(const char *p)
-{
- if (data1_tabpath)
- {
- xfree (data1_tabpath);
- data1_tabpath = NULL;
- }
- if (p)
- {
- data1_tabpath = xmalloc (strlen(p)+1);
- strcpy (data1_tabpath, p);
- }
-}
-
-const char *data1_get_tabpath (void)
-{
- return data1_tabpath;
-}
-
-
/*
* get the tag which is the immediate parent of this node (this may mean
* traversing intermediate things like variants and stuff.
*/
-data1_node *get_parent_tag(data1_node *n)
+data1_node *get_parent_tag (data1_handle dh, data1_node *n)
{
for (; n && n->which != DATA1N_root; n = n->parent)
if (n->which == DATA1N_tag)
return 0;
}
-data1_node *data1_mk_node(NMEM m)
+data1_node *data1_mk_node (data1_handle dh, NMEM m)
{
data1_node *r;
return r;
}
-void data1_free_tree(data1_node *t)
+void data1_free_tree (data1_handle dh, data1_node *t)
{
data1_node *p = t->child, *pn;
while (p)
{
pn = p->next;
- data1_free_tree(p);
+ data1_free_tree (dh, p);
p = pn;
}
if (t->destroy)
* which should be root or tag itself). Returns pointer to the data node,
* which can then be modified.
*/
-data1_node *data1_insert_taggeddata(data1_node *root, data1_node *at,
- char *tagname, NMEM m)
+data1_node *data1_insert_taggeddata(data1_handle dh, data1_node *root,
+ data1_node *at,
+ char *tagname, NMEM m)
{
- data1_node *tagn = data1_mk_node(m);
+ data1_node *tagn = data1_mk_node (dh, m);
data1_node *datn;
tagn->which = DATA1N_tag;
tagn->u.tag.make_variantlist = 0;
tagn->u.tag.no_data_requested = 0;
tagn->u.tag.get_bytes = -1;
- if (!(tagn->u.tag.element = data1_getelementbytagname(root->u.root.absyn,
- 0, tagname)))
+ if (!(tagn->u.tag.element = data1_getelementbytagname (dh,
+ root->u.root.absyn,
+ 0, tagname)))
return 0;
- tagn->child = datn = data1_mk_node(m);
+ tagn->child = datn = data1_mk_node (dh, m);
tagn->num_children = 1;
datn->parent = tagn;
datn->root = root;
* Ugh. Sometimes functions just grow and grow on you. This one reads a
* 'node' and its children.
*/
-data1_node *data1_read_node(char **buf, data1_node *parent, int *line,
- data1_absyn *absyn, NMEM m)
+data1_node *data1_read_node (data1_handle dh, char **buf,
+ data1_node *parent, int *line,
+ data1_absyn *absyn, NMEM m)
{
data1_node *res;
if (!absyn) /* parent node - what are we? */
{
- if (!(absyn = data1_get_absyn(tag)))
+ if (!(absyn = data1_get_absyn (dh, tag)))
{
logf(LOG_WARN, "Unable to acquire abstract syntax for '%s'",
tag);
return 0;
}
- res = data1_mk_node(m);
+ res = data1_mk_node (dh, m);
res->which = DATA1N_root;
res->u.root.type = tag;
res->u.root.absyn = absyn;
logf(LOG_WARN, "Malformed variant triple at '%s'", tag);
return 0;
}
- if (!(tp = data1_getvartypebyct(parent->root->u.root.absyn->varset,
+ if (!(tp = data1_getvartypebyct(dh, parent->root->u.root.absyn->varset,
tclass, type)))
return 0;
*/
if (parent->which != DATA1N_variant)
{
- res = data1_mk_node(m);
+ res = data1_mk_node (dh, m);
res->which = DATA1N_variant;
res->u.variant.type = 0;
res->u.variant.value = 0;
return 0;
}
- res = data1_mk_node(m);
+ res = data1_mk_node (dh, m);
res->which = DATA1N_variant;
res->root = parent->root;
res->u.variant.type = tp;
}
else /* tag.. acquire our element in the abstract syntax */
{
- data1_node *partag = get_parent_tag(parent);
+ data1_node *partag = get_parent_tag (dh, parent);
data1_element *e = 0;
int localtag = 0;
return 0;
}
#else
- elem = data1_getelementbytagname(absyn, e, tag);
+ elem = data1_getelementbytagname(dh, absyn, e, tag);
#endif
- res = data1_mk_node(m);
+ res = data1_mk_node (dh, m);
res->which = DATA1N_tag;
res->u.tag.element = elem;
res->u.tag.tag = tag;
/*
* Read child nodes.
*/
- while ((*pp = data1_read_node(buf, res, line, absyn, m)))
+ while ((*pp = data1_read_node(dh, buf, res, line, absyn, m)))
{
res->last_child = *pp;
res->num_children++;
}
while (isspace(data[len-1]))
len--;
- res = data1_mk_node(m);
+ res = data1_mk_node(dh, m);
res->parent = parent;
res->which = DATA1N_data;
res->u.data.what = DATA1I_text;
/*
* Read a record in the native syntax.
*/
-data1_node *data1_read_record(int (*rf)(void *, char *, size_t), void *fh,
+data1_node *data1_read_record(data1_handle dh,
+ int (*rf)(void *, char *, size_t), void *fh,
NMEM m)
{
- static char *buf = 0;
+ int *size;
+ char **buf = data1_get_read_buf (dh, &size);
char *bp;
- static int size;
int rd = 0, res;
int line = 0;
-
- if (!buf && !(buf = xmalloc(size = 4096)))
- abort();
-
+
+ if (!*buf)
+ *buf = xmalloc(*size = 4096);
+
for (;;)
{
- if (rd + 4096 > size && !(buf =xrealloc(buf, size *= 2)))
+ if (rd + 4096 > *size && !(*buf =xrealloc(*buf, *size *= 2)))
abort();
- if ((res = (*rf)(fh, buf + rd, 4096)) <= 0)
+ if ((res = (*rf)(fh, *buf + rd, 4096)) <= 0)
{
if (!res)
{
- bp = buf;
- return data1_read_node(&bp, 0, &line, 0, m);
+ bp = *buf;
+ return data1_read_node(dh, &bp, 0, &line, 0, m);
}
else
return 0;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_soif.c,v $
- * Revision 1.2 1997-04-30 08:52:11 quinn
+ * Revision 1.3 1997-09-17 12:10:37 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.2 1997/04/30 08:52:11 quinn
* Null
*
* Revision 1.1 1996/10/08 10:43:20 quinn
return 0;
}
-char *data1_nodetosoif(data1_node *n, int select, int *len)
+char *data1_nodetosoif (data1_handle dh, data1_node *n, int select, int *len)
{
- static WRBUF b = 0;
+ WRBUF b = data1_get_wrbuf (dh);
char buf[128];
- if (!b)
- b = wrbuf_alloc();
- else
- wrbuf_rewind(b);
+ wrbuf_rewind(b);
if (n->which != DATA1N_root)
return 0;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_sumout.c,v $
- * Revision 1.1 1996-06-10 08:56:03 quinn
+ * Revision 1.2 1997-09-17 12:10:38 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.1 1996/06/10 08:56:03 quinn
* Work on Summary.
*
*
return r;
}
-Z_BriefBib *data1_nodetosummary(data1_node *n, int select, ODR o)
+Z_BriefBib *data1_nodetosummary (data1_handle dh, data1_node *n,
+ int select, ODR o)
{
Z_BriefBib *res = odr_malloc(o, sizeof(*res));
data1_node *c;
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_sutrs.c,v $
- * Revision 1.3 1995-12-15 16:57:11 quinn
+ * Revision 1.4 1997-09-17 12:10:38 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.3 1995/12/15 16:57:11 quinn
* Added formatted-text.
*
* Revision 1.2 1995/11/01 13:54:49 quinn
#include <ctype.h>
-#include <wrbuf.h>
-
#include <data1.h>
#define NTOBUF_INDENT 2
* need changing.
*/
-char *data1_nodetobuf(data1_node *n, int select, int *len)
+char *data1_nodetobuf (data1_handle dh, data1_node *n, int select, int *len)
{
- static WRBUF b = 0;
+ WRBUF b = data1_get_wrbuf (dh);
- if (!b)
- b = wrbuf_alloc();
- else
- wrbuf_rewind(b);
+ wrbuf_rewind(b);
if (nodetobuf(n, select, b, 0, 0))
return 0;
wrbuf_putc(b, '\n');
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_tagset.c,v $
- * Revision 1.5 1997-09-05 09:50:57 adam
+ * Revision 1.6 1997-09-17 12:10:38 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.5 1997/09/05 09:50:57 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.4 1995/11/13 09:27:38 quinn
#include <ctype.h>
#include <string.h>
-#include <xmalloc.h>
#include <log.h>
#include <tpath.h>
* functions eventually.
*/
-data1_datatype data1_maptype(char *t)
+data1_datatype data1_maptype (data1_handle dh, char *t)
{
static struct
{
return 0;
}
-data1_tag *data1_gettagbynum(data1_tagset *s, int type, int value)
+data1_tag *data1_gettagbynum (data1_handle dh, data1_tagset *s,
+ int type, int value)
{
data1_tag *r;
if (r->which == DATA1T_numeric && r->value.numeric == value)
return r;
/* scan included sets */
- if (s->children && (r = data1_gettagbynum(s->children, type, value)))
+ if (s->children && (r = data1_gettagbynum (dh, s->children,
+ type, value)))
return r;
}
return 0;
}
-data1_tag *data1_gettagbyname(data1_tagset *s, char *name)
+data1_tag *data1_gettagbyname (data1_handle dh, data1_tagset *s, char *name)
{
data1_tag *r;
return r;
}
/* scan included sets */
- if (s->children && (r = data1_gettagbyname(s->children, name)))
+ if (s->children && (r = data1_gettagbyname (dh, s->children, name)))
return r;
}
return 0;
}
-data1_tagset *data1_read_tagset(char *file)
+data1_tagset *data1_read_tagset (data1_handle dh, char *file)
{
+ NMEM mem = data1_nmem_get (dh);
char line[512], *r, cmd[512], args[512];
data1_tagset *res = 0, **childp;
data1_tag **tagp;
FILE *f;
- if (!(f = yaz_path_fopen(data1_get_tabpath(), file, "r")))
+ if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
{
logf(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
}
- if (!(res = xmalloc(sizeof(*res))))
- abort();
+ res = nmem_malloc(mem, sizeof(*res));
res->name = 0;
res->type = 0;
res->tags = 0;
fclose(f);
return 0;
}
- if (!(rr = *tagp = xmalloc(sizeof(*rr))))
- abort();
-
+ rr = *tagp = nmem_malloc(mem, sizeof(*rr));
rr->tagset = res;
rr->next = 0;
rr->which = DATA1T_numeric;
* how to deal with local numeric tags?
*/
- if (!(rr->kind = data1_maptype(type)))
+ if (!(rr->kind = data1_maptype(dh, type)))
{
logf(LOG_WARN, "Unknown datatype %s in %s", type, file);
fclose(f);
{
char *e;
- if (!(*npp = xmalloc(sizeof(**npp))))
- abort();
+ *npp = nmem_malloc(mem, sizeof(**npp));
if ((e = strchr(nm, '/')))
*(e++) = '\0';
- if (!((*npp)->name = xmalloc(strlen(nm)+1)))
- abort();
- strcpy((*npp)->name, nm);
+ (*npp)->name = nmem_strdup(mem, nm);
(*npp)->next = 0;
npp = &(*npp)->next;
nm = e;
fclose(f);
return 0;
}
- if (!(res->name = xmalloc(strlen(args)+1)))
- abort();
- strcpy(res->name, name);
+ res->name = nmem_strdup(mem, args);
}
else if (!strcmp(cmd, "reference"))
{
fclose(f);
return 0;
}
- if (!(*childp = data1_read_tagset(name)))
+ if (!(*childp = data1_read_tagset (dh, name)))
{
logf(LOG_WARN, "Inclusion failed in %s", file);
fclose(f);
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_varset.c,v $
- * Revision 1.5 1997-09-05 09:50:58 adam
+ * Revision 1.6 1997-09-17 12:10:39 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.5 1997/09/05 09:50:58 adam
* Removed global data1_tabpath - uses data1_get_tabpath() instead.
*
* Revision 1.4 1997/05/14 06:54:04 adam
#include <tpath.h>
#include <data1.h>
-data1_vartype *data1_getvartypebyct(data1_varset *set, char *zclass, char *type)
+data1_vartype *data1_getvartypebyct (data1_handle dh, data1_varset *set,
+ char *zclass, char *type)
{
data1_varclass *c;
data1_vartype *t;
return 0;
}
-data1_varset *data1_read_varset(char *file)
+data1_varset *data1_read_varset (data1_handle dh, const char *file)
{
- data1_varset *res = xmalloc(sizeof(*res));
+ NMEM mem = data1_nmem_get (dh);
+ data1_varset *res = nmem_malloc(mem, sizeof(*res));
data1_varclass **classp = &res->classes, *zclass = 0;
data1_vartype **typep = 0;
FILE *f;
res->reference = VAL_NONE;
res->classes = 0;
- if (!(f = yaz_path_fopen(data1_get_tabpath(), file, "r")))
+ if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
{
logf(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
fclose(f);
return 0;
}
- *classp = r = zclass = xmalloc(sizeof(*r));
+ *classp = r = zclass = nmem_malloc(mem, sizeof(*r));
r->set = res;
r->zclass = atoi(argv[1]);
- r->name = xmalloc(strlen(argv[2])+1);
- strcpy(r->name, argv[2]);
+ r->name = nmem_strdup(mem, argv[2]);
r->types = 0;
typep = &r->types;
r->next = 0;
fclose(f);
return 0;
}
- *typep = r = xmalloc(sizeof(*r));
- r->name = xmalloc(strlen(argv[2])+1);
- strcpy(r->name, argv[2]);
+ *typep = r = nmem_malloc(mem, sizeof(*r));
+ r->name = nmem_strdup(mem, argv[2]);
r->zclass = zclass;
r->type = atoi(argv[1]);
- if (!(r->datatype = data1_maptype(argv[3])))
+ if (!(r->datatype = data1_maptype (dh, argv[3])))
{
logf(LOG_WARN, "%s: Unknown datatype '%s'", file, argv[3]);
fclose(f);
fclose(f);
return 0;
}
- res->name = xmalloc(strlen(argv[1])+1);
- strcpy(res->name, argv[1]);
+ res->name = nmem_strdup(mem, argv[1]);
}
else if (!strcmp(argv[0], "reference"))
{
/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_write.c,v $
- * Revision 1.2 1995-12-13 17:14:27 quinn
+ * Revision 1.3 1997-09-17 12:10:39 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.2 1995/12/13 17:14:27 quinn
* *** empty log message ***
*
* Revision 1.1 1995/12/13 15:38:43 quinn
return 0;
}
-char *data1_nodetoidsgml(data1_node *n, int select, int *len)
+char *data1_nodetoidsgml (data1_handle dh, data1_node *n, int select, int *len)
{
- static WRBUF b = 0;
+ WRBUF b = data1_get_wrbuf (dh);
char line[1024];
- if (!b)
- b = wrbuf_alloc();
- else
- wrbuf_rewind(b);
+ wrbuf_rewind(b);
sprintf(line, "<%s>\n", n->u.root.type);
wrbuf_write(b, line, strlen(line));
# Copyright (C) 1994-1997, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.32 1997-09-01 08:52:58 adam Exp $
+# $Id: Makefile,v 1.33 1997-09-17 12:10:39 adam Exp $
LIBDIR=../lib
SHELL=/bin/sh
INCLUDE=-I../include -I. -I../../xtimosi/src
LIBINCLUDE=-L$(LIBDIR)
-DEFS=$(INCLUDE)
+DEFS=$(INCLUDE) $(CDEFS)
LIB=$(LIBDIR)/libserver.a
LIBS=$(LIBDIR)/libserver.a $(LIBDIR)/libasn.a $(LIBDIR)/libodr.a \
$(LIBDIR)/libcomstack.a $(LIBMOSI) $(LIBDIR)/libutil.a $(ELIBS)
mv -f Makefile.tmp Makefile
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
ifeq (.depend,$(wildcard .depend))
include .depend
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: seshigh.c,v $
- * Revision 1.66 1997-09-05 15:26:44 adam
+ * Revision 1.67 1997-09-17 12:10:40 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.66 1997/09/05 15:26:44 adam
* Added ODR encode in search and scen bend request structures.
* Fixed a few enums that caused trouble with C++.
*
if (req->implementationVersion)
logf(LOG_LOG, "Version: %s", req->implementationVersion);
+ binitreq.stream = assoc->encode;
binitreq.configname = "default-config";
binitreq.auth = req->idAuthentication;
if (!(binitres = bend_init(&binitreq)))
* Chas Woodfield, Fretwell Downing Datasystem.
*
* $Log: statserv.c,v $
- * Revision 1.39 1997-09-09 10:10:19 adam
+ * Revision 1.40 1997-09-17 12:10:41 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.39 1997/09/09 10:10:19 adam
* Another MSV5.0 port. Changed projects to include proper
* library/include paths.
* Server starts server in test-mode when no options are given.
if (!where || sscanf(where, "%[^:]:%s", mode, addr) != 2)
{
- fprintf(stderr, "%s: Address format: ('tcp'|'osi')':'<address>.\n",
- me);
+ logf (LOG_WARN, "%s: Address format: ('tcp'|'osi')':'<address>", me);
+ return;
}
if (!strcmp(mode, "tcp"))
- {
- if (!(ap = tcpip_strtoaddr(addr)))
- {
- fprintf(stderr, "Address resolution failed for TCP.\n");
- }
type = tcpip_type;
- }
else if (!strcmp(mode, "osi"))
{
#ifdef USE_XTIMOSI
- if (!(ap = mosi_strtoaddr(addr)))
- {
- fprintf(stderr, "Address resolution failed for TCP.\n");
- }
type = mosi_type;
#else
- fprintf(stderr, "OSI Transport not allowed by configuration.\n");
+ logf (LOG_WARN, "OSI Transport not allowed by configuration.");
+ return;
#endif
}
else
{
- fprintf(stderr, "You must specify either 'osi:' or 'tcp:'.\n");
+ logf (LOG_WARN, "You must specify either 'osi:' or 'tcp:'");
+ return;
}
logf(LOG_LOG, "Adding %s %s listener on %s",
control_block.dynamic ? "dynamic" : "static",
{
logf(LOG_FATAL|LOG_ERRNO, "Failed to create listener");
}
+ ap = cs_straddr (l, addr);
+ if (!ap)
+ {
+ fprintf(stderr, "Address resolution failed.\n");
+ cs_close (l);
+ return;
+ }
if (cs_bind(l, ap, CS_SERVER) < 0)
{
logf(LOG_FATAL|LOG_ERRNO, "Failed to bind to %s", where);
att 1013 Authority/format-id
att 1014 Concept-text
att 1015 Concept-reference
-att 1016 Any
+att 1016 Any 4,1005,62
att 1017 Server-choice
att 1018 Publisher
att 1019 Record-source
esetname W gils-b.est # We don't really do bodyOfDisplay yet.
esetname F @
-all Any
+#all Any
elm (1,1) schemaIdentifier -
elm (1,10) rank -
# Copyright (C) 1994-1997, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.23 1997-09-04 07:59:29 adam Exp $
+# $Id: Makefile,v 1.24 1997-09-17 12:10:42 adam Exp $
SHELL=/bin/sh
INCLUDE=-I../include -I.
LIBDIR=../lib
LIBINCLUDE=-L$(LIBDIR)
-DEFS=$(INCLUDE)
+DEFS=$(INCLUDE) $(CDEFS)
#DEFS=$(INCLUDE) -DTRACE_XMALLOC=1
LIB=$(LIBDIR)/libutil.a
LIBS=
-PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o \
+PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o nmemsdup.o \
xmalloc.o readconf.o tpath.o nmem.o yaz-util.o atoin.o # dmalloc.o
CPP=$(CC) -E
RANLIB=ranlib
mv -f Makefile.tmp Makefile
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
ifeq (.depend,$(wildcard .depend))
include .depend
--- /dev/null
+/*
+ * Copyright (c) 1997, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: nmemsdup.c,v $
+ * Revision 1.1 1997-09-17 12:10:42 adam
+ * YAZ version 1.4.
+ *
+ */
+
+#include <string.h>
+#include <nmem.h>
+
+char *nmem_strdup (NMEM mem, const char *src)
+{
+ char *dst = nmem_malloc (mem, strlen(src)+1);
+ strcpy (dst, src);
+ return dst;
+}
/*
- * Copyright (c) 1995-1996, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: pquery.c,v $
- * Revision 1.12 1997-09-01 08:54:13 adam
+ * Revision 1.13 1997-09-17 12:10:42 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.12 1997/09/01 08:54:13 adam
* New windows NT/95 port using MSV5.0. Made prefix query handling
* thread safe. The function options ignores empty arguments when met.
*
char *left_sep;
char *right_sep;
int escape_char;
+ int term_type;
};
static Z_RPNStructure *rpn_structure (struct lex_info *li, ODR o, oid_proto,
return oid_getvalbyname (buf);
}
+static int compare_term (struct lex_info *li, const char *src, int off)
+{
+ size_t len=strlen(src);
+
+ if (li->lex_len == len && !memcmp (li->lex_buf+off, src, len-off))
+ return 1;
+ return 0;
+}
+
static int query_token (struct lex_info *li)
{
const char *sep_match;
}
if (li->lex_len >= 1 && li->lex_buf[0] == li->escape_char)
{
- if (li->lex_len == 4 && !memcmp (li->lex_buf+1, "and", 3))
- return 'a';
- if (li->lex_len == 3 && !memcmp (li->lex_buf+1, "or", 2))
+ if (compare_term (li, "and", 1))
+ return 'a';
+ if (compare_term (li, "or", 1))
return 'o';
- if (li->lex_len == 4 && !memcmp (li->lex_buf+1, "not", 3))
+ if (compare_term (li, "not", 1))
return 'n';
- if (li->lex_len == 5 && !memcmp (li->lex_buf+1, "attr", 4))
+ if (compare_term (li, "attr", 1))
return 'l';
- if (li->lex_len == 4 && !memcmp (li->lex_buf+1, "set", 3))
+ if (compare_term (li, "set", 1))
return 's';
- if (li->lex_len == 8 && !memcmp (li->lex_buf+1, "attrset", 7))
+ if (compare_term (li, "attrset", 1))
return 'r';
- if (li->lex_len == 5 && !memcmp (li->lex_buf+1, "prox", 4))
+ if (compare_term (li, "prox", 1))
return 'p';
+ if (compare_term (li, "term", 1))
+ return 'y';
}
return 't';
}
return
rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
attr_set);
+ case 'y':
+ lex (li);
+ if (!li->query_look)
+ return NULL;
+ if (compare_term (li, "general", 0))
+ li->term_type = Z_Term_general;
+ else if (compare_term (li, "numeric", 0))
+ li->term_type = Z_Term_numeric;
+ else if (compare_term (li, "string", 0))
+ li->term_type = Z_Term_characterString;
+ else if (compare_term (li, "oid", 0))
+ li->term_type = Z_Term_oid;
+ else if (compare_term (li, "datetime", 0))
+ li->term_type = Z_Term_dateTime;
+ else if (compare_term (li, "null", 0))
+ li->term_type = Z_Term_null;
+ lex (li);
+ return
+ rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
+ attr_set);
case 0: /* operator/operand expected! */
return NULL;
}
li.left_sep = "{\"";
li.right_sep = "}\"";
li.escape_char = '@';
+ li.term_type = Z_Term_general;
li.query_buf = qbuf;
return p_query_rpn_mk (o, &li, proto, qbuf);
}
li.left_sep = "{\"";
li.right_sep = "}\"";
li.escape_char = '@';
+ li.term_type = Z_Term_general;
li.query_buf = qbuf;
return p_query_scan_mk (&li, o, proto, attributeSetP, qbuf);
SOURCE=$(InputPath)\r
PostBuild_Desc=Copy Lib and Dll\r
PostBuild_Cmds=copy $(OutDir)\$(TargetName).lib $(ProjDir)\lib copy\\r
- $(OutDir)\$(TargetName).dll $(ProjDir)\lib\r
+ $(OutDir)\$(TargetName).dll $(ProjDir)\lib\r
# End Special Build Tool\r
\r
!ELSEIF "$(CFG)" == "yaz - Win32 Debug"\r
# PROP Ignore_Export_Lib 0\r
# PROP Target_Dir ""\r
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c\r
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINDOWS=1 /FR /FD /c\r
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINDOWS=1 /FR /FD /c\r
# SUBTRACT CPP /YX\r
# ADD BASE MTL /nologo /D "_DEBUG" /win32\r
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
SOURCE=$(InputPath)\r
PostBuild_Desc=Copy Lib and Dll\r
PostBuild_Cmds=copy $(OutDir)\$(TargetName).lib $(ProjDir)\lib copy\\r
- $(OutDir)\$(TargetName).dll $(ProjDir)\lib\r
+ $(OutDir)\$(TargetName).dll $(ProjDir)\lib\r
# End Special Build Tool\r
\r
!ENDIF \r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\retrieval\d1_handle.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\retrieval\d1_map.c\r
\r
!IF "$(CFG)" == "yaz - Win32 Release"\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\util\nmemsdup.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\odr\odr.c\r
\r
!IF "$(CFG)" == "yaz - Win32 Release"\r
# Copyright (C) 1995-1997, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.1 1997-09-01 08:55:52 adam Exp $
+# $Id: Makefile,v 1.2 1997-09-17 12:10:43 adam Exp $
LIBDIR=../lib
SHELL=/bin/sh
INCLUDE=-I../include -I. -I../../xtimosi/src
LIBINCLUDE=-L$(LIBDIR)
-DEFS=$(INCLUDE)
+DEFS=$(INCLUDE) $(CDEFS)
LIB=$(LIBDIR)/libserver.a
LIBS=$(LIBDIR)/libserver.a $(LIBDIR)/libasn.a $(LIBDIR)/libodr.a \
$(LIBDIR)/libcomstack.a $(LIBMOSI) $(LIBDIR)/libutil.a $(ELIBS)
mv -f Makefile.tmp Makefile
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
ifeq (.depend,$(wildcard .depend))
include .depend
* Chas Woodfield, Fretwell Downing Datasystems.
*
* $Log: ztest.c,v $
- * Revision 1.3 1997-09-09 10:10:20 adam
+ * Revision 1.4 1997-09-17 12:10:43 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.3 1997/09/09 10:10:20 adam
* Another MSV5.0 port. Changed projects to include proper
* library/include paths.
* Server starts server in test-mode when no options are given.
bend_initresult *bend_init(bend_initrequest *q)
{
- static bend_initresult r;
+ bend_initresult *r = odr_malloc (q->stream, sizeof(*r));
static char *dummy = "Hej fister";
- r.errcode = 0;
- r.errstring = 0;
- r.handle = dummy;
- return &r;
+ r->errcode = 0;
+ r->errstring = 0;
+ r->handle = dummy;
+ return r;
}
bend_searchresult *bend_search(void *handle, bend_searchrequest *q, int *fd)
{
- static bend_searchresult r;
+ bend_searchresult *r = odr_malloc (q->stream, sizeof(*r));
- r.errcode = 0;
- r.errstring = 0;
- r.hits = rand() % 22;
+ r->errcode = 0;
+ r->errstring = 0;
+ r->hits = rand() % 22;
- return &r;
+ return r;
}
static int atoin (const char *buf, int n)
bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *q, int *num)
{
- static bend_fetchresult r;
+ bend_fetchresult *r = odr_malloc (q->stream, sizeof(*r));
static char *bbb = 0;
- r.errstring = 0;
- r.last_in_set = 0;
- r.basename = "DUMMY";
+ r->errstring = 0;
+ r->last_in_set = 0;
+ r->basename = "DUMMY";
if (bbb)
{
xfree(bbb);
bbb = 0;
}
- r.format = q->format;
+ r->format = q->format;
if (q->format == VAL_SUTRS)
{
char buf[100];
sprintf(buf, "This is dummy SUTRS record number %d\n", q->number);
- assert(r.record = bbb = xmalloc(strlen(buf)+1));
+ assert(r->record = bbb = xmalloc(strlen(buf)+1));
strcpy(bbb, buf);
- r.len = strlen(buf);
+ r->len = strlen(buf);
}
else if (q->format == VAL_GRS1)
{
- r.len = -1;
- r.record = (char*) dummy_grs_record(q->number, q->stream);
- if (!r.record)
+ r->len = -1;
+ r->record = (char*) dummy_grs_record(q->number, q->stream);
+ if (!r->record)
{
- r.errcode = 13;
- return &r;
+ r->errcode = 13;
+ return r;
}
}
- else if (!(r.record = bbb = dummy_database_record(q->number)))
+ else if (!(r->record = bbb = dummy_database_record(q->number)))
{
- r.errcode = 13;
- r.format = VAL_USMARC;
- return &r;
+ r->errcode = 13;
+ r->format = VAL_USMARC;
+ return r;
}
else
- r.len = strlen(r.record);
- r.errcode = 0;
- return &r;
+ r->len = strlen(r->record);
+ r->errcode = 0;
+ return r;
}
bend_deleteresult *bend_delete(void *handle, bend_deleterequest *q, int *num)
*/
bend_scanresult *bend_scan(void *handle, bend_scanrequest *q, int *num)
{
- static bend_scanresult r;
+ bend_scanresult *r = odr_malloc (q->stream, sizeof(*r));
static FILE *f = 0;
static struct scan_entry list[200];
static char entries[200][80];
char term[80], *p;
int i, pos;
- r.errstring = 0;
- r.entries = list;
- r.status = BEND_SCAN_SUCCESS;
+ r->errstring = 0;
+ r->entries = list;
+ r->status = BEND_SCAN_SUCCESS;
if (!f && !(f = fopen("dummy-words", "r")))
{
perror("dummy-words");
}
if (q->term->term->which != Z_Term_general)
{
- r.errcode = 229; /* unsupported term type */
- return &r;
+ r->errcode = 229; /* unsupported term type */
+ return r;
}
if (q->term->term->u.general->len >= 80)
{
- r.errcode = 11; /* term too long */
- return &r;
+ r->errcode = 11; /* term too long */
+ return r;
}
if (q->num_entries > 200)
{
- r.errcode = 31;
- return &r;
+ r->errcode = 31;
+ return r;
}
memcpy(term, q->term->term->u.general->buf, q->term->term->u.general->len);
term[q->term->term->u.general->len] = '\0';
*p = toupper(*p);
fseek(f, 0, 0);
- r.num_entries = 0;
+ r->num_entries = 0;
for (i = 0, pos = 0; fscanf(f, " %79[^:]:%d", entries[pos], &hits[pos]) == 2;
i++, pos < 199 ? pos++ : (pos = 0))
{
- if (!r.num_entries && strcmp(entries[pos], term) >= 0) /* s-point fnd */
+ if (!r->num_entries && strcmp(entries[pos], term) >= 0) /* s-point fnd */
{
- if ((r.term_position = q->term_position) > i + 1)
+ if ((r->term_position = q->term_position) > i + 1)
{
- r.term_position = i + 1;
- r.status = BEND_SCAN_PARTIAL;
+ r->term_position = i + 1;
+ r->status = BEND_SCAN_PARTIAL;
}
- for (; r.num_entries < r.term_position; r.num_entries++)
+ for (; r->num_entries < r->term_position; r->num_entries++)
{
int po;
- po = pos - r.term_position + r.num_entries + 1; /* find pos */
+ po = pos - r->term_position + r->num_entries + 1; /* find pos */
if (po < 0)
po += 200;
- list[r.num_entries].term = entries[po];
- list[r.num_entries].occurrences = hits[po];
+ list[r->num_entries].term = entries[po];
+ list[r->num_entries].occurrences = hits[po];
}
}
- else if (r.num_entries)
+ else if (r->num_entries)
{
- list[r.num_entries].term = entries[pos];
- list[r.num_entries].occurrences = hits[pos];
- r.num_entries++;
+ list[r->num_entries].term = entries[pos];
+ list[r->num_entries].occurrences = hits[pos];
+ r->num_entries++;
}
- if (r.num_entries >= q->num_entries)
+ if (r->num_entries >= q->num_entries)
break;
}
if (feof(f))
- r.status = BEND_SCAN_PARTIAL;
- return &r;
+ r->status = BEND_SCAN_PARTIAL;
+ return r;
}
#endif
return;
}
+#ifndef WINDOWS
+/* UNIX version */
+int main(int argc, char **argv)
+{
+ statserv_main(argc, argv);
+ statserv_closedown();
+ exit (0);
+}
+#else
+/* Windows version with Service support */
+
typedef struct _Args
{
char **argv;
ArgDetails.argc = argc;
ArgDetails.argv = argv;
-#ifdef WIN32
-
/* Now setup the service with the service controller */
SetupService(argc, argv, &ArgDetails, SZAPPNAME, SZSERVICENAME, SZSERVICEDISPLAYNAME, SZDEPENDENCIES);
-
-#else /* WIN32 */
-
- /* The service controller does the following for us under windows */
- if (StartAppService(NULL, argc, argv))
- RunAppService(&ArgDetails);
-
- /* Ensure the service has been stopped */
- StopAppService(NULL);
-
-#endif /* WIN32 */
-
return(0);
}
/* Stops the app */
statserv_closedown();
}
+#endif