| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#include <xpap.h> |
| 6 |
|
| 7 |
#if HAVE_TCL |
| 8 |
|
| 9 |
#include <tcl.h> |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#define XCONST84 |
| 24 |
#if TCL_MAJOR_VERSION >= 8 |
| 25 |
#if TCL_MINOR_VERSION >= 4 |
| 26 |
#undef XCONST84 |
| 27 |
#define XCONST84 CONST |
| 28 |
#endif |
| 29 |
#endif |
| 30 |
|
| 31 |
#ifdef NULLSTRING |
| 32 |
#undef NULLSTRING |
| 33 |
#endif |
| 34 |
#define NULLSTRING "" |
| 35 |
|
| 36 |
#define TCL_NULLSTR(s) (!s || !*s || !strcmp(s, "{}")) |
| 37 |
|
| 38 |
#define TY_CLIENT 1 |
| 39 |
#define TY_SERVER 2 |
| 40 |
|
| 41 |
#ifndef MAX_XPAS |
| 42 |
#define MAX_XPAS 10000 |
| 43 |
#endif |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
typedef struct xpatclclientdatarec{ |
| 51 |
Tcl_Interp *interp; |
| 52 |
char *callback; |
| 53 |
char *client_data; |
| 54 |
} *XPATclClientData, XPATclClientDataRec; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
#ifdef ANSI_FUNC |
| 69 |
static int |
| 70 |
Tcl_GetXPAFromObj(Tcl_Interp *interp, Tcl_Obj *obj, int flag, XPA *xpa) |
| 71 |
#else |
| 72 |
static int Tcl_GetXPAFromObj(interp, obj, flag, xpa) |
| 73 |
Tcl_Interp *interp; |
| 74 |
Tcl_Obj *obj; |
| 75 |
int flag; |
| 76 |
XPA *xpa; |
| 77 |
#endif |
| 78 |
{ |
| 79 |
char *s; |
| 80 |
void *lval; |
| 81 |
Tcl_Obj *resultPtr; |
| 82 |
|
| 83 |
|
| 84 |
resultPtr = Tcl_GetObjResult(interp); |
| 85 |
|
| 86 |
if( (s = Tcl_GetStringFromObj(obj, NULL)) == NULL ){ |
| 87 |
return(TCL_ERROR); |
| 88 |
} |
| 89 |
if( strncmp(s, "xpa_", 4) || (sscanf(&(s[4]), "%p", &lval) != 1) ){ |
| 90 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa handle", -1); |
| 91 |
return(TCL_ERROR); |
| 92 |
} |
| 93 |
*xpa = (XPA)lval; |
| 94 |
|
| 95 |
switch(flag){ |
| 96 |
case TY_CLIENT: |
| 97 |
if( !XPAClientValid(*xpa) ){ |
| 98 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa client handle", -1); |
| 99 |
return(TCL_ERROR); |
| 100 |
} |
| 101 |
break; |
| 102 |
case TY_SERVER: |
| 103 |
if( !XPAValid(*xpa) ){ |
| 104 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa server handle", -1); |
| 105 |
return(TCL_ERROR); |
| 106 |
} |
| 107 |
break; |
| 108 |
} |
| 109 |
return(TCL_OK); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
#ifdef ANSI_FUNC |
| 129 |
static int |
| 130 |
XPATclHandler (void *client_data, void *call_data, char *paramlist, |
| 131 |
char *buf, int len, int nargs) |
| 132 |
#else |
| 133 |
static int XPATclHandler(client_data, call_data, paramlist, buf, len, nargs) |
| 134 |
void *client_data; |
| 135 |
void *call_data; |
| 136 |
char *paramlist; |
| 137 |
char *buf; |
| 138 |
int len; |
| 139 |
int nargs; |
| 140 |
#endif |
| 141 |
{ |
| 142 |
XPA xpa = (XPA)call_data; |
| 143 |
XPATclClientData xptr = (XPATclClientData)client_data; |
| 144 |
Tcl_CmdInfo info; |
| 145 |
Tcl_Obj *objv[10]; |
| 146 |
Tcl_Obj *resultPtr; |
| 147 |
int result; |
| 148 |
int object; |
| 149 |
char tbuf[SZ_LINE]; |
| 150 |
XCONST84 char *argv[10]; |
| 151 |
char *s=NULL; |
| 152 |
char *t=NULL; |
| 153 |
char *cmd; |
| 154 |
|
| 155 |
|
| 156 |
if( !xptr || !xptr->callback ){ |
| 157 |
XPAError(xpa, "Invalid tcl command for xpa callback"); |
| 158 |
return(-1); |
| 159 |
} |
| 160 |
|
| 161 |
cmd = xptr->callback; |
| 162 |
|
| 163 |
|
| 164 |
if( !Tcl_GetCommandInfo(xptr->interp, cmd, &info) ){ |
| 165 |
XPAError(xpa, "Unknown tcl command for xpa callback"); |
| 166 |
return(-1); |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
snprintf(tbuf, SZ_LINE, "xpa_%p", xpa); |
| 171 |
s = xstrdup(tbuf); |
| 172 |
if( nargs > 4 ){ |
| 173 |
snprintf(tbuf, SZ_LINE, "%d", len); |
| 174 |
t = xstrdup(tbuf); |
| 175 |
} |
| 176 |
|
| 177 |
|
| 178 |
object = info.isNativeObjectProc; |
| 179 |
if (object) { |
| 180 |
|
| 181 |
objv[0] = Tcl_NewStringObj(cmd, strlen(cmd)); |
| 182 |
objv[1] = Tcl_NewStringObj(s, strlen(s)); |
| 183 |
if( (xptr->client_data == NULL) || (*xptr->client_data == '\0') ) |
| 184 |
objv[2] = Tcl_NewStringObj(NULLSTRING, strlen(NULLSTRING)); |
| 185 |
else |
| 186 |
objv[2] = Tcl_NewStringObj(xptr->client_data, strlen(xptr->client_data)); |
| 187 |
if( (paramlist == NULL) || (*paramlist == '\0') ) |
| 188 |
objv[3] = Tcl_NewStringObj(NULLSTRING, strlen(NULLSTRING)); |
| 189 |
else |
| 190 |
objv[3] = Tcl_NewStringObj(paramlist, strlen(paramlist)); |
| 191 |
if( nargs > 4 ){ |
| 192 |
if( (buf == NULL) || (*buf == '\0') || (len == 0) ) |
| 193 |
objv[4] = Tcl_NewStringObj(NULLSTRING, strlen(NULLSTRING)); |
| 194 |
else |
| 195 |
objv[4] = Tcl_NewStringObj(buf, len); |
| 196 |
objv[5] = Tcl_NewStringObj(t, strlen(t)); |
| 197 |
} |
| 198 |
} else { |
| 199 |
argv[0] = cmd; |
| 200 |
argv[1] = s; |
| 201 |
argv[2] = xptr->client_data; |
| 202 |
argv[3] = paramlist; |
| 203 |
if( nargs > 4 ){ |
| 204 |
argv[4] = buf; |
| 205 |
argv[5] = t; |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
Tcl_ResetResult(xptr->interp); |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
if (object) { |
| 216 |
result = (*info.objProc)(info.objClientData, xptr->interp, nargs, objv); |
| 217 |
|
| 218 |
resultPtr = Tcl_GetObjResult(xptr->interp); |
| 219 |
Tcl_SetResult(xptr->interp, Tcl_GetStringFromObj(resultPtr, NULL), |
| 220 |
TCL_VOLATILE); |
| 221 |
} else { |
| 222 |
result = (*info.proc)(info.clientData, xptr->interp, nargs, argv); |
| 223 |
} |
| 224 |
|
| 225 |
|
| 226 |
if( s ) xfree(s); |
| 227 |
if( t ) xfree(t); |
| 228 |
|
| 229 |
|
| 230 |
if( result == TCL_OK ){ |
| 231 |
return(0); |
| 232 |
} |
| 233 |
else{ |
| 234 |
s = (char *)Tcl_GetStringResult(xptr->interp); |
| 235 |
if( !strncmp(s, "XPA$ERROR: ", 11) ) |
| 236 |
s += 11; |
| 237 |
XPAError(xpa, s); |
| 238 |
return(-1); |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
#ifdef ANSI_FUNC |
| 258 |
static int |
| 259 |
XPATclReceive (void *client_data, void *call_data, char *paramlist, |
| 260 |
char *buf, int len) |
| 261 |
#else |
| 262 |
static int XPATclReceive(client_data, call_data, paramlist, buf, len) |
| 263 |
void *client_data; |
| 264 |
void *call_data; |
| 265 |
char *paramlist; |
| 266 |
char *buf; |
| 267 |
int len; |
| 268 |
#endif |
| 269 |
{ |
| 270 |
return(XPATclHandler(client_data, call_data, paramlist, buf, len, 6)); |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
#ifdef ANSI_FUNC |
| 285 |
static int |
| 286 |
XPATclSend (void *client_data, void *call_data, char *paramlist, |
| 287 |
char **buf, int *len) |
| 288 |
#else |
| 289 |
static int XPATclSend(client_data, call_data, paramlist, buf, len) |
| 290 |
void *client_data; |
| 291 |
void *call_data; |
| 292 |
char *paramlist; |
| 293 |
char **buf; |
| 294 |
int *len; |
| 295 |
#endif |
| 296 |
{ |
| 297 |
return(XPATclHandler(client_data, call_data, paramlist, NULL, 0, 4)); |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
#ifdef ANSI_FUNC |
| 312 |
static int |
| 313 |
XPATclInfo (void *client_data, void *call_data, char *paramlist) |
| 314 |
#else |
| 315 |
static int XPATclInfo(client_data, call_data, paramlist) |
| 316 |
void *client_data; |
| 317 |
void *call_data; |
| 318 |
char *paramlist; |
| 319 |
#endif |
| 320 |
{ |
| 321 |
return(XPATclHandler(client_data, call_data, paramlist, NULL, 0, 4)); |
| 322 |
} |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
#ifdef ANSI_FUNC |
| 342 |
static int |
| 343 |
XPANew_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 344 |
int objc, Tcl_Obj *CONST objv[]) |
| 345 |
#else |
| 346 |
static int XPANew_Tcl(clientData, interp, objc, objv) |
| 347 |
ClientData clientData; |
| 348 |
Tcl_Interp *interp; |
| 349 |
int objc; |
| 350 |
Tcl_Obj *CONST objv[]; |
| 351 |
#endif |
| 352 |
{ |
| 353 |
char *xclass; |
| 354 |
char *name; |
| 355 |
char *help; |
| 356 |
char *send_cb; |
| 357 |
char *sdata; |
| 358 |
char *smode; |
| 359 |
char *rec_cb; |
| 360 |
char *rdata; |
| 361 |
char *rmode; |
| 362 |
char tbuf[SZ_LINE]; |
| 363 |
XPA xpa; |
| 364 |
SendCb sproc; |
| 365 |
ReceiveCb rproc; |
| 366 |
XPATclClientData sptr; |
| 367 |
XPATclClientData rptr; |
| 368 |
Tcl_Obj *resultPtr; |
| 369 |
|
| 370 |
|
| 371 |
if( objc != 10 ){ |
| 372 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 373 |
"class name help sproc sdata smode rproc rdata rmode"); |
| 374 |
return(TCL_ERROR); |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
xclass = Tcl_GetStringFromObj(objv[1], NULL); |
| 379 |
name = Tcl_GetStringFromObj(objv[2], NULL); |
| 380 |
help = Tcl_GetStringFromObj(objv[3], NULL); |
| 381 |
send_cb = Tcl_GetStringFromObj(objv[4], NULL); |
| 382 |
sdata = Tcl_GetStringFromObj(objv[5], NULL); |
| 383 |
smode = Tcl_GetStringFromObj(objv[6], NULL); |
| 384 |
rec_cb = Tcl_GetStringFromObj(objv[7], NULL); |
| 385 |
rdata = Tcl_GetStringFromObj(objv[8], NULL); |
| 386 |
rmode = Tcl_GetStringFromObj(objv[9], NULL); |
| 387 |
|
| 388 |
|
| 389 |
resultPtr = Tcl_GetObjResult(interp); |
| 390 |
|
| 391 |
|
| 392 |
if( ((send_cb == NULL) || (*send_cb == '\0') ) ){ |
| 393 |
sproc = NULL; |
| 394 |
sptr = NULL; |
| 395 |
} |
| 396 |
else{ |
| 397 |
sproc = XPATclSend; |
| 398 |
sptr = (XPATclClientData)xcalloc(1, sizeof(XPATclClientDataRec)); |
| 399 |
sptr->interp = interp; |
| 400 |
sptr->callback = xstrdup(send_cb); |
| 401 |
sptr->client_data = xstrdup(sdata); |
| 402 |
} |
| 403 |
if( ((rec_cb == NULL) || (*rec_cb == '\0') ) ){ |
| 404 |
rproc = NULL; |
| 405 |
rptr = NULL; |
| 406 |
} |
| 407 |
else{ |
| 408 |
rproc = XPATclReceive; |
| 409 |
rptr = (XPATclClientData)xcalloc(1, sizeof(XPATclClientDataRec)); |
| 410 |
rptr->interp = interp; |
| 411 |
rptr->callback = xstrdup(rec_cb); |
| 412 |
rptr->client_data = xstrdup(rdata); |
| 413 |
} |
| 414 |
|
| 415 |
|
| 416 |
if( !sproc && !rproc ){ |
| 417 |
Tcl_SetStringObj(resultPtr, |
| 418 |
"XPA$ERROR: xpanew requires send_cb or rec_cb (or both)", -1); |
| 419 |
return(TCL_ERROR); |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
xpa = XPANew(xclass, name, help, sproc, sptr, smode, rproc, rptr, rmode); |
| 424 |
if( xpa == NULL ){ |
| 425 |
Tcl_SetStringObj(resultPtr, |
| 426 |
"XPA$ERROR: could not create XPA access point", -1); |
| 427 |
return(TCL_ERROR); |
| 428 |
} |
| 429 |
else{ |
| 430 |
|
| 431 |
XPATclAddInput(xpa); |
| 432 |
|
| 433 |
snprintf(tbuf, SZ_LINE, "xpa_%p", xpa); |
| 434 |
Tcl_SetStringObj(resultPtr, tbuf, -1); |
| 435 |
return(TCL_OK); |
| 436 |
} |
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
#ifdef ANSI_FUNC |
| 455 |
static int |
| 456 |
XPAFree_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 457 |
int objc, Tcl_Obj *CONST objv[]) |
| 458 |
#else |
| 459 |
static int XPAFree_Tcl(clientData, interp, objc, objv) |
| 460 |
ClientData clientData; |
| 461 |
Tcl_Interp *interp; |
| 462 |
int objc; |
| 463 |
Tcl_Obj *CONST objv[]; |
| 464 |
#endif |
| 465 |
{ |
| 466 |
XPA xpa; |
| 467 |
XPATclClientData ptr; |
| 468 |
|
| 469 |
|
| 470 |
if( objc != 2 ){ |
| 471 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa"); |
| 472 |
return(TCL_ERROR); |
| 473 |
} |
| 474 |
|
| 475 |
|
| 476 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa) != TCL_OK){ |
| 477 |
return(TCL_ERROR); |
| 478 |
} |
| 479 |
|
| 480 |
|
| 481 |
Tcl_ResetResult(interp); |
| 482 |
|
| 483 |
|
| 484 |
if( xpa->send_data ){ |
| 485 |
ptr = (XPATclClientData)xpa->send_data; |
| 486 |
if( ptr->callback ) xfree( ptr->callback); |
| 487 |
if( ptr->client_data ) xfree( ptr->client_data); |
| 488 |
xfree(xpa->send_data); |
| 489 |
} |
| 490 |
if( xpa->receive_data ){ |
| 491 |
ptr = (XPATclClientData)xpa->receive_data; |
| 492 |
if( ptr->callback ) xfree( ptr->callback); |
| 493 |
if( ptr->client_data ) xfree( ptr->client_data); |
| 494 |
xfree(xpa->receive_data); |
| 495 |
} |
| 496 |
if( xpa->info_data ){ |
| 497 |
ptr = (XPATclClientData)xpa->info_data; |
| 498 |
if( ptr->callback ) xfree( ptr->callback); |
| 499 |
if( ptr->client_data ) xfree( ptr->client_data); |
| 500 |
xfree(xpa->info_data); |
| 501 |
} |
| 502 |
|
| 503 |
|
| 504 |
XPAFree(xpa); |
| 505 |
return(TCL_OK); |
| 506 |
} |
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
#ifdef ANSI_FUNC |
| 526 |
static int |
| 527 |
XPAInfoNew_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 528 |
int objc, Tcl_Obj *CONST objv[]) |
| 529 |
#else |
| 530 |
static int XPAInfoNew_Tcl(clientData, interp, objc, objv) |
| 531 |
ClientData clientData; |
| 532 |
Tcl_Interp *interp; |
| 533 |
int objc; |
| 534 |
Tcl_Obj *CONST objv[]; |
| 535 |
#endif |
| 536 |
{ |
| 537 |
char *xclass; |
| 538 |
char *name; |
| 539 |
char *info_cb; |
| 540 |
char *idata; |
| 541 |
char *imode; |
| 542 |
char tbuf[SZ_LINE]; |
| 543 |
XPA xpa; |
| 544 |
InfoCb iproc; |
| 545 |
XPATclClientData iptr; |
| 546 |
Tcl_Obj *resultPtr; |
| 547 |
|
| 548 |
|
| 549 |
if( objc != 6 ){ |
| 550 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 551 |
"class name iproc idata imode"); |
| 552 |
return(TCL_ERROR); |
| 553 |
} |
| 554 |
|
| 555 |
|
| 556 |
xclass = Tcl_GetStringFromObj(objv[1], NULL); |
| 557 |
name = Tcl_GetStringFromObj(objv[2], NULL); |
| 558 |
info_cb = Tcl_GetStringFromObj(objv[3], NULL); |
| 559 |
idata = Tcl_GetStringFromObj(objv[4], NULL); |
| 560 |
imode = Tcl_GetStringFromObj(objv[5], NULL); |
| 561 |
|
| 562 |
|
| 563 |
resultPtr = Tcl_GetObjResult(interp); |
| 564 |
|
| 565 |
|
| 566 |
if( info_cb == NULL ){ |
| 567 |
Tcl_SetStringObj(resultPtr, |
| 568 |
"XPA$ERROR: xpainfonew requires info_cb", -1); |
| 569 |
return(TCL_ERROR); |
| 570 |
} |
| 571 |
else{ |
| 572 |
iproc = XPATclInfo; |
| 573 |
iptr = (XPATclClientData)xcalloc(1, sizeof(XPATclClientDataRec)); |
| 574 |
iptr->interp = interp; |
| 575 |
iptr->callback = xstrdup(info_cb); |
| 576 |
iptr->client_data = xstrdup(idata); |
| 577 |
} |
| 578 |
|
| 579 |
|
| 580 |
xpa = XPAInfoNew(xclass, name, iproc, iptr, imode); |
| 581 |
if( xpa == NULL ){ |
| 582 |
Tcl_SetStringObj(resultPtr, |
| 583 |
"XPA$ERROR: could not create XPA info access point", -1); |
| 584 |
return(TCL_ERROR); |
| 585 |
} |
| 586 |
else{ |
| 587 |
|
| 588 |
XPATclAddInput(xpa); |
| 589 |
|
| 590 |
snprintf(tbuf, SZ_LINE, "xpa_%p", xpa); |
| 591 |
Tcl_SetStringObj(resultPtr, tbuf, -1); |
| 592 |
return(TCL_OK); |
| 593 |
} |
| 594 |
} |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
#ifdef ANSI_FUNC |
| 612 |
static int |
| 613 |
XPACmdNew_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 614 |
int objc, Tcl_Obj *CONST objv[]) |
| 615 |
#else |
| 616 |
static int XPACmdNew_Tcl(clientData, interp, objc, objv) |
| 617 |
ClientData clientData; |
| 618 |
Tcl_Interp *interp; |
| 619 |
int objc; |
| 620 |
Tcl_Obj *CONST objv[]; |
| 621 |
#endif |
| 622 |
{ |
| 623 |
char *xclass; |
| 624 |
char *name; |
| 625 |
char tbuf[SZ_LINE]; |
| 626 |
XPA xpa; |
| 627 |
Tcl_Obj *resultPtr; |
| 628 |
|
| 629 |
|
| 630 |
if( objc != 3 ){ |
| 631 |
Tcl_WrongNumArgs(interp, 1, objv, "class name"); |
| 632 |
return(TCL_ERROR); |
| 633 |
} |
| 634 |
|
| 635 |
|
| 636 |
xclass = Tcl_GetStringFromObj(objv[1], NULL); |
| 637 |
name = Tcl_GetStringFromObj(objv[2], NULL); |
| 638 |
|
| 639 |
|
| 640 |
resultPtr = Tcl_GetObjResult(interp); |
| 641 |
|
| 642 |
|
| 643 |
if( (xpa = XPACmdNew(xclass, name)) == NULL ){ |
| 644 |
Tcl_SetStringObj(resultPtr, |
| 645 |
"XPA$ERROR: could not create XPA command access point", -1); |
| 646 |
return(TCL_ERROR); |
| 647 |
} |
| 648 |
else{ |
| 649 |
|
| 650 |
XPATclAddInput(xpa); |
| 651 |
|
| 652 |
snprintf(tbuf, SZ_LINE, "xpa_%p", xpa); |
| 653 |
Tcl_SetStringObj(resultPtr, tbuf, -1); |
| 654 |
return(TCL_OK); |
| 655 |
} |
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
#ifdef ANSI_FUNC |
| 676 |
static int |
| 677 |
XPACmdAdd_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 678 |
int objc, Tcl_Obj *CONST objv[]) |
| 679 |
#else |
| 680 |
static int XPACmdAdd_Tcl(clientData, interp, objc, objv) |
| 681 |
ClientData clientData; |
| 682 |
Tcl_Interp *interp; |
| 683 |
int objc; |
| 684 |
Tcl_Obj *CONST objv[]; |
| 685 |
#endif |
| 686 |
{ |
| 687 |
char *name; |
| 688 |
char *help; |
| 689 |
char *send_cb; |
| 690 |
char *sdata; |
| 691 |
char *smode; |
| 692 |
char *rec_cb; |
| 693 |
char *rdata; |
| 694 |
char *rmode; |
| 695 |
char tbuf[SZ_LINE]; |
| 696 |
XPA xpa; |
| 697 |
XPACmd xpacmd; |
| 698 |
SendCb sproc; |
| 699 |
ReceiveCb rproc; |
| 700 |
XPATclClientData sptr; |
| 701 |
XPATclClientData rptr; |
| 702 |
Tcl_Obj *resultPtr; |
| 703 |
|
| 704 |
|
| 705 |
if( objc != 10 ){ |
| 706 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 707 |
"class name help sproc sdata smode rproc rdata rmode"); |
| 708 |
return(TCL_ERROR); |
| 709 |
} |
| 710 |
|
| 711 |
|
| 712 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa) != TCL_OK){ |
| 713 |
return(TCL_ERROR); |
| 714 |
} |
| 715 |
|
| 716 |
name = Tcl_GetStringFromObj(objv[2], NULL); |
| 717 |
help = Tcl_GetStringFromObj(objv[3], NULL); |
| 718 |
send_cb = Tcl_GetStringFromObj(objv[4], NULL); |
| 719 |
sdata = Tcl_GetStringFromObj(objv[5], NULL); |
| 720 |
smode = Tcl_GetStringFromObj(objv[6], NULL); |
| 721 |
rec_cb = Tcl_GetStringFromObj(objv[7], NULL); |
| 722 |
rdata = Tcl_GetStringFromObj(objv[8], NULL); |
| 723 |
rmode = Tcl_GetStringFromObj(objv[9], NULL); |
| 724 |
|
| 725 |
|
| 726 |
resultPtr = Tcl_GetObjResult(interp); |
| 727 |
|
| 728 |
|
| 729 |
if( ((send_cb == NULL) || (*send_cb == '\0') ) ){ |
| 730 |
sproc = NULL; |
| 731 |
sptr = NULL; |
| 732 |
} |
| 733 |
else{ |
| 734 |
sproc = XPATclSend; |
| 735 |
sptr = (XPATclClientData)xcalloc(1, sizeof(XPATclClientDataRec)); |
| 736 |
sptr->interp = interp; |
| 737 |
sptr->callback = xstrdup(send_cb); |
| 738 |
sptr->client_data = xstrdup(sdata); |
| 739 |
} |
| 740 |
if( ((rec_cb == NULL) || (*rec_cb == '\0') ) ){ |
| 741 |
rproc = NULL; |
| 742 |
rptr = NULL; |
| 743 |
} |
| 744 |
else{ |
| 745 |
rproc = XPATclReceive; |
| 746 |
rptr = (XPATclClientData)xcalloc(1, sizeof(XPATclClientDataRec)); |
| 747 |
rptr->interp = interp; |
| 748 |
rptr->callback = xstrdup(rec_cb); |
| 749 |
rptr->client_data = xstrdup(rdata); |
| 750 |
} |
| 751 |
|
| 752 |
|
| 753 |
if( !sproc && !rproc ){ |
| 754 |
Tcl_SetStringObj(resultPtr, |
| 755 |
"XPA$ERROR: xpacmdadd requires send_cb or rec_cb (or both)", -1); |
| 756 |
return(TCL_ERROR); |
| 757 |
} |
| 758 |
|
| 759 |
|
| 760 |
xpacmd = XPACmdAdd(xpa, name, help, sproc, sptr, smode, rproc, rptr, rmode); |
| 761 |
if( xpacmd == NULL ){ |
| 762 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: could not create XPA command", -1); |
| 763 |
return(TCL_ERROR); |
| 764 |
} |
| 765 |
else{ |
| 766 |
|
| 767 |
snprintf(tbuf, SZ_LINE, "xpacmd_%p", xpacmd); |
| 768 |
Tcl_SetStringObj(resultPtr, tbuf, -1); |
| 769 |
return(TCL_OK); |
| 770 |
} |
| 771 |
} |
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
#ifdef ANSI_FUNC |
| 789 |
static int |
| 790 |
XPACmdDel_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 791 |
int objc, Tcl_Obj *CONST objv[]) |
| 792 |
#else |
| 793 |
static int XPACmdDel_Tcl(clientData, interp, objc, objv) |
| 794 |
ClientData clientData; |
| 795 |
Tcl_Interp *interp; |
| 796 |
int objc; |
| 797 |
Tcl_Obj *CONST objv[]; |
| 798 |
#endif |
| 799 |
{ |
| 800 |
void *lval; |
| 801 |
char *s; |
| 802 |
XPA xpa; |
| 803 |
XPACmd cmd; |
| 804 |
Tcl_Obj *resultPtr; |
| 805 |
|
| 806 |
|
| 807 |
if( objc != 3 ){ |
| 808 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa cmd"); |
| 809 |
return(TCL_ERROR); |
| 810 |
} |
| 811 |
|
| 812 |
|
| 813 |
resultPtr = Tcl_GetObjResult(interp); |
| 814 |
|
| 815 |
|
| 816 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa) != TCL_OK){ |
| 817 |
return(TCL_ERROR); |
| 818 |
} |
| 819 |
|
| 820 |
|
| 821 |
if( (s = Tcl_GetStringFromObj(objv[2], NULL)) == NULL ){ |
| 822 |
return(TCL_ERROR); |
| 823 |
} |
| 824 |
if( strncmp(s, "xpacmd_", 7) || (sscanf(&(s[7]), "%p", &lval) != 1) ){ |
| 825 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpacmd handle", -1); |
| 826 |
return(TCL_ERROR); |
| 827 |
} |
| 828 |
cmd = (XPACmd)lval; |
| 829 |
|
| 830 |
|
| 831 |
Tcl_ResetResult(interp); |
| 832 |
|
| 833 |
|
| 834 |
if( XPACmdDel(xpa, cmd) == 0 ){ |
| 835 |
|
| 836 |
if( cmd->send_data ) xfree(cmd->send_data); |
| 837 |
if( cmd->receive_data ) xfree(cmd->receive_data); |
| 838 |
return(TCL_OK); |
| 839 |
} |
| 840 |
else{ |
| 841 |
resultPtr = Tcl_GetObjResult(interp); |
| 842 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: could not delete xpa cmd", -1); |
| 843 |
return(TCL_ERROR); |
| 844 |
} |
| 845 |
} |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
#ifdef ANSI_FUNC |
| 879 |
static int |
| 880 |
XPARec_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 881 |
int objc, Tcl_Obj *CONST objv[]) |
| 882 |
#else |
| 883 |
static int XPARec_Tcl(clientData, interp, objc, objv) |
| 884 |
ClientData clientData; |
| 885 |
Tcl_Interp *interp; |
| 886 |
int objc; |
| 887 |
Tcl_Obj *CONST objv[]; |
| 888 |
#endif |
| 889 |
{ |
| 890 |
#ifndef HAVE_CYGWIN |
| 891 |
Tcl_Channel chan; |
| 892 |
#endif |
| 893 |
static XCONST84 char *subCmds[] = { |
| 894 |
"cendian", |
| 895 |
"class", |
| 896 |
#ifndef HAVE_CYGWIN |
| 897 |
"cmdchan", |
| 898 |
#endif |
| 899 |
"cmdfd", |
| 900 |
#ifndef HAVE_CYGWIN |
| 901 |
"datachan", |
| 902 |
#endif |
| 903 |
"datafd", |
| 904 |
"method", |
| 905 |
"name", |
| 906 |
"sendian", |
| 907 |
"version", |
| 908 |
(char *) NULL}; |
| 909 |
enum ISubCmdIdx { |
| 910 |
ICendianIdx, |
| 911 |
IClassIdx, |
| 912 |
#ifndef HAVE_CYGWIN |
| 913 |
ICmdChanIdx, |
| 914 |
#endif |
| 915 |
ICmdFdIdx, |
| 916 |
#ifndef HAVE_CYGWIN |
| 917 |
IDataChanIdx, |
| 918 |
#endif |
| 919 |
IDataFdIdx, |
| 920 |
IMethodIdx, |
| 921 |
INameIdx, |
| 922 |
ISendianIdx, |
| 923 |
IVersionIdx |
| 924 |
} index; |
| 925 |
XPA xpa; |
| 926 |
int result; |
| 927 |
char tbuf[SZ_LINE]; |
| 928 |
|
| 929 |
|
| 930 |
if (objc != 3) { |
| 931 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa option"); |
| 932 |
return TCL_ERROR; |
| 933 |
} |
| 934 |
|
| 935 |
|
| 936 |
if( (result = Tcl_GetIndexFromObj(interp, objv[2], subCmds, "option", 0, |
| 937 |
(int *)&index)) != TCL_OK ){ |
| 938 |
return result; |
| 939 |
} |
| 940 |
|
| 941 |
|
| 942 |
if( (result=Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa)) != TCL_OK){ |
| 943 |
|
| 944 |
if( index != IVersionIdx ) |
| 945 |
return(TCL_ERROR); |
| 946 |
} |
| 947 |
|
| 948 |
|
| 949 |
switch (index) { |
| 950 |
case ICendianIdx: |
| 951 |
Tcl_SetResult(interp, (char *)xpa_cendian(xpa), TCL_VOLATILE); |
| 952 |
result = TCL_OK; |
| 953 |
break; |
| 954 |
case IClassIdx: |
| 955 |
Tcl_SetResult(interp, xpa_class(xpa), TCL_VOLATILE); |
| 956 |
result = TCL_OK; |
| 957 |
break; |
| 958 |
#ifndef HAVE_CYGWIN |
| 959 |
case ICmdChanIdx: |
| 960 |
snprintf(tbuf, SZ_LINE, "sock%d", xpa_cmdfd(xpa)); |
| 961 |
|
| 962 |
if( xpa_cmdfd(xpa) < 0 ){ |
| 963 |
Tcl_SetResult(interp, "none", TCL_STATIC); |
| 964 |
result = TCL_OK; |
| 965 |
} |
| 966 |
|
| 967 |
else if( Tcl_GetChannel(interp, tbuf, NULL) != NULL ){ |
| 968 |
Tcl_SetResult(interp, tbuf, TCL_VOLATILE); |
| 969 |
result = TCL_OK; |
| 970 |
} |
| 971 |
|
| 972 |
else{ |
| 973 |
|
| 974 |
if( !(chan = Tcl_MakeTcpClientChannel((ClientData)xpa_cmdfd(xpa))) ){ |
| 975 |
Tcl_SetResult(interp, "XPA$ERROR: could not map XPA cmdfd to tcl", |
| 976 |
TCL_STATIC); |
| 977 |
result = TCL_ERROR; |
| 978 |
} |
| 979 |
else{ |
| 980 |
|
| 981 |
Tcl_RegisterChannel(NULL, chan); |
| 982 |
|
| 983 |
Tcl_RegisterChannel(interp, chan); |
| 984 |
|
| 985 |
Tcl_SetChannelOption(interp, chan, "-buffering", "none"); |
| 986 |
|
| 987 |
Tcl_SetResult(interp, (char *)Tcl_GetChannelName(chan), TCL_VOLATILE); |
| 988 |
result = TCL_OK; |
| 989 |
} |
| 990 |
} |
| 991 |
break; |
| 992 |
#endif |
| 993 |
case ICmdFdIdx: |
| 994 |
if( xpa_cmdfd(xpa) < 0 ) |
| 995 |
strcpy(tbuf, "none"); |
| 996 |
else |
| 997 |
snprintf(tbuf, SZ_LINE, "%d", xpa_cmdfd(xpa)); |
| 998 |
Tcl_SetResult(interp, tbuf, TCL_VOLATILE); |
| 999 |
result = TCL_OK; |
| 1000 |
break; |
| 1001 |
#ifndef HAVE_CYGWIN |
| 1002 |
case IDataChanIdx: |
| 1003 |
snprintf(tbuf, SZ_LINE, "sock%d", xpa_datafd(xpa)); |
| 1004 |
|
| 1005 |
if( xpa_datafd(xpa) < 0 ){ |
| 1006 |
Tcl_SetResult(interp, "none", TCL_STATIC); |
| 1007 |
result = TCL_OK; |
| 1008 |
} |
| 1009 |
|
| 1010 |
else if( Tcl_GetChannel(interp, tbuf, NULL) != NULL ){ |
| 1011 |
Tcl_SetResult(interp, tbuf, TCL_VOLATILE); |
| 1012 |
result = TCL_OK; |
| 1013 |
} |
| 1014 |
|
| 1015 |
else{ |
| 1016 |
if( !(chan = Tcl_MakeTcpClientChannel((ClientData)xpa_datafd(xpa))) ){ |
| 1017 |
Tcl_SetResult(interp, "XPA$ERROR: could not map XPA datafd to tcl", |
| 1018 |
TCL_STATIC); |
| 1019 |
result = TCL_ERROR; |
| 1020 |
} |
| 1021 |
else{ |
| 1022 |
|
| 1023 |
Tcl_RegisterChannel(NULL, chan); |
| 1024 |
|
| 1025 |
Tcl_RegisterChannel(interp, chan); |
| 1026 |
|
| 1027 |
Tcl_SetChannelOption(interp, chan, "-buffering", "none"); |
| 1028 |
|
| 1029 |
Tcl_SetResult(interp, (char *)Tcl_GetChannelName(chan), TCL_VOLATILE); |
| 1030 |
result = TCL_OK; |
| 1031 |
} |
| 1032 |
} |
| 1033 |
break; |
| 1034 |
#endif |
| 1035 |
case IDataFdIdx: |
| 1036 |
if( xpa_datafd(xpa) < 0 ) |
| 1037 |
strcpy(tbuf, "none"); |
| 1038 |
else |
| 1039 |
snprintf(tbuf, SZ_LINE, "%d", xpa_datafd(xpa)); |
| 1040 |
Tcl_SetResult(interp, tbuf, TCL_VOLATILE); |
| 1041 |
result = TCL_OK; |
| 1042 |
break; |
| 1043 |
case IMethodIdx: |
| 1044 |
Tcl_SetResult(interp, xpa_method(xpa), TCL_VOLATILE); |
| 1045 |
result = TCL_OK; |
| 1046 |
break; |
| 1047 |
case INameIdx: |
| 1048 |
Tcl_SetResult(interp, xpa_name(xpa), TCL_VOLATILE); |
| 1049 |
result = TCL_OK; |
| 1050 |
break; |
| 1051 |
case ISendianIdx: |
| 1052 |
Tcl_SetResult(interp, xpa_sendian(xpa), TCL_VOLATILE); |
| 1053 |
result = TCL_OK; |
| 1054 |
break; |
| 1055 |
case IVersionIdx: |
| 1056 |
snprintf(tbuf, SZ_LINE, "%s", XPA_VERSION); |
| 1057 |
Tcl_SetResult(interp, tbuf, TCL_VOLATILE); |
| 1058 |
result = TCL_OK; |
| 1059 |
break; |
| 1060 |
} |
| 1061 |
return result; |
| 1062 |
} |
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
#ifdef ANSI_FUNC |
| 1080 |
static int |
| 1081 |
XPASetBuf_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 1082 |
int objc, Tcl_Obj *CONST objv[]) |
| 1083 |
#else |
| 1084 |
static int XPASetBuf_Tcl(clientData, interp, objc, objv) |
| 1085 |
ClientData clientData; |
| 1086 |
Tcl_Interp *interp; |
| 1087 |
int objc; |
| 1088 |
Tcl_Obj *CONST objv[]; |
| 1089 |
#endif |
| 1090 |
{ |
| 1091 |
int error; |
| 1092 |
size_t len; |
| 1093 |
char *buf; |
| 1094 |
XPA xpa; |
| 1095 |
|
| 1096 |
|
| 1097 |
if( objc < 3 ){ |
| 1098 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa buf len"); |
| 1099 |
return(TCL_ERROR); |
| 1100 |
} |
| 1101 |
|
| 1102 |
|
| 1103 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa) != TCL_OK){ |
| 1104 |
return(TCL_ERROR); |
| 1105 |
} |
| 1106 |
|
| 1107 |
|
| 1108 |
buf = Tcl_GetStringFromObj(objv[2], &len); |
| 1109 |
|
| 1110 |
if( objc >= 4 ){ |
| 1111 |
if( (error = Tcl_GetIntFromObj(interp, objv[3], &len)) != TCL_OK ) |
| 1112 |
return(error); |
| 1113 |
} |
| 1114 |
|
| 1115 |
XPASetBuf(xpa, buf, len, 1); |
| 1116 |
|
| 1117 |
return(TCL_OK); |
| 1118 |
} |
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
#ifdef ANSI_FUNC |
| 1138 |
static int |
| 1139 |
XPAOpen_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 1140 |
int objc, Tcl_Obj *CONST objv[]) |
| 1141 |
#else |
| 1142 |
static int XPAOpen_Tcl(clientData, interp, objc, objv) |
| 1143 |
ClientData clientData; |
| 1144 |
Tcl_Interp *interp; |
| 1145 |
int objc; |
| 1146 |
Tcl_Obj *CONST objv[]; |
| 1147 |
#endif |
| 1148 |
{ |
| 1149 |
char *mode; |
| 1150 |
char tbuf[SZ_LINE]; |
| 1151 |
XPA xpa; |
| 1152 |
Tcl_Obj *resultPtr; |
| 1153 |
|
| 1154 |
|
| 1155 |
if( objc != 2 ){ |
| 1156 |
Tcl_WrongNumArgs(interp, 1, objv, "mode"); |
| 1157 |
return(TCL_ERROR); |
| 1158 |
} |
| 1159 |
|
| 1160 |
|
| 1161 |
mode = Tcl_GetStringFromObj(objv[1], NULL); |
| 1162 |
|
| 1163 |
|
| 1164 |
resultPtr = Tcl_GetObjResult(interp); |
| 1165 |
|
| 1166 |
|
| 1167 |
xpa = XPAOpen(mode); |
| 1168 |
if( xpa == NULL ){ |
| 1169 |
Tcl_SetStringObj(resultPtr, |
| 1170 |
"XPA$ERROR: could not open XPA", -1); |
| 1171 |
return(TCL_ERROR); |
| 1172 |
} |
| 1173 |
else{ |
| 1174 |
|
| 1175 |
snprintf(tbuf, SZ_LINE, "xpa_%p", xpa); |
| 1176 |
Tcl_SetStringObj(resultPtr, tbuf, -1); |
| 1177 |
return(TCL_OK); |
| 1178 |
} |
| 1179 |
} |
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
#ifdef ANSI_FUNC |
| 1197 |
static int |
| 1198 |
XPAClose_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 1199 |
int objc, Tcl_Obj *CONST objv[]) |
| 1200 |
#else |
| 1201 |
static int XPAClose_Tcl(clientData, interp, objc, objv) |
| 1202 |
ClientData clientData; |
| 1203 |
Tcl_Interp *interp; |
| 1204 |
int objc; |
| 1205 |
Tcl_Obj *CONST objv[]; |
| 1206 |
#endif |
| 1207 |
{ |
| 1208 |
XPA xpa; |
| 1209 |
|
| 1210 |
|
| 1211 |
if( objc != 2 ){ |
| 1212 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa"); |
| 1213 |
return(TCL_ERROR); |
| 1214 |
} |
| 1215 |
|
| 1216 |
|
| 1217 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_CLIENT, &xpa) != TCL_OK){ |
| 1218 |
return(TCL_ERROR); |
| 1219 |
} |
| 1220 |
|
| 1221 |
|
| 1222 |
Tcl_ResetResult(interp); |
| 1223 |
|
| 1224 |
|
| 1225 |
XPAClose(xpa); |
| 1226 |
return(TCL_OK); |
| 1227 |
} |
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
#ifdef ANSI_FUNC |
| 1245 |
static int |
| 1246 |
XPAGet_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 1247 |
int objc, Tcl_Obj *CONST objv[]) |
| 1248 |
#else |
| 1249 |
static int XPAGet_Tcl(clientData, interp, objc, objv) |
| 1250 |
ClientData clientData; |
| 1251 |
Tcl_Interp *interp; |
| 1252 |
int objc; |
| 1253 |
Tcl_Obj *CONST objv[]; |
| 1254 |
#endif |
| 1255 |
{ |
| 1256 |
XPA xpa; |
| 1257 |
int got; |
| 1258 |
int n; |
| 1259 |
int i; |
| 1260 |
size_t *clens=NULL; |
| 1261 |
char *xpastr; |
| 1262 |
char *tmpl; |
| 1263 |
char *paramlist; |
| 1264 |
char *mode; |
| 1265 |
|
| 1266 |
|
| 1267 |
char *names; |
| 1268 |
char *errs; |
| 1269 |
char **cbufs=NULL; |
| 1270 |
char **cnames=NULL; |
| 1271 |
char **cerrs=NULL; |
| 1272 |
Tcl_Obj *resultPtr; |
| 1273 |
Tcl_Obj *nullPtr; |
| 1274 |
Tcl_Obj *bufsPtr; |
| 1275 |
Tcl_Obj *lensPtr; |
| 1276 |
Tcl_Obj *namesPtr; |
| 1277 |
Tcl_Obj *errsPtr; |
| 1278 |
Tcl_Obj **bufsObjv; |
| 1279 |
Tcl_Obj **lensObjv; |
| 1280 |
Tcl_Obj **namesObjv=NULL; |
| 1281 |
Tcl_Obj **errsObjv=NULL; |
| 1282 |
|
| 1283 |
|
| 1284 |
if( objc != 10 ){ |
| 1285 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 1286 |
"xpa template paramlist mode bufs lens names errs n"); |
| 1287 |
return(TCL_ERROR); |
| 1288 |
} |
| 1289 |
|
| 1290 |
|
| 1291 |
resultPtr = Tcl_GetObjResult(interp); |
| 1292 |
|
| 1293 |
|
| 1294 |
xpastr = Tcl_GetStringFromObj(objv[1], NULL); |
| 1295 |
if( TCL_NULLSTR(xpastr) ) |
| 1296 |
xpa = NULL; |
| 1297 |
else{ |
| 1298 |
|
| 1299 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_CLIENT, &xpa) != TCL_OK){ |
| 1300 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa client handle", -1); |
| 1301 |
return(TCL_ERROR); |
| 1302 |
} |
| 1303 |
} |
| 1304 |
|
| 1305 |
|
| 1306 |
tmpl = Tcl_GetStringFromObj(objv[2], NULL); |
| 1307 |
paramlist = Tcl_GetStringFromObj(objv[3], NULL); |
| 1308 |
mode = Tcl_GetStringFromObj(objv[4], NULL); |
| 1309 |
|
| 1310 |
|
| 1311 |
names = Tcl_GetStringFromObj(objv[7], NULL); |
| 1312 |
errs = Tcl_GetStringFromObj(objv[8], NULL); |
| 1313 |
if( (Tcl_GetIntFromObj(interp, objv[9], &n) != TCL_OK) || (n < 1) ){ |
| 1314 |
n = 1; |
| 1315 |
} |
| 1316 |
|
| 1317 |
|
| 1318 |
cbufs = (char **)xcalloc(n, sizeof(char *)); |
| 1319 |
bufsObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1320 |
clens = (int *)xcalloc(n, sizeof(size_t)); |
| 1321 |
lensObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1322 |
if( !TCL_NULLSTR(names) ){ |
| 1323 |
cnames = (char **)xcalloc(n, sizeof(char *)); |
| 1324 |
namesObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1325 |
} |
| 1326 |
if( !TCL_NULLSTR(errs) ){ |
| 1327 |
cerrs = (char **)xcalloc(n, sizeof(char *)); |
| 1328 |
errsObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1329 |
} |
| 1330 |
|
| 1331 |
|
| 1332 |
Tcl_ResetResult(interp); |
| 1333 |
|
| 1334 |
|
| 1335 |
got = XPAGet(xpa, tmpl, paramlist, mode, cbufs, clens, cnames, cerrs, n); |
| 1336 |
|
| 1337 |
|
| 1338 |
if( got > 0 ){ |
| 1339 |
|
| 1340 |
for(i=0; i<got; i++){ |
| 1341 |
bufsObjv[i] = Tcl_NewObj(); |
| 1342 |
Tcl_SetStringObj(bufsObjv[i], cbufs[i], clens[i]); |
| 1343 |
|
| 1344 |
lensObjv[i] = Tcl_NewObj(); |
| 1345 |
Tcl_SetIntObj(lensObjv[i], clens[i]); |
| 1346 |
|
| 1347 |
if( cnames ){ |
| 1348 |
namesObjv[i] = Tcl_NewObj(); |
| 1349 |
Tcl_SetStringObj(namesObjv[i], cnames[i], |
| 1350 |
cnames[i] ? strlen(cnames[i]) : 0); |
| 1351 |
} |
| 1352 |
|
| 1353 |
if( cerrs ){ |
| 1354 |
errsObjv[i] = Tcl_NewObj(); |
| 1355 |
Tcl_SetStringObj(errsObjv[i], cerrs[i], |
| 1356 |
cerrs[i] ? strlen(cerrs[i]) : 0); |
| 1357 |
} |
| 1358 |
} |
| 1359 |
|
| 1360 |
bufsPtr = Tcl_NewObj(); |
| 1361 |
Tcl_SetListObj(bufsPtr, got, bufsObjv); |
| 1362 |
Tcl_ObjSetVar2(interp, objv[5], NULL, bufsPtr, TCL_PARSE_PART1); |
| 1363 |
|
| 1364 |
lensPtr = Tcl_NewObj(); |
| 1365 |
Tcl_SetListObj(lensPtr, got, lensObjv); |
| 1366 |
Tcl_ObjSetVar2(interp, objv[6], NULL, lensPtr, TCL_PARSE_PART1); |
| 1367 |
|
| 1368 |
if( cnames ){ |
| 1369 |
namesPtr = Tcl_NewObj(); |
| 1370 |
Tcl_SetListObj(namesPtr, got, namesObjv); |
| 1371 |
Tcl_ObjSetVar2(interp, objv[7], NULL, namesPtr, TCL_PARSE_PART1); |
| 1372 |
} |
| 1373 |
|
| 1374 |
if( cerrs ){ |
| 1375 |
errsPtr = Tcl_NewObj(); |
| 1376 |
Tcl_SetListObj(errsPtr, got, errsObjv); |
| 1377 |
Tcl_ObjSetVar2(interp, objv[8], NULL, errsPtr, TCL_PARSE_PART1); |
| 1378 |
} |
| 1379 |
} |
| 1380 |
else{ |
| 1381 |
nullPtr = Tcl_NewObj(); |
| 1382 |
Tcl_SetStringObj(nullPtr, "", -1); |
| 1383 |
Tcl_ObjSetVar2(interp, objv[5], NULL, nullPtr, TCL_PARSE_PART1); |
| 1384 |
Tcl_ObjSetVar2(interp, objv[6], NULL, nullPtr, TCL_PARSE_PART1); |
| 1385 |
if( cnames ) |
| 1386 |
Tcl_ObjSetVar2(interp, objv[7], NULL, nullPtr, TCL_PARSE_PART1); |
| 1387 |
if( cerrs ) |
| 1388 |
Tcl_ObjSetVar2(interp, objv[8], NULL, nullPtr, TCL_PARSE_PART1); |
| 1389 |
} |
| 1390 |
|
| 1391 |
|
| 1392 |
for(i=0; i<got; i++){ |
| 1393 |
if( cbufs[i] ) xfree((char *)cbufs[i]); |
| 1394 |
if( cnames[i] ) xfree((char *)cnames[i]); |
| 1395 |
if( cerrs[i] ) xfree((char *)cerrs[i]); |
| 1396 |
} |
| 1397 |
if( cbufs ) xfree((char *)cbufs); |
| 1398 |
if( clens ) xfree((char *)clens); |
| 1399 |
if( cnames ) xfree((char *)cnames); |
| 1400 |
if( cerrs ) xfree((char *)cerrs); |
| 1401 |
if( bufsObjv ) xfree((char *)bufsObjv); |
| 1402 |
if( lensObjv ) xfree((char *)lensObjv); |
| 1403 |
if( namesObjv ) xfree((char *)namesObjv); |
| 1404 |
if( errsObjv ) xfree((char *)errsObjv); |
| 1405 |
|
| 1406 |
|
| 1407 |
resultPtr = Tcl_GetObjResult(interp); |
| 1408 |
Tcl_SetIntObj(resultPtr, got); |
| 1409 |
|
| 1410 |
|
| 1411 |
return(TCL_OK); |
| 1412 |
} |
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
#ifdef ANSI_FUNC |
| 1430 |
static int |
| 1431 |
XPAGetFd_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 1432 |
int objc, Tcl_Obj *CONST objv[]) |
| 1433 |
#else |
| 1434 |
static int XPAGetFd_Tcl(clientData, interp, objc, objv) |
| 1435 |
ClientData clientData; |
| 1436 |
Tcl_Interp *interp; |
| 1437 |
int objc; |
| 1438 |
Tcl_Obj *CONST objv[]; |
| 1439 |
#endif |
| 1440 |
{ |
| 1441 |
XPA xpa; |
| 1442 |
int got; |
| 1443 |
int n; |
| 1444 |
int i; |
| 1445 |
int flag; |
| 1446 |
int *cfds; |
| 1447 |
char *xpastr; |
| 1448 |
char *tmpl; |
| 1449 |
char *paramlist; |
| 1450 |
char *mode; |
| 1451 |
char *names; |
| 1452 |
char *errs; |
| 1453 |
char **cnames=NULL; |
| 1454 |
char **cerrs=NULL; |
| 1455 |
Tcl_Obj *resultPtr; |
| 1456 |
Tcl_Obj *nullPtr; |
| 1457 |
Tcl_Obj *fdPtr; |
| 1458 |
Tcl_Obj *namesPtr; |
| 1459 |
Tcl_Obj *errsPtr; |
| 1460 |
Tcl_Obj **namesObjv=NULL; |
| 1461 |
Tcl_Obj **errsObjv=NULL; |
| 1462 |
Tcl_Channel chan; |
| 1463 |
|
| 1464 |
|
| 1465 |
if( objc != 9 ){ |
| 1466 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 1467 |
"xpa template paramlist mode chans names errs n"); |
| 1468 |
return(TCL_ERROR); |
| 1469 |
} |
| 1470 |
|
| 1471 |
|
| 1472 |
resultPtr = Tcl_GetObjResult(interp); |
| 1473 |
|
| 1474 |
|
| 1475 |
xpastr = Tcl_GetStringFromObj(objv[1], NULL); |
| 1476 |
if( TCL_NULLSTR(xpastr) ) |
| 1477 |
xpa = NULL; |
| 1478 |
else{ |
| 1479 |
|
| 1480 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_CLIENT, &xpa) != TCL_OK ){ |
| 1481 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa client handle", -1); |
| 1482 |
return(TCL_ERROR); |
| 1483 |
} |
| 1484 |
} |
| 1485 |
|
| 1486 |
|
| 1487 |
tmpl = Tcl_GetStringFromObj(objv[2], NULL); |
| 1488 |
paramlist = Tcl_GetStringFromObj(objv[3], NULL); |
| 1489 |
mode = Tcl_GetStringFromObj(objv[4], NULL); |
| 1490 |
names = Tcl_GetStringFromObj(objv[6], NULL); |
| 1491 |
errs = Tcl_GetStringFromObj(objv[7], NULL); |
| 1492 |
if( (Tcl_GetIntFromObj(interp, objv[8], &n) != TCL_OK) || (n < 1) ){ |
| 1493 |
n = 1; |
| 1494 |
} |
| 1495 |
|
| 1496 |
|
| 1497 |
if( n < 0 ){ |
| 1498 |
cfds = (int *)xcalloc(1, sizeof(int)); |
| 1499 |
if( Tcl_ListObjIndex(interp, objv[5], 0, &fdPtr) != TCL_OK ){ |
| 1500 |
Tcl_SetStringObj(resultPtr, |
| 1501 |
"XPA$ERROR: invalid channel list passed to xpagetfd", -1); |
| 1502 |
return(TCL_ERROR); |
| 1503 |
} |
| 1504 |
else{ |
| 1505 |
chan = Tcl_GetChannel(interp, Tcl_GetStringFromObj(fdPtr, NULL), |
| 1506 |
&flag); |
| 1507 |
if( chan == NULL ){ |
| 1508 |
Tcl_SetStringObj(resultPtr, |
| 1509 |
"XPA$ERROR: invalid channel passed to xpagetfd", -1); |
| 1510 |
return(TCL_ERROR); |
| 1511 |
} |
| 1512 |
if( !(flag&TCL_WRITABLE) ){ |
| 1513 |
Tcl_SetStringObj(resultPtr, |
| 1514 |
"XPA$ERROR: non-writable channel passed to xpagetfd", -1); |
| 1515 |
return(TCL_ERROR); |
| 1516 |
} |
| 1517 |
Tcl_GetChannelHandle(chan, TCL_WRITABLE, (ClientData *)&(cfds[0])); |
| 1518 |
} |
| 1519 |
} |
| 1520 |
else{ |
| 1521 |
cfds = (int *)xcalloc(n, sizeof(int)); |
| 1522 |
for(i=0; i<n; i++){ |
| 1523 |
if( Tcl_ListObjIndex(interp, objv[5], i, &fdPtr) != TCL_OK ){ |
| 1524 |
Tcl_SetStringObj(resultPtr, |
| 1525 |
"XPA$ERROR: invalid channel list passed to xpagetfd", -1); |
| 1526 |
return(TCL_ERROR); |
| 1527 |
} |
| 1528 |
else{ |
| 1529 |
chan = Tcl_GetChannel(interp, Tcl_GetStringFromObj(fdPtr, NULL), |
| 1530 |
&flag); |
| 1531 |
if( chan == NULL ){ |
| 1532 |
Tcl_SetStringObj(resultPtr, |
| 1533 |
"XPA$ERROR: invalid channel passed to xpagetfd", -1); |
| 1534 |
return(TCL_ERROR); |
| 1535 |
} |
| 1536 |
if( !(flag&TCL_WRITABLE) ){ |
| 1537 |
Tcl_SetStringObj(resultPtr, |
| 1538 |
"XPA$ERROR: non-writable channel passed to xpagetfd", -1); |
| 1539 |
return(TCL_ERROR); |
| 1540 |
} |
| 1541 |
Tcl_GetChannelHandle(chan, TCL_WRITABLE, (ClientData *)&(cfds[i])); |
| 1542 |
} |
| 1543 |
} |
| 1544 |
} |
| 1545 |
|
| 1546 |
|
| 1547 |
if( !TCL_NULLSTR(names) ){ |
| 1548 |
cnames = (char **)xcalloc(n, sizeof(char *)); |
| 1549 |
namesObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1550 |
} |
| 1551 |
if( !TCL_NULLSTR(errs) ){ |
| 1552 |
cerrs = (char **)xcalloc(n, sizeof(char *)); |
| 1553 |
errsObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1554 |
} |
| 1555 |
|
| 1556 |
|
| 1557 |
Tcl_ResetResult(interp); |
| 1558 |
|
| 1559 |
|
| 1560 |
got = XPAGetFd(xpa, tmpl, paramlist, mode, cfds, cnames, cerrs, n); |
| 1561 |
|
| 1562 |
|
| 1563 |
if( got > 0 ){ |
| 1564 |
|
| 1565 |
for(i=0; i<got; i++){ |
| 1566 |
if( cnames ){ |
| 1567 |
namesObjv[i] = Tcl_NewObj(); |
| 1568 |
Tcl_SetStringObj(namesObjv[i], cnames[i], |
| 1569 |
cnames[i] ? strlen(cnames[i]) : 0); |
| 1570 |
} |
| 1571 |
|
| 1572 |
if( cerrs ){ |
| 1573 |
errsObjv[i] = Tcl_NewObj(); |
| 1574 |
Tcl_SetStringObj(errsObjv[i], cerrs[i], |
| 1575 |
cerrs[i] ? strlen(cerrs[i]) : 0); |
| 1576 |
} |
| 1577 |
} |
| 1578 |
|
| 1579 |
if( cnames ){ |
| 1580 |
namesPtr = Tcl_NewObj(); |
| 1581 |
Tcl_SetListObj(namesPtr, got, namesObjv); |
| 1582 |
Tcl_ObjSetVar2(interp, objv[6], NULL, namesPtr, TCL_PARSE_PART1); |
| 1583 |
} |
| 1584 |
if( cerrs ){ |
| 1585 |
errsPtr = Tcl_NewObj(); |
| 1586 |
Tcl_SetListObj(errsPtr, got, errsObjv); |
| 1587 |
Tcl_ObjSetVar2(interp, objv[7], NULL, errsPtr, TCL_PARSE_PART1); |
| 1588 |
} |
| 1589 |
} |
| 1590 |
else{ |
| 1591 |
nullPtr = Tcl_NewObj(); |
| 1592 |
Tcl_SetStringObj(nullPtr, "", -1); |
| 1593 |
if( cnames ) |
| 1594 |
Tcl_ObjSetVar2(interp, objv[6], NULL, nullPtr, TCL_PARSE_PART1); |
| 1595 |
if( cerrs ) |
| 1596 |
Tcl_ObjSetVar2(interp, objv[7], NULL, nullPtr, TCL_PARSE_PART1); |
| 1597 |
} |
| 1598 |
|
| 1599 |
|
| 1600 |
for(i=0; i<got; i++){ |
| 1601 |
if( cnames[i] ) xfree((char *)cnames[i]); |
| 1602 |
if( cerrs[i] ) xfree((char *)cerrs[i]); |
| 1603 |
} |
| 1604 |
if( cfds ) xfree((char *)cfds); |
| 1605 |
if( cnames ) xfree((char *)cnames); |
| 1606 |
if( cerrs ) xfree((char *)cerrs); |
| 1607 |
if( namesObjv ) xfree((char *)namesObjv); |
| 1608 |
if( errsObjv ) xfree((char *)errsObjv); |
| 1609 |
|
| 1610 |
|
| 1611 |
Tcl_SetIntObj(resultPtr, got); |
| 1612 |
|
| 1613 |
|
| 1614 |
return(TCL_OK); |
| 1615 |
} |
| 1616 |
|
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
#ifdef ANSI_FUNC |
| 1633 |
static int |
| 1634 |
XPASet_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 1635 |
int objc, Tcl_Obj *CONST objv[]) |
| 1636 |
#else |
| 1637 |
static int XPASet_Tcl(clientData, interp, objc, objv) |
| 1638 |
ClientData clientData; |
| 1639 |
Tcl_Interp *interp; |
| 1640 |
int objc; |
| 1641 |
Tcl_Obj *CONST objv[]; |
| 1642 |
#endif |
| 1643 |
{ |
| 1644 |
XPA xpa; |
| 1645 |
int got; |
| 1646 |
int n; |
| 1647 |
int i; |
| 1648 |
int blen; |
| 1649 |
size_t len; |
| 1650 |
char *xpastr; |
| 1651 |
char *tmpl; |
| 1652 |
char *paramlist; |
| 1653 |
char *mode; |
| 1654 |
char *buf; |
| 1655 |
char *names; |
| 1656 |
char *errs; |
| 1657 |
char **cnames=NULL; |
| 1658 |
char **cerrs=NULL; |
| 1659 |
Tcl_Obj *resultPtr; |
| 1660 |
Tcl_Obj *nullPtr; |
| 1661 |
Tcl_Obj *namesPtr; |
| 1662 |
Tcl_Obj *errsPtr; |
| 1663 |
Tcl_Obj **namesObjv=NULL; |
| 1664 |
Tcl_Obj **errsObjv=NULL; |
| 1665 |
|
| 1666 |
|
| 1667 |
if( objc != 10 ){ |
| 1668 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 1669 |
"xpa template paramlist mode buf len names errs n"); |
| 1670 |
return(TCL_ERROR); |
| 1671 |
} |
| 1672 |
|
| 1673 |
|
| 1674 |
resultPtr = Tcl_GetObjResult(interp); |
| 1675 |
|
| 1676 |
|
| 1677 |
xpastr = Tcl_GetStringFromObj(objv[1], NULL); |
| 1678 |
if( TCL_NULLSTR(xpastr) ) |
| 1679 |
xpa = NULL; |
| 1680 |
else{ |
| 1681 |
|
| 1682 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_CLIENT, &xpa) != TCL_OK ){ |
| 1683 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa client handle", -1); |
| 1684 |
return(TCL_ERROR); |
| 1685 |
} |
| 1686 |
} |
| 1687 |
|
| 1688 |
|
| 1689 |
tmpl = Tcl_GetStringFromObj(objv[2], NULL); |
| 1690 |
paramlist = Tcl_GetStringFromObj(objv[3], NULL); |
| 1691 |
mode = Tcl_GetStringFromObj(objv[4], NULL); |
| 1692 |
buf = Tcl_GetStringFromObj(objv[5], &blen); |
| 1693 |
if( (Tcl_GetIntFromObj(interp, objv[6], &len) != TCL_OK) || (len < 0) ){ |
| 1694 |
len = blen; |
| 1695 |
} |
| 1696 |
names = Tcl_GetStringFromObj(objv[7], NULL); |
| 1697 |
errs = Tcl_GetStringFromObj(objv[8], NULL); |
| 1698 |
if( (Tcl_GetIntFromObj(interp, objv[9], &n) != TCL_OK) || (n < 1) ){ |
| 1699 |
n = 1; |
| 1700 |
} |
| 1701 |
|
| 1702 |
|
| 1703 |
if( !TCL_NULLSTR(names) ){ |
| 1704 |
cnames = (char **)xcalloc(n, sizeof(char *)); |
| 1705 |
namesObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1706 |
} |
| 1707 |
if( !TCL_NULLSTR(errs) ){ |
| 1708 |
cerrs = (char **)xcalloc(n, sizeof(char *)); |
| 1709 |
errsObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1710 |
} |
| 1711 |
|
| 1712 |
|
| 1713 |
Tcl_ResetResult(interp); |
| 1714 |
|
| 1715 |
|
| 1716 |
got = XPASet(xpa, tmpl, paramlist, mode, buf, len, cnames, cerrs, n); |
| 1717 |
|
| 1718 |
|
| 1719 |
if( got > 0 ){ |
| 1720 |
|
| 1721 |
for(i=0; i<got; i++){ |
| 1722 |
if( cnames ){ |
| 1723 |
namesObjv[i] = Tcl_NewObj(); |
| 1724 |
Tcl_SetStringObj(namesObjv[i], cnames[i], |
| 1725 |
cnames[i] ? strlen(cnames[i]) : 0); |
| 1726 |
} |
| 1727 |
if( cerrs ){ |
| 1728 |
errsObjv[i] = Tcl_NewObj(); |
| 1729 |
Tcl_SetStringObj(errsObjv[i], cerrs[i], |
| 1730 |
cerrs[i] ? strlen(cerrs[i]) : 0); |
| 1731 |
} |
| 1732 |
} |
| 1733 |
|
| 1734 |
if( cnames ){ |
| 1735 |
namesPtr = Tcl_NewObj(); |
| 1736 |
Tcl_SetListObj(namesPtr, got, namesObjv); |
| 1737 |
Tcl_ObjSetVar2(interp, objv[7], NULL, namesPtr, TCL_PARSE_PART1); |
| 1738 |
} |
| 1739 |
if( cerrs ){ |
| 1740 |
errsPtr = Tcl_NewObj(); |
| 1741 |
Tcl_SetListObj(errsPtr, got, errsObjv); |
| 1742 |
Tcl_ObjSetVar2(interp, objv[8], NULL, errsPtr, TCL_PARSE_PART1); |
| 1743 |
} |
| 1744 |
} |
| 1745 |
else{ |
| 1746 |
nullPtr = Tcl_NewObj(); |
| 1747 |
Tcl_SetStringObj(nullPtr, "", -1); |
| 1748 |
if( cnames ) |
| 1749 |
Tcl_ObjSetVar2(interp, objv[7], NULL, nullPtr, TCL_PARSE_PART1); |
| 1750 |
if( cerrs ) |
| 1751 |
Tcl_ObjSetVar2(interp, objv[8], NULL, nullPtr, TCL_PARSE_PART1); |
| 1752 |
} |
| 1753 |
|
| 1754 |
|
| 1755 |
for(i=0; i<got; i++){ |
| 1756 |
if( cnames[i] ) xfree((char *)cnames[i]); |
| 1757 |
if( cerrs[i] ) xfree((char *)cerrs[i]); |
| 1758 |
} |
| 1759 |
if( cnames ) xfree((char *)cnames); |
| 1760 |
if( cerrs ) xfree((char *)cerrs); |
| 1761 |
if( namesObjv ) xfree((char *)namesObjv); |
| 1762 |
if( errsObjv ) xfree((char *)errsObjv); |
| 1763 |
|
| 1764 |
|
| 1765 |
Tcl_SetIntObj(resultPtr, got); |
| 1766 |
|
| 1767 |
|
| 1768 |
return(TCL_OK); |
| 1769 |
} |
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
|
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
#ifdef ANSI_FUNC |
| 1787 |
static int |
| 1788 |
XPASetFd_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 1789 |
int objc, Tcl_Obj *CONST objv[]) |
| 1790 |
#else |
| 1791 |
static int XPASetFd_Tcl(clientData, interp, objc, objv) |
| 1792 |
ClientData clientData; |
| 1793 |
Tcl_Interp *interp; |
| 1794 |
int objc; |
| 1795 |
Tcl_Obj *CONST objv[]; |
| 1796 |
#endif |
| 1797 |
{ |
| 1798 |
XPA xpa; |
| 1799 |
int got; |
| 1800 |
int n; |
| 1801 |
int i; |
| 1802 |
int flag; |
| 1803 |
int fd; |
| 1804 |
char *xpastr; |
| 1805 |
char *tmpl; |
| 1806 |
char *paramlist; |
| 1807 |
char *mode; |
| 1808 |
char *names; |
| 1809 |
char *errs; |
| 1810 |
char **cnames=NULL; |
| 1811 |
char **cerrs=NULL; |
| 1812 |
Tcl_Obj *resultPtr; |
| 1813 |
Tcl_Obj *nullPtr; |
| 1814 |
Tcl_Obj *namesPtr; |
| 1815 |
Tcl_Obj *errsPtr; |
| 1816 |
Tcl_Obj **namesObjv=NULL; |
| 1817 |
Tcl_Obj **errsObjv=NULL; |
| 1818 |
Tcl_Channel chan; |
| 1819 |
|
| 1820 |
|
| 1821 |
if( objc != 9 ){ |
| 1822 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 1823 |
"xpa template paramlist mode chan names errs n"); |
| 1824 |
return(TCL_ERROR); |
| 1825 |
} |
| 1826 |
|
| 1827 |
|
| 1828 |
resultPtr = Tcl_GetObjResult(interp); |
| 1829 |
|
| 1830 |
|
| 1831 |
xpastr = Tcl_GetStringFromObj(objv[1], NULL); |
| 1832 |
if( TCL_NULLSTR(xpastr) ) |
| 1833 |
xpa = NULL; |
| 1834 |
else{ |
| 1835 |
|
| 1836 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_CLIENT, &xpa) != TCL_OK){ |
| 1837 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa client handle", -1); |
| 1838 |
return(TCL_ERROR); |
| 1839 |
} |
| 1840 |
} |
| 1841 |
|
| 1842 |
|
| 1843 |
tmpl = Tcl_GetStringFromObj(objv[2], NULL); |
| 1844 |
paramlist = Tcl_GetStringFromObj(objv[3], NULL); |
| 1845 |
mode = Tcl_GetStringFromObj(objv[4], NULL); |
| 1846 |
names = Tcl_GetStringFromObj(objv[6], NULL); |
| 1847 |
errs = Tcl_GetStringFromObj(objv[7], NULL); |
| 1848 |
if( (Tcl_GetIntFromObj(interp, objv[8], &n) != TCL_OK) || (n < 1) ){ |
| 1849 |
n = 1; |
| 1850 |
} |
| 1851 |
|
| 1852 |
|
| 1853 |
if( !TCL_NULLSTR(names) ){ |
| 1854 |
cnames = (char **)xcalloc(n, sizeof(char *)); |
| 1855 |
namesObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1856 |
} |
| 1857 |
if( !TCL_NULLSTR(errs) ){ |
| 1858 |
cerrs = (char **)xcalloc(n, sizeof(char *)); |
| 1859 |
errsObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 1860 |
} |
| 1861 |
|
| 1862 |
|
| 1863 |
chan = Tcl_GetChannel(interp, Tcl_GetStringFromObj(objv[5], NULL), &flag); |
| 1864 |
if( chan == NULL ){ |
| 1865 |
Tcl_SetStringObj(resultPtr, |
| 1866 |
"XPA$ERROR: invalid channel passed to xpasetfd", -1); |
| 1867 |
return(TCL_ERROR); |
| 1868 |
} |
| 1869 |
if( !(flag&TCL_READABLE) ){ |
| 1870 |
Tcl_SetStringObj(resultPtr, |
| 1871 |
"XPA$ERROR: non-readable channel passed to xpasetfd", -1); |
| 1872 |
return(TCL_ERROR); |
| 1873 |
} |
| 1874 |
Tcl_GetChannelHandle(chan, TCL_READABLE, (ClientData *)&fd); |
| 1875 |
|
| 1876 |
|
| 1877 |
Tcl_ResetResult(interp); |
| 1878 |
|
| 1879 |
|
| 1880 |
got = XPASetFd(xpa, tmpl, paramlist, mode, fd, cnames, cerrs, n); |
| 1881 |
|
| 1882 |
|
| 1883 |
if( got > 0 ){ |
| 1884 |
|
| 1885 |
for(i=0; i<got; i++){ |
| 1886 |
if( cnames ){ |
| 1887 |
namesObjv[i] = Tcl_NewObj(); |
| 1888 |
Tcl_SetStringObj(namesObjv[i], cnames[i], |
| 1889 |
cnames[i] ? strlen(cnames[i]) : 0); |
| 1890 |
} |
| 1891 |
if( cerrs ){ |
| 1892 |
errsObjv[i] = Tcl_NewObj(); |
| 1893 |
Tcl_SetStringObj(errsObjv[i], cerrs[i], |
| 1894 |
cerrs[i] ? strlen(cerrs[i]) : 0); |
| 1895 |
} |
| 1896 |
} |
| 1897 |
|
| 1898 |
if( cnames ){ |
| 1899 |
namesPtr = Tcl_NewObj(); |
| 1900 |
Tcl_SetListObj(namesPtr, got, namesObjv); |
| 1901 |
Tcl_ObjSetVar2(interp, objv[6], NULL, namesPtr, TCL_PARSE_PART1); |
| 1902 |
} |
| 1903 |
if( cerrs ){ |
| 1904 |
errsPtr = Tcl_NewObj(); |
| 1905 |
Tcl_SetListObj(errsPtr, got, errsObjv); |
| 1906 |
Tcl_ObjSetVar2(interp, objv[7], NULL, errsPtr, TCL_PARSE_PART1); |
| 1907 |
} |
| 1908 |
} |
| 1909 |
else{ |
| 1910 |
nullPtr = Tcl_NewObj(); |
| 1911 |
Tcl_SetStringObj(nullPtr, "", -1); |
| 1912 |
if( cnames ) |
| 1913 |
Tcl_ObjSetVar2(interp, objv[6], NULL, nullPtr, TCL_PARSE_PART1); |
| 1914 |
if( cerrs ) |
| 1915 |
Tcl_ObjSetVar2(interp, objv[7], NULL, nullPtr, TCL_PARSE_PART1); |
| 1916 |
} |
| 1917 |
|
| 1918 |
|
| 1919 |
for(i=0; i<got; i++){ |
| 1920 |
if( cnames[i] ) xfree((char *)cnames[i]); |
| 1921 |
if( cerrs[i] ) xfree((char *)cerrs[i]); |
| 1922 |
} |
| 1923 |
if( cnames ) xfree((char *)cnames); |
| 1924 |
if( cerrs ) xfree((char *)cerrs); |
| 1925 |
if( namesObjv ) xfree((char *)namesObjv); |
| 1926 |
if( errsObjv ) xfree((char *)errsObjv); |
| 1927 |
|
| 1928 |
|
| 1929 |
Tcl_SetIntObj(resultPtr, got); |
| 1930 |
|
| 1931 |
|
| 1932 |
return(TCL_OK); |
| 1933 |
} |
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
|
| 1944 |
|
| 1945 |
|
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
|
| 1950 |
#ifdef ANSI_FUNC |
| 1951 |
static int |
| 1952 |
XPAInfo_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 1953 |
int objc, Tcl_Obj *CONST objv[]) |
| 1954 |
#else |
| 1955 |
static int XPAInfo_Tcl(clientData, interp, objc, objv) |
| 1956 |
ClientData clientData; |
| 1957 |
Tcl_Interp *interp; |
| 1958 |
int objc; |
| 1959 |
Tcl_Obj *CONST objv[]; |
| 1960 |
#endif |
| 1961 |
{ |
| 1962 |
XPA xpa; |
| 1963 |
int got; |
| 1964 |
int n; |
| 1965 |
int i; |
| 1966 |
char *xpastr; |
| 1967 |
char *tmpl; |
| 1968 |
char *paramlist; |
| 1969 |
char *mode; |
| 1970 |
char *names; |
| 1971 |
char *errs; |
| 1972 |
char **cnames=NULL; |
| 1973 |
char **cerrs=NULL; |
| 1974 |
Tcl_Obj *resultPtr; |
| 1975 |
Tcl_Obj *nullPtr; |
| 1976 |
Tcl_Obj *namesPtr; |
| 1977 |
Tcl_Obj *errsPtr; |
| 1978 |
Tcl_Obj **namesObjv=NULL; |
| 1979 |
Tcl_Obj **errsObjv=NULL; |
| 1980 |
|
| 1981 |
|
| 1982 |
if( objc != 8 ){ |
| 1983 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 1984 |
"xpa template paramlist mode names errs n"); |
| 1985 |
return(TCL_ERROR); |
| 1986 |
} |
| 1987 |
|
| 1988 |
|
| 1989 |
resultPtr = Tcl_GetObjResult(interp); |
| 1990 |
|
| 1991 |
|
| 1992 |
xpastr = Tcl_GetStringFromObj(objv[1], NULL); |
| 1993 |
if( TCL_NULLSTR(xpastr) ) |
| 1994 |
xpa = NULL; |
| 1995 |
else{ |
| 1996 |
|
| 1997 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_CLIENT, &xpa) != TCL_OK){ |
| 1998 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa client handle", -1); |
| 1999 |
return(TCL_ERROR); |
| 2000 |
} |
| 2001 |
} |
| 2002 |
|
| 2003 |
|
| 2004 |
tmpl = Tcl_GetStringFromObj(objv[2], NULL); |
| 2005 |
paramlist = Tcl_GetStringFromObj(objv[3], NULL); |
| 2006 |
mode = Tcl_GetStringFromObj(objv[4], NULL); |
| 2007 |
names = Tcl_GetStringFromObj(objv[5], NULL); |
| 2008 |
errs = Tcl_GetStringFromObj(objv[6], NULL); |
| 2009 |
if( (Tcl_GetIntFromObj(interp, objv[7], &n) != TCL_OK) || (n < 1) ){ |
| 2010 |
n = 1; |
| 2011 |
} |
| 2012 |
|
| 2013 |
|
| 2014 |
if( !TCL_NULLSTR(names) ){ |
| 2015 |
cnames = (char **)xcalloc(n, sizeof(char *)); |
| 2016 |
namesObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 2017 |
} |
| 2018 |
if( !TCL_NULLSTR(errs) ){ |
| 2019 |
cerrs = (char **)xcalloc(n, sizeof(char *)); |
| 2020 |
errsObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 2021 |
} |
| 2022 |
|
| 2023 |
|
| 2024 |
Tcl_ResetResult(interp); |
| 2025 |
|
| 2026 |
|
| 2027 |
got = XPAInfo(xpa, tmpl, paramlist, mode, cnames, cerrs, n); |
| 2028 |
|
| 2029 |
|
| 2030 |
if( got > 0 ){ |
| 2031 |
|
| 2032 |
for(i=0; i<got; i++){ |
| 2033 |
if( cnames ){ |
| 2034 |
namesObjv[i] = Tcl_NewObj(); |
| 2035 |
Tcl_SetStringObj(namesObjv[i], cnames[i], |
| 2036 |
cnames[i] ? strlen(cnames[i]) : 0); |
| 2037 |
} |
| 2038 |
if( cerrs ){ |
| 2039 |
errsObjv[i] = Tcl_NewObj(); |
| 2040 |
Tcl_SetStringObj(errsObjv[i], cerrs[i], |
| 2041 |
cerrs[i] ? strlen(cerrs[i]) : 0); |
| 2042 |
} |
| 2043 |
} |
| 2044 |
|
| 2045 |
if( cnames ){ |
| 2046 |
namesPtr = Tcl_NewObj(); |
| 2047 |
Tcl_SetListObj(namesPtr, got, namesObjv); |
| 2048 |
Tcl_ObjSetVar2(interp, objv[5], NULL, namesPtr, TCL_PARSE_PART1); |
| 2049 |
} |
| 2050 |
|
| 2051 |
if( cerrs ){ |
| 2052 |
errsPtr = Tcl_NewObj(); |
| 2053 |
Tcl_SetListObj(errsPtr, got, errsObjv); |
| 2054 |
Tcl_ObjSetVar2(interp, objv[6], NULL, errsPtr, TCL_PARSE_PART1); |
| 2055 |
} |
| 2056 |
} |
| 2057 |
else{ |
| 2058 |
nullPtr = Tcl_NewObj(); |
| 2059 |
Tcl_SetStringObj(nullPtr, "", -1); |
| 2060 |
if( cnames ) |
| 2061 |
Tcl_ObjSetVar2(interp, objv[5], NULL, nullPtr, TCL_PARSE_PART1); |
| 2062 |
if( cerrs ) |
| 2063 |
Tcl_ObjSetVar2(interp, objv[6], NULL, nullPtr, TCL_PARSE_PART1); |
| 2064 |
} |
| 2065 |
|
| 2066 |
|
| 2067 |
for(i=0; i<got; i++){ |
| 2068 |
if( cnames[i] ) xfree((char *)cnames[i]); |
| 2069 |
if( cerrs[i] ) xfree((char *)cerrs[i]); |
| 2070 |
} |
| 2071 |
if( cnames ) xfree((char *)cnames); |
| 2072 |
if( cerrs ) xfree((char *)cerrs); |
| 2073 |
if( namesObjv ) xfree((char *)namesObjv); |
| 2074 |
if( errsObjv ) xfree((char *)errsObjv); |
| 2075 |
|
| 2076 |
|
| 2077 |
Tcl_SetIntObj(resultPtr, got); |
| 2078 |
|
| 2079 |
|
| 2080 |
return(TCL_OK); |
| 2081 |
} |
| 2082 |
|
| 2083 |
|
| 2084 |
|
| 2085 |
|
| 2086 |
|
| 2087 |
|
| 2088 |
|
| 2089 |
|
| 2090 |
|
| 2091 |
|
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
|
| 2097 |
|
| 2098 |
#ifdef ANSI_FUNC |
| 2099 |
static int |
| 2100 |
XPAAccess_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 2101 |
int objc, Tcl_Obj *CONST objv[]) |
| 2102 |
#else |
| 2103 |
static int XPAAccess_Tcl(clientData, interp, objc, objv) |
| 2104 |
ClientData clientData; |
| 2105 |
Tcl_Interp *interp; |
| 2106 |
int objc; |
| 2107 |
Tcl_Obj *CONST objv[]; |
| 2108 |
#endif |
| 2109 |
{ |
| 2110 |
XPA xpa; |
| 2111 |
int got; |
| 2112 |
int n; |
| 2113 |
int i; |
| 2114 |
char *xpastr; |
| 2115 |
char *tmpl; |
| 2116 |
char *paramlist; |
| 2117 |
char *mode; |
| 2118 |
char *names; |
| 2119 |
char *errs; |
| 2120 |
char **cnames=NULL; |
| 2121 |
char **cerrs=NULL; |
| 2122 |
Tcl_Obj *resultPtr; |
| 2123 |
Tcl_Obj *nullPtr; |
| 2124 |
Tcl_Obj *namesPtr; |
| 2125 |
Tcl_Obj *errsPtr; |
| 2126 |
Tcl_Obj **namesObjv=NULL; |
| 2127 |
Tcl_Obj **errsObjv=NULL; |
| 2128 |
|
| 2129 |
|
| 2130 |
if( objc != 8 ){ |
| 2131 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 2132 |
"xpa template paramlist mode names errs n"); |
| 2133 |
return(TCL_ERROR); |
| 2134 |
} |
| 2135 |
|
| 2136 |
|
| 2137 |
resultPtr = Tcl_GetObjResult(interp); |
| 2138 |
|
| 2139 |
|
| 2140 |
xpastr = Tcl_GetStringFromObj(objv[1], NULL); |
| 2141 |
if( TCL_NULLSTR(xpastr) ) |
| 2142 |
xpa = NULL; |
| 2143 |
else{ |
| 2144 |
|
| 2145 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_CLIENT, &xpa) != TCL_OK){ |
| 2146 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa client handle", -1); |
| 2147 |
return(TCL_ERROR); |
| 2148 |
} |
| 2149 |
} |
| 2150 |
|
| 2151 |
|
| 2152 |
tmpl = Tcl_GetStringFromObj(objv[2], NULL); |
| 2153 |
paramlist = Tcl_GetStringFromObj(objv[3], NULL); |
| 2154 |
mode = Tcl_GetStringFromObj(objv[4], NULL); |
| 2155 |
names = Tcl_GetStringFromObj(objv[5], NULL); |
| 2156 |
errs = Tcl_GetStringFromObj(objv[6], NULL); |
| 2157 |
if( (Tcl_GetIntFromObj(interp, objv[7], &n) != TCL_OK) || (n < 1) ){ |
| 2158 |
n = 1; |
| 2159 |
} |
| 2160 |
|
| 2161 |
if( !TCL_NULLSTR(names) ){ |
| 2162 |
cnames = (char **)xcalloc(n, sizeof(char *)); |
| 2163 |
namesObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 2164 |
} |
| 2165 |
if( !TCL_NULLSTR(errs) ){ |
| 2166 |
cerrs = (char **)xcalloc(n, sizeof(char *)); |
| 2167 |
errsObjv = (Tcl_Obj **)xcalloc(n, sizeof(Tcl_Obj *)); |
| 2168 |
} |
| 2169 |
|
| 2170 |
|
| 2171 |
Tcl_ResetResult(interp); |
| 2172 |
|
| 2173 |
|
| 2174 |
got = XPAAccess(xpa, tmpl, paramlist, mode, cnames, cerrs, n); |
| 2175 |
|
| 2176 |
|
| 2177 |
if( got > 0 ){ |
| 2178 |
|
| 2179 |
for(i=0; i<got; i++){ |
| 2180 |
if( cnames ){ |
| 2181 |
namesObjv[i] = Tcl_NewObj(); |
| 2182 |
Tcl_SetStringObj(namesObjv[i], cnames[i], |
| 2183 |
cnames[i] ? strlen(cnames[i]) : 0); |
| 2184 |
} |
| 2185 |
if( cerrs ){ |
| 2186 |
errsObjv[i] = Tcl_NewObj(); |
| 2187 |
Tcl_SetStringObj(errsObjv[i], cerrs[i], |
| 2188 |
cerrs[i] ? strlen(cerrs[i]) : 0); |
| 2189 |
} |
| 2190 |
} |
| 2191 |
|
| 2192 |
if( cnames ){ |
| 2193 |
namesPtr = Tcl_NewObj(); |
| 2194 |
Tcl_SetListObj(namesPtr, got, namesObjv); |
| 2195 |
Tcl_ObjSetVar2(interp, objv[5], NULL, namesPtr, TCL_PARSE_PART1); |
| 2196 |
} |
| 2197 |
if( cerrs ){ |
| 2198 |
errsPtr = Tcl_NewObj(); |
| 2199 |
Tcl_SetListObj(errsPtr, got, errsObjv); |
| 2200 |
Tcl_ObjSetVar2(interp, objv[6], NULL, errsPtr, TCL_PARSE_PART1); |
| 2201 |
} |
| 2202 |
} |
| 2203 |
else{ |
| 2204 |
nullPtr = Tcl_NewObj(); |
| 2205 |
Tcl_SetStringObj(nullPtr, "", -1); |
| 2206 |
if( cnames ) |
| 2207 |
Tcl_ObjSetVar2(interp, objv[5], NULL, nullPtr, TCL_PARSE_PART1); |
| 2208 |
if( cerrs ) |
| 2209 |
Tcl_ObjSetVar2(interp, objv[6], NULL, nullPtr, TCL_PARSE_PART1); |
| 2210 |
} |
| 2211 |
|
| 2212 |
|
| 2213 |
for(i=0; i<got; i++){ |
| 2214 |
if( cnames[i] ) xfree((char *)cnames[i]); |
| 2215 |
if( cerrs[i] ) xfree((char *)cerrs[i]); |
| 2216 |
} |
| 2217 |
if( cnames ) xfree((char *)cnames); |
| 2218 |
if( cerrs ) xfree((char *)cerrs); |
| 2219 |
if( namesObjv ) xfree((char *)namesObjv); |
| 2220 |
if( errsObjv ) xfree((char *)errsObjv); |
| 2221 |
|
| 2222 |
|
| 2223 |
Tcl_SetIntObj(resultPtr, got); |
| 2224 |
|
| 2225 |
|
| 2226 |
return(TCL_OK); |
| 2227 |
} |
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
|
| 2232 |
|
| 2233 |
|
| 2234 |
|
| 2235 |
|
| 2236 |
|
| 2237 |
|
| 2238 |
|
| 2239 |
|
| 2240 |
|
| 2241 |
|
| 2242 |
|
| 2243 |
|
| 2244 |
#ifdef ANSI_FUNC |
| 2245 |
static int |
| 2246 |
XPANSLookup_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 2247 |
int objc, Tcl_Obj *CONST objv[]) |
| 2248 |
#else |
| 2249 |
static int XPANSLookup_Tcl(clientData, interp, objc, objv) |
| 2250 |
ClientData clientData; |
| 2251 |
Tcl_Interp *interp; |
| 2252 |
int objc; |
| 2253 |
Tcl_Obj *CONST objv[]; |
| 2254 |
#endif |
| 2255 |
{ |
| 2256 |
XPA xpa; |
| 2257 |
int i; |
| 2258 |
int got; |
| 2259 |
char *xpastr; |
| 2260 |
char *tmpl; |
| 2261 |
char *ttype; |
| 2262 |
char **xclasses; |
| 2263 |
char **names; |
| 2264 |
char **methods; |
| 2265 |
char **infos; |
| 2266 |
Tcl_Obj *resultPtr; |
| 2267 |
Tcl_Obj *nullPtr; |
| 2268 |
Tcl_Obj *classesPtr; |
| 2269 |
Tcl_Obj *namesPtr; |
| 2270 |
Tcl_Obj *methodsPtr; |
| 2271 |
Tcl_Obj *infosPtr; |
| 2272 |
Tcl_Obj **classesObjv; |
| 2273 |
Tcl_Obj **namesObjv; |
| 2274 |
Tcl_Obj **methodsObjv; |
| 2275 |
Tcl_Obj **infosObjv; |
| 2276 |
|
| 2277 |
|
| 2278 |
if( objc != 7 ){ |
| 2279 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 2280 |
"template type classes names methods infos"); |
| 2281 |
return(TCL_ERROR); |
| 2282 |
} |
| 2283 |
|
| 2284 |
|
| 2285 |
resultPtr = Tcl_GetObjResult(interp); |
| 2286 |
|
| 2287 |
|
| 2288 |
tmpl = Tcl_GetStringFromObj(objv[1], NULL); |
| 2289 |
ttype = Tcl_GetStringFromObj(objv[2], NULL); |
| 2290 |
|
| 2291 |
|
| 2292 |
Tcl_ResetResult(interp); |
| 2293 |
|
| 2294 |
|
| 2295 |
xpastr = Tcl_GetStringFromObj(objv[1], NULL); |
| 2296 |
if( TCL_NULLSTR(xpastr) ) |
| 2297 |
xpa = NULL; |
| 2298 |
else{ |
| 2299 |
|
| 2300 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_CLIENT, &xpa) != TCL_OK){ |
| 2301 |
Tcl_SetStringObj(resultPtr, "XPA$ERROR: invalid xpa client handle", -1); |
| 2302 |
return(TCL_ERROR); |
| 2303 |
} |
| 2304 |
} |
| 2305 |
|
| 2306 |
|
| 2307 |
got = XPANSLookup(xpa, tmpl, ttype, &xclasses, &names, &methods, &infos); |
| 2308 |
|
| 2309 |
|
| 2310 |
if( got > 0 ){ |
| 2311 |
|
| 2312 |
classesObjv = (Tcl_Obj **)xcalloc(got, sizeof(Tcl_Obj *)); |
| 2313 |
namesObjv = (Tcl_Obj **)xcalloc(got, sizeof(Tcl_Obj *)); |
| 2314 |
methodsObjv = (Tcl_Obj **)xcalloc(got, sizeof(Tcl_Obj *)); |
| 2315 |
infosObjv = (Tcl_Obj **)xcalloc(got, sizeof(Tcl_Obj *)); |
| 2316 |
|
| 2317 |
|
| 2318 |
for(i=0; i<got; i++){ |
| 2319 |
classesObjv[i] = Tcl_NewObj(); |
| 2320 |
Tcl_SetStringObj(classesObjv[i], xclasses[i], strlen(xclasses[i])); |
| 2321 |
namesObjv[i] = Tcl_NewObj(); |
| 2322 |
Tcl_SetStringObj(namesObjv[i], names[i], strlen(names[i])); |
| 2323 |
methodsObjv[i] = Tcl_NewObj(); |
| 2324 |
Tcl_SetStringObj(methodsObjv[i], methods[i], strlen(methods[i])); |
| 2325 |
infosObjv[i] = Tcl_NewObj(); |
| 2326 |
Tcl_SetStringObj(infosObjv[i], infos[i], strlen(infos[i])); |
| 2327 |
} |
| 2328 |
|
| 2329 |
classesPtr = Tcl_NewObj(); |
| 2330 |
Tcl_SetListObj(classesPtr, got, classesObjv); |
| 2331 |
Tcl_ObjSetVar2(interp, objv[3], NULL, classesPtr, TCL_PARSE_PART1); |
| 2332 |
|
| 2333 |
namesPtr = Tcl_NewObj(); |
| 2334 |
Tcl_SetListObj(namesPtr, got, namesObjv); |
| 2335 |
Tcl_ObjSetVar2(interp, objv[4], NULL, namesPtr, TCL_PARSE_PART1); |
| 2336 |
|
| 2337 |
methodsPtr = Tcl_NewObj(); |
| 2338 |
Tcl_SetListObj(methodsPtr, got, methodsObjv); |
| 2339 |
Tcl_ObjSetVar2(interp, objv[5], NULL, methodsPtr, TCL_PARSE_PART1); |
| 2340 |
|
| 2341 |
infosPtr = Tcl_NewObj(); |
| 2342 |
Tcl_SetListObj(infosPtr, got, infosObjv); |
| 2343 |
Tcl_ObjSetVar2(interp, objv[5], NULL, infosPtr, TCL_PARSE_PART1); |
| 2344 |
|
| 2345 |
|
| 2346 |
for(i=0; i<got; i++){ |
| 2347 |
|
| 2348 |
xfree(xclasses[i]); |
| 2349 |
xfree(names[i]); |
| 2350 |
xfree(methods[i]); |
| 2351 |
xfree(infos[i]); |
| 2352 |
} |
| 2353 |
|
| 2354 |
if( got > 0 ){ |
| 2355 |
xfree(xclasses); |
| 2356 |
xfree(names); |
| 2357 |
xfree(methods); |
| 2358 |
xfree(infos); |
| 2359 |
xfree(classesObjv); |
| 2360 |
xfree(namesObjv); |
| 2361 |
xfree(methodsObjv); |
| 2362 |
xfree(infosObjv); |
| 2363 |
} |
| 2364 |
} |
| 2365 |
else{ |
| 2366 |
nullPtr = Tcl_NewObj(); |
| 2367 |
Tcl_SetStringObj(nullPtr, "", -1); |
| 2368 |
Tcl_ObjSetVar2(interp, objv[3], NULL, nullPtr, TCL_PARSE_PART1); |
| 2369 |
Tcl_ObjSetVar2(interp, objv[4], NULL, nullPtr, TCL_PARSE_PART1); |
| 2370 |
Tcl_ObjSetVar2(interp, objv[5], NULL, nullPtr, TCL_PARSE_PART1); |
| 2371 |
Tcl_ObjSetVar2(interp, objv[6], NULL, nullPtr, TCL_PARSE_PART1); |
| 2372 |
} |
| 2373 |
|
| 2374 |
|
| 2375 |
Tcl_SetIntObj(resultPtr, got); |
| 2376 |
|
| 2377 |
|
| 2378 |
return(TCL_OK); |
| 2379 |
} |
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
|
| 2385 |
|
| 2386 |
|
| 2387 |
|
| 2388 |
|
| 2389 |
|
| 2390 |
|
| 2391 |
|
| 2392 |
|
| 2393 |
|
| 2394 |
|
| 2395 |
|
| 2396 |
#ifdef ANSI_FUNC |
| 2397 |
static int |
| 2398 |
XPANSKeepAlive_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 2399 |
int objc, Tcl_Obj *CONST objv[]) |
| 2400 |
#else |
| 2401 |
static int XPANSKeepAlive_Tcl(clientData, interp, objc, objv) |
| 2402 |
ClientData clientData; |
| 2403 |
Tcl_Interp *interp; |
| 2404 |
int objc; |
| 2405 |
Tcl_Obj *CONST objv[]; |
| 2406 |
#endif |
| 2407 |
{ |
| 2408 |
XPA xpa; |
| 2409 |
int type=0; |
| 2410 |
char *s=NULL; |
| 2411 |
|
| 2412 |
|
| 2413 |
if( objc < 2 ){ |
| 2414 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa [type]"); |
| 2415 |
return(TCL_ERROR); |
| 2416 |
} |
| 2417 |
|
| 2418 |
|
| 2419 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa) != TCL_OK){ |
| 2420 |
return(TCL_ERROR); |
| 2421 |
} |
| 2422 |
|
| 2423 |
|
| 2424 |
if( (objc >= 3) && (s = Tcl_GetStringFromObj(objv[2], NULL)) != NULL ) |
| 2425 |
type = atoi(s); |
| 2426 |
|
| 2427 |
|
| 2428 |
Tcl_ResetResult(interp); |
| 2429 |
|
| 2430 |
|
| 2431 |
XPANSKeepAlive(xpa, type); |
| 2432 |
|
| 2433 |
return(TCL_OK); |
| 2434 |
} |
| 2435 |
|
| 2436 |
|
| 2437 |
|
| 2438 |
|
| 2439 |
|
| 2440 |
|
| 2441 |
|
| 2442 |
|
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
|
| 2447 |
|
| 2448 |
|
| 2449 |
|
| 2450 |
|
| 2451 |
|
| 2452 |
|
| 2453 |
#ifdef ANSI_FUNC |
| 2454 |
static int |
| 2455 |
XPARemote_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 2456 |
int objc, Tcl_Obj *CONST objv[]) |
| 2457 |
#else |
| 2458 |
static int XPARemote_Tcl(clientData, interp, objc, objv) |
| 2459 |
ClientData clientData; |
| 2460 |
Tcl_Interp *interp; |
| 2461 |
int objc; |
| 2462 |
Tcl_Obj *CONST objv[]; |
| 2463 |
#endif |
| 2464 |
{ |
| 2465 |
int got; |
| 2466 |
char *host; |
| 2467 |
char *acl="+"; |
| 2468 |
char *s; |
| 2469 |
char *mode=NULL; |
| 2470 |
char tbuf[SZ_LINE]; |
| 2471 |
XPA xpa; |
| 2472 |
Tcl_Obj *resultPtr; |
| 2473 |
|
| 2474 |
|
| 2475 |
if( (objc < 3) || (objc > 5) ){ |
| 2476 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa host [acl] [-proxy]"); |
| 2477 |
return(TCL_ERROR); |
| 2478 |
} |
| 2479 |
|
| 2480 |
|
| 2481 |
resultPtr = Tcl_GetObjResult(interp); |
| 2482 |
|
| 2483 |
|
| 2484 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa) != TCL_OK){ |
| 2485 |
return(TCL_ERROR); |
| 2486 |
} |
| 2487 |
|
| 2488 |
|
| 2489 |
if( XPAMtype() != XPA_INET ){ |
| 2490 |
snprintf(tbuf, SZ_LINE, "remote requires that XPA_METHOD be 'inet'\n"); |
| 2491 |
Tcl_SetStringObj(resultPtr, tbuf, -1); |
| 2492 |
return(TCL_ERROR); |
| 2493 |
} |
| 2494 |
|
| 2495 |
|
| 2496 |
host = Tcl_GetStringFromObj(objv[2], NULL); |
| 2497 |
|
| 2498 |
|
| 2499 |
if( objc >= 4 ){ |
| 2500 |
s = Tcl_GetStringFromObj(objv[3], NULL); |
| 2501 |
if( !strcmp(s, "-proxy") ){ |
| 2502 |
mode="proxy=true"; |
| 2503 |
} |
| 2504 |
else{ |
| 2505 |
acl = s; |
| 2506 |
} |
| 2507 |
} |
| 2508 |
|
| 2509 |
|
| 2510 |
if( objc == 5 ){ |
| 2511 |
s = Tcl_GetStringFromObj(objv[4], NULL); |
| 2512 |
if( !strcmp(s, "-proxy") ){ |
| 2513 |
mode="proxy=true"; |
| 2514 |
} |
| 2515 |
else if( mode ){ |
| 2516 |
acl = s; |
| 2517 |
} |
| 2518 |
else{ |
| 2519 |
snprintf(tbuf, SZ_LINE, |
| 2520 |
"XPA$ERROR: invalid arg (%s): xpa -remote host [acl] [-proxy]\n", |
| 2521 |
s); |
| 2522 |
Tcl_SetStringObj(resultPtr, tbuf, -1); |
| 2523 |
return(TCL_ERROR); |
| 2524 |
} |
| 2525 |
} |
| 2526 |
|
| 2527 |
|
| 2528 |
Tcl_ResetResult(interp); |
| 2529 |
|
| 2530 |
|
| 2531 |
got = XPARemote(xpa, host, acl, mode); |
| 2532 |
if( got >= 0 ){ |
| 2533 |
return(TCL_OK); |
| 2534 |
} |
| 2535 |
else{ |
| 2536 |
snprintf(tbuf, SZ_LINE, |
| 2537 |
"XPA$ERROR: remote xpans %s failed to process %s\n", |
| 2538 |
host, xpa->name); |
| 2539 |
Tcl_SetStringObj(resultPtr, tbuf, -1); |
| 2540 |
return(TCL_ERROR); |
| 2541 |
} |
| 2542 |
} |
| 2543 |
|
| 2544 |
|
| 2545 |
|
| 2546 |
|
| 2547 |
|
| 2548 |
|
| 2549 |
|
| 2550 |
|
| 2551 |
|
| 2552 |
|
| 2553 |
|
| 2554 |
|
| 2555 |
|
| 2556 |
|
| 2557 |
|
| 2558 |
|
| 2559 |
#ifdef ANSI_FUNC |
| 2560 |
static int |
| 2561 |
XPAError_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 2562 |
int objc, Tcl_Obj *CONST objv[]) |
| 2563 |
#else |
| 2564 |
static int XPAError_Tcl(clientData, interp, objc, objv) |
| 2565 |
ClientData clientData; |
| 2566 |
Tcl_Interp *interp; |
| 2567 |
int objc; |
| 2568 |
Tcl_Obj *CONST objv[]; |
| 2569 |
#endif |
| 2570 |
{ |
| 2571 |
char *message; |
| 2572 |
XPA xpa; |
| 2573 |
|
| 2574 |
|
| 2575 |
if( objc != 3 ){ |
| 2576 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa message"); |
| 2577 |
return(TCL_ERROR); |
| 2578 |
} |
| 2579 |
|
| 2580 |
|
| 2581 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa) != TCL_OK){ |
| 2582 |
return(TCL_ERROR); |
| 2583 |
} |
| 2584 |
|
| 2585 |
|
| 2586 |
message = Tcl_GetStringFromObj(objv[2], NULL); |
| 2587 |
|
| 2588 |
|
| 2589 |
Tcl_ResetResult(interp); |
| 2590 |
|
| 2591 |
|
| 2592 |
XPAError(xpa, message); |
| 2593 |
|
| 2594 |
|
| 2595 |
return(TCL_OK); |
| 2596 |
} |
| 2597 |
|
| 2598 |
|
| 2599 |
|
| 2600 |
|
| 2601 |
|
| 2602 |
|
| 2603 |
|
| 2604 |
|
| 2605 |
|
| 2606 |
|
| 2607 |
|
| 2608 |
|
| 2609 |
|
| 2610 |
|
| 2611 |
|
| 2612 |
|
| 2613 |
#ifdef ANSI_FUNC |
| 2614 |
static int |
| 2615 |
XPAMessage_Tcl(ClientData clientData, Tcl_Interp *interp, |
| 2616 |
int objc, Tcl_Obj *CONST objv[]) |
| 2617 |
#else |
| 2618 |
static int XPAMessage_Tcl(clientData, interp, objc, objv) |
| 2619 |
ClientData clientData; |
| 2620 |
Tcl_Interp *interp; |
| 2621 |
int objc; |
| 2622 |
Tcl_Obj *CONST objv[]; |
| 2623 |
#endif |
| 2624 |
{ |
| 2625 |
char *message; |
| 2626 |
XPA xpa; |
| 2627 |
|
| 2628 |
|
| 2629 |
if( objc != 3 ){ |
| 2630 |
Tcl_WrongNumArgs(interp, 1, objv, "xpa message"); |
| 2631 |
return(TCL_ERROR); |
| 2632 |
} |
| 2633 |
|
| 2634 |
|
| 2635 |
if( Tcl_GetXPAFromObj(interp, objv[1], TY_SERVER, &xpa) != TCL_OK){ |
| 2636 |
return(TCL_ERROR); |
| 2637 |
} |
| 2638 |
|
| 2639 |
|
| 2640 |
message = Tcl_GetStringFromObj(objv[2], NULL); |
| 2641 |
|
| 2642 |
|
| 2643 |
Tcl_ResetResult(interp); |
| 2644 |
|
| 2645 |
|
| 2646 |
XPAMessage(xpa, message); |
| 2647 |
|
| 2648 |
|
| 2649 |
return(TCL_OK); |
| 2650 |
} |
| 2651 |
|
| 2652 |
|
| 2653 |
|
| 2654 |
|
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
|
| 2663 |
|
| 2664 |
|
| 2665 |
|
| 2666 |
|
| 2667 |
|
| 2668 |
|
| 2669 |
|
| 2670 |
|
| 2671 |
|
| 2672 |
|
| 2673 |
#ifdef ANSI_FUNC |
| 2674 |
int |
| 2675 |
Tclxpa_Init (void *vinterp) |
| 2676 |
#else |
| 2677 |
int Tclxpa_Init (vinterp) |
| 2678 |
void *vinterp; |
| 2679 |
#endif |
| 2680 |
{ |
| 2681 |
Tcl_Interp *interp = (Tcl_Interp *)vinterp; |
| 2682 |
|
| 2683 |
if( |
| 2684 |
#ifdef USE_TCL_STUBS |
| 2685 |
Tcl_InitStubs(interp, "8.4", 0) |
| 2686 |
#else |
| 2687 |
Tcl_PkgRequire(interp, "Tcl", "8.4", 0) |
| 2688 |
#endif |
| 2689 |
== NULL) { |
| 2690 |
return TCL_ERROR; |
| 2691 |
} |
| 2692 |
|
| 2693 |
|
| 2694 |
Tcl_CreateObjCommand(interp, "xpanew", XPANew_Tcl, |
| 2695 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2696 |
|
| 2697 |
Tcl_CreateObjCommand(interp, "xpafree", XPAFree_Tcl, |
| 2698 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2699 |
|
| 2700 |
Tcl_CreateObjCommand(interp, "xpainfonew", XPAInfoNew_Tcl, |
| 2701 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2702 |
|
| 2703 |
Tcl_CreateObjCommand(interp, "xpacmdnew", XPACmdNew_Tcl, |
| 2704 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2705 |
|
| 2706 |
Tcl_CreateObjCommand(interp, "xpacmddel", XPACmdDel_Tcl, |
| 2707 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2708 |
|
| 2709 |
Tcl_CreateObjCommand(interp, "xpacmdadd", XPACmdAdd_Tcl, |
| 2710 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2711 |
|
| 2712 |
Tcl_CreateObjCommand(interp, "xparec", XPARec_Tcl, |
| 2713 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2714 |
|
| 2715 |
Tcl_CreateObjCommand(interp, "xpasetbuf", XPASetBuf_Tcl, |
| 2716 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2717 |
|
| 2718 |
Tcl_CreateObjCommand(interp, "xpaopen", XPAOpen_Tcl, |
| 2719 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2720 |
|
| 2721 |
Tcl_CreateObjCommand(interp, "xpaclose", XPAClose_Tcl, |
| 2722 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2723 |
|
| 2724 |
Tcl_CreateObjCommand(interp, "xpaget", XPAGet_Tcl, |
| 2725 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2726 |
|
| 2727 |
Tcl_CreateObjCommand(interp, "xpagetfd", XPAGetFd_Tcl, |
| 2728 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2729 |
|
| 2730 |
Tcl_CreateObjCommand(interp, "xpaset", XPASet_Tcl, |
| 2731 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2732 |
|
| 2733 |
Tcl_CreateObjCommand(interp, "xpasetfd", XPASetFd_Tcl, |
| 2734 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2735 |
|
| 2736 |
Tcl_CreateObjCommand(interp, "xpainfo", XPAInfo_Tcl, |
| 2737 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2738 |
|
| 2739 |
Tcl_CreateObjCommand(interp, "xpaaccess", XPAAccess_Tcl, |
| 2740 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2741 |
|
| 2742 |
Tcl_CreateObjCommand(interp, "xpanslookup", XPANSLookup_Tcl, |
| 2743 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2744 |
|
| 2745 |
Tcl_CreateObjCommand(interp, "xpanskeepalive", XPANSKeepAlive_Tcl, |
| 2746 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2747 |
|
| 2748 |
Tcl_CreateObjCommand(interp, "xparemote", XPARemote_Tcl, |
| 2749 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2750 |
|
| 2751 |
Tcl_CreateObjCommand(interp, "xpaerror", XPAError_Tcl, |
| 2752 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2753 |
|
| 2754 |
Tcl_CreateObjCommand(interp, "xpamessage", XPAMessage_Tcl, |
| 2755 |
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 2756 |
|
| 2757 |
Tcl_PkgProvide(interp, "tclxpa", "2.1"); |
| 2758 |
return(TCL_OK); |
| 2759 |
} |
| 2760 |
|
| 2761 |
|
| 2762 |
Tclxpa_Unload() {} |
| 2763 |
Tclxpa_SafeUnload() {} |
| 2764 |
Tclxpa_SafeInit() {} |
| 2765 |
|
| 2766 |
|
| 2767 |
int xpa_tclbinding = 1; |
| 2768 |
|
| 2769 |
#else |
| 2770 |
|
| 2771 |
int xpa_tclbinding = 0; |
| 2772 |
|
| 2773 |
#endif |