From 0c66cddf6e923db676ed30691cd1d47b50db0d4a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 5 Feb 1996 17:58:02 +0000 Subject: [PATCH] Ported ir-tcl to use the beta releases of tcl7.5/tk4.1. --- CHANGELOG | 5 ++++- ir-tcl.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- ir-tcl.h | 19 ++++++++++++++++++- ir-tclp.h | 8 +++++++- tclmain.c | 29 ++++++++++++++++++++++++++++- 5 files changed, 108 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bce844d..d9ae8fa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -$Id: CHANGELOG,v 1.14 1996-01-29 11:35:17 adam Exp $ +$Id: CHANGELOG,v 1.15 1996-02-05 17:58:02 adam Exp $ 06/19/95 Release of ir-tcl-1.0b ------------------------------------------------------ @@ -77,4 +77,7 @@ $Id: CHANGELOG,v 1.14 1996-01-29 11:35:17 adam Exp $ 29/01/96 Bug fix: cs_type member in ir-tclp.h renamed to comstackType to avoid conflict with cs_type macro defined by YAZ. +05/02/96 Ported ir-tcl to Tcl7.5b1/tk4.1b1. Ir-tcl is now incompatible with + the alpha versions of tcl7.5/tk4.1. + diff --git a/ir-tcl.c b/ir-tcl.c index 3c6de3b..3cc1149 100644 --- a/ir-tcl.c +++ b/ir-tcl.c @@ -5,7 +5,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ir-tcl.c,v $ - * Revision 1.73 1996-01-29 11:35:19 adam + * Revision 1.74 1996-02-05 17:58:03 adam + * Ported ir-tcl to use the beta releases of tcl7.5/tk4.1. + * + * Revision 1.73 1996/01/29 11:35:19 adam * Bug fix: cs_type member renamed to comstackType to avoid conflict with * cs_type macro defined by YAZ. * @@ -262,11 +265,7 @@ #include #include #include -#ifdef WINDOWS #include -#else -#include -#endif #include #define CS_BLOCK 0 @@ -1058,6 +1057,13 @@ static int do_connect (void *obj, Tcl_Interp *interp, p->comstackType, NULL); return TCL_ERROR; } +#if IRTCL_GENERIC_FILES +#ifdef WINDOWS + p->csFile = Tcl_GetFile (cs_fileno(p->cs_link), TCL_WIN_SOCKET); +#else + p->csFile = Tcl_GetFile (cs_fileno(p->cs_link), TCL_UNIX_FD); +#endif +#endif if ((r=cs_connect (p->cs_link, addr)) < 0) { interp->result = "connect fail"; @@ -1066,10 +1072,18 @@ static int do_connect (void *obj, Tcl_Interp *interp, } logf(LOG_DEBUG, "cs_connect() returned %d", r); p->eventType = "connect"; +#if IRTCL_GENERIC_FILES + ir_select_add (p->csFile, p); +#else ir_select_add (cs_fileno (p->cs_link), p); +#endif if (r == 1) { +#if IRTCL_GENERIC_FILES + ir_select_add_write (p->csFile, p); +#else ir_select_add_write (cs_fileno (p->cs_link), p); +#endif p->state = IR_TCL_R_Connecting; } else @@ -1098,14 +1112,22 @@ static int do_disconnect (void *obj, Tcl_Interp *interp, p->eventType = NULL; p->hostname = NULL; p->cs_link = NULL; +#if IRTCL_GENERIC_FILES + p->csFile = 0; +#endif return TCL_OK; } if (p->hostname) { free (p->hostname); p->hostname = NULL; +#if IRTCL_GENERIC_FILES + ir_select_remove_write (p->csFile, p); + ir_select_remove (p->csFile, p); +#else ir_select_remove_write (cs_fileno (p->cs_link), p); ir_select_remove (cs_fileno (p->cs_link), p); +#endif odr_reset (p->odr_in); @@ -1113,6 +1135,10 @@ static int do_disconnect (void *obj, Tcl_Interp *interp, logf(LOG_DEBUG, "Closing connection"); cs_close (p->cs_link); p->cs_link = NULL; +#if IRTCL_GENERIC_FILES + Tcl_FreeFile (p->csFile); + p->csFile = NULL; +#endif ODR_MASK_ZERO (&p->options); ODR_MASK_SET (&p->options, 0); @@ -3360,7 +3386,11 @@ void ir_select_read (ClientData clientData) return; } p->state = IR_TCL_R_Idle; +#if IRTCL_GENERIC_FILES + ir_select_remove_write (p->csFile, p); +#else ir_select_remove_write (cs_fileno (p->cs_link), p); +#endif if (r < 0) { logf (LOG_DEBUG, "cs_rcvconnect error"); @@ -3390,7 +3420,11 @@ void ir_select_read (ClientData clientData) if ((r=cs_get (p->cs_link, &p->buf_in, &p->len_in)) <= 0) { logf (LOG_DEBUG, "cs_get failed, code %d", r); +#if IRTCL_GENERIC_FILES + ir_select_remove (p->csFile, p); +#else ir_select_remove (cs_fileno (p->cs_link), p); +#endif do_disconnect (p, NULL, 2, NULL); if (p->failback) { @@ -3522,7 +3556,11 @@ void ir_select_write (ClientData clientData) if (r < 0) { logf (LOG_DEBUG, "cs_rcvconnect error"); +#if IRTCL_GENERIC_FILES + ir_select_remove_write (p->csFile, p); +#else ir_select_remove_write (cs_fileno (p->cs_link), p); +#endif if (p->failback) { p->failInfo = IR_TCL_FAIL_CONNECT; @@ -3531,7 +3569,11 @@ void ir_select_write (ClientData clientData) do_disconnect (p, NULL, 2, NULL); return; } +#if IRTCL_GENERIC_FILES + ir_select_remove_write (p->csFile, p); +#else ir_select_remove_write (cs_fileno (p->cs_link), p); +#endif if (p->callback) IrTcl_eval (p->interp, p->callback); return; @@ -3556,7 +3598,11 @@ void ir_select_write (ClientData clientData) { logf(LOG_DEBUG, "Write completed"); p->state = IR_TCL_R_Waiting; +#if IRTCL_GENERIC_FILES + ir_select_remove_write (p->csFile, p); +#else ir_select_remove_write (cs_fileno (p->cs_link), p); +#endif free (rq->buf_out); rq->buf_out = NULL; } diff --git a/ir-tcl.h b/ir-tcl.h index 6dd74ff..7e2db18 100644 --- a/ir-tcl.h +++ b/ir-tcl.h @@ -24,7 +24,10 @@ * OF THIS SOFTWARE. * * $Log: ir-tcl.h,v $ - * Revision 1.11 1995-09-21 13:11:52 adam + * Revision 1.12 1996-02-05 17:58:04 adam + * Ported ir-tcl to use the beta releases of tcl7.5/tk4.1. + * + * Revision 1.11 1995/09/21 13:11:52 adam * Support of dynamic loading. * Test script uses load command if necessary. * @@ -60,12 +63,26 @@ #ifndef IR_TCL_H #define IR_TCL_H +#if TCL_MAJOR_VERSION > 7 || (TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5) +#define IRTCL_GENERIC_FILES 1 +#else +#define IRTCL_GENERIC_FILES 0 +#endif + int Irtcl_Init (Tcl_Interp *interp); +#if IRTCL_GENERIC_FILES +void ir_select_add (Tcl_File file, void *obj); +void ir_select_add_write (Tcl_File file, void *obj); +void ir_select_remove (Tcl_File file, void *obj); +void ir_select_remove_write (Tcl_File file, void *obj); +#else void ir_select_add (int fd, void *obj); void ir_select_add_write (int fd, void *obj); void ir_select_remove (int fd, void *obj); void ir_select_remove_write (int fd, void *obj); +#endif + void ir_select_read (ClientData clientData); void ir_select_write (ClientData clientData); diff --git a/ir-tclp.h b/ir-tclp.h index 72a417f..2959875 100644 --- a/ir-tclp.h +++ b/ir-tclp.h @@ -5,7 +5,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ir-tclp.h,v $ - * Revision 1.24 1996-01-29 11:35:27 adam + * Revision 1.25 1996-02-05 17:58:04 adam + * Ported ir-tcl to use the beta releases of tcl7.5/tk4.1. + * + * Revision 1.24 1996/01/29 11:35:27 adam * Bug fix: cs_type member renamed to comstackType to avoid conflict with * cs_type macro defined by YAZ. * @@ -146,6 +149,9 @@ typedef struct { int protocol_type; int failInfo; COMSTACK cs_link; +#if IRTCL_GENERIC_FILES + Tcl_File csFile; +#endif int state; diff --git a/tclmain.c b/tclmain.c index 46fe8eb..a238fba 100644 --- a/tclmain.c +++ b/tclmain.c @@ -5,7 +5,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: tclmain.c,v $ - * Revision 1.15 1996-01-10 09:18:45 adam + * Revision 1.16 1996-02-05 17:58:05 adam + * Ported ir-tcl to use the beta releases of tcl7.5/tk4.1. + * + * Revision 1.15 1996/01/10 09:18:45 adam * PDU specific callbacks implemented: initRespnse, searchResponse, * presentResponse and scanResponse. * Bug fix in the command line shell (tclmain.c) - discovered on OSF/1. @@ -240,8 +243,14 @@ void tcl_mainloop (Tcl_Interp *interp, int interactive) } } +#if IRTCL_GENERIC_FILES +void ir_select_add (Tcl_File file, void *obj) +{ + int fd = (int) Tcl_GetFileInfo (file, NULL); +#else void ir_select_add (int fd, void *obj) { +#endif callback_table[fd].obj = obj; callback_table[fd].r_handle = ir_select_read; callback_table[fd].w_handle = NULL; @@ -250,20 +259,38 @@ void ir_select_add (int fd, void *obj) max_fd = fd; } +#if IRTCL_GENERIC_FILES +void ir_select_add_write (Tcl_File file, void *obj) +{ + int fd = (int) Tcl_GetFileInfo (file, NULL); +#else void ir_select_add_write (int fd, void *obj) { +#endif callback_table[fd].w_handle = ir_select_write; if (fd > max_fd) max_fd = fd; } +#if IRTCL_GENERIC_FILES +void ir_select_remove_write (Tcl_File file, void *obj) +{ + int fd = (int) Tcl_GetFileInfo (file, NULL); +#else void ir_select_remove_write (int fd, void *obj) { +#endif callback_table[fd].w_handle = NULL; } +#if IRTCL_GENERIC_FILES +void ir_select_remove (Tcl_File file, void *obj) +{ + int fd = (int) Tcl_GetFileInfo (file, NULL); +#else void ir_select_remove (int fd, void *obj) { +#endif callback_table[fd].r_handle = NULL; callback_table[fd].w_handle = NULL; callback_table[fd].x_handle = NULL; -- 1.7.10.4