res= op.resolver;
- rc= scriptinv_set_xa(&query->on_yes, ip,on_yes); if (rc) goto x_rc;
- rc= scriptinv_set_xa(&query->on_no, ip,on_no); if (rc) goto x_rc;
- rc= scriptinv_set_xa(&query->on_fail,ip,on_fail); if (rc) goto x_rc;
+ rc= scriptinv_set(&query->on_yes, ip,on_yes, xargs); if (rc) goto x_rc;
+ rc= scriptinv_set(&query->on_no, ip,on_no, xargs); if (rc) goto x_rc;
+ rc= scriptinv_set(&query->on_fail,ip,on_fail,xargs); if (rc) goto x_rc;
query->xargs= xargs;
Tcl_IncrRefCount(xargs);
*result= query;
typedef struct { /* semi-opaque - read only, and then only where commented */
Tcl_Interp *ip; /* valid, non-0 and useable if set */
Tcl_Obj *obj; /* non-0 iff set (but only test for 0/non-0) */
+ Tcl_Obj *xargs;
int llength;
} ScriptToInvoke;
void scriptinv_init(ScriptToInvoke *si);
-int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, Tcl_Obj *newscript);
+int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip,
+ Tcl_Obj *newscript, Tcl_Obj *xargs);
void scriptinv_cancel(ScriptToInvoke *si); /* then don't invoke */
/* no separate free function - just cancel */
}
}
-int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, Tcl_Obj *newscript) {
+int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip,
+ Tcl_Obj *newscript, Tcl_Obj *xargs) {
int rc;
scriptinv_cancel(si);
- rc= Tcl_ListObjLength(ip, newscript, &si->llength);
- if (rc) return rc;
-
+ rc= Tcl_ListObjLength(ip, newscript, &si->llength); if (rc) return rc;
Tcl_IncrRefCount(newscript);
+
+ if (xargs) {
+ rc= Tcl_ListObjLength(ip, xargs, &si->llength); if (rc) return rc;
+ Tcl_IncrRefCount(xargs);
+ }
+
si->obj= newscript;
+ si->xargs= xargs;
si->ip= ip;
return 0;
}
invoke= Tcl_DuplicateObj(si->obj);
Tcl_IncrRefCount(invoke);
- rc= Tcl_ListObjReplace(si->ip,invoke,si->llength,0,argc,argv);
+ if (si->xargs) {
+ rc= Tcl_ListObjAppendList(si->ip, invoke, si->xargs);
+ if (rc) goto x_rc;
+ }
+
+ rc= Tcl_ListObjReplace(si->ip, invoke,si->llength,0, argc,argv);
for (i=0; i<argc; i++) { Tcl_DecrRefCount(argv[i]); argv[i]= 0; }
if (rc) goto x_rc;
cancel(sock);
if (newscript) {
- rc= scriptinv_set(&sock->script, ip, newscript);
+ rc= scriptinv_set(&sock->script, ip, newscript, 0);
if (rc) return rc;
}
typedef struct { /* semi-opaque - read only, and then only where commented */
Tcl_Interp *ip; /* valid, non-0 and useable if set */
Tcl_Obj *obj; /* non-0 iff set (but only test for 0/non-0) */
+ Tcl_Obj *xargs;
int llength;
} ScriptToInvoke;
void scriptinv_init(ScriptToInvoke *si);
-int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, Tcl_Obj *newscript);
+int scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip,
+ Tcl_Obj *newscript, Tcl_Obj *xargs);
void scriptinv_cancel(ScriptToInvoke *si); /* then don't invoke */
/* no separate free function - just cancel */
cancel(sock);
if (newscript) {
- rc= scriptinv_set(&sock->script,ip,newscript);
+ rc= scriptinv_set(&sock->script,ip,newscript,0);
if (rc) return rc;
sock->mtu= mtu;