(clientData, offset, buffer, maxBytes)
| 1662 | * HandleTclCommand -- |
| 1663 | * |
| 1664 | * This procedure acts as selection handler for handlers created |
| 1665 | * by the "selection handle" command. It invokes a Tcl command to |
| 1666 | * retrieve the selection. |
| 1667 | * |
| 1668 | * Results: |
| 1669 | * The return value is a count of the number of bytes actually |
| 1670 | * stored at buffer. |
| 1671 | * |
| 1672 | * Side effects: |
| 1673 | * None except for things done by the Tcl command. |
| 1674 | * |
| 1675 | *---------------------------------------------------------------------- |
| 1676 | */ |
| 1677 | |
| 1678 | static int |
| 1679 | HandleTclCommand(clientData, offset, buffer, maxBytes) |
| 1680 | ClientData clientData; /* Information about command to execute. */ |
| 1681 | int offset; /* Return selection bytes starting at this |
| 1682 | * offset. */ |
| 1683 | char *buffer; /* Place to store converted selection. */ |
| 1684 | int maxBytes; /* Maximum # of bytes to store at buffer. */ |
| 1685 | { |
| 1686 | register CommandInfo *cmdInfoPtr = (CommandInfo *) clientData; |
| 1687 | char *oldResultString; |
| 1688 | Tcl_FreeProc *oldFreeProc; |
| 1689 | int spaceNeeded, length; |
| 1690 | #define MAX_STATIC_SIZE 100 |
| 1691 | char staticSpace[MAX_STATIC_SIZE]; |
| 1692 | char *command; |
| 1693 | |
| 1694 | /* |
| 1695 | * First, generate a command by taking the command string |
| 1696 | * and appending the offset and maximum # of bytes. |
| 1697 | */ |
| 1698 | |
| 1699 | spaceNeeded = cmdInfoPtr->cmdLength + 30; |
| 1700 | if (spaceNeeded < MAX_STATIC_SIZE) { |
| 1701 | command = staticSpace; |
| 1702 | } else { |
| 1703 | command = (char *) ckalloc((unsigned) spaceNeeded); |
| 1704 | } |
| 1705 | sprintf(command, "%s %d %d", cmdInfoPtr->command, offset, maxBytes); |
| 1706 | |
| 1707 | /* |
| 1708 | * Execute the command. Be sure to restore the state of the |
| 1709 | * interpreter after executing the command. |
| 1710 | */ |
| 1711 | |
| 1712 | oldFreeProc = cmdInfoPtr->interp->freeProc; |
| 1713 | if (oldFreeProc != 0) { |
| 1714 | oldResultString = cmdInfoPtr->interp->result; |
| 1715 | } else { |
| 1716 | oldResultString = (char *) ckalloc((unsigned) |
| 1717 | (strlen(cmdInfoPtr->interp->result) + 1)); |
| 1718 | strcpy(oldResultString, cmdInfoPtr->interp->result); |
| 1719 | oldFreeProc = TCL_DYNAMIC; |
| 1720 | } |
| 1721 | cmdInfoPtr->interp->freeProc = 0; |
nothing calls this directly
no test coverage detected