Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch bug-473946 Excluding Merge-Ins
This is equivalent to a diff from 1a117d1880 to 7bb9d6699f
2012-05-10
| ||
20:38 | [Bug 473946]: special characters not correctly sen check-in: 98d6eb2b34 user: jan.nijtmans tags: core-8-4-branch | |
2012-05-09
| ||
19:18 | Increase version to 1.2.5 Now should work on Win95 as well Use Tcl_GetUnicodeFromObj in stead of Tcl... Closed-Leaf check-in: 7bb9d6699f user: jan.nijtmans tags: bug-473946 | |
08:47 | [Bug 473946]: special characters not correctly sent check-in: 18027385fd user: jan.nijtmans tags: bug-473946 | |
2012-05-07
| ||
08:21 | move TCHAR definition for Cygwin from tclUnixPort.h to tclPlatDecls.h, so it can be used for the Pla... check-in: d87557d5c3 user: jan.nijtmans tags: core-8-5-branch | |
07:50 | proposal from jmphilippe check-in: 6036f72024 user: jan.nijtmans tags: bug-473946 | |
06:33 | move TCHAR definition for Cygwin from tclUnixPort.h to tclPlatDecls.h, so it can be used for the Pl... check-in: 1a117d1880 user: jan.nijtmans tags: core-8-4-branch | |
2012-05-03
| ||
20:55 | don't try to run the cpuid test if cpuid is not available check-in: aa572ec793 user: jan.nijtmans tags: core-8-4-branch | |
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2012-05-02 Jan Nijtmans <[email protected]> * generic/configure.in: Better detection and implementation for cpuid * generic/configure: instruction on Intel-derived processors, both * generic/tclUnixCompat.c: 32-bit and 64-bit. * generic/tclTest.c: Move cpuid testcase from win-specific to generic * win/tclWinTest.c: tests, as it should work on all Intel-related | > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | 2012-05-?? Jan Nijtmans <[email protected]> * win/tclWinDde.c: [Bug 473946]: special characters not correctly sent * library/dde/pkgIndex.tcl Increase version to 1.2.5 2012-05-02 Jan Nijtmans <[email protected]> * generic/configure.in: Better detection and implementation for cpuid * generic/configure: instruction on Intel-derived processors, both * generic/tclUnixCompat.c: 32-bit and 64-bit. * generic/tclTest.c: Move cpuid testcase from win-specific to generic * win/tclWinTest.c: tests, as it should work on all Intel-related |
︙ | ︙ |
Changes to library/dde/pkgIndex.tcl.
1 2 3 | if {![package vsatisfies [package provide Tcl] 8]} return if {[string compare [info sharedlibextension] .dll]} return if {[info exists ::tcl_platform(debug)]} { | | | | 1 2 3 4 5 6 7 | if {![package vsatisfies [package provide Tcl] 8]} return if {[string compare [info sharedlibextension] .dll]} return if {[info exists ::tcl_platform(debug)]} { package ifneeded dde 1.2.5 [list load [file join $dir tcldde12g.dll] dde] } else { package ifneeded dde 1.2.5 [list load [file join $dir tcldde12.dll] dde] } |
Changes to win/tclWinDde.c.
|
| | | 1 2 3 4 5 6 7 8 | /* * 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. |
︙ | ︙ | |||
20 21 22 23 24 25 26 | * Registry_Init declaration is in the source file itself, which is only * accessed when we are building a library. */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * Registry_Init declaration is in the source file itself, which is only * accessed when we are building a library. */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT /* * The following structure is used to keep track of the interpreters * registered by this process. */ typedef struct RegisteredInterp { struct RegisteredInterp *nextPtr; /* The next interp this application knows |
︙ | ︙ | |||
64 65 66 67 68 69 70 | * The Mutex ddeMutex guards access to the ddeInstance. */ static HSZ ddeServiceGlobal = 0; static DWORD ddeInstance; /* The application instance handle given * to us by DdeInitialize. */ static int ddeIsServer = 0; | | | | > | | | | | | | | | | | | | | | | < | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | * The Mutex ddeMutex guards access to the ddeInstance. */ static HSZ ddeServiceGlobal = 0; static DWORD ddeInstance; /* The application instance handle given * to us by DdeInitialize. */ static int ddeIsServer = 0; #define TCL_DDE_VERSION "1.2.5" #define TCL_DDE_PACKAGE_NAME "dde" #define TCL_DDE_SERVICE_NAME "TclEval" #define TCL_DDE_EXECUTE_RESULT "$TCLEVAL$EXECUTE$RESULT" TCL_DECLARE_MUTEX(ddeMutex) /* * Forward declarations for procedures defined later in this file. */ static void DdeExitProc(ClientData clientData); static void DeleteProc(ClientData clientData); static Tcl_Obj * ExecuteRemoteObject( RegisteredInterp *riPtr, Tcl_Obj *ddeObjectPtr); static int MakeDdeConnection(Tcl_Interp *interp, const char *name, HCONV *ddeConvPtr); static HDDEDATA CALLBACK DdeServerProc(UINT uType, UINT uFmt, HCONV hConv, HSZ ddeTopic, HSZ ddeItem, HDDEDATA hData, DWORD dwData1, DWORD dwData2); static void SetDdeError(Tcl_Interp *interp); static int DdeGetServicesList( Tcl_Interp *interp, const char *serviceName, const char *topicName); static int DdeObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); EXTERN int Dde_Init(Tcl_Interp *interp); /* *---------------------------------------------------------------------- * * Dde_Init -- * * This procedure initializes the dde command. |
︙ | ︙ | |||
117 118 119 120 121 122 123 | *---------------------------------------------------------------------- */ int Dde_Init( Tcl_Interp *interp) { | | | < < | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | *---------------------------------------------------------------------- */ int Dde_Init( Tcl_Interp *interp) { if (!Tcl_InitStubs(interp, "8.1", 0)) { return TCL_ERROR; } Tcl_CreateObjCommand(interp, "dde", DdeObjCmd, NULL, NULL); Tcl_CreateExitHandler(DdeExitProc, NULL); return Tcl_PkgProvide(interp, TCL_DDE_PACKAGE_NAME, TCL_DDE_VERSION); } /* *---------------------------------------------------------------------- * * Initialize -- |
︙ | ︙ | |||
149 150 151 152 153 154 155 | */ static void Initialize(void) { int nameFound = 0; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); | | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | */ static void Initialize(void) { 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) { |
︙ | ︙ | |||
171 172 173 174 175 176 177 | if (ddeInstance == 0) { Tcl_MutexLock(&ddeMutex); if (ddeInstance == 0) { if (DdeInitialize(&ddeInstance, (PFNCALLBACK) DdeServerProc, CBF_SKIP_REGISTRATIONS | CBF_SKIP_UNREGISTRATIONS | | | | 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 | if (ddeInstance == 0) { Tcl_MutexLock(&ddeMutex); if (ddeInstance == 0) { if (DdeInitialize(&ddeInstance, (PFNCALLBACK) DdeServerProc, CBF_SKIP_REGISTRATIONS | CBF_SKIP_UNREGISTRATIONS | CBF_FAIL_POKES, 0) != DMLERR_NO_ERROR) { ddeInstance = 0; } } Tcl_MutexUnlock(&ddeMutex); } if ((ddeServiceGlobal == 0) && (nameFound != 0)) { Tcl_MutexLock(&ddeMutex); if ((ddeServiceGlobal == 0) && (nameFound != 0)) { ddeIsServer = 1; Tcl_CreateExitHandler(DdeExitProc, NULL); ddeServiceGlobal = DdeCreateStringHandle(ddeInstance, \ TCL_DDE_SERVICE_NAME, 0); DdeNameService(ddeInstance, ddeServiceGlobal, 0L, DNS_REGISTER); } else { ddeIsServer = 0; } Tcl_MutexUnlock(&ddeMutex); } } /* *-------------------------------------------------------------- * * DdeSetServerName -- * * This procedure is called to associate an ASCII name with a Dde |
︙ | ︙ | |||
221 222 223 224 225 226 227 | * *-------------------------------------------------------------- */ static char * DdeSetServerName( Tcl_Interp *interp, | | | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | * *-------------------------------------------------------------- */ static char * DdeSetServerName( Tcl_Interp *interp, const char *name /* The name that will be used to * refer to the interpreter in later * "send" commands. Must be globally * unique. */ ) { RegisteredInterp *riPtr, *prevPtr; Tcl_DString dString; 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. */ for (riPtr = tsdPtr->interpListPtr, prevPtr = NULL; riPtr != NULL; prevPtr = riPtr, riPtr = riPtr->nextPtr) { if (riPtr->interp == interp) { if (name != NULL) { if (prevPtr == NULL) { tsdPtr->interpListPtr = tsdPtr->interpListPtr->nextPtr; } else { prevPtr->nextPtr = riPtr->nextPtr; |
︙ | ︙ | |||
267 268 269 270 271 272 273 | * the name was NULL, so the caller is asking for * the name of the current interp, but it doesn't * have a name. */ return ""; } | | | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | * the name was NULL, so the caller is asking for * the name of the current interp, but it doesn't * have a name. */ return ""; } /* * Pick a name to use for the application. Use "name" if it's not * already in use. Otherwise add a suffix such as " #2", trying * larger and larger numbers until we eventually find one that is * unique. */ Tcl_DStringInit(&dString); /* * We have found a unique name. Now add it to the registry. */ riPtr = (RegisteredInterp *) ckalloc(sizeof(RegisteredInterp)); riPtr->interp = interp; riPtr->name = ckalloc((unsigned int) strlen(name) + 1); riPtr->nextPtr = tsdPtr->interpListPtr; tsdPtr->interpListPtr = riPtr; strcpy(riPtr->name, name); Tcl_CreateObjCommand(interp, "dde", DdeObjCmd, (ClientData) riPtr, DeleteProc); if (Tcl_IsSafe(interp)) { Tcl_HideCommand(interp, "dde", "dde"); } Tcl_DStringFree(&dString); /* * re-initialize with the new name */ Initialize(); return riPtr->name; } /* *-------------------------------------------------------------- * * DeleteProc |
︙ | ︙ | |||
424 425 426 427 428 429 430 | static HDDEDATA CALLBACK DdeServerProc ( UINT uType, /* The type of DDE transaction we * are performing. */ UINT uFmt, /* The format that data is sent or * received. */ | | | | | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | static HDDEDATA CALLBACK DdeServerProc ( UINT uType, /* The type of DDE transaction we * are performing. */ UINT uFmt, /* The format that data is sent or * received. */ HCONV hConv, /* The conversation associated with the * current transaction. */ HSZ ddeTopic, /* A string handle. Transaction-type * dependent. */ HSZ ddeItem, /* A string handle. Transaction-type * dependent. */ HDDEDATA hData, /* DDE data. Transaction-type dependent. */ DWORD dwData1, /* Transaction-dependent data. */ DWORD dwData2) /* Transaction-dependent data. */ { Tcl_DString dString; int len; |
︙ | ︙ | |||
473 474 475 476 477 478 479 | Tcl_DStringFree(&dString); return (HDDEDATA) FALSE; case XTYP_CONNECT_CONFIRM: /* | | | | | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | Tcl_DStringFree(&dString); return (HDDEDATA) FALSE; case XTYP_CONNECT_CONFIRM: /* * Dde has decided that we can connect, so it gives us a * conversation handle. We need to keep track of it * so we know which execution result to return in an * XTYP_REQUEST. */ len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, 0); Tcl_DStringInit(&dString); Tcl_DStringSetLength(&dString, len); utilString = Tcl_DStringValue(&dString); DdeQueryString(ddeInstance, ddeTopic, utilString, (DWORD) len + 1, CP_WINANSI); for (riPtr = tsdPtr->interpListPtr; riPtr != NULL; riPtr = riPtr->nextPtr) { if (stricmp(riPtr->name, utilString) == 0) { convPtr = (Conversation *) ckalloc(sizeof(Conversation)); convPtr->nextPtr = tsdPtr->currentConversations; convPtr->returnPackagePtr = NULL; convPtr->hConv = hConv; convPtr->riPtr = riPtr; |
︙ | ︙ | |||
508 509 510 511 512 513 514 | /* * The client has disconnected from our server. Forget this * conversation. */ for (convPtr = tsdPtr->currentConversations, prevConvPtr = NULL; | | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | /* * The client has disconnected from our server. Forget this * conversation. */ for (convPtr = tsdPtr->currentConversations, prevConvPtr = NULL; convPtr != NULL; prevConvPtr = convPtr, convPtr = convPtr->nextPtr) { if (hConv == convPtr->hConv) { if (prevConvPtr == NULL) { tsdPtr->currentConversations = convPtr->nextPtr; } else { prevConvPtr->nextPtr = convPtr->nextPtr; } |
︙ | ︙ | |||
533 534 535 536 537 538 539 | /* * This could be either a request for a value of a Tcl variable, * or it could be the send command requesting the results of the * last execute. */ | | | | | > | | > > > > > | < | > > | > > > | > | < | 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | /* * This could be either a request for a value of a Tcl variable, * or it could be the send command requesting the results of the * last execute. */ if ((uFmt != CF_TEXT) && (uFmt != CF_UNICODETEXT)) { return (HDDEDATA) FALSE; } ddeReturn = (HDDEDATA) FALSE; for (convPtr = tsdPtr->currentConversations; (convPtr != NULL) && (convPtr->hConv != hConv); convPtr = convPtr->nextPtr) { /* * Empty loop body. */ } if (convPtr != NULL) { char *returnString; len = DdeQueryString(ddeInstance, ddeItem, NULL, 0, CP_WINANSI); Tcl_DStringInit(&dString); Tcl_DStringSetLength(&dString, len); utilString = Tcl_DStringValue(&dString); DdeQueryString(ddeInstance, ddeItem, utilString, (DWORD) len + 1, CP_WINANSI); if (stricmp(utilString, TCL_DDE_EXECUTE_RESULT) == 0) { if (uFmt == CF_TEXT) { returnString = Tcl_GetStringFromObj(convPtr->returnPackagePtr, &len); } else { returnString = (char *) Tcl_GetUnicodeFromObj(convPtr->returnPackagePtr, &len); len = 2 * len + 1; } ddeReturn = DdeCreateDataHandle(ddeInstance, (BYTE *)returnString, (DWORD) len+1, 0, ddeItem, uFmt, 0); } else { Tcl_Obj *variableObjPtr = Tcl_GetVar2Ex( convPtr->riPtr->interp, utilString, NULL, TCL_GLOBAL_ONLY); if (variableObjPtr != NULL) { if (uFmt == CF_TEXT) { returnString = Tcl_GetStringFromObj(variableObjPtr, &len); } else { returnString = (char *) Tcl_GetUnicodeFromObj(variableObjPtr, &len); len = 2 * len + 1; } ddeReturn = DdeCreateDataHandle(ddeInstance, (BYTE *)returnString, (DWORD) len+1, 0, ddeItem, uFmt, 0); } else { ddeReturn = NULL; } } Tcl_DStringFree(&dString); } return ddeReturn; |
︙ | ︙ | |||
610 611 612 613 614 615 616 | ddeObjectPtr = Tcl_NewStringObj(utilString, -1); Tcl_IncrRefCount(ddeObjectPtr); DdeUnaccessData(hData); if (convPtr->returnPackagePtr != NULL) { Tcl_DecrRefCount(convPtr->returnPackagePtr); } convPtr->returnPackagePtr = NULL; | | | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | ddeObjectPtr = Tcl_NewStringObj(utilString, -1); Tcl_IncrRefCount(ddeObjectPtr); DdeUnaccessData(hData); if (convPtr->returnPackagePtr != NULL) { Tcl_DecrRefCount(convPtr->returnPackagePtr); } convPtr->returnPackagePtr = NULL; returnPackagePtr = ExecuteRemoteObject(convPtr->riPtr, ddeObjectPtr); Tcl_IncrRefCount(returnPackagePtr); for (convPtr = tsdPtr->currentConversations; (convPtr != NULL) && (convPtr->hConv != hConv); convPtr = convPtr->nextPtr) { /* * Empty loop body. */ |
︙ | ︙ | |||
632 633 634 635 636 637 638 | Tcl_DecrRefCount(ddeObjectPtr); if (returnPackagePtr == NULL) { return (HDDEDATA) DDE_FNOTPROCESSED; } else { return (HDDEDATA) DDE_FACK; } } | | | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | Tcl_DecrRefCount(ddeObjectPtr); if (returnPackagePtr == NULL) { return (HDDEDATA) DDE_FNOTPROCESSED; } else { return (HDDEDATA) DDE_FACK; } } case XTYP_WILDCONNECT: { /* * Dde wants a list of services and topics that we support. */ HSZPAIR *returnPtr; |
︙ | ︙ | |||
656 657 658 659 660 661 662 | } numItems = i; ddeReturn = DdeCreateDataHandle(ddeInstance, NULL, (numItems + 1) * sizeof(HSZPAIR), 0, 0, 0, 0); returnPtr = (HSZPAIR *) DdeAccessData(ddeReturn, &dlen); len = dlen; | | | | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | } numItems = i; ddeReturn = DdeCreateDataHandle(ddeInstance, NULL, (numItems + 1) * sizeof(HSZPAIR), 0, 0, 0, 0); returnPtr = (HSZPAIR *) DdeAccessData(ddeReturn, &dlen); len = dlen; for (i = 0, riPtr = tsdPtr->interpListPtr; i < numItems; i++, riPtr = riPtr->nextPtr) { returnPtr[i].hszSvc = DdeCreateStringHandle( ddeInstance, TCL_DDE_SERVICE_NAME, CP_WINANSI); returnPtr[i].hszTopic = DdeCreateStringHandle( ddeInstance, riPtr->name, CP_WINANSI); } returnPtr[i].hszSvc = NULL; returnPtr[i].hszTopic = NULL; DdeUnaccessData(ddeReturn); return ddeReturn; |
︙ | ︙ | |||
708 709 710 711 712 713 714 | * MakeDdeConnection -- * * This procedure is a utility used to connect to a DDE * server when given a server name and a topic name. * * Results: * A standard Tcl result. | | | | | | 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | * MakeDdeConnection -- * * This procedure is a utility used to connect to a DDE * server when given a server name and a topic name. * * Results: * A standard Tcl result. * * * Side effects: * Passes back a conversation through ddeConvPtr * *-------------------------------------------------------------- */ static int MakeDdeConnection( Tcl_Interp *interp, /* Used to report errors. */ const char *name, /* The connection to use. */ HCONV *ddeConvPtr) { HSZ ddeTopic, ddeService; HCONV ddeConv; ddeService = DdeCreateStringHandle(ddeInstance, TCL_DDE_SERVICE_NAME, 0); ddeTopic = DdeCreateStringHandle(ddeInstance, name, 0); ddeConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL); DdeFreeStringHandle(ddeInstance, ddeService); DdeFreeStringHandle(ddeInstance, ddeTopic); if (ddeConv == (HCONV) NULL) { |
︙ | ︙ | |||
771 772 773 774 775 776 777 | Tcl_Interp *interp; int result; ATOM service; ATOM topic; HWND hwnd; } ddeEnumServices; | | | 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | Tcl_Interp *interp; int result; ATOM service; ATOM topic; HWND hwnd; } ddeEnumServices; static LRESULT CALLBACK DdeClientWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT DdeServicesOnAck(HWND hwnd, WPARAM wParam, LPARAM lParam); static int DdeCreateClient(ddeEnumServices *es) { |
︙ | ︙ | |||
798 799 800 801 802 803 804 | es->hwnd = CreateWindowEx(0, szDdeClientClassName, szDdeClientWindowName, WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, (LPVOID)es); return TCL_OK; } | | | 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 | es->hwnd = CreateWindowEx(0, szDdeClientClassName, szDdeClientWindowName, WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, (LPVOID)es); return TCL_OK; } static LRESULT CALLBACK DdeClientWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lr = 0L; switch (uMsg) { case WM_CREATE: { LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; |
︙ | ︙ | |||
879 880 881 882 883 884 885 | (WPARAM)es->hwnd, MAKELONG(es->service, es->topic), SMTO_ABORTIFHUNG, 1000, &dwResult); return TRUE; } static int | | | | | | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 | (WPARAM)es->hwnd, MAKELONG(es->service, es->topic), SMTO_ABORTIFHUNG, 1000, &dwResult); return TRUE; } static int DdeGetServicesList(Tcl_Interp *interp, const char *serviceName, const char *topicName) { ddeEnumServices es; es.interp = interp; es.result = TCL_OK; es.service = (serviceName == NULL) ? (ATOM)0 : GlobalAddAtom(serviceName); es.topic = (topicName == NULL) ? (ATOM)0 : GlobalAddAtom(topicName); Tcl_ResetResult(interp); /* our list is to be appended to result. */ DdeCreateClient(&es); EnumWindows(DdeEnumWindowsCallback, (LPARAM)&es); if (IsWindow(es.hwnd)) DestroyWindow(es.hwnd); if (es.service != (ATOM)0) GlobalDeleteAtom(es.service); if (es.topic != (ATOM)0) GlobalDeleteAtom(es.topic); return es.result; } /* *-------------------------------------------------------------- * * SetDdeError -- * * Sets the interp result to a cogent error message * describing the last DDE error. * * Results: * None. * * * Side effects: * The interp's result object is changed. * *-------------------------------------------------------------- */ |
︙ | ︙ | |||
941 942 943 944 945 946 947 | break; case DMLERR_BUSY: Tcl_SetStringObj(resultPtr, "remote server is busy", -1); break; case DMLERR_NOTPROCESSED: | | | | | | | | | | | | | | | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | break; case DMLERR_BUSY: Tcl_SetStringObj(resultPtr, "remote server is busy", -1); break; case DMLERR_NOTPROCESSED: Tcl_SetStringObj(resultPtr, "remote server cannot handle this command", -1); break; default: Tcl_SetStringObj(resultPtr, "dde command failed", -1); } } /* *-------------------------------------------------------------- * * DdeObjCmd -- * * This procedure is invoked to process the "dde" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *-------------------------------------------------------------- */ static int DdeObjCmd( ClientData clientData, /* Used only for deletion */ Tcl_Interp *interp, /* The interp we are sending from */ int objc, /* Number of arguments */ Tcl_Obj *const *objv) /* The arguments */ { enum { DDE_SERVERNAME, DDE_EXECUTE, DDE_POKE, DDE_REQUEST, DDE_SERVICES, DDE_EVAL }; static const char *ddeCommands[] = {"servername", "execute", "poke", "request", "services", "eval", (char *) NULL}; static const char *ddeOptions[] = {"-async", (char *) NULL}; static const char *ddeReqOptions[] = {"-binary", (char *) NULL}; int index, argIndex; int async = 0, binary = 0; int result = TCL_OK; HSZ ddeService = NULL; HSZ ddeTopic = NULL; HSZ ddeItem = NULL; HDDEDATA ddeData = NULL; HDDEDATA ddeItemData = NULL; HCONV hConv = NULL; HSZ ddeCookie = 0; const char *serviceName, *topicName = NULL, *itemString; char *string; int firstArg = 0, length, dataLength; DWORD ddeResult; HDDEDATA ddeReturn; RegisteredInterp *riPtr; Tcl_Interp *sendInterp; Tcl_Obj *objPtr; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); /* * Initialize DDE server/client */ if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "?-async? serviceName topicName value"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], ddeCommands, "command", 0, &index) != TCL_OK) { return TCL_ERROR; } switch (index) { case DDE_SERVERNAME: if ((objc != 3) && (objc != 2)) { Tcl_WrongNumArgs(interp, 1, objv, "servername ?serverName?"); return TCL_ERROR; } firstArg = (objc - 1); break; case DDE_EXECUTE: if ((objc < 5) || (objc > 6)) { Tcl_WrongNumArgs(interp, 1, objv, "execute ?-async? serviceName topicName value"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(NULL, objv[2], ddeOptions, "option", 0, &argIndex) != TCL_OK) { if (objc != 5) { Tcl_WrongNumArgs(interp, 1, objv, |
︙ | ︙ | |||
1066 1067 1068 1069 1070 1071 1072 | "poke serviceName topicName item value"); return TCL_ERROR; } firstArg = 2; break; case DDE_REQUEST: if ((objc < 5) || (objc > 6)) { | | | 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 | "poke serviceName topicName item value"); return TCL_ERROR; } firstArg = 2; break; case DDE_REQUEST: if ((objc < 5) || (objc > 6)) { Tcl_WrongNumArgs(interp, 1, objv, "request ?-binary? serviceName topicName value"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(NULL, objv[2], ddeReqOptions, "option", 0, &argIndex) != TCL_OK) { if (objc != 5) { Tcl_WrongNumArgs(interp, 1, objv, |
︙ | ︙ | |||
1099 1100 1101 1102 1103 1104 1105 | "services serviceName topicName"); return TCL_ERROR; } firstArg = 2; break; case DDE_EVAL: if (objc < 4) { | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | "services serviceName topicName"); return TCL_ERROR; } firstArg = 2; break; case DDE_EVAL: if (objc < 4) { Tcl_WrongNumArgs(interp, 1, objv, "eval ?-async? serviceName args"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(NULL, objv[2], ddeOptions, "option", 0, &argIndex) != TCL_OK) { if (objc < 4) { Tcl_WrongNumArgs(interp, 1, objv, |
︙ | ︙ | |||
1144 1145 1146 1147 1148 1149 1150 | } if ((index != DDE_SERVERNAME) &&(index != DDE_EVAL)) { topicName = Tcl_GetStringFromObj(objv[firstArg + 1], &length); if (length == 0) { topicName = NULL; } else { | | | 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 | } if ((index != DDE_SERVERNAME) &&(index != DDE_EVAL)) { topicName = Tcl_GetStringFromObj(objv[firstArg + 1], &length); if (length == 0) { topicName = NULL; } else { ddeTopic = DdeCreateStringHandle(ddeInstance, topicName, CP_WINANSI); } } switch (index) { case DDE_SERVERNAME: { serviceName = DdeSetServerName(interp, serviceName); |
︙ | ︙ | |||
1183 1184 1185 1186 1187 1188 1189 | break; } ddeData = DdeCreateDataHandle(ddeInstance, dataString, (DWORD) dataLength+1, 0, 0, CF_TEXT, 0); if (ddeData != NULL) { if (async) { | | | | 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 | break; } ddeData = DdeCreateDataHandle(ddeInstance, dataString, (DWORD) dataLength+1, 0, 0, CF_TEXT, 0); if (ddeData != NULL) { if (async) { DdeClientTransaction((LPBYTE) ddeData, 0xFFFFFFFF, hConv, 0, CF_TEXT, XTYP_EXECUTE, TIMEOUT_ASYNC, &ddeResult); DdeAbandonTransaction(ddeInstance, hConv, ddeResult); } else { ddeReturn = DdeClientTransaction((LPBYTE) ddeData, 0xFFFFFFFF, hConv, 0, CF_TEXT, XTYP_EXECUTE, 30000, NULL); if (ddeReturn == 0) { SetDdeError(interp); result = TCL_ERROR; |
︙ | ︙ | |||
1212 1213 1214 1215 1216 1217 1218 | Tcl_SetStringObj(Tcl_GetObjResult(interp), "cannot request value of null data", -1); goto errorNoResult; } hConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL); DdeFreeStringHandle(ddeInstance, ddeService); DdeFreeStringHandle(ddeInstance, ddeTopic); | | | | 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | Tcl_SetStringObj(Tcl_GetObjResult(interp), "cannot request value of null data", -1); goto errorNoResult; } hConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL); DdeFreeStringHandle(ddeInstance, ddeService); DdeFreeStringHandle(ddeInstance, ddeTopic); if (hConv == NULL) { SetDdeError(interp); result = TCL_ERROR; } else { Tcl_Obj *returnObjPtr; ddeItem = DdeCreateStringHandle(ddeInstance, itemString, CP_WINANSI); if (ddeItem != NULL) { ddeData = DdeClientTransaction(NULL, 0, hConv, ddeItem, CF_TEXT, XTYP_REQUEST, 5000, NULL); if (ddeData == NULL) { SetDdeError(interp); result = TCL_ERROR; |
︙ | ︙ | |||
1257 1258 1259 1260 1261 1262 1263 | itemString = Tcl_GetStringFromObj(objv[firstArg + 2], &length); if (length == 0) { Tcl_SetStringObj(Tcl_GetObjResult(interp), "cannot have a null item", -1); goto errorNoResult; } dataString = (BYTE *) Tcl_GetStringFromObj(objv[firstArg + 3], &length); | | | 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 | itemString = Tcl_GetStringFromObj(objv[firstArg + 2], &length); if (length == 0) { Tcl_SetStringObj(Tcl_GetObjResult(interp), "cannot have a null item", -1); goto errorNoResult; } dataString = (BYTE *) Tcl_GetStringFromObj(objv[firstArg + 3], &length); hConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL); DdeFreeStringHandle(ddeInstance, ddeService); DdeFreeStringHandle(ddeInstance, ddeTopic); if (hConv == NULL) { SetDdeError(interp); result = TCL_ERROR; |
︙ | ︙ | |||
1301 1302 1303 1304 1305 1306 1307 | objc -= (async + 3); objv += (async + 3); /* * See if the target interpreter is local. If so, execute * the command directly without going through the DDE server. * Don't exchange objects between interps. The target interp could | | | | | | | | 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 | objc -= (async + 3); objv += (async + 3); /* * See if the target interpreter is local. If so, execute * the command directly without going through the DDE server. * Don't exchange objects between interps. The target interp could * compile an object, producing a bytecode structure that refers to * other objects owned by the target interp. If the target interp * is then deleted, the bytecode structure would be referring to * deallocated objects. */ for (riPtr = tsdPtr->interpListPtr; riPtr != NULL; riPtr = riPtr->nextPtr) { if (stricmp(serviceName, riPtr->name) == 0) { break; } } if (riPtr != NULL) { /* * This command is to a local interp. No need to go through * the server. */ Tcl_Preserve((ClientData) riPtr); sendInterp = riPtr->interp; Tcl_Preserve((ClientData) sendInterp); /* * Don't exchange objects between interps. The target interp * would compile an object, producing a bytecode structure that * refers to other objects owned by the target interp. If the * target interp is then deleted, the bytecode structure would * be referring to deallocated objects. */ |
︙ | ︙ | |||
1349 1350 1351 1352 1353 1354 1355 | if (interp != sendInterp) { if (result == TCL_ERROR) { /* * An error occurred, so transfer error information * from the destination interpreter back to our * interpreter. */ | | | | | | | | | | | | | | | | | 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 | if (interp != sendInterp) { if (result == TCL_ERROR) { /* * An error occurred, so transfer error information * from the destination interpreter back to our * interpreter. */ Tcl_ResetResult(interp); objPtr = Tcl_GetVar2Ex(sendInterp, "errorInfo", NULL, TCL_GLOBAL_ONLY); string = Tcl_GetStringFromObj(objPtr, &length); Tcl_AddObjErrorInfo(interp, string, length); objPtr = Tcl_GetVar2Ex(sendInterp, "errorCode", NULL, TCL_GLOBAL_ONLY); Tcl_SetObjErrorCode(interp, objPtr); } Tcl_SetObjResult(interp, Tcl_GetObjResult(sendInterp)); } Tcl_Release((ClientData) riPtr); Tcl_Release((ClientData) sendInterp); } else { /* * This is a non-local request. Send the script to the server * and poll it for a result. */ if (MakeDdeConnection(interp, serviceName, &hConv) != TCL_OK) { goto error; } objPtr = Tcl_ConcatObj(objc, objv); string = Tcl_GetStringFromObj(objPtr, &length); ddeItemData = DdeCreateDataHandle(ddeInstance, (BYTE *) string, (DWORD) length+1, 0, 0, CF_TEXT, 0); if (async) { ddeData = DdeClientTransaction((LPBYTE) ddeItemData, 0xFFFFFFFF, hConv, 0, CF_TEXT, XTYP_EXECUTE, TIMEOUT_ASYNC, &ddeResult); DdeAbandonTransaction(ddeInstance, hConv, ddeResult); } else { ddeData = DdeClientTransaction((LPBYTE) ddeItemData, 0xFFFFFFFF, hConv, 0, CF_TEXT, XTYP_EXECUTE, 30000, NULL); if (ddeData != 0) { ddeCookie = DdeCreateStringHandle(ddeInstance, TCL_DDE_EXECUTE_RESULT, CP_WINANSI); ddeData = DdeClientTransaction(NULL, 0, hConv, ddeCookie, CF_TEXT, XTYP_REQUEST, 30000, NULL); } } Tcl_DecrRefCount(objPtr); if (ddeData == 0) { SetDdeError(interp); goto errorNoResult; } if (async == 0) { Tcl_Obj *resultPtr; /* * The return handle has a two or four element list in * it. The first element is the return code (TCL_OK, * TCL_ERROR, etc.). The second is the result of the * script. If the return code is TCL_ERROR, then the third * element is the value of the variable "errorCode", and * the fourth is the value of the variable "errorInfo". */ resultPtr = Tcl_NewObj(); length = DdeGetData(ddeData, NULL, 0, 0); Tcl_SetObjLength(resultPtr, length); string = Tcl_GetString(resultPtr); DdeGetData(ddeData, (BYTE *) string, (DWORD) length, 0); Tcl_SetObjLength(resultPtr, (int) strlen(string)); if (Tcl_ListObjIndex(NULL, resultPtr, 0, &objPtr) != TCL_OK) { Tcl_DecrRefCount(resultPtr); goto error; } if (Tcl_GetIntFromObj(NULL, objPtr, &result) != TCL_OK) { Tcl_DecrRefCount(resultPtr); goto error; } if (result == TCL_ERROR) { Tcl_ResetResult(interp); if (Tcl_ListObjIndex(NULL, resultPtr, 3, &objPtr) != TCL_OK) { Tcl_DecrRefCount(resultPtr); goto error; } length = -1; string = Tcl_GetStringFromObj(objPtr, &length); Tcl_AddObjErrorInfo(interp, string, length); Tcl_ListObjIndex(NULL, resultPtr, 2, &objPtr); Tcl_SetObjErrorCode(interp, objPtr); } if (Tcl_ListObjIndex(NULL, resultPtr, 1, &objPtr) != TCL_OK) { Tcl_DecrRefCount(resultPtr); goto error; |
︙ | ︙ |