1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1997 Alexandre Julliard
7 * Copyright 1997 Len White
8 * Copyright 1999 Keith Matthews
10 * Copyright 2001 Eric Pouech
13 #ifndef __WINE_DDEML_PRIVATE_H
14 #define __WINE_DDEML_PRIVATE_H
16 /* defined in atom.c file.
19 #define MAX_ATOM_LEN 255
21 /* Maximum buffer size ( including the '\0' ).
23 #define MAX_BUFFER_LEN (MAX_ATOM_LEN + 1)
25 /* This is a simple list to keep track of the strings created
26 * by DdeCreateStringHandle. The list is used to free
27 * the strings whenever DdeUninitialize is called.
28 * This mechanism is not complete and does not handle multiple instances.
29 * Most of the DDE API use a DWORD parameter indicating which instance
30 * of a given program is calling them. The API are supposed to
31 * associate the data to the instance that created it.
34 /* The internal structures (prefixed by WDML) are used as follows:
35 * + a WDML_INSTANCE is created for each instance creation (DdeInitialize)
36 * - a popup windows (InstanceClass) is created for each instance. It will be
37 * used to receive all the DDEML events (server registration, conversation
39 * + when registring a server (DdeNameService) a WDML_SERVER is created
40 * - a popup window (ServerNameClass) is created
41 * + a conversation is represented by two WDML_CONV structures:
42 * - one on the client side, the other one on the server side
43 * - this is needed because the address spaces may be different
44 * - therefore, two lists of links are kept for each instance
45 * - two windows are created for a conversation:
46 * o a popup window on client side (ClientConvClass)
47 * o a child window (of the ServerName) on the server side
49 * - all the exchanges then take place between those two windows
50 * + a (warm or link) is represented by two WDML_LINK structures:
51 * - one on client side, the other one on server side
52 * - therefore, two lists of links are kept for each instance
54 * To help getting back to data, WDML windows store information:
55 * - offset 0: the DDE instance
56 * - offset 4: the current conversation (for ClientConv and ServerConv only)
60 typedef struct tagHSZNode
62 struct tagHSZNode* next;
67 typedef struct tagWDML_SERVER
69 struct tagWDML_SERVER* next;
76 typedef struct tagWDML_XACT {
77 struct tagWDML_XACT* next;
107 typedef struct tagWDML_CONV
109 struct tagWDML_CONV* next; /* to link all the conversations */
110 struct tagWDML_INSTANCE* thisInstance;
111 HSZ hszService; /* pmt used for connection */
112 HSZ hszTopic; /* pmt used for connection */
113 UINT afCmd; /* service name flag */
114 CONVCONTEXT convContext;
115 HWND hwndClient; /* source of conversation (ClientConvClass) */
116 HWND hwndServer; /* destination of conversation (ServerConvClass) */
117 WDML_XACT* transactions; /* pending transactions (client only) */
118 DWORD hUser; /* user defined value */
121 /* DDE_LINK struct defines hot, warm, and cold links */
122 typedef struct tagWDML_LINK {
123 struct tagWDML_LINK* next; /* to link all the active links */
124 HCONV hConv; /* to get back to the converstaion */
125 UINT transactionType;/* 0 for no link */
126 HSZ hszItem; /* item targetted for (hot/warm) link */
127 UINT uFmt; /* format for data */
128 HDDEDATA hDdeData; /* data them selves */
131 typedef struct tagWDML_INSTANCE
133 struct tagWDML_INSTANCE* next;
134 DWORD instanceID; /* needed to track monitor usage */
135 BOOL monitor; /* have these two as full Booleans cos they'll be tested frequently */
136 BOOL clientOnly; /* bit wasteful of space but it will be faster */
137 BOOL unicode; /* Flag to indicate Win32 API used to initialise */
138 BOOL win16; /* flag to indicate Win16 API used to initialize */
139 HSZNode* nodeList; /* for cleaning upon exit */
140 PFNCALLBACK callback;
143 UINT txnCount; /* count transactions open to simplify closure */
146 WDML_SERVER* servers; /* list of registered servers */
147 WDML_CONV* convs[2]; /* active conversations for this instance (client and server) */
148 WDML_LINK* links[2]; /* active links for this instance (client and server) */
151 extern WDML_INSTANCE* WDML_InstanceList; /* list of created instances, a process can create many */
152 extern DWORD WDML_MaxInstanceID; /* FIXME: OK for present, may have to worry about wrap-around later */
153 extern HANDLE handle_mutex;
155 /* header for the DDE Data objects */
156 typedef struct tagDDE_DATAHANDLE_HEAD
159 } DDE_DATAHANDLE_HEAD;
161 typedef enum tagWDML_SIDE
163 WDML_CLIENT_SIDE = 0, WDML_SERVER_SIDE = 1
166 /* server calls this. */
167 extern WDML_SERVER* WDML_AddServer(WDML_INSTANCE* thisInstance, HSZ hszService, HSZ hszTopic);
168 extern void WDML_RemoveServer(WDML_INSTANCE* thisInstance, HSZ hszService, HSZ hszTopic);
169 extern WDML_SERVER* WDML_FindServer(WDML_INSTANCE* thisInstance, HSZ hszService, HSZ hszTopic);
170 /* called both in DdeClientTransaction and server side. */
171 extern WDML_CONV* WDML_AddConv(WDML_INSTANCE* thisInstance, WDML_SIDE side,
172 HSZ hszService, HSZ hszTopic, HWND hwndClient, HWND hwndServer);
173 extern void WDML_RemoveConv(WDML_INSTANCE* thisInstance, WDML_SIDE side, HCONV hConv);
174 extern WDML_CONV* WDML_GetConv(HCONV hConv);
175 extern WDML_CONV* WDML_FindConv(WDML_INSTANCE* thisInstance, WDML_SIDE side,
176 HSZ hszService, HSZ hszTopic);
177 extern void WDML_AddLink(WDML_INSTANCE* thisInstance, HCONV hConv, WDML_SIDE side,
178 UINT wType, HSZ hszItem, UINT wFmt);
179 extern WDML_LINK* WDML_FindLink(WDML_INSTANCE* thisInstance, HCONV hConv, WDML_SIDE side,
180 HSZ hszItem, UINT uFmt);
181 extern void WDML_RemoveLink(WDML_INSTANCE* thisInstance, HCONV hConv, WDML_SIDE side,
182 HSZ hszItem, UINT wFmt);
183 extern void WDML_RemoveAllLinks(WDML_INSTANCE* thisInstance, HCONV hConv, WDML_SIDE side);
184 /* client calls these */
185 extern WDML_XACT* WDML_AllocTransaction(WDML_INSTANCE* thisInstance, UINT ddeMsg);
186 extern void WDML_QueueTransaction(WDML_CONV* pConv, WDML_XACT* pXAct);
187 extern BOOL WDML_UnQueueTransaction(WDML_CONV* pConv, WDML_XACT* pXAct);
188 extern void WDML_FreeTransaction(WDML_XACT* pXAct);
189 extern WDML_XACT* WDML_FindTransaction(WDML_CONV* pConv, DWORD tid);
190 extern HGLOBAL WDML_DataHandle2Global(HDDEDATA hDdeData, BOOL fResponse, BOOL fRelease,
191 BOOL fDeferUpd, BOOL dAckReq);
192 extern HDDEDATA WDML_Global2DataHandle(HGLOBAL hMem);
193 extern WDML_INSTANCE* WDML_FindInstance(DWORD InstId);
194 extern BOOL WDML_WaitForMutex(HANDLE mutex);
195 extern DWORD WDML_ReleaseMutex(HANDLE mutex, LPSTR mutex_name, BOOL release_handle_m);
196 extern void WDML_FreeAllHSZ(WDML_INSTANCE* thisInstance);
197 extern void WDML_ReleaseAtom(WDML_INSTANCE* thisInstance, HSZ hsz);
198 extern void WDML_ReserveAtom(WDML_INSTANCE* thisInstance, HSZ hsz);
199 /* broadcasting to DDE windows */
200 extern void WDML_BroadcastDDEWindows(const char* clsName, UINT uMsg,
201 WPARAM wParam, LPARAM lParam);
203 extern const char WDML_szEventClass[]; /* class of window for events (aka instance) */
205 #define WM_WDML_REGISTER (WM_USER + 0x200)
206 #define WM_WDML_UNREGISTER (WM_USER + 0x201)
208 #endif /* __WINE_DDEML_PRIVATE_H */