(interp, cmdName, proc, clientData, deleteProc)
| 329 | * manual entry for details on the calling sequence. |
| 330 | * |
| 331 | *---------------------------------------------------------------------- |
| 332 | */ |
| 333 | |
| 334 | void |
| 335 | Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc) |
| 336 | Tcl_Interp *interp; /* Token for command interpreter (returned |
| 337 | * by a previous call to Tcl_CreateInterp). */ |
| 338 | char *cmdName; /* Name of command. */ |
| 339 | Tcl_CmdProc *proc; /* Command procedure to associate with |
| 340 | * cmdName. */ |
| 341 | ClientData clientData; /* Arbitrary one-word value to pass to proc. */ |
| 342 | Tcl_CmdDeleteProc *deleteProc; |
| 343 | /* If not NULL, gives a procedure to call when |
| 344 | * this command is deleted. */ |
| 345 | { |
| 346 | Interp *iPtr = (Interp *) interp; |
| 347 | register Command *cmdPtr; |
| 348 | Tcl_HashEntry *hPtr; |
| 349 | int new; |
| 350 | |
| 351 | hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, cmdName, &new); |
| 352 | if (!new) { |
| 353 | /* |
| 354 | * Command already exists: delete the old one. |
| 355 | */ |
| 356 | |
| 357 | cmdPtr = (Command *) Tcl_GetHashValue(hPtr); |
| 358 | if (cmdPtr->deleteProc != NULL) { |
| 359 | (*cmdPtr->deleteProc)(cmdPtr->clientData); |
| 360 | } |
| 361 | } else { |
| 362 | cmdPtr = (Command *) ckalloc(sizeof(Command)); |
| 363 | Tcl_SetHashValue(hPtr, cmdPtr); |
| 364 | } |
| 365 | cmdPtr->proc = proc; |
| 366 | cmdPtr->clientData = clientData; |
| 367 | cmdPtr->deleteProc = deleteProc; |
| 368 | } |
no outgoing calls