# (c) Index Data 1995
# See the file LICENSE for details.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile.in,v 1.13 1995-06-29 14:06:24 adam Exp $
+# $Id: Makefile.in,v 1.14 1995-07-28 10:28:36 adam Exp $
SHELL=/bin/sh
# IrTcl Version
INSTALL_DATA = @INSTALL_DATA@
RANLIB = @RANLIB@
-O=ir-tcl.o marc.o
+O=ir-tcl.o marc.o queue.o
all: ir-tk ir-tcl
dnl IR toolkit for tcl/tk
dnl (c) Index Data 1995
dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.6 1995-06-29 14:06:26 adam Exp $
+dnl $Id: configure.in,v 1.7 1995-07-28 10:28:37 adam Exp $
AC_INIT(ir-tcl.h)
CC=${CC-cc}
AC_SUBST(CC)
YAZDIR="../yaz-1.0b"
elif test "$YAZDIR" = ""; then
YAZDIR="../yaz"
- for i in ../yaz-1.0b3 ../yaz-1.0b2 ../yaz-1.0b1 ../yaz-1.0b ../yaz; do
+ for i in ../yaz-1.0b ../yaz-1.0b2 ../yaz-1.0b3 ../yaz-1.0b4 ../yaz-1.0 ../yaz; do
if test -d $i; then
YAZDIR=$i
fi
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ir-tclp.h,v $
- * Revision 1.11 1995-06-20 08:07:35 adam
+ * Revision 1.12 1995-07-28 10:28:38 adam
+ * First work on request queue.
+ *
+ * Revision 1.11 1995/06/20 08:07:35 adam
* New setting: failInfo.
* Working on better cancel mechanism.
*
struct IrTcl_SetObj_ *set_child;
struct IrTcl_ScanObj_ *scan_child;
+ struct IrTcl_Request_ *request_queue;
IrTcl_SetCObj set_inher;
} IrTcl_Obj;
+typedef struct IrTcl_Request_ {
+ char *name_of_object;
+ struct IrTcl_Request_ *next;
+
+ char *buf_out;
+ int len_out;
+ char *buf_in;
+ int len_in;
+
+ char *callback;
+ char *failback;
+
+ int state;
+} IrTcl_Request;
+
typedef struct {
int condition;
char *addinfo;
int ir_tcl_get_marc (Tcl_Interp *interp, const char *buf,
int argc, char **argv);
+int ir_tcl_send (Tcl_Interp *interp, IrTcl_Obj *p, Z_APDU *apdu,
+ const char *msg);
char *ir_tcl_fread_marc (FILE *inf, size_t *size);
#define IR_TCL_FAIL_CONNECT 1
#define IR_TCL_FAIL_WRITE 3
#define IR_TCL_FAIL_IN_APDU 4
#define IR_TCL_FAIL_UNKNOWN_APDU 5
+
+#define IR_TCL_R_Queue 0
+#define IR_TCL_R_Writing 1
+#define IR_TCL_R_Waiting 2
#endif
--- /dev/null
+
+/*
+ * IR toolkit for tcl/tk
+ * (c) Index Data 1995
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: queue.c,v $
+ * Revision 1.1 1995-07-28 10:28:39 adam
+ * First work on request queue.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <assert.h>
+
+#include "ir-tclp.h"
+
+void *ir_tcl_malloc (size_t size)
+{
+ void *p = malloc (size);
+ if (!p)
+ {
+ logf (LOG_FATAL, "Out of memory. %d bytes requested", size);
+ exit (1);
+ }
+ return p;
+}
+
+int ir_tcl_send (Tcl_Interp *interp, IrTcl_Obj *p, Z_APDU *apdu,
+ const char *msg)
+{
+ IrTcl_Request **rp;
+ int empty;
+
+ if (!z_APDU (p->odr_out, &apdu, 0))
+ {
+ Tcl_AppendResult (interp, odr_errlist [odr_geterror (p->odr_out)],
+ NULL);
+ odr_reset (p->odr_out);
+ return TCL_ERROR;
+ }
+ rp = &p->request_queue;
+ empty = *rp ? 0 : 1;
+ while (*rp)
+ rp = &(*rp)->next;
+ *rp = ir_tcl_malloc (sizeof(**rp));
+ (*rp)->next = NULL;
+ (*rp)->state = IR_TCL_R_Queue;
+ (*rp)->buf_out = odr_getbuf (p->odr_out, &(*rp)->len_out, NULL);
+ odr_reset (p->odr_out);
+ if (empty)
+ {
+ int r;
+
+ r = cs_put (p->cs_link, (*rp)->buf_out, (*rp)->len_out);
+ if (r < 0)
+ {
+ sprintf (interp->result, "cs_put failed in %s", msg);
+ return TCL_ERROR;
+ }
+ else if (r == 1)
+ {
+ ir_select_add_write (cs_fileno (p->cs_link), p);
+ logf (LOG_DEBUG, "Send part of %s", msg);
+ (*rp)->state = IR_TCL_R_Writing;
+ }
+ else
+ {
+ logf (LOG_DEBUG, "Send %s (%d bytes)", msg, (*rp)->len_out);
+ (*rp)->state = IR_TCL_R_Waiting;
+ }
+ }
+ return TCL_OK;
+}
+