From: Sebastian Hammer Date: Wed, 8 Nov 1995 17:41:11 +0000 (+0000) Subject: Smallish. X-Git-Tag: YAZ.1.8~879 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=20183db4fcbb8161529ee557ead6789ae2097ae0 Smallish. --- diff --git a/CHANGELOG b/CHANGELOG index 232d1cc..d276eeb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,15 @@ Possible compatibility problems with earlier versions marked with '*'. ---- XXXXX XXXX/XX/XX +--- 1.0 1995/XX/XX + +The shift to v1.0 signals that we now consider the *core* functionality +of YAZ reasonably stable (the core being more or less equivalent to +Z39.50-1992). Some of the really nifty v3 stuff is still not heavily +tested (Explain not at all - though that will happen soonish). + +Minor changes to code to support Windows port. + +Various minor changes after we're getting to use GRS-1 & co. more. Added Espec-1 format. @@ -10,7 +19,7 @@ when decoding). Needed to talk to some servers. Demo client can request simple element set names. -Added Diagnostic Format. +Added Diagnostic Format encoders/decoders. Added simple Close handling to frontend server (no hooks for resource reporting yet), and demonstration client. diff --git a/include/odr.h b/include/odr.h index f9d55d7..e1b0c0c 100644 --- a/include/odr.h +++ b/include/odr.h @@ -24,7 +24,10 @@ * OF THIS SOFTWARE. * * $Log: odr.h,v $ - * Revision 1.16 1995-11-01 13:54:36 quinn + * Revision 1.17 1995-11-08 17:41:27 quinn + * Smallish. + * + * Revision 1.16 1995/11/01 13:54:36 quinn * Minor adjustments * * Revision 1.15 1995/10/18 16:12:36 quinn @@ -126,6 +129,7 @@ #include #include +#include #include #ifndef bool_t @@ -245,7 +249,7 @@ typedef struct odr FILE *print; /* output file for direction print */ int indent; /* current indent level for printing */ - struct odr_memblock *mem; + NMEM mem; /* memory handle for decoding (primarily) */ /* stack for constructed types */ #define ODR_MAX_STACK 50 @@ -290,8 +294,9 @@ void odr_destroy(ODR o); void odr_setbuf(ODR o, char *buf, int len, int can_grow); char *odr_getbuf(ODR o, int *len, int *size); void *odr_malloc(ODR o, int size); -ODR_MEM odr_extract_mem(ODR o); -void odr_release_mem(ODR_MEM p); +NMEM odr_extract_mem(ODR o); +#define odr_release_mem(m) nmem_destroy(m) +#define ODR_MEM NMEM #define odr_implicit(o, t, p, cl, tg, opt)\ (odr_implicit_settag((o), cl, tg), t ((o), (p), opt) ) @@ -355,6 +360,8 @@ void odr_release_mem(ODR_MEM p); #define odr_tell(o) ((o)->ecb.pos) #define odr_offset(o) ((o)->bp - (o)->buf) #define odr_ok(o) (!(o)->error) +#define odr_getmem(o) ((o)->mem) +#define odr_setmem(o, v) ((o)->mem = (v)) #define ODR_MAXNAME 256 diff --git a/include/prt.h b/include/prt.h index bb1cad9..4c80085 100644 --- a/include/prt.h +++ b/include/prt.h @@ -41,7 +41,6 @@ int ber_any(ODR o, Odr_any **p); int completeBER(unsigned char *buf, int len); void odr_begin(ODR o); void odr_end(ODR o); -void odr_release_mem(struct odr_memblock *p); Odr_oid *odr_oiddup(ODR odr, Odr_oid *o); int odr_grow_block(odr_ecblock *b, int min_bytes); int odr_write(ODR o, unsigned char *buf, int bytes); diff --git a/odr/odr.c b/odr/odr.c index b44078a..af2665d 100644 --- a/odr/odr.c +++ b/odr/odr.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: odr.c,v $ - * Revision 1.19 1995-11-01 13:54:41 quinn + * Revision 1.20 1995-11-08 17:41:32 quinn + * Smallish. + * + * Revision 1.19 1995/11/01 13:54:41 quinn * Minor adjustments * * Revision 1.18 1995/09/29 17:12:22 quinn @@ -121,7 +124,7 @@ ODR odr_createmem(int direction) r->ecb.size = r->ecb.pos = r->ecb.top = 0; r->ecb.can_grow = 1; r->buflen = 0; - r->mem = 0; + r->mem = nmem_create(); odr_reset(r); return r; } @@ -137,14 +140,13 @@ void odr_reset(ODR o) o->t_tag = -1; o->indent = 0; o->stackp = -1; - odr_release_mem(o->mem); - o->mem = 0; + nmem_reset(o->mem); o->choice_bias = -1; } void odr_destroy(ODR o) { - odr_release_mem(o->mem); + nmem_destroy(o->mem); if (o->ecb.buf && o->ecb.can_grow) xfree(o->ecb.buf); if (o->print != stderr) diff --git a/odr/odr_mem.c b/odr/odr_mem.c index 3894907..f0792d0 100644 --- a/odr/odr_mem.c +++ b/odr/odr_mem.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: odr_mem.c,v $ - * Revision 1.11 1995-11-01 13:54:43 quinn + * Revision 1.12 1995-11-08 17:41:33 quinn + * Smallish. + * + * Revision 1.11 1995/11/01 13:54:43 quinn * Minor adjustments * * Revision 1.10 1995/10/25 16:58:19 quinn @@ -47,77 +50,12 @@ /* ------------------------ NIBBLE MEMORY ---------------------- */ -#define ODR_MEM_CHUNK (10*1024) - -typedef struct odr_memblock -{ - char *buf; - int size; - int top; - int total; - struct odr_memblock *next; -} odr_memblock; - -static odr_memblock *freelist = 0; /* global freelist */ - -static void free_block(odr_memblock *p) -{ - p->next = freelist; - freelist = p; -} - -/* - * acquire a block with a minimum of size free bytes. - */ -static odr_memblock *get_block(int size) -{ - odr_memblock *r, *l; - - for (r = freelist, l = 0; r; l = r, r = r->next) - if (r->size >= size) - break; - if (r) - if (l) - l->next = r->next; - else - freelist = r->next; - else - { - int get = ODR_MEM_CHUNK; - - if (get < size) - get = size; - if (!(r = xmalloc(sizeof(*r)))) - abort(); - if (!(r->buf = xmalloc(r->size = get))) - abort(); - } - r->top = 0; - r->total = 0; - return r; -} - -/* - * Return p to the global freelist. - */ -void odr_release_mem(ODR_MEM p) -{ - odr_memblock *t; - - while (p) - { - t = p; - p = p->next; - free_block(t); - } -} - /* * Extract the memory control block from o. */ -ODR_MEM odr_extract_mem(ODR o) +NMEM odr_extract_mem(ODR o) { - ODR_MEM r = o->mem; + NMEM r = o->mem; o->mem = 0; return r; @@ -125,36 +63,14 @@ ODR_MEM odr_extract_mem(ODR o) void *odr_malloc(ODR o, int size) { - struct odr_memblock *p; - char *r; - - if (!o) - { - if (!(r = xmalloc(size))) - abort(); - return r; - } - p = o->mem; - if (!p || p->size - p->top < size) - if (!(p = get_block(size))) - abort(); - else - { - if (o->mem) - p->total = o->mem->total; - p->next = o->mem; - o->mem = p; - } - r = p->buf + p->top; - /* align size */ - p->top += (size + (sizeof(long) - 1)) & ~(sizeof(long) - 1); - p->total += size; - return r; + if (o && !o->mem) + o->mem = nmem_create(); + return nmem_malloc(o ? o->mem : 0, size); } int odr_total(ODR o) { - return o->mem ? o->mem->total : 0; + return o->mem ? nmem_total(o->mem) : 0; } /* ---------- memory management for data encoding ----------*/ diff --git a/server/seshigh.c b/server/seshigh.c index 5f2131a..0082e71 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.54 1995-11-08 15:11:29 quinn + * Revision 1.55 1995-11-08 17:41:37 quinn + * Smallish. + * + * Revision 1.54 1995/11/08 15:11:29 quinn * Log of close transmit. * * Revision 1.53 1995/11/01 13:54:58 quinn @@ -452,7 +455,7 @@ void ir_session(IOCHAN h, int event) break; case 0: /* all sent - release the request structure */ logf(LOG_DEBUG, "Wrote PDU, %d bytes", req->len_response); - odr_release_mem(req->request_mem); + nmem_destroy(req->request_mem); request_deq(&assoc->outgoing); request_release(req); if (!request_head(&assoc->outgoing)) diff --git a/server/session.h b/server/session.h index 48129f9..ab63da3 100644 --- a/server/session.h +++ b/server/session.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: session.h,v $ - * Revision 1.10 1995-08-29 11:18:01 quinn + * Revision 1.11 1995-11-08 17:41:40 quinn + * Smallish. + * + * Revision 1.10 1995/08/29 11:18:01 quinn * Added code to receive close * * Revision 1.9 1995/06/16 10:31:38 quinn @@ -59,7 +62,7 @@ typedef struct request } state; Z_APDU *request; /* Current request */ - ODR_MEM request_mem; /* ODR memory handle for request */ + NMEM request_mem; /* memory handle for request */ int size_response; /* size of buffer */ int len_response; /* length of encoded data */ diff --git a/util/Makefile b/util/Makefile index c096cf5..87b1967 100644 --- a/util/Makefile +++ b/util/Makefile @@ -1,7 +1,7 @@ # Copyright (C) 1994, Index Data I/S # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile,v 1.16 1995-11-01 16:34:59 quinn Exp $ +# $Id: Makefile,v 1.17 1995-11-08 17:41:43 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 tpath.o # dmalloc.o + xmalloc.o readconf.o tpath.o nmem.o # dmalloc.o CPP=$(CC) -E RANLIB=ranlib