4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Len White
6 * Copyright 1999 Keith Matthews
8 * Copyright 2001,2002 Eric Pouech
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "wine/windef16.h"
34 #include "dde/dde_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(ddeml);
40 typedef HDDEDATA (CALLBACK *PFNCALLBACK16)(UINT16,UINT16,HCONV,HSZ,HSZ,HDDEDATA,
51 } CONVCONTEXT16, *LPCONVCONTEXT16;
68 CONVCONTEXT16 ConvCtxt;
69 } CONVINFO16, *LPCONVINFO16;
71 static void map1632_conv_context(CONVCONTEXT* cc32, const CONVCONTEXT16* cc16)
73 cc32->cb = sizeof(*cc32);
74 cc32->wFlags = cc16->wFlags;
75 cc32->wCountryID = cc16->wCountryID;
76 cc32->iCodePage = cc16->iCodePage;
77 cc32->dwLangID = cc16->dwLangID;
78 cc32->dwSecurity = cc16->dwSecurity;
81 static void map3216_conv_context(CONVCONTEXT16* cc16, const CONVCONTEXT* cc32)
83 cc16->cb = sizeof(*cc16);
84 cc16->wFlags = cc32->wFlags;
85 cc16->wCountryID = cc32->wCountryID;
86 cc16->iCodePage = cc32->iCodePage;
87 cc16->dwLangID = cc32->dwLangID;
88 cc16->dwSecurity = cc32->dwSecurity;
91 /* ### start build ### */
92 extern LONG CALLBACK WDML_CallTo16_long_llllllll(FARPROC16,LONG,LONG,LONG,LONG,LONG,LONG,LONG,LONG);
93 /* ### stop build ### */
95 /******************************************************************
96 * WDML_InvokeCallback16
100 HDDEDATA WDML_InvokeCallback16(PFNCALLBACK pfn, UINT uType, UINT uFmt,
101 HCONV hConv, HSZ hsz1, HSZ hsz2,
102 HDDEDATA hdata, DWORD dwData1, DWORD dwData2)
111 case XTYP_WILDCONNECT:
114 map3216_conv_context(&cc16, (const CONVCONTEXT*)dwData1);
123 ret = WDML_CallTo16_long_llllllll((FARPROC16)pfn, uType, uFmt, hConv,
124 hsz1, hsz2, hdata, d1, dwData2);
128 case XTYP_WILDCONNECT:
129 if (d1 != 0) UnMapLS(d1);
135 /******************************************************************************
136 * DdeInitialize (DDEML.2)
138 UINT16 WINAPI DdeInitialize16(LPDWORD pidInst, PFNCALLBACK16 pfnCallback,
139 DWORD afCmd, DWORD ulRes)
141 return WDML_Initialize(pidInst, (PFNCALLBACK)pfnCallback, afCmd, ulRes,
145 /*****************************************************************
146 * DdeUninitialize (DDEML.3)
148 BOOL16 WINAPI DdeUninitialize16(DWORD idInst)
150 return (BOOL16)DdeUninitialize(idInst);
153 /*****************************************************************
154 * DdeConnectList [DDEML.4]
157 HCONVLIST WINAPI DdeConnectList16(DWORD idInst, HSZ hszService, HSZ hszTopic,
158 HCONVLIST hConvList, LPCONVCONTEXT16 pCC16)
161 CONVCONTEXT* pCC = NULL;
164 map1632_conv_context(pCC = &cc, pCC16);
165 return DdeConnectList(idInst, hszService, hszTopic, hConvList, pCC);
168 /*****************************************************************
169 * DdeQueryNextServer [DDEML.5]
171 HCONV WINAPI DdeQueryNextServer16(HCONVLIST hConvList, HCONV hConvPrev)
173 return DdeQueryNextServer(hConvList, hConvPrev);
176 /*****************************************************************
177 * DdeDisconnectList (DDEML.6)
179 BOOL16 WINAPI DdeDisconnectList16(HCONVLIST hConvList)
181 return (BOOL16)DdeDisconnectList(hConvList);
185 /*****************************************************************
186 * DdeQueryString (DDEML.23)
188 DWORD WINAPI DdeQueryString16(DWORD idInst, HSZ hsz, LPSTR lpsz, DWORD cchMax,
191 return DdeQueryStringA(idInst, hsz, lpsz, cchMax, codepage);
194 /*****************************************************************
195 * DdeConnect (DDEML.7)
197 HCONV WINAPI DdeConnect16(DWORD idInst, HSZ hszService, HSZ hszTopic,
198 LPCONVCONTEXT16 pCC16)
201 CONVCONTEXT* pCC = NULL;
204 map1632_conv_context(pCC = &cc, pCC16);
205 return DdeConnect(idInst, hszService, hszTopic, pCC);
208 /*****************************************************************
209 * DdeDisconnect (DDEML.8)
211 BOOL16 WINAPI DdeDisconnect16(HCONV hConv)
213 return (BOOL16)DdeDisconnect(hConv);
216 /*****************************************************************
217 * DdeSetUserHandle (DDEML.10)
219 BOOL16 WINAPI DdeSetUserHandle16(HCONV hConv, DWORD id, DWORD hUser)
221 return DdeSetUserHandle(hConv, id, hUser);
224 /*****************************************************************
225 * DdeCreateDataHandle (DDEML.14)
227 HDDEDATA WINAPI DdeCreateDataHandle16(DWORD idInst, LPBYTE pSrc, DWORD cb,
228 DWORD cbOff, HSZ hszItem, UINT16 wFmt,
231 return DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd);
234 /*****************************************************************
235 * DdeCreateStringHandle (DDEML.21)
237 HSZ WINAPI DdeCreateStringHandle16(DWORD idInst, LPCSTR str, INT16 codepage)
241 return DdeCreateStringHandleA(idInst, str, codepage);
245 TRACE("Default codepage supplied\n");
246 return DdeCreateStringHandleA(idInst, str, CP_WINANSI);
250 /*****************************************************************
251 * DdeFreeStringHandle (DDEML.22)
253 BOOL16 WINAPI DdeFreeStringHandle16(DWORD idInst, HSZ hsz)
255 return (BOOL16)DdeFreeStringHandle(idInst, hsz);
258 /*****************************************************************
259 * DdeFreeDataHandle (DDEML.19)
261 BOOL16 WINAPI DdeFreeDataHandle16(HDDEDATA hData)
263 return (BOOL16)DdeFreeDataHandle(hData);
266 /*****************************************************************
267 * DdeKeepStringHandle (DDEML.24)
269 BOOL16 WINAPI DdeKeepStringHandle16(DWORD idInst, HSZ hsz)
271 return (BOOL)DdeKeepStringHandle(idInst, hsz);
274 /*****************************************************************
275 * DdeClientTransaction (DDEML.11)
277 HDDEDATA WINAPI DdeClientTransaction16(LPVOID pData, DWORD cbData, HCONV hConv,
278 HSZ hszItem, UINT16 wFmt, UINT16 wType,
279 DWORD dwTimeout, LPDWORD pdwResult)
281 return DdeClientTransaction((LPBYTE)pData, cbData, hConv, hszItem,
282 wFmt, wType, dwTimeout, pdwResult);
285 /*****************************************************************
287 * DdeAbandonTransaction (DDEML.12)
290 BOOL16 WINAPI DdeAbandonTransaction16(DWORD idInst, HCONV hConv, DWORD idTransaction)
292 return (BOOL16)DdeAbandonTransaction(idInst, hConv, idTransaction);
295 /*****************************************************************
296 * DdePostAdvise [DDEML.13]
298 BOOL16 WINAPI DdePostAdvise16(DWORD idInst, HSZ hszTopic, HSZ hszItem)
300 return (BOOL16)DdePostAdvise(idInst, hszTopic, hszItem);
303 /*****************************************************************
304 * DdeAddData (DDEML.15)
306 HDDEDATA WINAPI DdeAddData16(HDDEDATA hData, LPBYTE pSrc, DWORD cb, DWORD cbOff)
308 return DdeAddData(hData, pSrc, cb, cbOff);
311 /*****************************************************************
312 * DdeGetData [DDEML.16]
314 DWORD WINAPI DdeGetData16(HDDEDATA hData, LPBYTE pDst, DWORD cbMax, DWORD cbOff)
316 return DdeGetData(hData, pDst, cbMax, cbOff);
319 /*****************************************************************
320 * DdeAccessData (DDEML.17)
322 LPBYTE WINAPI DdeAccessData16(HDDEDATA hData, LPDWORD pcbDataSize)
324 FIXME("expect trouble\n");
325 /* FIXME: there's a memory leak here... */
326 return (LPBYTE)MapLS(DdeAccessData(hData, pcbDataSize));
329 /*****************************************************************
330 * DdeUnaccessData (DDEML.18)
332 BOOL16 WINAPI DdeUnaccessData16(HDDEDATA hData)
334 return DdeUnaccessData(hData);
337 /*****************************************************************
338 * DdeEnableCallback (DDEML.26)
340 BOOL16 WINAPI DdeEnableCallback16(DWORD idInst, HCONV hConv, UINT16 wCmd)
342 return DdeEnableCallback(idInst, hConv, wCmd);
345 /*****************************************************************
346 * DdeNameService (DDEML.27)
348 HDDEDATA WINAPI DdeNameService16(DWORD idInst, HSZ hsz1, HSZ hsz2, UINT16 afCmd)
350 return DdeNameService(idInst, hsz1, hsz2, afCmd);
353 /*****************************************************************
354 * DdeGetLastError (DDEML.20)
356 UINT16 WINAPI DdeGetLastError16(DWORD idInst)
358 return (UINT16)DdeGetLastError(idInst);
361 /*****************************************************************
362 * DdeCmpStringHandles (DDEML.36)
364 INT16 WINAPI DdeCmpStringHandles16(HSZ hsz1, HSZ hsz2)
366 return DdeCmpStringHandles(hsz1, hsz2);
369 /******************************************************************
370 * DdeQueryConvInfo (DDEML.9)
373 UINT16 WINAPI DdeQueryConvInfo16(HCONV hConv, DWORD idTransaction,
374 LPCONVINFO16 lpConvInfo)
380 ci32.cb = sizeof(ci32);
381 ci32.ConvCtxt.cb = sizeof(ci32.ConvCtxt);
383 ret = DdeQueryConvInfo(hConv, idTransaction, &ci32);
384 if (ret == 0) return 0;
386 ci16.hUser = ci32.hUser;
387 ci16.hConvPartner = ci32.hConvPartner;
388 ci16.hszSvcPartner = ci32.hszSvcPartner;
389 ci16.hszServiceReq = ci32.hszServiceReq;
390 ci16.hszTopic = ci32.hszTopic;
391 ci16.hszItem = ci32.hszItem;
392 ci16.wFmt = ci32.wFmt;
393 ci16.wType = ci32.wType;
394 ci16.wStatus = ci32.wStatus;
395 ci16.wConvst = ci32.wConvst;
396 ci16.wLastError = ci32.wLastError;
397 ci16.hConvList = ci32.hConvList;
399 map3216_conv_context(&ci16.ConvCtxt, &ci32.ConvCtxt);
401 memcpy(lpConvInfo, &ci16, lpConvInfo->cb);
402 return lpConvInfo->cb;