Tcl Source Code

Check-in [ca77050cc6]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Fix DDE code for Win95/98
Downloads: Tarball | ZIP archive | SQL 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
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
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to win/tclWinDde.c.

     6      6    *	to interpreter.
     7      7    *
     8      8    * Copyright (c) 1997 by Sun Microsystems, Inc.
     9      9    *
    10     10    * See the file "license.terms" for information on usage and redistribution
    11     11    * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    12     12    *
    13         - * RCS: @(#) $Id: tclWinDde.c,v 1.1.2.1 1999/04/02 23:48:34 redman Exp $
           13  + * RCS: @(#) $Id: tclWinDde.c,v 1.1.2.2 1999/04/03 00:44:38 redman Exp $
    14     14    */
    15     15   
    16     16   #include "tclPort.h"
    17     17   #include <ddeml.h>
    18     18   
    19     19   /*
    20     20    * TCL_STORAGE_CLASS is set unconditionally to DLLEXPORT because the
................................................................................
    60     60   } ThreadSpecificData;
    61     61   static Tcl_ThreadDataKey dataKey;
    62     62   
    63     63   /*
    64     64    * The following variables cannot be placed in thread-local storage.
    65     65    * The Mutex ddeMutex guards access to the ddeInstance.
    66     66    */
           67  +static HSZ ddeService = 0;
    67     68   static DWORD ddeInstance;       /* The application instance handle given
    68     69   				 * to us by DdeInitialize. */
    69     70   static int ddeIsServer = 0;
    70     71   
    71     72   TCL_DECLARE_MUTEX(ddeMutex)
    72     73   
    73     74   /*
................................................................................
   136    137   
   137    138   
   138    139   
   139    140   static void
   140    141   Initialize()
   141    142   {
   142    143       int nameFound = 0;
   143         -    HSZ ddeService = 0;
   144    144       ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
   145    145       
   146    146       /*
   147    147        * See if the application is already registered; if so, remove its
   148    148        * current name from the registry. The deletion of the command
   149    149        * will take care of disposing of this entry.
   150    150        */
   151    151   
   152    152       if (tsdPtr->interpListPtr != NULL) {
   153    153   	nameFound = 1;
   154    154       }
   155    155   
   156         -    /*
   157         -     * First, if Dde has been initialized as a client, uninitialize it.
   158         -     */
   159         -    if ((ddeInstance != 0) && (ddeIsServer == 0) && (nameFound != 0)) {
   160         -	Tcl_MutexLock(&ddeMutex);
   161         -	DdeUninitialize(ddeInstance);
   162         -	ddeInstance = 0;
   163         -    }
   164         -
   165         -	
   166    156       /*
   167    157        * Make sure that the DDE server is there. This is done only once,
   168    158        * add an exit handler tear it down.
   169    159        */
   170    160   
   171    161       if (ddeInstance == 0) {
   172    162   	Tcl_MutexLock(&ddeMutex);
   173    163   	if (ddeInstance == 0) {
   174         -	    if (nameFound != 0) {
   175         -		if (DdeInitialize(&ddeInstance, DdeServerProc,
   176         -			CBF_SKIP_REGISTRATIONS
   177         -			| CBF_SKIP_UNREGISTRATIONS
   178         -			| CBF_FAIL_POKES, 0) 
   179         -			!= DMLERR_NO_ERROR) {
   180         -		    DdeUninitialize(ddeInstance);
   181         -		    ddeInstance = 0;
   182         -		} else {
   183         -		    ddeIsServer = 1;
   184         -		    Tcl_CreateExitHandler(DdeExitProc, NULL);
   185         -		    ddeService = DdeCreateStringHandle(ddeInstance, "TclEval", 0);
   186         -		    DdeNameService(ddeInstance, ddeService, 0L, DNS_REGISTER);
   187         -		}
   188         -	    } else {
   189         -		if (DdeInitialize(&ddeInstance, NULL,
   190         -			CBF_SKIP_REGISTRATIONS
   191         -			| CBF_SKIP_UNREGISTRATIONS
   192         -			| CBF_FAIL_POKES
   193         -			| APPCMD_CLIENTONLY
   194         -			| APPCMD_FILTERINITS, 0) 
   195         -			!= DMLERR_NO_ERROR) {
   196         -		    DdeUninitialize(ddeInstance);
   197         -		    ddeInstance = 0;
   198         -		} else {
   199         -		    ddeIsServer = 0;
   200         -		}
   201         -	    }
          164  +	    if (DdeInitialize(&ddeInstance, DdeServerProc,
          165  +		    CBF_SKIP_REGISTRATIONS
          166  +		    | CBF_SKIP_UNREGISTRATIONS
          167  +		    | CBF_FAIL_POKES, 0) 
          168  +		    != DMLERR_NO_ERROR) {
          169  +		DdeUninitialize(ddeInstance);
          170  +		ddeInstance = 0;
          171  +	    }
          172  +	}
          173  +	Tcl_MutexUnlock(&ddeMutex);
          174  +    }
          175  +    if ((ddeService == 0) && (nameFound != 0)) {
          176  +	Tcl_MutexLock(&ddeMutex);
          177  +	if ((ddeService == 0) && (nameFound != 0)) {
          178  +	    ddeIsServer = 1;
          179  +	    Tcl_CreateExitHandler(DdeExitProc, NULL);
          180  +	    ddeService = DdeCreateStringHandle(ddeInstance, "TclEval", 0);
          181  +	    DdeNameService(ddeInstance, ddeService, 0L, DNS_REGISTER);
          182  +	} else {
          183  +	    ddeIsServer = 0;
   202    184   	}
   203    185   	Tcl_MutexUnlock(&ddeMutex);
   204    186       }
   205    187   }    
   206    188   
   207    189   
   208    190   /*