Corrected small bug in GetCommState16. Parity check can be disabled
[wine.git] / misc / ddeml.c
blob8432b4b3edfbc5493416d56845d385482bf85ff8
1 /*
2 * DDEML library
4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Len White
6 * Copyright 1999 Keith Matthews
7 */
9 /* Only empty stubs for now */
11 #include <stdlib.h>
12 #include <strings.h>
13 #include "winbase.h"
14 #include "winuser.h"
15 #include "ddeml.h"
16 #include "winerror.h"
17 #include "heap.h"
18 #include "shm_semaph.h"
19 #include "debug.h"
20 #include "winnt.h"
22 /* Has defined in atom.c file.
24 #define MAX_ATOM_LEN 255
26 /* Maximum buffer size ( including the '\0' ).
28 #define MAX_BUFFER_LEN (MAX_ATOM_LEN + 1)
31 static DDE_HANDLE_ENTRY *DDE_Handle_Table_Base = NULL;
32 static DWORD DDE_Max_Assigned_Instance = 0; // OK for present, may have to worry about wrap-around later
33 static const char inst_string[]= "DDEMaxInstance";
34 static LPCWSTR DDEInstanceAccess = (LPCWSTR)&inst_string;
35 static const char handle_string[] = "DDEHandleAccess";
36 static LPCWSTR DDEHandleAccess = (LPCWSTR)&handle_string;
37 static HANDLE inst_count_mutex = 0;
38 static HANDLE handle_mutex = 0;
39 DDE_HANDLE_ENTRY *this_instance;
40 SECURITY_ATTRIBUTES *s_att= NULL;
41 DWORD err_no = 0;
43 /* typedef struct {
44 DWORD nLength;
45 LPVOID lpSecurityDescriptor;
46 BOOL bInheritHandle;
47 } SECURITY_ATTRIBUTES; */
49 #define TRUE 1
50 #define FALSE 0
54 /* This is a simple list to keep track of the strings created
55 * by DdeCreateStringHandle. The list is used to free
56 * the strings whenever DdeUninitialize is called.
57 * This mechanism is not complete and does not handle multiple instances.
58 * Most of the DDE API use a DWORD parameter indicating which instance
59 * of a given program is calling them. The API are supposed to
60 * associate the data to the instance that created it.
62 typedef struct tagHSZNode HSZNode;
63 struct tagHSZNode
65 HSZNode* next;
66 HSZ hsz;
69 /* Start off the list pointer with a NULL.
71 static HSZNode* pHSZNodes = NULL;
74 /******************************************************************************
75 * RemoveHSZNodes (INTERNAL)
77 * Remove a node from the list of HSZ nodes.
79 ******************************************************************************
81 * Change History
83 * Vn Date Author Comment
85 * 1.0 Dec 1998 Corel/Macadamian Initial version
88 static void RemoveHSZNode( DWORD idInst, HSZ hsz )
90 HSZNode* pPrev = NULL;
91 HSZNode* pCurrent = NULL;
93 /* Set the current node at the start of the list.
95 pCurrent = pHSZNodes;
96 /* While we have more nodes.
98 while( pCurrent != NULL )
100 /* If we found the node we were looking for.
102 if( pCurrent->hsz == hsz )
104 /* Remove the node.
106 /* If the first node in the list is to to be removed.
107 * Set the global list pointer to the next node.
109 if( pCurrent == pHSZNodes )
111 pHSZNodes = pCurrent->next;
113 /* Just fix the pointers has to skip the current
114 * node so we can delete it.
116 else
118 pPrev->next = pCurrent->next;
120 /* Destroy this node.
122 free( pCurrent );
123 break;
125 /* Save the previous node pointer.
127 pPrev = pCurrent;
128 /* Move on to the next node.
130 pCurrent = pCurrent->next;
134 /******************************************************************************
135 * FreeAndRemoveHSZNodes (INTERNAL)
137 * Frees up all the strings still allocated in the list and
138 * remove all the nodes from the list of HSZ nodes.
140 ******************************************************************************
142 * Change History
144 * Vn Date Author Comment
146 * 1.0 Dec 1998 Corel/Macadamian Initial version
149 static void FreeAndRemoveHSZNodes( DWORD idInst )
151 /* Free any strings created in this instance.
153 while( pHSZNodes != NULL )
155 DdeFreeStringHandle( idInst, pHSZNodes->hsz );
159 /******************************************************************************
160 * InsertHSZNode (INTERNAL)
162 * Insert a node to the head of the list.
164 ******************************************************************************
166 * Change History
168 * Vn Date Author Comment
170 * 1.0 Dec 1998 Corel/Macadamian Initial version
173 static void InsertHSZNode( DWORD idInst, HSZ hsz )
175 if( hsz != 0 )
177 HSZNode* pNew = NULL;
178 /* Create a new node for this HSZ.
180 pNew = (HSZNode*) malloc( sizeof( HSZNode ) );
181 if( pNew != NULL )
183 /* Set the handle value.
185 pNew->hsz = hsz;
186 /* Attach the node to the head of the list.
188 pNew->next = pHSZNodes;
189 /* The new node is now at the head of the list
190 * so set the global list pointer to it.
192 pHSZNodes = pNew;
197 /******************************************************************************
198 * Release_reserved_mutex
200 * generic routine to release a reserved mutex
203 ******************************************************************************
205 * Change History
207 * Vn Date Author Comment
209 * 1.0 Jan 1999 Keith Matthews Initial version
210 * 1.1 Mar 1999 Keith Matthews Corrected Heap handling.
213 DWORD Release_reserved_mutex (HANDLE mutex, LPTSTR mutex_name, BOOL release_handle_m, BOOL release_this_i )
215 ReleaseMutex(mutex);
216 if ( (err_no=GetLastError()) != 0 )
218 ERR(ddeml,"ReleaseMutex failed - %s mutex %li\n",mutex_name,err_no);
219 HeapFree(SystemHeap, 0, this_instance);
220 if ( release_handle_m )
222 ReleaseMutex(handle_mutex);
224 return DMLERR_SYS_ERROR;
226 if ( release_this_i )
228 HeapFree(SystemHeap, 0, this_instance);
230 return DMLERR_NO_ERROR;
233 /******************************************************************************
234 * IncrementInstanceId
236 * generic routine to increment the max instance Id and allocate a new application instance
238 ******************************************************************************
240 * Change History
242 * Vn Date Author Comment
244 * 1.0 Jan 1999 Keith Matthews Initial version
247 DWORD IncrementInstanceId()
249 SECURITY_ATTRIBUTES s_attrib;
250 /* Need to set up Mutex in case it is not already present */
251 // increment handle count & get value
252 if ( !inst_count_mutex )
254 s_attrib.bInheritHandle = TRUE;
255 s_attrib.lpSecurityDescriptor = NULL;
256 s_attrib.nLength = sizeof(s_attrib);
257 inst_count_mutex = CreateMutexW(&s_attrib,1,DDEInstanceAccess); // 1st time through
258 } else {
259 WaitForSingleObject(inst_count_mutex,1000); // subsequent calls
260 /* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
262 if ( (err_no=GetLastError()) != 0 )
264 ERR(ddeml,"CreateMutex failed - inst_count %li\n",err_no);
265 err_no=Release_reserved_mutex (handle_mutex,"handle_mutex",0,1);
266 return DMLERR_SYS_ERROR;
268 DDE_Max_Assigned_Instance++;
269 this_instance->Instance_id = DDE_Max_Assigned_Instance;
270 if (Release_reserved_mutex(inst_count_mutex,"instance_count",1,0)) return DMLERR_SYS_ERROR;
271 return DMLERR_NO_ERROR;
274 /******************************************************************************
275 * DdeInitialize16 (DDEML.2)
277 UINT16 WINAPI DdeInitialize16( LPDWORD pidInst, PFNCALLBACK16 pfnCallback,
278 DWORD afCmd, DWORD ulRes)
280 TRACE(ddeml,"DdeInitialize16 called - calling DdeInitializeA\n");
281 return (UINT16)DdeInitializeA(pidInst,(PFNCALLBACK)pfnCallback,
282 afCmd, ulRes);
286 /******************************************************************************
287 * DdeInitializeA (USER32.106)
289 UINT WINAPI DdeInitializeA( LPDWORD pidInst, PFNCALLBACK pfnCallback,
290 DWORD afCmd, DWORD ulRes )
292 TRACE(ddeml,"DdeInitializeA called - calling DdeInitializeW\n");
293 return DdeInitializeW(pidInst,pfnCallback,afCmd,ulRes);
297 /******************************************************************************
298 * DdeInitializeW [USER32.107]
299 * Registers an application with the DDEML
301 * PARAMS
302 * pidInst [I] Pointer to instance identifier
303 * pfnCallback [I] Pointer to callback function
304 * afCmd [I] Set of command and filter flags
305 * ulRes [I] Reserved
307 * RETURNS
308 * Success: DMLERR_NO_ERROR
309 * Failure: DMLERR_DLL_USAGE, DMLERR_INVALIDPARAMETER, DMLERR_SYS_ERROR
311 ******************************************************************************
313 * Change History
315 * Vn Date Author Comment
317 * 1.0 Pre 1998 Alexandre/Len Initial Stub
318 * 1.1 Jan 1999 Keith Matthews Initial (near-)complete version
319 * 1.2 Mar 1999 Keith Matthews Corrected Heap handling, CreateMutex failure handling
322 UINT WINAPI DdeInitializeW( LPDWORD pidInst, PFNCALLBACK pfnCallback,
323 DWORD afCmd, DWORD ulRes )
325 DDE_HANDLE_ENTRY *reference_inst;
326 SECURITY_ATTRIBUTES s_attrib;
327 s_att = &s_attrib;
329 // probably not really capable of handling mutliple processes, but should handle
330 // multiple instances within one process
332 if( ulRes )
334 ERR(dde, "Reserved value not zero? What does this mean?\n");
335 FIXME(ddeml, "(%p,%p,0x%lx,%ld): stub\n",pidInst,pfnCallback,afCmd,ulRes);
336 /* trap this and no more until we know more */
337 return DMLERR_NO_ERROR;
339 if (!pfnCallback )
341 /* this one may be wrong - MS dll seems to accept the condition, leave this until we find out more !! */
344 /* can't set up the instance with nothing to act as a callback */
345 TRACE(ddeml,"No callback provided\n");
346 return DMLERR_INVALIDPARAMETER; /* might be DMLERR_DLL_USAGE */
349 /* grab enough heap for one control struct - not really necessary for re-initialise
350 but allows us to use same validation routines */
351 this_instance= (DDE_HANDLE_ENTRY*)HeapAlloc( SystemHeap, 0, sizeof(DDE_HANDLE_ENTRY) );
352 if ( this_instance == NULL )
354 // catastrophe !! warn user & abort
355 ERR (ddeml,"Instance create failed - out of memory\n");
356 return DMLERR_SYS_ERROR;
358 this_instance->Next_Entry = NULL;
359 this_instance->Monitor=(afCmd|APPCLASS_MONITOR);
361 // messy bit, spec implies that 'Client Only' can be set in 2 different ways, catch 1 here
363 this_instance->Client_only=afCmd&APPCMD_CLIENTONLY;
364 this_instance->Instance_id = *pidInst; // May need to add calling proc Id
365 this_instance->CallBack=*pfnCallback;
366 this_instance->Txn_count=0;
367 this_instance->Unicode = TRUE;
368 this_instance->Win16 = FALSE;
369 this_instance->Monitor_flags = afCmd & MF_MASK;
371 // isolate CBF flags in one go, expect this will go the way of all attempts to be clever !!
373 this_instance->CBF_Flags=afCmd^((afCmd&MF_MASK)|((afCmd&APPCMD_MASK)|(afCmd&APPCLASS_MASK)));
375 if ( ! this_instance->Client_only )
378 // Check for other way of setting Client-only !!
380 this_instance->Client_only=(this_instance->CBF_Flags&CBF_FAIL_ALLSVRXACTIONS)
381 ==CBF_FAIL_ALLSVRXACTIONS;
384 TRACE(ddeml,"instance created - checking validity \n");
386 if( *pidInst == 0 ) {
387 /* Initialisation of new Instance Identifier */
388 TRACE(ddeml,"new instance, callback %p flags %lX\n",pfnCallback,afCmd);
389 /* Need to set up Mutex in case it is not already present */
390 s_att->bInheritHandle = TRUE;
391 s_att->lpSecurityDescriptor = NULL;
392 s_att->nLength = sizeof(s_att);
393 handle_mutex = CreateMutexW(s_att,1,DDEHandleAccess);
394 if ( (err_no=GetLastError()) != 0 )
396 ERR(ddeml,"CreateMutex failed - handle list %li\n",err_no);
397 HeapFree(SystemHeap, 0, this_instance);
398 return DMLERR_SYS_ERROR;
400 TRACE(ddeml,"Handle Mutex created/reserved\n");
401 if (DDE_Handle_Table_Base == NULL )
403 /* can't be another instance in this case, assign to the base pointer */
404 DDE_Handle_Table_Base= this_instance;
406 // since first must force filter of XTYP_CONNECT and XTYP_WILDCONNECT for
407 // present
408 // ------------------------------- NOTE NOTE NOTE --------------------------
410 // the manual is not clear if this condition
411 // applies to the first call to DdeInitialize from an application, or the
412 // first call for a given callback !!!
415 this_instance->CBF_Flags=this_instance->CBF_Flags|APPCMD_FILTERINITS;
416 TRACE(ddeml,"First application instance detected OK\n");
417 // allocate new instance ID
418 if ((err_no = IncrementInstanceId()) ) return err_no;
419 } else {
420 /* really need to chain the new one in to the latest here, but after checking conditions
421 such as trying to start a conversation from an application trying to monitor */
422 reference_inst = DDE_Handle_Table_Base;
423 TRACE(ddeml,"Subsequent application instance - starting checks\n");
424 while ( reference_inst->Next_Entry != NULL )
427 // This set of tests will work if application uses same instance Id
428 // at application level once allocated - which is what manual implies
429 // should happen. If someone tries to be
430 // clever (lazy ?) it will fail to pick up that later calls are for
431 // the same application - should we trust them ?
433 if ( this_instance->Instance_id == reference_inst->Instance_id)
435 // Check 1 - must be same Client-only state
437 if ( this_instance->Client_only != reference_inst->Client_only)
439 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,1))
440 return DMLERR_SYS_ERROR;
441 return DMLERR_DLL_USAGE;
444 // Check 2 - cannot use 'Monitor' with any non-monitor modes
446 if ( this_instance->Monitor != reference_inst->Monitor)
448 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,1))
449 return DMLERR_SYS_ERROR;
450 return DMLERR_INVALIDPARAMETER;
453 // Check 3 - must supply different callback address
455 if ( this_instance->CallBack == reference_inst->CallBack)
457 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,1))
458 return DMLERR_SYS_ERROR;
459 return DMLERR_DLL_USAGE;
462 reference_inst = reference_inst->Next_Entry;
464 // All cleared, add to chain
466 TRACE(ddeml,"Application Instance checks finished\n");
467 if ((err_no = IncrementInstanceId())) return err_no;
468 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,0)) return DMLERR_SYS_ERROR;
469 reference_inst->Next_Entry = this_instance;
471 pidInst = (LPDWORD)this_instance->Instance_id;
472 TRACE(ddeml,"New application instance processing finished OK\n");
473 } else {
474 /* Reinitialisation situation --- FIX */
475 TRACE(ddeml,"reinitialisation of (%p,%p,0x%lx,%ld): stub\n",pidInst,pfnCallback,afCmd,ulRes);
476 WaitForSingleObject(handle_mutex,1000);
477 if ( (err_no=GetLastError()) != 0 )
480 /* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
482 ERR(ddeml,"WaitForSingleObject failed - handle list %li\n",err_no);
483 HeapFree(SystemHeap, 0, this_instance);
484 return DMLERR_SYS_ERROR;
486 if (DDE_Handle_Table_Base == NULL )
488 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,1)) return DMLERR_SYS_ERROR;
489 return DMLERR_DLL_USAGE;
491 HeapFree(SystemHeap, 0, this_instance); // finished - release heap space used as work store
492 // can't reinitialise if we have initialised nothing !!
493 reference_inst = DDE_Handle_Table_Base;
494 /* must first check if we have been given a valid instance to re-initialise !! how do we do that ? */
495 while ( reference_inst->Next_Entry != NULL )
497 if ( *pidInst == reference_inst->Instance_id && pfnCallback == reference_inst->CallBack )
499 // Check 1 - cannot change client-only mode if set via APPCMD_CLIENTONLY
501 if ( reference_inst->Client_only )
503 if ((reference_inst->CBF_Flags & CBF_FAIL_ALLSVRXACTIONS) != CBF_FAIL_ALLSVRXACTIONS)
505 // i.e. Was set to Client-only and through APPCMD_CLIENTONLY
507 if ( ! ( afCmd & APPCMD_CLIENTONLY))
509 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,1))
510 return DMLERR_SYS_ERROR;
511 return DMLERR_DLL_USAGE;
515 // Check 2 - cannot change monitor modes
517 if ( this_instance->Monitor != reference_inst->Monitor)
519 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,1))
520 return DMLERR_SYS_ERROR;
521 return DMLERR_DLL_USAGE;
524 // Check 3 - trying to set Client-only via APPCMD when not set so previously
526 if (( afCmd&APPCMD_CLIENTONLY) && ! reference_inst->Client_only )
528 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,1))
529 return DMLERR_SYS_ERROR;
530 return DMLERR_DLL_USAGE;
534 // All checked - change relevant flags
536 reference_inst->CBF_Flags = this_instance->CBF_Flags;
537 reference_inst->Client_only = this_instance->Client_only;
538 reference_inst->Monitor_flags = this_instance->Monitor_flags;
539 if ( Release_reserved_mutex(handle_mutex,"handle_mutex",0,1))
540 return DMLERR_SYS_ERROR;
543 return DMLERR_NO_ERROR;
547 /*****************************************************************
548 * DdeUninitialize16 (DDEML.3)
550 BOOL16 WINAPI DdeUninitialize16( DWORD idInst )
552 return (BOOL16)DdeUninitialize( idInst );
556 /*****************************************************************
557 * DdeUninitialize [USER32.119] Frees DDEML resources
559 * PARAMS
560 * idInst [I] Instance identifier
562 * RETURNS
563 * Success: TRUE
564 * Failure: FALSE
566 BOOL WINAPI DdeUninitialize( DWORD idInst )
569 FIXME(ddeml, "(%ld): stub\n", idInst);
571 /* Free the nodes that were not freed by this instance
572 * and remove the nodes from the list of HSZ nodes.
574 FreeAndRemoveHSZNodes( idInst );
576 return TRUE;
580 /*****************************************************************
581 * DdeConnectList16 [DDEML.4]
583 HCONVLIST WINAPI DdeConnectList16( DWORD idInst, HSZ hszService, HSZ hszTopic,
584 HCONVLIST hConvList, LPCONVCONTEXT16 pCC )
586 return DdeConnectList(idInst, hszService, hszTopic, hConvList,
587 (LPCONVCONTEXT)pCC);
591 /******************************************************************************
592 * DdeConnectList [USER32.93] Establishes conversation with DDE servers
594 * PARAMS
595 * idInst [I] Instance identifier
596 * hszService [I] Handle to service name string
597 * hszTopic [I] Handle to topic name string
598 * hConvList [I] Handle to conversation list
599 * pCC [I] Pointer to structure with context data
601 * RETURNS
602 * Success: Handle to new conversation list
603 * Failure: 0
605 HCONVLIST WINAPI DdeConnectList( DWORD idInst, HSZ hszService, HSZ hszTopic,
606 HCONVLIST hConvList, LPCONVCONTEXT pCC )
608 FIXME(ddeml, "(%ld,%ld,%ld,%ld,%p): stub\n", idInst, hszService, hszTopic,
609 hConvList,pCC);
610 return 1;
614 /*****************************************************************
615 * DdeQueryNextServer16 [DDEML.5]
617 HCONV WINAPI DdeQueryNextServer16( HCONVLIST hConvList, HCONV hConvPrev )
619 return DdeQueryNextServer(hConvList, hConvPrev);
623 /*****************************************************************
624 * DdeQueryNextServer [USER32.112]
626 HCONV WINAPI DdeQueryNextServer( HCONVLIST hConvList, HCONV hConvPrev )
628 FIXME(ddeml, "(%ld,%ld): stub\n",hConvList,hConvPrev);
629 return 0;
632 /*****************************************************************
633 * DdeQueryStringA [USER32.113]
635 *****************************************************************
637 * Change History
639 * Vn Date Author Comment
641 * 1.0 Dec 1998 Corel/Macadamian Initial version
644 DWORD WINAPI DdeQueryStringA(DWORD idInst, HSZ hsz, LPSTR psz, DWORD cchMax, INT iCodePage)
646 DWORD ret = 0;
647 CHAR pString[MAX_BUFFER_LEN];
649 FIXME(ddeml,
650 "(%ld, 0x%lx, %p, %ld, %d): stub\n",
651 idInst,
652 hsz,
653 psz,
654 cchMax,
655 iCodePage);
657 if( iCodePage == CP_WINANSI )
659 /* If psz is null, we have to return only the length
660 * of the string.
662 if( psz == NULL )
664 psz = pString;
665 cchMax = MAX_BUFFER_LEN;
668 ret = GlobalGetAtomNameA( hsz, (LPSTR)psz, cchMax );
671 return ret;
674 /*****************************************************************
675 * DdeQueryStringW [USER32.114]
677 *****************************************************************
679 * Change History
681 * Vn Date Author Comment
683 * 1.0 Dec 1998 Corel/Macadamian Initial version
686 DWORD WINAPI DdeQueryStringW(DWORD idInst, HSZ hsz, LPWSTR psz, DWORD cchMax, INT iCodePage)
688 DWORD ret = 0;
689 WCHAR pString[MAX_BUFFER_LEN];
690 int factor = 1;
692 FIXME(ddeml,
693 "(%ld, 0x%lx, %p, %ld, %d): stub\n",
694 idInst,
695 hsz,
696 psz,
697 cchMax,
698 iCodePage);
700 if( iCodePage == CP_WINUNICODE )
702 /* If psz is null, we have to return only the length
703 * of the string.
705 if( psz == NULL )
707 psz = pString;
708 cchMax = MAX_BUFFER_LEN;
709 /* Note: According to documentation if the psz parameter
710 * was NULL this API must return the length of the string in bytes.
712 factor = (int) sizeof(WCHAR)/sizeof(BYTE);
714 ret = GlobalGetAtomNameW( hsz, (LPWSTR)psz, cchMax ) * factor;
716 return ret;
719 /*****************************************************************
721 * DdeQueryString16 (DDEML.23)
723 ******************************************************************
725 * Change History
727 * Vn Date Author Comment
729 * 1.0 March 1999 K Matthews stub only
732 DWORD DdeQueryString16(DWORD idInst, HSZ hsz, LPSTR lpsz, DWORD cchMax, int codepage)
734 FIXME(ddeml,"(%ld, 0x%lx, %p, %ld, %d): stub \n",
735 idInst,
736 hsz,
737 lpsz,
738 cchMax,
739 codepage);
740 return 0;
744 /*****************************************************************
745 * DdeDisconnectList (DDEML.6)
747 BOOL16 WINAPI DdeDisconnectList16( HCONVLIST hConvList )
749 return (BOOL16)DdeDisconnectList(hConvList);
753 /******************************************************************************
754 * DdeDisconnectList [USER32.98] Destroys list and terminates conversations
756 * RETURNS
757 * Success: TRUE
758 * Failure: FALSE
760 BOOL WINAPI DdeDisconnectList(
761 HCONVLIST hConvList) /* [in] Handle to conversation list */
763 FIXME(ddeml, "(%ld): stub\n", hConvList);
764 return TRUE;
768 /*****************************************************************
769 * DdeConnect16 (DDEML.7)
771 HCONV WINAPI DdeConnect16( DWORD idInst, HSZ hszService, HSZ hszTopic,
772 LPCONVCONTEXT16 pCC )
774 FIXME( ddeml, "empty stub\n" );
775 return 0;
779 /*****************************************************************
780 * DdeConnect (USER32.92)
782 HCONV WINAPI DdeConnect( DWORD idInst, HSZ hszService, HSZ hszTopic,
783 LPCONVCONTEXT pCC )
785 FIXME(ddeml, "(0x%lx,%ld,%ld,%p): stub\n",idInst,hszService,hszTopic,
786 pCC);
787 return 0;
791 /*****************************************************************
792 * DdeDisconnect16 (DDEML.8)
794 BOOL16 WINAPI DdeDisconnect16( HCONV hConv )
796 return (BOOL16)DdeDisconnect( hConv );
799 /*****************************************************************
800 * DdeSetUserHandle16 (DDEML.10)
802 BOOL16 WINAPI DdeSetUserHandle16( HCONV hConv, DWORD id, DWORD hUser )
804 FIXME( ddeml, "(%ld,%ld,%ld): stub\n",hConv,id, hUser );
805 return 0;
808 /*****************************************************************
809 * DdeCreateDataHandle16 (DDEML.14)
811 HDDEDATA WINAPI DdeCreateDataHandle16( DWORD idInst, LPBYTE pSrc, DWORD cb,
812 DWORD cbOff, HSZ hszItem, UINT16 wFmt,
813 UINT16 afCmd )
815 return DdeCreateDataHandle(idInst,
816 pSrc,
818 cbOff,
819 hszItem,
820 wFmt,
821 afCmd);
824 /*****************************************************************
825 * DdeCreateDataHandle (USER32.94)
827 HDDEDATA WINAPI DdeCreateDataHandle( DWORD idInst, LPBYTE pSrc, DWORD cb,
828 DWORD cbOff, HSZ hszItem, UINT wFmt,
829 UINT afCmd )
831 FIXME( ddeml,
832 "(%ld,%p,%ld,%ld,0x%lx,%d,%d): stub\n",
833 idInst,
834 pSrc,
836 cbOff,
837 hszItem,
838 wFmt,
839 afCmd );
841 return 0;
844 /*****************************************************************
845 * DdeDisconnect (USER32.97)
847 BOOL WINAPI DdeDisconnect( HCONV hConv )
849 FIXME( ddeml, "empty stub\n" );
850 return 0;
854 /*****************************************************************
855 * DdeReconnect (DDEML.37) (USER32.115)
857 HCONV WINAPI DdeReconnect( HCONV hConv )
859 FIXME( ddeml, "empty stub\n" );
860 return 0;
864 /*****************************************************************
865 * DdeCreateStringHandle16 (DDEML.21)
867 HSZ WINAPI DdeCreateStringHandle16( DWORD idInst, LPCSTR str, INT16 codepage )
869 return DdeCreateStringHandleA( idInst, str, codepage );
873 /*****************************************************************
874 * DdeCreateStringHandleA [USER32.95]
876 * RETURNS
877 * Success: String handle
878 * Failure: 0
880 HSZ WINAPI DdeCreateStringHandleA( DWORD idInst, LPCSTR psz, INT codepage )
882 HSZ hsz = 0;
883 TRACE(ddeml, "(%ld,%s,%d): stub\n",idInst,debugstr_a(psz),codepage);
885 if (codepage==CP_WINANSI)
887 hsz = GlobalAddAtomA (psz);
888 /* Save the handle so we know to clean it when
889 * uninitialize is called.
891 InsertHSZNode( idInst, hsz );
892 return hsz;
894 return 0;
898 /******************************************************************************
899 * DdeCreateStringHandleW [USER32.96] Creates handle to identify string
901 * RETURNS
902 * Success: String handle
903 * Failure: 0
905 HSZ WINAPI DdeCreateStringHandleW(
906 DWORD idInst, /* [in] Instance identifier */
907 LPCWSTR psz, /* [in] Pointer to string */
908 INT codepage) /* [in] Code page identifier */
910 HSZ hsz = 0;
912 FIXME(ddeml, "(%ld,%s,%d): stub\n",idInst,debugstr_w(psz),codepage);
914 if (codepage==CP_WINUNICODE)
916 hsz = GlobalAddAtomW (psz);
917 /* Save the handle so we know to clean it when
918 * uninitialize is called.
920 InsertHSZNode( idInst, hsz );
921 return hsz;
923 return 0;
927 /*****************************************************************
928 * DdeFreeStringHandle16 (DDEML.22)
930 BOOL16 WINAPI DdeFreeStringHandle16( DWORD idInst, HSZ hsz )
932 return (BOOL)DdeFreeStringHandle( idInst, hsz );
936 /*****************************************************************
937 * DdeFreeStringHandle (USER32.101)
938 * RETURNS: success: nonzero
939 * fail: zero
941 BOOL WINAPI DdeFreeStringHandle( DWORD idInst, HSZ hsz )
943 TRACE( ddeml, "(%ld,%ld): stub\n",idInst, hsz );
944 /* Remove the node associated with this HSZ.
946 RemoveHSZNode( idInst, hsz );
947 /* Free the string associated with this HSZ.
949 return GlobalDeleteAtom (hsz) ? 0 : hsz;
953 /*****************************************************************
954 * DdeFreeDataHandle16 (DDEML.19)
956 BOOL16 WINAPI DdeFreeDataHandle16( HDDEDATA hData )
958 return (BOOL)DdeFreeDataHandle( hData );
962 /*****************************************************************
963 * DdeFreeDataHandle (USER32.100)
965 BOOL WINAPI DdeFreeDataHandle( HDDEDATA hData )
967 FIXME( ddeml, "empty stub\n" );
968 return TRUE;
974 /*****************************************************************
975 * DdeKeepStringHandle16 (DDEML.24)
977 BOOL16 WINAPI DdeKeepStringHandle16( DWORD idInst, HSZ hsz )
979 return (BOOL)DdeKeepStringHandle( idInst, hsz );
983 /*****************************************************************
984 * DdeKeepStringHandle (USER32.108)
986 BOOL WINAPI DdeKeepStringHandle( DWORD idInst, HSZ hsz )
988 FIXME( ddeml, "empty stub\n" );
989 return TRUE;
993 /*****************************************************************
994 * DdeClientTransaction16 (DDEML.11)
996 HDDEDATA WINAPI DdeClientTransaction16( LPVOID pData, DWORD cbData,
997 HCONV hConv, HSZ hszItem, UINT16 wFmt,
998 UINT16 wType, DWORD dwTimeout,
999 LPDWORD pdwResult )
1001 return DdeClientTransaction( (LPBYTE)pData, cbData, hConv, hszItem,
1002 wFmt, wType, dwTimeout, pdwResult );
1006 /*****************************************************************
1007 * DdeClientTransaction (USER32.90)
1009 HDDEDATA WINAPI DdeClientTransaction( LPBYTE pData, DWORD cbData,
1010 HCONV hConv, HSZ hszItem, UINT wFmt,
1011 UINT wType, DWORD dwTimeout,
1012 LPDWORD pdwResult )
1014 FIXME( ddeml, "empty stub\n" );
1015 return 0;
1018 /*****************************************************************
1020 * DdeAbandonTransaction16 (DDEML.12)
1023 BOOL16 WINAPI DdeAbandonTransaction16( DWORD idInst, HCONV hConv,
1024 DWORD idTransaction )
1026 FIXME( ddeml, "empty stub\n" );
1027 return TRUE;
1031 /*****************************************************************
1033 * DdeAbandonTransaction (USER32.87)
1035 ******************************************************************
1037 * Change History
1039 * Vn Date Author Comment
1041 * 1.0 March 1999 K Matthews stub only
1043 BOOL WINAPI DdeAbandonTransaction( DWORD idInst, HCONV hConv,
1044 DWORD idTransaction )
1046 FIXME( ddeml, "empty stub\n" );
1047 return TRUE;
1050 /*****************************************************************
1051 * DdePostAdvise16 [DDEML.13]
1053 BOOL16 WINAPI DdePostAdvise16( DWORD idInst, HSZ hszTopic, HSZ hszItem )
1055 return (BOOL16)DdePostAdvise(idInst, hszTopic, hszItem);
1059 /******************************************************************************
1060 * DdePostAdvise [USER32.110] Send transaction to DDE callback function.
1062 * RETURNS
1063 * Success: TRUE
1064 * Failure: FALSE
1066 BOOL WINAPI DdePostAdvise(
1067 DWORD idInst, /* [in] Instance identifier */
1068 HSZ hszTopic, /* [in] Handle to topic name string */
1069 HSZ hszItem) /* [in] Handle to item name string */
1071 FIXME(ddeml, "(%ld,%ld,%ld): stub\n",idInst,hszTopic,hszItem);
1072 return TRUE;
1076 /*****************************************************************
1077 * DdeAddData16 (DDEML.15)
1079 HDDEDATA WINAPI DdeAddData16( HDDEDATA hData, LPBYTE pSrc, DWORD cb,
1080 DWORD cbOff )
1082 FIXME( ddeml, "empty stub\n" );
1083 return 0;
1086 /*****************************************************************
1088 * DdeAddData (USER32.89)
1090 ******************************************************************
1092 * Change History
1094 * Vn Date Author Comment
1096 * 1.0 March 1999 K Matthews stub only
1098 HDDEDATA WINAPI DdeAddData( HDDEDATA hData, LPBYTE pSrc, DWORD cb,
1099 DWORD cbOff )
1101 FIXME( ddeml, "empty stub\n" );
1102 return 0;
1106 /*****************************************************************
1108 * DdeImpersonateClient (USER32.105)
1110 ******************************************************************
1112 * Change History
1114 * Vn Date Author Comment
1116 * 1.0 March 1999 K Matthews stub only
1119 BOOL WINAPI DdeImpersonateClient( HCONV hConv)
1121 FIXME( ddeml, "empty stub\n" );
1122 return TRUE;
1126 /*****************************************************************
1128 * DdeSetQualityOfService (USER32.116)
1130 ******************************************************************
1132 * Change History
1134 * Vn Date Author Comment
1136 * 1.0 March 1999 K Matthews stub only
1139 BOOL WINAPI DdeSetQualityOfService( HWND hwndClient, CONST SECURITY_QUALITY_OF_SERVICE *pqosNew,
1140 PSECURITY_QUALITY_OF_SERVICE pqosPrev)
1142 FIXME( ddeml, "empty stub\n" );
1143 return TRUE;
1146 /*****************************************************************
1148 * DdeSetUserHandle (USER32.117)
1150 ******************************************************************
1152 * Change History
1154 * Vn Date Author Comment
1156 * 1.0 March 1999 K Matthews stub only
1159 BOOL WINAPI DdeSetUserHandle( HCONV hConv, DWORD id, DWORD hUser)
1161 FIXME( ddeml, "empty stub\n" );
1162 return TRUE;
1165 /******************************************************************************
1166 * DdeGetData [USER32.102] Copies data from DDE object ot local buffer
1168 * RETURNS
1169 * Size of memory object associated with handle
1171 DWORD WINAPI DdeGetData(
1172 HDDEDATA hData, /* [in] Handle to DDE object */
1173 LPBYTE pDst, /* [in] Pointer to destination buffer */
1174 DWORD cbMax, /* [in] Amount of data to copy */
1175 DWORD cbOff) /* [in] Offset to beginning of data */
1177 FIXME(ddeml, "(%ld,%p,%ld,%ld): stub\n",hData,pDst,cbMax,cbOff);
1178 return cbMax;
1182 /*****************************************************************
1183 * DdeGetData16 [DDEML.16]
1185 DWORD WINAPI DdeGetData16(
1186 HDDEDATA hData,
1187 LPBYTE pDst,
1188 DWORD cbMax,
1189 DWORD cbOff)
1191 return DdeGetData(hData, pDst, cbMax, cbOff);
1195 /*****************************************************************
1196 * DdeAccessData16 (DDEML.17)
1198 LPBYTE WINAPI DdeAccessData16( HDDEDATA hData, LPDWORD pcbDataSize )
1200 return DdeAccessData(hData, pcbDataSize);
1203 /*****************************************************************
1204 * DdeAccessData (USER32.88)
1206 LPBYTE WINAPI DdeAccessData( HDDEDATA hData, LPDWORD pcbDataSize )
1208 FIXME( ddeml, "(%ld,%p): stub\n", hData, pcbDataSize);
1209 return 0;
1212 /*****************************************************************
1213 * DdeUnaccessData16 (DDEML.18)
1215 BOOL16 WINAPI DdeUnaccessData16( HDDEDATA hData )
1217 return DdeUnaccessData(hData);
1220 /*****************************************************************
1221 * DdeUnaccessData (USER32.118)
1223 BOOL WINAPI DdeUnaccessData( HDDEDATA hData )
1225 FIXME( ddeml, "(0x%lx): stub\n", hData);
1227 return 0;
1230 /*****************************************************************
1231 * DdeEnableCallback16 (DDEML.26)
1233 BOOL16 WINAPI DdeEnableCallback16( DWORD idInst, HCONV hConv, UINT16 wCmd )
1235 return DdeEnableCallback(idInst, hConv, wCmd);
1238 /*****************************************************************
1239 * DdeEnableCallback (USER32.99)
1241 BOOL WINAPI DdeEnableCallback( DWORD idInst, HCONV hConv, UINT wCmd )
1243 FIXME( ddeml, "(%ld, 0x%lx, %d) stub\n", idInst, hConv, wCmd);
1245 return 0;
1248 /*****************************************************************
1249 * DdeNameService16 (DDEML.27)
1251 HDDEDATA WINAPI DdeNameService16( DWORD idInst, HSZ hsz1, HSZ hsz2,
1252 UINT16 afCmd )
1254 return DdeNameService( idInst, hsz1, hsz2, afCmd );
1258 /******************************************************************************
1259 * DdeNameService [USER32.109] {Un}registers service name of DDE server
1261 * PARAMS
1262 * idInst [I] Instance identifier
1263 * hsz1 [I] Handle to service name string
1264 * hsz2 [I] Reserved
1265 * afCmd [I] Service name flags
1267 * RETURNS
1268 * Success: Non-zero
1269 * Failure: 0
1271 HDDEDATA WINAPI DdeNameService( DWORD idInst, HSZ hsz1, HSZ hsz2,
1272 UINT afCmd )
1274 FIXME(ddeml, "(%ld,%ld,%ld,%d): stub\n",idInst,hsz1,hsz2,afCmd);
1275 return 1;
1279 /*****************************************************************
1280 * DdeGetLastError16 (DDEML.20)
1282 UINT16 WINAPI DdeGetLastError16( DWORD idInst )
1284 return (UINT16)DdeGetLastError( idInst );
1288 /******************************************************************************
1289 * DdeGetLastError [USER32.103] Gets most recent error code
1291 * PARAMS
1292 * idInst [I] Instance identifier
1294 * RETURNS
1295 * Last error code
1297 UINT WINAPI DdeGetLastError( DWORD idInst )
1299 FIXME(ddeml, "(%ld): stub\n",idInst);
1300 return 0;
1304 /*****************************************************************
1305 * DdeCmpStringHandles16 (DDEML.36)
1307 int WINAPI DdeCmpStringHandles16( HSZ hsz1, HSZ hsz2 )
1309 return DdeCmpStringHandles(hsz1, hsz2);
1312 /*****************************************************************
1313 * DdeCmpStringHandles (USER32.91)
1315 * Compares the value of two string handles. This comparison is
1316 * not case sensitive.
1318 * Returns:
1319 * -1 The value of hsz1 is zero or less than hsz2
1320 * 0 The values of hsz 1 and 2 are the same or both zero.
1321 * 1 The value of hsz2 is zero of less than hsz1
1323 int WINAPI DdeCmpStringHandles( HSZ hsz1, HSZ hsz2 )
1325 CHAR psz1[MAX_BUFFER_LEN];
1326 CHAR psz2[MAX_BUFFER_LEN];
1327 int ret = 0;
1328 int ret1, ret2;
1330 TRACE( ddeml, "handle 1, handle 2\n" );
1332 ret1 = GlobalGetAtomNameA( hsz1, psz1, MAX_BUFFER_LEN );
1333 ret2 = GlobalGetAtomNameA( hsz2, psz2, MAX_BUFFER_LEN );
1334 /* Make sure we found both strings.
1336 if( ret1 == 0 && ret2 == 0 )
1338 /* If both are not found, return both "zero strings".
1340 ret = 0;
1342 else if( ret1 == 0 )
1344 /* If hsz1 is a not found, return hsz1 is "zero string".
1346 ret = -1;
1348 else if( ret2 == 0 )
1350 /* If hsz2 is a not found, return hsz2 is "zero string".
1352 ret = 1;
1354 else
1356 /* Compare the two strings we got ( case insensitive ).
1358 ret = strcasecmp( psz1, psz2 );
1359 /* Since strcmp returns any number smaller than
1360 * 0 when the first string is found to be less than
1361 * the second one we must make sure we are returning
1362 * the proper values.
1364 if( ret < 0 )
1366 ret = -1;
1368 else if( ret > 0 )
1370 ret = 1;
1374 return ret;
1377 /*****************************************************************
1378 * PackDDElParam (USER32.414)
1380 * RETURNS
1381 * success: nonzero
1382 * failure: zero
1384 UINT WINAPI PackDDElParam(UINT msg, UINT uiLo, UINT uiHi)
1386 FIXME(ddeml, "stub.\n");
1387 return 0;
1391 /*****************************************************************
1392 * UnpackDDElParam (USER32.562)
1394 * RETURNS
1395 * success: nonzero
1396 * failure: zero
1398 UINT WINAPI UnpackDDElParam(UINT msg, UINT lParam,
1399 UINT *uiLo, UINT *uiHi)
1401 FIXME(ddeml, "stub.\n");
1402 return 0;
1406 /*****************************************************************
1407 * FreeDDElParam (USER32.204)
1409 * RETURNS
1410 * success: nonzero
1411 * failure: zero
1413 UINT WINAPI FreeDDElParam(UINT msg, UINT lParam)
1415 FIXME(ddeml, "stub.\n");
1416 return 0;
1419 /*****************************************************************
1420 * ReuseDDElParam (USER32.446)
1423 UINT WINAPI ReuseDDElParam(UINT lParam, UINT msgIn, UINT msgOut,
1424 UINT uiLi, UINT uiHi)
1426 FIXME(ddeml, "stub.\n");
1427 return 0;
1430 /******************************************************************
1431 * DdeQueryConvInfo16 (DDEML.9)
1434 UINT16 WINAPI DdeQueryConvInfo16( HCONV hconv, DWORD idTransaction , LPCONVINFO16 lpConvInfo)
1436 FIXME(ddeml,"stub.\n");
1437 return 0;
1441 /******************************************************************
1442 * DdeQueryConvInfo (USER32.111)
1445 UINT WINAPI DdeQueryConvInfo( HCONV hconv, DWORD idTransaction , LPCONVINFO lpConvInfo)
1447 FIXME(ddeml,"stub.\n");
1448 return 0;