3 * IR toolkit for tcl/tk
5 * See the file LICENSE for details.
6 * Sebastian Hammer, Adam Dickmeiss
9 * Revision 1.1 1995-07-28 10:28:39 adam
10 * First work on request queue.
21 void *ir_tcl_malloc (size_t size)
23 void *p = malloc (size);
26 logf (LOG_FATAL, "Out of memory. %d bytes requested", size);
32 int ir_tcl_send (Tcl_Interp *interp, IrTcl_Obj *p, Z_APDU *apdu,
38 if (!z_APDU (p->odr_out, &apdu, 0))
40 Tcl_AppendResult (interp, odr_errlist [odr_geterror (p->odr_out)],
42 odr_reset (p->odr_out);
45 rp = &p->request_queue;
49 *rp = ir_tcl_malloc (sizeof(**rp));
51 (*rp)->state = IR_TCL_R_Queue;
52 (*rp)->buf_out = odr_getbuf (p->odr_out, &(*rp)->len_out, NULL);
53 odr_reset (p->odr_out);
58 r = cs_put (p->cs_link, (*rp)->buf_out, (*rp)->len_out);
61 sprintf (interp->result, "cs_put failed in %s", msg);
66 ir_select_add_write (cs_fileno (p->cs_link), p);
67 logf (LOG_DEBUG, "Send part of %s", msg);
68 (*rp)->state = IR_TCL_R_Writing;
72 logf (LOG_DEBUG, "Send %s (%d bytes)", msg, (*rp)->len_out);
73 (*rp)->state = IR_TCL_R_Waiting;