Tcl Source Code

Check-in [ca77050cc6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix DDE code for Win95/98
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | core-8-1-branch-old
Files: files | file ages | folders
SHA1: ca77050cc6a9f034985131dc4509ab6f559e186a
User & Date: redman 1999-04-03 00:44:38.000
Context
1999-04-03
01:19
* generic/tclThreadTest.c (ThreadExitProc): Fixed bug where static memory was being returned instead... check-in: 580aaa126e user: stanton tags: core-8-1-branch-old
00:44
Fix DDE code for Win95/98 check-in: ca77050cc6 user: redman tags: core-8-1-branch-old
1999-04-02
23:48
Add DDE package (moved from Tk). check-in: 26586b1d7e user: redman tags: core-8-1-branch-old
Changes
Unified Diff Ignore Whitespace Patch
Changes to win/tclWinDde.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 
 * tclWinDde.c --
 *
 *	This file provides procedures that implement the "send"
 *	command, allowing commands to be passed from interpreter
 *	to interpreter.
 *
 * Copyright (c) 1997 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinDde.c,v 1.1.2.1 1999/04/02 23:48:34 redman Exp $
 */

#include "tclPort.h"
#include <ddeml.h>

/*
 * TCL_STORAGE_CLASS is set unconditionally to DLLEXPORT because the












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 
 * tclWinDde.c --
 *
 *	This file provides procedures that implement the "send"
 *	command, allowing commands to be passed from interpreter
 *	to interpreter.
 *
 * Copyright (c) 1997 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinDde.c,v 1.1.2.2 1999/04/03 00:44:38 redman Exp $
 */

#include "tclPort.h"
#include <ddeml.h>

/*
 * TCL_STORAGE_CLASS is set unconditionally to DLLEXPORT because the
60
61
62
63
64
65
66

67
68
69
70
71
72
73
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

/*
 * The following variables cannot be placed in thread-local storage.
 * The Mutex ddeMutex guards access to the ddeInstance.
 */

static DWORD ddeInstance;       /* The application instance handle given
				 * to us by DdeInitialize. */
static int ddeIsServer = 0;

TCL_DECLARE_MUTEX(ddeMutex)

/*







>







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

/*
 * The following variables cannot be placed in thread-local storage.
 * The Mutex ddeMutex guards access to the ddeInstance.
 */
static HSZ ddeService = 0;
static DWORD ddeInstance;       /* The application instance handle given
				 * to us by DdeInitialize. */
static int ddeIsServer = 0;

TCL_DECLARE_MUTEX(ddeMutex)

/*
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208



static void
Initialize()
{
    int nameFound = 0;
    HSZ ddeService = 0;
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    
    /*
     * See if the application is already registered; if so, remove its
     * current name from the registry. The deletion of the command
     * will take care of disposing of this entry.
     */

    if (tsdPtr->interpListPtr != NULL) {
	nameFound = 1;
    }

    /*
     * First, if Dde has been initialized as a client, uninitialize it.
     */
    if ((ddeInstance != 0) && (ddeIsServer == 0) && (nameFound != 0)) {
	Tcl_MutexLock(&ddeMutex);
	DdeUninitialize(ddeInstance);
	ddeInstance = 0;
    }

	
    /*
     * Make sure that the DDE server is there. This is done only once,
     * add an exit handler tear it down.
     */

    if (ddeInstance == 0) {
	Tcl_MutexLock(&ddeMutex);
	if (ddeInstance == 0) {
	    if (nameFound != 0) {
		if (DdeInitialize(&ddeInstance, DdeServerProc,
			CBF_SKIP_REGISTRATIONS
			| CBF_SKIP_UNREGISTRATIONS
			| CBF_FAIL_POKES, 0) 
			!= DMLERR_NO_ERROR) {
		    DdeUninitialize(ddeInstance);
		    ddeInstance = 0;
		} else {







		    ddeIsServer = 1;
		    Tcl_CreateExitHandler(DdeExitProc, NULL);
		    ddeService = DdeCreateStringHandle(ddeInstance, "TclEval", 0);
		    DdeNameService(ddeInstance, ddeService, 0L, DNS_REGISTER);
		}
	    } else {
		if (DdeInitialize(&ddeInstance, NULL,
			CBF_SKIP_REGISTRATIONS
			| CBF_SKIP_UNREGISTRATIONS
			| CBF_FAIL_POKES
			| APPCMD_CLIENTONLY
			| APPCMD_FILTERINITS, 0) 
			!= DMLERR_NO_ERROR) {
		    DdeUninitialize(ddeInstance);
		    ddeInstance = 0;
		} else {
		    ddeIsServer = 0;
		}
	    }
	}
	Tcl_MutexUnlock(&ddeMutex);
    }
}    


/*







<












<
<
<
<
<
<
<
<
<
<








<
|
|
|
|
|
|
|
<
>
>
>
>
>
>
>
|
|
|
|
<
|
<
<
<
<
<
<
<
<
<
<
|
<
<







137
138
139
140
141
142
143

144
145
146
147
148
149
150
151
152
153
154
155










156
157
158
159
160
161
162
163

164
165
166
167
168
169
170

171
172
173
174
175
176
177
178
179
180
181

182










183


184
185
186
187
188
189
190



static void
Initialize()
{
    int nameFound = 0;

    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    
    /*
     * See if the application is already registered; if so, remove its
     * current name from the registry. The deletion of the command
     * will take care of disposing of this entry.
     */

    if (tsdPtr->interpListPtr != NULL) {
	nameFound = 1;
    }











    /*
     * Make sure that the DDE server is there. This is done only once,
     * add an exit handler tear it down.
     */

    if (ddeInstance == 0) {
	Tcl_MutexLock(&ddeMutex);
	if (ddeInstance == 0) {

	    if (DdeInitialize(&ddeInstance, DdeServerProc,
		    CBF_SKIP_REGISTRATIONS
		    | CBF_SKIP_UNREGISTRATIONS
		    | CBF_FAIL_POKES, 0) 
		    != DMLERR_NO_ERROR) {
		DdeUninitialize(ddeInstance);
		ddeInstance = 0;

	    }
	}
	Tcl_MutexUnlock(&ddeMutex);
    }
    if ((ddeService == 0) && (nameFound != 0)) {
	Tcl_MutexLock(&ddeMutex);
	if ((ddeService == 0) && (nameFound != 0)) {
	    ddeIsServer = 1;
	    Tcl_CreateExitHandler(DdeExitProc, NULL);
	    ddeService = DdeCreateStringHandle(ddeInstance, "TclEval", 0);
	    DdeNameService(ddeInstance, ddeService, 0L, DNS_REGISTER);

	} else {










	    ddeIsServer = 0;


	}
	Tcl_MutexUnlock(&ddeMutex);
    }
}    


/*