diff options
Diffstat (limited to 'tk/unix/tkUnixSend.c')
-rw-r--r-- | tk/unix/tkUnixSend.c | 73 |
1 files changed, 52 insertions, 21 deletions
diff --git a/tk/unix/tkUnixSend.c b/tk/unix/tkUnixSend.c index b661923e694..531f09172cb 100644 --- a/tk/unix/tkUnixSend.c +++ b/tk/unix/tkUnixSend.c @@ -85,7 +85,7 @@ typedef struct PendingCommand { int serial; /* Serial number expected in * result. */ TkDisplay *dispPtr; /* Display being used for communication. */ - char *target; /* Name of interpreter command is + CONST char *target; /* Name of interpreter command is * being sent to. */ Window commWindow; /* Target's communication window. */ Tcl_Interp *interp; /* Interpreter from which the send @@ -224,12 +224,12 @@ static void AppendPropCarefully _ANSI_ARGS_((Display *display, int length, PendingCommand *pendingPtr)); static void DeleteProc _ANSI_ARGS_((ClientData clientData)); static void RegAddName _ANSI_ARGS_((NameRegistry *regPtr, - char *name, Window commWindow)); + CONST char *name, Window commWindow)); static void RegClose _ANSI_ARGS_((NameRegistry *regPtr)); static void RegDeleteName _ANSI_ARGS_((NameRegistry *regPtr, - char *name)); + CONST char *name)); static Window RegFindName _ANSI_ARGS_((NameRegistry *regPtr, - char *name)); + CONST char *name)); static NameRegistry * RegOpen _ANSI_ARGS_((Tcl_Interp *interp, TkDisplay *dispPtr, int lock)); static void SendEventProc _ANSI_ARGS_((ClientData clientData, @@ -241,7 +241,7 @@ static Tk_RestrictAction SendRestrictProc _ANSI_ARGS_((ClientData clientData, static int ServerSecure _ANSI_ARGS_((TkDisplay *dispPtr)); static void UpdateCommWindow _ANSI_ARGS_((TkDisplay *dispPtr)); static int ValidateName _ANSI_ARGS_((TkDisplay *dispPtr, - char *name, Window commWindow, int oldOK)); + CONST char *name, Window commWindow, int oldOK)); /* *---------------------------------------------------------------------- @@ -365,7 +365,7 @@ static Window RegFindName(regPtr, name) NameRegistry *regPtr; /* Pointer to a registry opened with a * previous call to RegOpen. */ - char *name; /* Name of an application. */ + CONST char *name; /* Name of an application. */ { char *p, *entry; unsigned int id; @@ -416,7 +416,7 @@ static void RegDeleteName(regPtr, name) NameRegistry *regPtr; /* Pointer to a registry opened with a * previous call to RegOpen. */ - char *name; /* Name of an application. */ + CONST char *name; /* Name of an application. */ { char *p, *entry, *entryName; int count; @@ -476,7 +476,7 @@ static void RegAddName(regPtr, name, commWindow) NameRegistry *regPtr; /* Pointer to a registry opened with a * previous call to RegOpen. */ - char *name; /* Name of an application. The caller + CONST char *name; /* Name of an application. The caller * must ensure that this name isn't * already registered. */ Window commWindow; /* X identifier for comm. window of @@ -590,7 +590,7 @@ static int ValidateName(dispPtr, name, commWindow, oldOK) TkDisplay *dispPtr; /* Display for which to perform the * validation. */ - char *name; /* The name of an application. */ + CONST char *name; /* The name of an application. */ Window commWindow; /* X identifier for the application's * comm. window. */ int oldOK; /* Non-zero means that we should consider @@ -603,7 +603,7 @@ ValidateName(dispPtr, name, commWindow, oldOK) Atom actualType; char *property; Tk_ErrorHandler handler; - char **argv; + CONST char **argv; property = NULL; @@ -735,12 +735,12 @@ ServerSecure(dispPtr) *-------------------------------------------------------------- */ -char * +CONST char * Tk_SetAppName(tkwin, name) Tk_Window tkwin; /* Token for any window in the application * to be named: it is just used to identify * the application and the display. */ - char *name; /* The name that will be used to + CONST char *name; /* The name that will be used to * refer to the interpreter in later * "send" commands. Must be globally * unique. */ @@ -751,7 +751,7 @@ Tk_SetAppName(tkwin, name) TkDisplay *dispPtr = winPtr->dispPtr; NameRegistry *regPtr; Tcl_Interp *interp; - char *actualName; + CONST char *actualName; Tcl_DString dString; int offset, i; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) @@ -821,10 +821,10 @@ Tk_SetAppName(tkwin, name) Tcl_DStringAppend(&dString, name, -1); Tcl_DStringAppend(&dString, " #", 2); offset = Tcl_DStringLength(&dString); - Tcl_DStringSetLength(&dString, offset+10); + Tcl_DStringSetLength(&dString, offset+TCL_INTEGER_SPACE); actualName = Tcl_DStringValue(&dString); } - sprintf(actualName + offset, "%d", i); + sprintf(Tcl_DStringValue(&dString) + offset, "%d", i); } w = RegFindName(regPtr, actualName); if (w == None) { @@ -896,13 +896,13 @@ Tk_SendCmd(clientData, interp, argc, argv) * dispPtr field is used). */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { TkWindow *winPtr; Window commWindow; PendingCommand pending; register RegisteredInterp *riPtr; - char *destName; + CONST char *destName; int result, c, async, i, firstArg; size_t length; Tk_RestrictProc *prevRestrictProc; @@ -1104,7 +1104,7 @@ Tk_SendCmd(clientData, interp, argc, argv) prevRestrictProc = Tk_RestrictEvents(SendRestrictProc, (ClientData) NULL, &prevArg); - TclpGetTime(&timeout); + Tcl_GetTime(&timeout); timeout.sec += 2; while (!pending.gotResponse) { if (!TkUnixDoOneXEvent(&timeout)) { @@ -1128,7 +1128,7 @@ Tk_SendCmd(clientData, interp, argc, argv) strcpy(pending.result, msg); pending.gotResponse = 1; } else { - TclpGetTime(&timeout); + Tcl_GetTime(&timeout); timeout.sec += 2; } } @@ -1256,6 +1256,37 @@ TkGetInterpNames(interp, tkwin) /* *-------------------------------------------------------------- * + * TkSendCleanup -- + * + * This procedure is called to free resources used by the + * communication channels for sending commands and + * receiving results. + * + * Results: + * None. + * + * Side effects: + * Frees various data structures and windows. + * + *-------------------------------------------------------------- + */ + +void +TkSendCleanup(dispPtr) + TkDisplay *dispPtr; +{ + if (dispPtr->commTkwin != NULL) { + Tk_DeleteEventHandler(dispPtr->commTkwin, PropertyChangeMask, + SendEventProc, (ClientData) dispPtr); + Tk_DestroyWindow(dispPtr->commTkwin); + Tcl_Release((ClientData) dispPtr->commTkwin); + dispPtr->commTkwin = NULL; + } +} + +/* + *-------------------------------------------------------------- + * * SendInit -- * * This procedure is called to initialize the @@ -1290,6 +1321,7 @@ SendInit(interp, dispPtr) if (dispPtr->commTkwin == NULL) { panic("Tk_CreateWindow failed in SendInit!"); } + Tcl_Preserve((ClientData) dispPtr->commTkwin); atts.override_redirect = True; Tk_ChangeWindowAttributes(dispPtr->commTkwin, CWOverrideRedirect, &atts); @@ -1508,7 +1540,7 @@ SendEventProc(clientData, eventPtr) Tcl_DStringAppend(&reply, Tcl_GetStringResult(remoteInterp), -1); if (result == TCL_ERROR) { - char *varValue; + CONST char *varValue; varValue = Tcl_GetVar2(remoteInterp, "errorInfo", (char *) NULL, TCL_GLOBAL_ONLY); @@ -1865,4 +1897,3 @@ UpdateCommWindow(dispPtr) Tcl_DStringLength(&names)); Tcl_DStringFree(&names); } - |