Move the name directive from the .spec file to the Makefile.
[wine/gsoc_dplay.git] / dlls / user / dde / ddeml16.c
bloba6d5ff4e92f6c1258b893cfed5baa1b1846e0249
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 <string.h>
26 #include "winbase.h"
27 #include "windef.h"
28 #include "wine/windef16.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winerror.h"
32 #include "dde.h"
33 #include "ddeml.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,
41 DWORD,DWORD);
43 typedef struct
45 UINT16 cb;
46 UINT16 wFlags;
47 UINT16 wCountryID;
48 INT16 iCodePage;
49 DWORD dwLangID;
50 DWORD dwSecurity;
51 } CONVCONTEXT16, *LPCONVCONTEXT16;
53 typedef struct
55 DWORD cb;
56 DWORD hUser;
57 HCONV hConvPartner;
58 HSZ hszSvcPartner;
59 HSZ hszServiceReq;
60 HSZ hszTopic;
61 HSZ hszItem;
62 UINT16 wFmt;
63 UINT16 wType;
64 UINT16 wStatus;
65 UINT16 wConvst;
66 UINT16 wLastError;
67 HCONVLIST hConvList;
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)
104 DWORD d1;
105 HDDEDATA ret;
106 CONVCONTEXT16 cc16;
108 switch (uType)
110 case XTYP_CONNECT:
111 case XTYP_WILDCONNECT:
112 map3216_conv_context(&cc16, (const CONVCONTEXT*)dwData1);
113 d1 = MapLS(&cc16);
114 break;
115 default:
116 d1 = dwData1;
117 break;
119 ret = WDML_CallTo16_long_llllllll((FARPROC16)pfn, uType, uFmt, hConv,
120 hsz1, hsz2, hdata, d1, dwData2);
121 switch (uType)
123 case XTYP_CONNECT:
124 case XTYP_WILDCONNECT:
125 UnMapLS(d1);
126 break;
128 return ret;
131 /******************************************************************************
132 * DdeInitialize (DDEML.2)
134 UINT16 WINAPI DdeInitialize16(LPDWORD pidInst, PFNCALLBACK16 pfnCallback,
135 DWORD afCmd, DWORD ulRes)
137 return WDML_Initialize(pidInst, (PFNCALLBACK)pfnCallback, afCmd, ulRes,
138 FALSE, TRUE);
141 /*****************************************************************
142 * DdeUninitialize (DDEML.3)
144 BOOL16 WINAPI DdeUninitialize16(DWORD idInst)
146 return (BOOL16)DdeUninitialize(idInst);
149 /*****************************************************************
150 * DdeConnectList [DDEML.4]
153 HCONVLIST WINAPI DdeConnectList16(DWORD idInst, HSZ hszService, HSZ hszTopic,
154 HCONVLIST hConvList, LPCONVCONTEXT16 pCC16)
156 CONVCONTEXT cc;
157 CONVCONTEXT* pCC = NULL;
159 if (pCC16)
160 map1632_conv_context(pCC = &cc, pCC16);
161 return DdeConnectList(idInst, hszService, hszTopic, hConvList, pCC);
164 /*****************************************************************
165 * DdeQueryNextServer [DDEML.5]
167 HCONV WINAPI DdeQueryNextServer16(HCONVLIST hConvList, HCONV hConvPrev)
169 return DdeQueryNextServer(hConvList, hConvPrev);
172 /*****************************************************************
173 * DdeDisconnectList (DDEML.6)
175 BOOL16 WINAPI DdeDisconnectList16(HCONVLIST hConvList)
177 return (BOOL16)DdeDisconnectList(hConvList);
181 /*****************************************************************
182 * DdeQueryString (DDEML.23)
184 DWORD WINAPI DdeQueryString16(DWORD idInst, HSZ hsz, LPSTR lpsz, DWORD cchMax,
185 INT16 codepage)
187 return DdeQueryStringA(idInst, hsz, lpsz, cchMax, codepage);
190 /*****************************************************************
191 * DdeConnect (DDEML.7)
193 HCONV WINAPI DdeConnect16(DWORD idInst, HSZ hszService, HSZ hszTopic,
194 LPCONVCONTEXT16 pCC16)
196 CONVCONTEXT cc;
197 CONVCONTEXT* pCC = NULL;
199 if (pCC16)
200 map1632_conv_context(pCC = &cc, pCC16);
201 return DdeConnect(idInst, hszService, hszTopic, pCC);
204 /*****************************************************************
205 * DdeDisconnect (DDEML.8)
207 BOOL16 WINAPI DdeDisconnect16(HCONV hConv)
209 return (BOOL16)DdeDisconnect(hConv);
212 /*****************************************************************
213 * DdeSetUserHandle (DDEML.10)
215 BOOL16 WINAPI DdeSetUserHandle16(HCONV hConv, DWORD id, DWORD hUser)
217 return DdeSetUserHandle(hConv, id, hUser);
220 /*****************************************************************
221 * DdeCreateDataHandle (DDEML.14)
223 HDDEDATA WINAPI DdeCreateDataHandle16(DWORD idInst, LPBYTE pSrc, DWORD cb,
224 DWORD cbOff, HSZ hszItem, UINT16 wFmt,
225 UINT16 afCmd)
227 return DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd);
230 /*****************************************************************
231 * DdeCreateStringHandle (DDEML.21)
233 HSZ WINAPI DdeCreateStringHandle16(DWORD idInst, LPCSTR str, INT16 codepage)
235 if (codepage)
237 return DdeCreateStringHandleA(idInst, str, codepage);
239 else
241 TRACE("Default codepage supplied\n");
242 return DdeCreateStringHandleA(idInst, str, CP_WINANSI);
246 /*****************************************************************
247 * DdeFreeStringHandle (DDEML.22)
249 BOOL16 WINAPI DdeFreeStringHandle16(DWORD idInst, HSZ hsz)
251 return (BOOL16)DdeFreeStringHandle(idInst, hsz);
254 /*****************************************************************
255 * DdeFreeDataHandle (DDEML.19)
257 BOOL16 WINAPI DdeFreeDataHandle16(HDDEDATA hData)
259 return (BOOL16)DdeFreeDataHandle(hData);
262 /*****************************************************************
263 * DdeKeepStringHandle (DDEML.24)
265 BOOL16 WINAPI DdeKeepStringHandle16(DWORD idInst, HSZ hsz)
267 return (BOOL)DdeKeepStringHandle(idInst, hsz);
270 /*****************************************************************
271 * DdeClientTransaction (DDEML.11)
273 HDDEDATA WINAPI DdeClientTransaction16(LPVOID pData, DWORD cbData, HCONV hConv,
274 HSZ hszItem, UINT16 wFmt, UINT16 wType,
275 DWORD dwTimeout, LPDWORD pdwResult)
277 return DdeClientTransaction((LPBYTE)pData, cbData, hConv, hszItem,
278 wFmt, wType, dwTimeout, pdwResult);
281 /*****************************************************************
283 * DdeAbandonTransaction (DDEML.12)
286 BOOL16 WINAPI DdeAbandonTransaction16(DWORD idInst, HCONV hConv, DWORD idTransaction)
288 return (BOOL16)DdeAbandonTransaction(idInst, hConv, idTransaction);
291 /*****************************************************************
292 * DdePostAdvise [DDEML.13]
294 BOOL16 WINAPI DdePostAdvise16(DWORD idInst, HSZ hszTopic, HSZ hszItem)
296 return (BOOL16)DdePostAdvise(idInst, hszTopic, hszItem);
299 /*****************************************************************
300 * DdeAddData (DDEML.15)
302 HDDEDATA WINAPI DdeAddData16(HDDEDATA hData, LPBYTE pSrc, DWORD cb, DWORD cbOff)
304 return DdeAddData(hData, pSrc, cb, cbOff);
307 /*****************************************************************
308 * DdeGetData [DDEML.16]
310 DWORD WINAPI DdeGetData16(HDDEDATA hData, LPBYTE pDst, DWORD cbMax, DWORD cbOff)
312 return DdeGetData(hData, pDst, cbMax, cbOff);
315 /*****************************************************************
316 * DdeAccessData (DDEML.17)
318 LPBYTE WINAPI DdeAccessData16(HDDEDATA hData, LPDWORD pcbDataSize)
320 FIXME("expect trouble\n");
321 /* FIXME: there's a memory leak here... */
322 return (LPBYTE)MapLS(DdeAccessData(hData, pcbDataSize));
325 /*****************************************************************
326 * DdeUnaccessData (DDEML.18)
328 BOOL16 WINAPI DdeUnaccessData16(HDDEDATA hData)
330 return DdeUnaccessData(hData);
333 /*****************************************************************
334 * DdeEnableCallback (DDEML.26)
336 BOOL16 WINAPI DdeEnableCallback16(DWORD idInst, HCONV hConv, UINT16 wCmd)
338 return DdeEnableCallback(idInst, hConv, wCmd);
341 /*****************************************************************
342 * DdeNameService (DDEML.27)
344 HDDEDATA WINAPI DdeNameService16(DWORD idInst, HSZ hsz1, HSZ hsz2, UINT16 afCmd)
346 return DdeNameService(idInst, hsz1, hsz2, afCmd);
349 /*****************************************************************
350 * DdeGetLastError (DDEML.20)
352 UINT16 WINAPI DdeGetLastError16(DWORD idInst)
354 return (UINT16)DdeGetLastError(idInst);
357 /*****************************************************************
358 * DdeCmpStringHandles (DDEML.36)
360 INT16 WINAPI DdeCmpStringHandles16(HSZ hsz1, HSZ hsz2)
362 return DdeCmpStringHandles(hsz1, hsz2);
365 /******************************************************************
366 * DdeQueryConvInfo (DDEML.9)
369 UINT16 WINAPI DdeQueryConvInfo16(HCONV hConv, DWORD idTransaction,
370 LPCONVINFO16 lpConvInfo)
372 CONVINFO ci32;
373 CONVINFO16 ci16;
374 UINT ret;
376 ci32.cb = sizeof(ci32);
377 ci32.ConvCtxt.cb = sizeof(ci32.ConvCtxt);
379 ret = DdeQueryConvInfo(hConv, idTransaction, &ci32);
380 if (ret == 0) return 0;
382 ci16.hUser = ci32.hUser;
383 ci16.hConvPartner = ci32.hConvPartner;
384 ci16.hszSvcPartner = ci32.hszSvcPartner;
385 ci16.hszServiceReq = ci32.hszServiceReq;
386 ci16.hszTopic = ci32.hszTopic;
387 ci16.hszItem = ci32.hszItem;
388 ci16.wFmt = ci32.wFmt;
389 ci16.wType = ci32.wType;
390 ci16.wStatus = ci32.wStatus;
391 ci16.wConvst = ci32.wConvst;
392 ci16.wLastError = ci32.wLastError;
393 ci16.hConvList = ci32.hConvList;
395 map3216_conv_context(&ci16.ConvCtxt, &ci32.ConvCtxt);
397 memcpy(lpConvInfo, &ci16, lpConvInfo->cb);
398 return lpConvInfo->cb;