Better implementation of GetCalendarInfo{A,W}, not perfect.
[wine] / dlls / user / dde / ddeml16.c
1 /* -*- tab-width: 8; c-basic-offset: 8 -*- */
2
3 /*
4  * DDEML library
5  *
6  * Copyright 1997 Alexandre Julliard
7  * Copyright 1997 Len White
8  * Copyright 1999 Keith Matthews
9  * Copyright 2000 Corel
10  * Copyright 2001 Eric Pouech
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25  */
26
27 #include <string.h>
28 #include "winbase.h"
29 #include "windef.h"
30 #include "wine/windef16.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winerror.h"
34 #include "dde.h"
35 #include "ddeml.h"
36 #include "dde/dde_private.h"
37 #include "wine/debug.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(ddeml);
40
41
42 typedef HDDEDATA (CALLBACK *PFNCALLBACK16)(UINT16,UINT16,HCONV,HSZ,HSZ,HDDEDATA,DWORD,DWORD);
43
44 typedef struct
45 {
46     UINT16  cb;
47     UINT16  wFlags;
48     UINT16  wCountryID;
49     INT16   iCodePage;
50     DWORD   dwLangID;
51     DWORD   dwSecurity;
52 } CONVCONTEXT16, *LPCONVCONTEXT16;
53
54 typedef struct
55 {
56     DWORD          cb;
57     DWORD          hUser;
58     HCONV          hConvPartner;
59     HSZ            hszSvcPartner;
60     HSZ            hszServiceReq;
61     HSZ            hszTopic;
62     HSZ            hszItem;
63     UINT16         wFmt;
64     UINT16         wType;
65     UINT16         wStatus;
66     UINT16         wConvst;
67     UINT16         wLastError;
68     HCONVLIST      hConvList;
69     CONVCONTEXT16  ConvCtxt;
70 } CONVINFO16, *LPCONVINFO16;
71
72 /* ### start build ### */
73 extern LONG CALLBACK WDML_CallTo16_long_llllllll    (FARPROC16,LONG,LONG,LONG,LONG,LONG,LONG,LONG,LONG);
74 /* ### stop build ### */
75
76 /******************************************************************
77  *              WDML_InvokeCallback16
78  *
79  *
80  */
81 HDDEDATA        WDML_InvokeCallback16(PFNCALLBACK pfn, UINT uType, UINT uFmt, HCONV hConv,
82                                       HSZ hsz1, HSZ hsz2, HDDEDATA hdata, 
83                                       DWORD dwData1, DWORD dwData2)
84 {
85         return WDML_CallTo16_long_llllllll((FARPROC16)pfn, uType, uFmt, hConv, 
86                                            hsz1, hsz2, hdata, dwData1, dwData2);
87 }
88
89 /******************************************************************************
90  *            DdeInitialize   (DDEML.2)
91  */
92 UINT16 WINAPI DdeInitialize16(LPDWORD pidInst, PFNCALLBACK16 pfnCallback,
93                               DWORD afCmd, DWORD ulRes)
94 {
95     return WDML_Initialize(pidInst, (PFNCALLBACK)pfnCallback, afCmd, ulRes, FALSE, TRUE);
96 }
97
98 /*****************************************************************
99  *            DdeUninitialize   (DDEML.3)
100  */
101 BOOL16 WINAPI DdeUninitialize16(DWORD idInst)
102 {
103      FIXME(" stub calling DdeUninitialize\n");
104      return (BOOL16)DdeUninitialize(idInst);
105 }
106
107 /*****************************************************************
108  * DdeConnectList [DDEML.4]
109  */
110
111 HCONVLIST WINAPI DdeConnectList16(DWORD idInst, HSZ hszService, HSZ hszTopic,
112                                   HCONVLIST hConvList, LPCONVCONTEXT16 pCC)
113 {
114      return DdeConnectList(idInst, hszService, hszTopic, hConvList, 
115                            (LPCONVCONTEXT)pCC);
116 }
117
118 /*****************************************************************
119  * DdeQueryNextServer [DDEML.5]
120  */
121 HCONV WINAPI DdeQueryNextServer16(HCONVLIST hConvList, HCONV hConvPrev)
122 {
123      return DdeQueryNextServer(hConvList, hConvPrev);
124 }
125
126 /*****************************************************************
127  *            DdeDisconnectList (DDEML.6)
128  */
129 BOOL16 WINAPI DdeDisconnectList16(HCONVLIST hConvList)
130 {
131      return (BOOL16)DdeDisconnectList(hConvList);
132 }
133
134
135 /*****************************************************************
136  *              DdeQueryString (DDEML.23)
137  */
138 DWORD WINAPI DdeQueryString16(DWORD idInst, HSZ hsz, LPSTR lpsz, DWORD cchMax, INT16 codepage)
139 {
140      FIXME("(%ld, 0x%x, %p, %ld, %d): stub \n", 
141            idInst, hsz, lpsz, cchMax, codepage);
142      return 0;
143 }
144
145 /*****************************************************************
146  *            DdeConnect   (DDEML.7)
147  */
148 HCONV WINAPI DdeConnect16(DWORD idInst, HSZ hszService, HSZ hszTopic,
149                           LPCONVCONTEXT16 pCC16)
150 {
151      CONVCONTEXT        cc;
152      CONVCONTEXT*       pCC = NULL;
153      
154      if (pCC16) {
155           pCC = &cc;
156           cc.cb = sizeof(cc);
157           cc.wFlags = pCC16->wFlags;
158           cc.iCodePage = pCC16->iCodePage;
159           cc.dwLangID = pCC16->dwLangID;
160           cc.dwSecurity = pCC16->dwSecurity;
161      }
162      return DdeConnect(idInst, hszService, hszTopic, pCC);
163 }
164
165 /*****************************************************************
166  *            DdeDisconnect   (DDEML.8)
167  */
168 BOOL16 WINAPI DdeDisconnect16(HCONV hConv)
169 {
170      return (BOOL16)DdeDisconnect(hConv);
171 }
172
173 /*****************************************************************
174  *            DdeSetUserHandle (DDEML.10)
175  */
176 BOOL16 WINAPI DdeSetUserHandle16(HCONV hConv, DWORD id, DWORD hUser)
177 {
178      return DdeSetUserHandle(hConv, id, hUser);
179 }
180
181 /*****************************************************************
182  *            DdeCreateDataHandle (DDEML.14)
183  */
184 HDDEDATA WINAPI DdeCreateDataHandle16(DWORD idInst, LPBYTE pSrc, DWORD cb, 
185                                       DWORD cbOff, HSZ hszItem, UINT16 wFmt, 
186                                       UINT16 afCmd)
187 {
188      return DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd);
189 }
190
191 /*****************************************************************
192  *            DdeCreateStringHandle   (DDEML.21)
193  */
194 HSZ WINAPI DdeCreateStringHandle16(DWORD idInst, LPCSTR str, INT16 codepage)
195 {
196      if  (codepage)
197      {
198           return DdeCreateStringHandleA(idInst, str, codepage);
199      } 
200      else 
201      {
202           TRACE("Default codepage supplied\n");
203           return DdeCreateStringHandleA(idInst, str, CP_WINANSI);
204      }
205 }
206
207 /*****************************************************************
208  *            DdeFreeStringHandle   (DDEML.22)
209  */
210 BOOL16 WINAPI DdeFreeStringHandle16(DWORD idInst, HSZ hsz)
211 {
212      TRACE("idInst %ld hsz 0x%x\n",idInst,hsz);
213      return (BOOL)DdeFreeStringHandle(idInst, hsz);
214 }
215
216 /*****************************************************************
217  *            DdeFreeDataHandle   (DDEML.19)
218  */
219 BOOL16 WINAPI DdeFreeDataHandle16(HDDEDATA hData)
220 {
221      return (BOOL)DdeFreeDataHandle(hData);
222 }
223
224 /*****************************************************************
225  *            DdeKeepStringHandle   (DDEML.24)
226  */
227 BOOL16 WINAPI DdeKeepStringHandle16(DWORD idInst, HSZ hsz)
228 {
229      return (BOOL)DdeKeepStringHandle(idInst, hsz);
230 }
231
232 /*****************************************************************
233  *            DdeClientTransaction  (DDEML.11)
234  */
235 HDDEDATA WINAPI DdeClientTransaction16(LPVOID pData, DWORD cbData,
236                                        HCONV hConv, HSZ hszItem, UINT16 wFmt,
237                                        UINT16 wType, DWORD dwTimeout,
238                                        LPDWORD pdwResult)
239 {
240      return DdeClientTransaction((LPBYTE)pData, cbData, hConv, hszItem,
241                                  wFmt, wType, dwTimeout, pdwResult);
242 }
243
244 /*****************************************************************
245  *
246  *            DdeAbandonTransaction (DDEML.12)
247  *
248  */
249 BOOL16 WINAPI DdeAbandonTransaction16(DWORD idInst, HCONV hConv, 
250                                       DWORD idTransaction)
251 {
252      return DdeAbandonTransaction(idInst, hConv, idTransaction);
253 }
254
255 /*****************************************************************
256  * DdePostAdvise [DDEML.13]
257  */
258 BOOL16 WINAPI DdePostAdvise16(DWORD idInst, HSZ hszTopic, HSZ hszItem)
259 {
260      return (BOOL16)DdePostAdvise(idInst, hszTopic, hszItem);
261 }
262
263 /*****************************************************************
264  *            DdeAddData (DDEML.15)
265  */
266 HDDEDATA WINAPI DdeAddData16(HDDEDATA hData, LPBYTE pSrc, DWORD cb,
267                              DWORD cbOff)
268 {
269      return DdeAddData(hData, pSrc, cb, cbOff);
270 }
271
272 /*****************************************************************
273  * DdeGetData [DDEML.16]
274  */
275 DWORD WINAPI DdeGetData16(
276      HDDEDATA hData,
277      LPBYTE pDst,
278      DWORD cbMax, 
279      DWORD cbOff)
280 {
281      return DdeGetData(hData, pDst, cbMax, cbOff);
282 }
283
284 /*****************************************************************
285  *            DdeAccessData (DDEML.17)
286  */
287 LPBYTE WINAPI DdeAccessData16(HDDEDATA hData, LPDWORD pcbDataSize)
288 {
289     /* FIXME: there's a memory leak here... */
290     return (LPBYTE)MapLS(DdeAccessData(hData, pcbDataSize));
291 }
292
293 /*****************************************************************
294  *            DdeUnaccessData (DDEML.18)
295  */
296 BOOL16 WINAPI DdeUnaccessData16(HDDEDATA hData)
297 {
298     return DdeUnaccessData(hData);
299 }
300
301 /*****************************************************************
302  *            DdeEnableCallback (DDEML.26)
303  */
304 BOOL16 WINAPI DdeEnableCallback16(DWORD idInst, HCONV hConv, UINT16 wCmd)
305 {
306     return DdeEnableCallback(idInst, hConv, wCmd);
307 }
308
309 /*****************************************************************
310  *            DdeNameService  (DDEML.27)
311  */
312 HDDEDATA WINAPI DdeNameService16(DWORD idInst, HSZ hsz1, HSZ hsz2,
313                                  UINT16 afCmd)
314 {
315     return DdeNameService(idInst, hsz1, hsz2, afCmd);
316 }
317
318 /*****************************************************************
319  *            DdeGetLastError  (DDEML.20)
320  */
321 UINT16 WINAPI DdeGetLastError16(DWORD idInst)
322 {
323     return (UINT16)DdeGetLastError(idInst);
324 }
325
326 /*****************************************************************
327  *            DdeCmpStringHandles (DDEML.36)
328  */
329 INT16 WINAPI DdeCmpStringHandles16(HSZ hsz1, HSZ hsz2)
330 {
331     return DdeCmpStringHandles(hsz1, hsz2);
332 }
333
334 /******************************************************************
335  *              DdeQueryConvInfo (DDEML.9)
336  *
337  */
338 UINT16 WINAPI DdeQueryConvInfo16(HCONV hconv, DWORD idTransaction, LPCONVINFO16 lpConvInfo)
339 {
340      FIXME("stub.\n");
341      return 0;
342 }