ddraw: Add MAKEFOURCC to ddraw.h.
[wine/multimedia.git] / dlls / user / ddeml16.c
blob9ceb432929eab9b17e91281e3d7bbeaeb90c739a
1 /*
2 * DDEML library
4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Len White
6 * Copyright 1999 Keith Matthews
7 * Copyright 2000 Corel
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
25 #include <stdarg.h>
26 #include <string.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wine/windef16.h"
30 #include "wownt32.h"
31 #include "dde.h"
32 #include "ddeml.h"
33 #include "dde_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(ddeml);
39 typedef HDDEDATA (CALLBACK *PFNCALLBACK16)(UINT16,UINT16,HCONV,HSZ,HSZ,HDDEDATA,
40 DWORD,DWORD);
42 typedef struct
44 UINT16 cb;
45 UINT16 wFlags;
46 UINT16 wCountryID;
47 INT16 iCodePage;
48 DWORD dwLangID;
49 DWORD dwSecurity;
50 } CONVCONTEXT16, *LPCONVCONTEXT16;
52 typedef struct
54 DWORD cb;
55 DWORD hUser;
56 HCONV hConvPartner;
57 HSZ hszSvcPartner;
58 HSZ hszServiceReq;
59 HSZ hszTopic;
60 HSZ hszItem;
61 UINT16 wFmt;
62 UINT16 wType;
63 UINT16 wStatus;
64 UINT16 wConvst;
65 UINT16 wLastError;
66 HCONVLIST hConvList;
67 CONVCONTEXT16 ConvCtxt;
68 } CONVINFO16, *LPCONVINFO16;
70 static void map1632_conv_context(CONVCONTEXT* cc32, const CONVCONTEXT16* cc16)
72 cc32->cb = sizeof(*cc32);
73 cc32->wFlags = cc16->wFlags;
74 cc32->wCountryID = cc16->wCountryID;
75 cc32->iCodePage = cc16->iCodePage;
76 cc32->dwLangID = cc16->dwLangID;
77 cc32->dwSecurity = cc16->dwSecurity;
80 static void map3216_conv_context(CONVCONTEXT16* cc16, const CONVCONTEXT* cc32)
82 cc16->cb = sizeof(*cc16);
83 cc16->wFlags = cc32->wFlags;
84 cc16->wCountryID = cc32->wCountryID;
85 cc16->iCodePage = cc32->iCodePage;
86 cc16->dwLangID = cc32->dwLangID;
87 cc16->dwSecurity = cc32->dwSecurity;
91 /******************************************************************
92 * WDML_InvokeCallback16
96 HDDEDATA WDML_InvokeCallback16(PFNCALLBACK pfn, UINT uType, UINT uFmt,
97 HCONV hConv, HSZ hsz1, HSZ hsz2,
98 HDDEDATA hdata, DWORD dwData1, DWORD dwData2)
100 DWORD d1 = 0;
101 HDDEDATA ret;
102 CONVCONTEXT16 cc16;
103 WORD args[16];
105 switch (uType)
107 case XTYP_CONNECT:
108 case XTYP_WILDCONNECT:
109 if (dwData1)
111 map3216_conv_context(&cc16, (const CONVCONTEXT*)dwData1);
112 d1 = MapLS(&cc16);
114 else
115 break;
116 default:
117 d1 = dwData1;
118 break;
120 args[15] = HIWORD(uType);
121 args[14] = LOWORD(uType);
122 args[13] = HIWORD(uFmt);
123 args[12] = LOWORD(uFmt);
124 args[11] = HIWORD(hConv);
125 args[10] = LOWORD(hConv);
126 args[9] = HIWORD(hsz1);
127 args[8] = LOWORD(hsz1);
128 args[7] = HIWORD(hsz2);
129 args[6] = LOWORD(hsz2);
130 args[5] = HIWORD(hdata);
131 args[4] = LOWORD(hdata);
132 args[3] = HIWORD(d1);
133 args[2] = LOWORD(d1);
134 args[1] = HIWORD(dwData2);
135 args[0] = LOWORD(dwData2);
136 WOWCallback16Ex( (DWORD)pfn, WCB16_PASCAL, sizeof(args), args, (DWORD *)&ret );
138 switch (uType)
140 case XTYP_CONNECT:
141 case XTYP_WILDCONNECT:
142 if (d1 != 0) UnMapLS(d1);
143 break;
145 return ret;
148 /******************************************************************************
149 * DdeInitialize (DDEML.2)
151 UINT16 WINAPI DdeInitialize16(LPDWORD pidInst, PFNCALLBACK16 pfnCallback,
152 DWORD afCmd, DWORD ulRes)
154 return WDML_Initialize(pidInst, (PFNCALLBACK)pfnCallback, afCmd, ulRes,
155 FALSE, TRUE);
158 /*****************************************************************
159 * DdeUninitialize (DDEML.3)
161 BOOL16 WINAPI DdeUninitialize16(DWORD idInst)
163 return (BOOL16)DdeUninitialize(idInst);
166 /*****************************************************************
167 * DdeConnectList [DDEML.4]
170 HCONVLIST WINAPI DdeConnectList16(DWORD idInst, HSZ hszService, HSZ hszTopic,
171 HCONVLIST hConvList, LPCONVCONTEXT16 pCC16)
173 CONVCONTEXT cc;
174 CONVCONTEXT* pCC = NULL;
176 if (pCC16)
177 map1632_conv_context(pCC = &cc, pCC16);
178 return DdeConnectList(idInst, hszService, hszTopic, hConvList, pCC);
181 /*****************************************************************
182 * DdeQueryNextServer [DDEML.5]
184 HCONV WINAPI DdeQueryNextServer16(HCONVLIST hConvList, HCONV hConvPrev)
186 return DdeQueryNextServer(hConvList, hConvPrev);
189 /*****************************************************************
190 * DdeDisconnectList (DDEML.6)
192 BOOL16 WINAPI DdeDisconnectList16(HCONVLIST hConvList)
194 return (BOOL16)DdeDisconnectList(hConvList);
198 /*****************************************************************
199 * DdeQueryString (DDEML.23)
201 DWORD WINAPI DdeQueryString16(DWORD idInst, HSZ hsz, LPSTR lpsz, DWORD cchMax,
202 INT16 codepage)
204 return DdeQueryStringA(idInst, hsz, lpsz, cchMax, codepage);
207 /*****************************************************************
208 * DdeConnect (DDEML.7)
210 HCONV WINAPI DdeConnect16(DWORD idInst, HSZ hszService, HSZ hszTopic,
211 LPCONVCONTEXT16 pCC16)
213 CONVCONTEXT cc;
214 CONVCONTEXT* pCC = NULL;
216 if (pCC16)
217 map1632_conv_context(pCC = &cc, pCC16);
218 return DdeConnect(idInst, hszService, hszTopic, pCC);
221 /*****************************************************************
222 * DdeDisconnect (DDEML.8)
224 BOOL16 WINAPI DdeDisconnect16(HCONV hConv)
226 return (BOOL16)DdeDisconnect(hConv);
229 /*****************************************************************
230 * DdeSetUserHandle (DDEML.10)
232 BOOL16 WINAPI DdeSetUserHandle16(HCONV hConv, DWORD id, DWORD hUser)
234 return DdeSetUserHandle(hConv, id, hUser);
237 /*****************************************************************
238 * DdeCreateDataHandle (DDEML.14)
240 HDDEDATA WINAPI DdeCreateDataHandle16(DWORD idInst, LPBYTE pSrc, DWORD cb,
241 DWORD cbOff, HSZ hszItem, UINT16 wFmt,
242 UINT16 afCmd)
244 return DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd);
247 /*****************************************************************
248 * DdeCreateStringHandle (DDEML.21)
250 HSZ WINAPI DdeCreateStringHandle16(DWORD idInst, LPCSTR str, INT16 codepage)
252 if (codepage)
254 return DdeCreateStringHandleA(idInst, str, codepage);
256 else
258 TRACE("Default codepage supplied\n");
259 return DdeCreateStringHandleA(idInst, str, CP_WINANSI);
263 /*****************************************************************
264 * DdeFreeStringHandle (DDEML.22)
266 BOOL16 WINAPI DdeFreeStringHandle16(DWORD idInst, HSZ hsz)
268 return (BOOL16)DdeFreeStringHandle(idInst, hsz);
271 /*****************************************************************
272 * DdeFreeDataHandle (DDEML.19)
274 BOOL16 WINAPI DdeFreeDataHandle16(HDDEDATA hData)
276 return (BOOL16)DdeFreeDataHandle(hData);
279 /*****************************************************************
280 * DdeKeepStringHandle (DDEML.24)
282 BOOL16 WINAPI DdeKeepStringHandle16(DWORD idInst, HSZ hsz)
284 return (BOOL)DdeKeepStringHandle(idInst, hsz);
287 /*****************************************************************
288 * DdeClientTransaction (DDEML.11)
290 HDDEDATA WINAPI DdeClientTransaction16(LPVOID pData, DWORD cbData, HCONV hConv,
291 HSZ hszItem, UINT16 wFmt, UINT16 wType,
292 DWORD dwTimeout, LPDWORD pdwResult)
294 return DdeClientTransaction((LPBYTE)pData, cbData, hConv, hszItem,
295 wFmt, wType, dwTimeout, pdwResult);
298 /*****************************************************************
300 * DdeAbandonTransaction (DDEML.12)
303 BOOL16 WINAPI DdeAbandonTransaction16(DWORD idInst, HCONV hConv, DWORD idTransaction)
305 return (BOOL16)DdeAbandonTransaction(idInst, hConv, idTransaction);
308 /*****************************************************************
309 * DdePostAdvise [DDEML.13]
311 BOOL16 WINAPI DdePostAdvise16(DWORD idInst, HSZ hszTopic, HSZ hszItem)
313 return (BOOL16)DdePostAdvise(idInst, hszTopic, hszItem);
316 /*****************************************************************
317 * DdeAddData (DDEML.15)
319 HDDEDATA WINAPI DdeAddData16(HDDEDATA hData, LPBYTE pSrc, DWORD cb, DWORD cbOff)
321 return DdeAddData(hData, pSrc, cb, cbOff);
324 /*****************************************************************
325 * DdeGetData [DDEML.16]
327 DWORD WINAPI DdeGetData16(HDDEDATA hData, LPBYTE pDst, DWORD cbMax, DWORD cbOff)
329 return DdeGetData(hData, pDst, cbMax, cbOff);
332 /*****************************************************************
333 * DdeAccessData (DDEML.17)
335 LPBYTE WINAPI DdeAccessData16(HDDEDATA hData, LPDWORD pcbDataSize)
337 FIXME("expect trouble\n");
338 /* FIXME: there's a memory leak here... */
339 return (LPBYTE)MapLS(DdeAccessData(hData, pcbDataSize));
342 /*****************************************************************
343 * DdeUnaccessData (DDEML.18)
345 BOOL16 WINAPI DdeUnaccessData16(HDDEDATA hData)
347 return DdeUnaccessData(hData);
350 /*****************************************************************
351 * DdeEnableCallback (DDEML.26)
353 BOOL16 WINAPI DdeEnableCallback16(DWORD idInst, HCONV hConv, UINT16 wCmd)
355 return DdeEnableCallback(idInst, hConv, wCmd);
358 /*****************************************************************
359 * DdeNameService (DDEML.27)
361 HDDEDATA WINAPI DdeNameService16(DWORD idInst, HSZ hsz1, HSZ hsz2, UINT16 afCmd)
363 return DdeNameService(idInst, hsz1, hsz2, afCmd);
366 /*****************************************************************
367 * DdeGetLastError (DDEML.20)
369 UINT16 WINAPI DdeGetLastError16(DWORD idInst)
371 return (UINT16)DdeGetLastError(idInst);
374 /*****************************************************************
375 * DdeCmpStringHandles (DDEML.36)
377 INT16 WINAPI DdeCmpStringHandles16(HSZ hsz1, HSZ hsz2)
379 return DdeCmpStringHandles(hsz1, hsz2);
382 /******************************************************************
383 * DdeQueryConvInfo (DDEML.9)
386 UINT16 WINAPI DdeQueryConvInfo16(HCONV hConv, DWORD idTransaction,
387 LPCONVINFO16 lpConvInfo)
389 CONVINFO ci32;
390 CONVINFO16 ci16;
391 UINT ret;
393 ci32.cb = sizeof(ci32);
394 ci32.ConvCtxt.cb = sizeof(ci32.ConvCtxt);
396 ret = DdeQueryConvInfo(hConv, idTransaction, &ci32);
397 if (ret == 0) return 0;
399 ci16.hUser = ci32.hUser;
400 ci16.hConvPartner = ci32.hConvPartner;
401 ci16.hszSvcPartner = ci32.hszSvcPartner;
402 ci16.hszServiceReq = ci32.hszServiceReq;
403 ci16.hszTopic = ci32.hszTopic;
404 ci16.hszItem = ci32.hszItem;
405 ci16.wFmt = ci32.wFmt;
406 ci16.wType = ci32.wType;
407 ci16.wStatus = ci32.wStatus;
408 ci16.wConvst = ci32.wConvst;
409 ci16.wLastError = ci32.wLastError;
410 ci16.hConvList = ci32.hConvList;
412 map3216_conv_context(&ci16.ConvCtxt, &ci32.ConvCtxt);
414 memcpy(lpConvInfo, &ci16, lpConvInfo->cb);
415 return lpConvInfo->cb;