# Copyright (C) 1994, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.24 1995-09-29 17:01:34 quinn Exp $
+# $Id: Makefile,v 1.25 1995-10-06 08:51:13 quinn Exp $
# Uncomment the lines below to enable mOSI communcation.
-#ODEFS=-DUSE_XTIMOSI
-#RFC1006=rfc1006
-#LIBMOSI=../../xtimosi/src/libmosi.a ../lib/librfc.a
-#XMOSI=xmosi.o
+ODEFS=-DUSE_XTIMOSI
+RFC1006=rfc1006
+LIBMOSI=../../xtimosi/src/libmosi.a ../lib/librfc.a
+XMOSI=xmosi.o
CDEFS=$(ODEFS)
#CC=
--- /dev/null
+/*
+ * 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 WRBUF_H
+#define WRBUF_H
+
+typedef struct wrbuf
+{
+ char *buf;
+ int pos;
+ int size;
+} wrbuf, *WRBUF;
+
+WRBUF wrbuf_alloc(void);
+void wrbuf_free(WRBUF b, int free_buf);
+void wrbuf_rewind(WRBUF b);
+int wrbuf_grow(WRBUF b, int minsize);
+int wrbuf_write(WRBUF b, char *buf, int size);
+
+#define wrbuf_putc(b, c) \
+ (((b)->pos >= (b)->size ? wrbuf_grow(b, 1) : 0), \
+ (b)->buf[(b)->pos++] = (c), 0)
+
+#endif
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: seshigh.c,v $
- * Revision 1.47 1995-08-29 14:24:16 quinn
+ * Revision 1.48 1995-10-06 08:51:20 quinn
+ * Added Write-buffer.
+ *
+ * Revision 1.47 1995/08/29 14:24:16 quinn
* Added second half of close-handshake
*
* Revision 1.46 1995/08/29 11:17:58 quinn
* Updated External
*
* Revision 1.42 1995/08/15 11:16:50 quinn
- * CV:e ----------------------------------------------------------------------
- * CV:e ----------------------------------------------------------------------
*
* Revision 1.41 1995/08/02 10:23:06 quinn
* Smallish
/*
* Handle init request.
- * At the moment, we don't check the protocol version or the options
+ * At the moment, we don't check the options
* anywhere else in the code - we just try not to do anything that would
* break a naive client. We'll toss 'em into the association block when
* we need them there.
# Copyright (C) 1994, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.13 1995-06-25 10:53:59 quinn Exp $
+# $Id: Makefile,v 1.14 1995-10-06 08:51:24 quinn Exp $
SHELL=/bin/sh
INCLUDE=-I../include -I.
DEFS=$(INCLUDE)
LIB=$(LIBDIR)/libutil.a
LIBS=
-PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o # dmalloc.o
+PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o # dmalloc.o
CPP=$(CC) -E
RANLIB=ranlib
--- /dev/null
+/*
+ * Copyright (c) 1995, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: wrbuf.c,v $
+ * Revision 1.1 1995-10-06 08:51:25 quinn
+ * Added Write-buffer.
+ *
+ *
+ */
+
+/*
+ * Growing buffer for writing various stuff.
+ */
+
+#include <stdlib.h>
+
+#include <wrbuf.h>
+
+WRBUF wrbuf_alloc(void)
+{
+ WRBUF n;
+
+ if (!(n = malloc(sizeof(*n))))
+ abort();
+ n->buf = 0;
+ n->size = 0;
+ n->pos = 0;
+ return n;
+}
+
+void wrbuf_free(WRBUF b, int free_buf)
+{
+ if (free_buf && b->buf)
+ free(b->buf);
+ free(b);
+}
+
+void wrbuf_rewind(WRBUF b)
+{
+ b->pos = 0;
+}
+
+int wrbuf_grow(WRBUF b, int minsize)
+{
+ int togrow;
+
+ if (!b->size)
+ togrow = 1024;
+ else
+ togrow = b->size;
+ if (togrow < minsize)
+ togrow = minsize;
+ if (b->size && !(b->buf = realloc(b->buf, b->size += togrow)))
+ abort();
+ else if (!b->size && !(b->buf = malloc(b->size = togrow)))
+ abort();
+ return 0;
+}
+
+int wrbuf_write(WRBUF b, char *buf, int size)
+{
+ if (b->pos + size >= b->size)
+ wrbuf_grow(b, size);
+ memcpy(b->buf + b->pos, buf, size);
+ b->pos += size;
+ return 0;
+}