* (c) Index Data 1995
*
* $Log: ir-tcl.c,v $
- * Revision 1.12 1995-03-17 15:45:00 adam
+ * Revision 1.13 1995-03-17 18:26:17 adam
+ * Non-blocking i/o used now. Database names popup as cascade items.
+ *
+ * Revision 1.12 1995/03/17 15:45:00 adam
* Improved target/database setup.
*
* Revision 1.11 1995/03/16 17:54:03 adam
char *buf_in;
int len_in;
+ char *sbuf;
+ int slen;
+
ODR odr_in;
ODR odr_out;
ODR odr_pr;
Z_APDU apdu, *apdup;
IRObj *p = obj;
Z_InitRequest req;
- char *sbuf;
- int slen;
+ int r;
req.referenceId = 0;
req.options = &p->options;
odr_reset (p->odr_out);
return TCL_ERROR;
}
- sbuf = odr_getbuf (p->odr_out, &slen);
- if (cs_put (p->cs_link, sbuf, slen) < 0)
- {
+ p->sbuf = odr_getbuf (p->odr_out, &p->slen);
+ if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
+ {
interp->result = "cs_put failed in init";
return TCL_ERROR;
}
- printf("Sent initializeRequest (%d bytes).\n", slen);
+ else if (r == 1)
+ {
+ ir_select_add_write (cs_fileno(p->cs_link), p);
+ printf("Sent part of initializeRequest (%d bytes).\n", p->slen);
+ }
+ else
+ printf("Sent whole initializeRequest (%d bytes).\n", p->slen);
return TCL_OK;
}
if (cs_type (p->cs_link) == tcpip_type)
{
cs_close (p->cs_link);
- p->cs_link = cs_create (tcpip_type, 1);
+ p->cs_link = cs_create (tcpip_type, 0);
}
else if (cs_type (p->cs_link) == mosi_type)
{
cs_close (p->cs_link);
- p->cs_link = cs_create (mosi_type, 1);
+ p->cs_link = cs_create (mosi_type, 0);
}
else
{
char *cs_type = NULL;
if (argc == 3)
{
+ cs_close (((IRObj*) obj)->cs_link);
if (!strcmp (argv[2], "tcpip"))
- ((IRObj *)obj)->cs_link = cs_create (tcpip_type, 1);
+ ((IRObj *)obj)->cs_link = cs_create (tcpip_type, 0);
else if (!strcmp (argv[2], "mosi"))
- ((IRObj *)obj)->cs_link = cs_create (mosi_type, 1);
+ ((IRObj *)obj)->cs_link = cs_create (mosi_type, 0);
else
{
interp->result = "wrong comstack type";
}
if (!(obj = ir_malloc (interp, sizeof(*obj))))
return TCL_ERROR;
- obj->cs_link = cs_create (tcpip_type, 1);
+ obj->cs_link = cs_create (tcpip_type, 0);
obj->maximumRecordSize = 32768;
obj->preferredMessageSize = 4096;
Odr_oct ccl_query;
IRSetObj *obj = o;
IRObj *p = obj->parent;
- char *sbuf;
- int slen;
+ int r;
p->child = o;
if (argc != 3)
odr_reset (p->odr_out);
return TCL_ERROR;
}
- sbuf = odr_getbuf (p->odr_out, &slen);
- if (cs_put (p->cs_link, sbuf, slen) < 0)
+ p->sbuf = odr_getbuf (p->odr_out, &p->slen);
+ if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
{
interp->result = "cs_put failed in init";
return TCL_ERROR;
}
- printf ("Search request\n");
+ else if (r == 1)
+ {
+ ir_select_add_write (cs_fileno(p->cs_link), p);
+ printf("Sent part of searchRequest (%d bytes).\n", p->slen);
+ }
+ else
+ {
+ printf ("Whole search request\n");
+ }
return TCL_OK;
}
Z_PresentRequest req;
int start;
int number;
- char *sbuf;
- int slen;
+ int r;
if (argc >= 3)
{
odr_reset (p->odr_out);
return TCL_ERROR;
}
- sbuf = odr_getbuf (p->odr_out, &slen);
- if (cs_put (p->cs_link, sbuf, slen) < 0)
+ p->sbuf = odr_getbuf (p->odr_out, &p->slen);
+ if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
{
interp->result = "cs_put failed in init";
return TCL_ERROR;
}
- printf ("Present request, start=%d, num=%d\n", start, number);
+ else if (r == 1)
+ {
+ ir_select_add_write (cs_fileno(p->cs_link), p);
+ printf ("Part of present request, start=%d, num=%d (%d bytes)\n",
+ start, number, p->slen);
+ }
+ else
+ {
+ printf ("Whole present request, start=%d, num=%d (%d bytes)\n",
+ start, number, p->slen);
+ }
return TCL_OK;
}
}
}
-void ir_select_proc (ClientData clientData)
+/*
+ * ir_select_read: handle incoming packages
+ */
+void ir_select_read (ClientData clientData)
{
IRObj *p = clientData;
Z_APDU *apdu;
} while (cs_more (p->cs_link));
}
+/*
+ * ir_select_write: handle outgoing packages - not yet written.
+ */
+void ir_select_write (ClientData clientData)
+{
+ IRObj *p = clientData;
+ int r;
+
+ if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
+ {
+ printf ("select write fail\n");
+ cs_close (p->cs_link);
+ }
+ else if (r == 0) /* remove select bit */
+ {
+ ir_select_remove_write (cs_fileno (p->cs_link), p);
+ }
+}
+
/* ------------------------------------------------------- */
/*
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
return TCL_OK;
}
+
+