- 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;
- }
+ }
+ else
+ logf (LOG_DEBUG, "send_apdu. Not idle (%s)", msg);
+ return TCL_OK;
+}
+
+int ir_tcl_send_q (IrTcl_Obj *p, IrTcl_Request *rp, const char *msg)
+{
+ int r;
+
+ assert (rp);
+ r = cs_put (p->cs_link, rp->buf_out, rp->len_out);
+ if (r < 0)
+ 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);
+ p->state = IR_TCL_R_Writing;
+ }
+ else
+ {
+ logf (LOG_DEBUG, "Send %s (%d bytes)", msg, rp->len_out);
+ p->state = IR_TCL_R_Waiting;
+ free (rp->buf_out);
+ rp->buf_out = NULL;