wined3d: Add shader_get_param() fn, which processes address tokens.
[wine] / dlls / capi2032 / cap20wxx.c
1 /*
2  * cap20wxx.c
3  *
4  * Copyright 2002-2003 AVM Computersysteme Vertriebs GmbH
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #define __NO_CAPIUTILS__
23
24 #include "config.h"
25 #include "wine/port.h"
26
27 #include <stdio.h>
28 #include <sys/types.h>
29 #ifdef HAVE_UNISTD_H
30 # include <unistd.h>
31 #endif
32
33 #define __user
34 #ifdef HAVE_LINUX_CAPI_H
35 # include <linux/capi.h>
36 #endif
37 #ifdef HAVE_CAPI20_H
38 # include <capi20.h>
39 #endif
40 #include "wine/library.h"
41 #include "wine/debug.h"
42 #include "cap20wxx.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(capi);
45
46 #ifdef HAVE_CAPI4LINUX
47
48 #ifndef SONAME_LIBCAPI20
49 #define SONAME_LIBCAPI20 "libcapi20.so"
50 #endif
51
52 static unsigned (*pcapi20_register)(unsigned, unsigned, unsigned, unsigned *) = NULL;
53 static unsigned (*pcapi20_release)(unsigned) = NULL;
54 static unsigned (*pcapi20_put_message)(unsigned, unsigned char *) = NULL;
55 static unsigned (*pcapi20_get_message)(unsigned, unsigned char **) = NULL;
56 static unsigned (*pcapi20_waitformessage)(unsigned, struct timeval *) = NULL;
57 static unsigned (*pcapi20_isinstalled)() = NULL;
58 static unsigned (*pcapi20_get_profile)(unsigned, unsigned char *) = NULL;
59 static unsigned char *(*pcapi20_get_manufacturer)(unsigned, unsigned char *) = NULL;
60 static unsigned char *(*pcapi20_get_serial_number)(unsigned, unsigned char *) = NULL;
61 static unsigned char *(*pcapi20_get_version)(unsigned, unsigned char *) = NULL;
62
63 static void load_functions() {
64     void *capi_handle = NULL;
65
66     if (pcapi20_register) /* loaded already */
67         return;
68     capi_handle = wine_dlopen(SONAME_LIBCAPI20, RTLD_NOW, NULL, 0);
69     if(!capi_handle) {
70         FIXME("Wine cannot find the library %s, capi2032.dll not working.\n", SONAME_LIBCAPI20);
71         return;
72     }
73 #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(capi_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); return;}
74 LOAD_FUNCPTR(capi20_register);
75 LOAD_FUNCPTR(capi20_release);
76 LOAD_FUNCPTR(capi20_put_message);
77 LOAD_FUNCPTR(capi20_get_message);
78 LOAD_FUNCPTR(capi20_waitformessage);
79 LOAD_FUNCPTR(capi20_isinstalled);
80 LOAD_FUNCPTR(capi20_get_profile);
81 LOAD_FUNCPTR(capi20_get_manufacturer);
82 LOAD_FUNCPTR(capi20_get_serial_number);
83 LOAD_FUNCPTR(capi20_get_version);
84 #undef LOAD_FUNCPTR
85 }
86
87 #endif
88
89 /*===========================================================================*\
90 \*===========================================================================*/
91
92 DWORD WINAPI wrapCAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD *pApplID) {
93 #ifdef HAVE_CAPI4LINUX
94     unsigned aid = 0;
95     DWORD fret;
96
97     load_functions();
98     if (!pcapi20_register)
99         return 0x1009;
100     fret = pcapi20_register (maxLogicalConnection, maxBDataBlocks, maxBDataLen, &aid);
101     *pApplID   = aid;
102     TRACE ( "(%lx) -> %lx\n", *pApplID, fret);
103     return fret;
104 #else
105     FIXME ( "(), no CAPI4LINUX support compiled into WINE.\n" );
106     return 0x1009;
107 #endif
108 }
109
110 /*---------------------------------------------------------------------------*\
111 \*---------------------------------------------------------------------------*/
112 DWORD WINAPI wrapCAPI_RELEASE (DWORD ApplID) {
113 #ifdef HAVE_CAPI4LINUX
114     DWORD fret;
115
116     load_functions();
117     if (!pcapi20_release)
118         return 0x1109;
119     fret = pcapi20_release (ApplID);
120     TRACE ("(%lx) -> %lx\n", ApplID, fret);
121     return fret;
122 #else
123     return 0x1109;
124 #endif
125 }
126
127 /*---------------------------------------------------------------------------*\
128 \*---------------------------------------------------------------------------*/
129 DWORD WINAPI wrapCAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage) {
130 #ifdef HAVE_CAPI4LINUX
131     DWORD fret;
132
133     load_functions();
134     if (!pcapi20_put_message)
135         return 0x1109;
136     fret = pcapi20_put_message (ApplID, pCAPIMessage);
137     TRACE ("(%lx) -> %lx\n", ApplID, fret);
138     return fret;
139 #else
140     return 0x1109;
141 #endif
142 }
143
144 /*---------------------------------------------------------------------------*\
145 \*---------------------------------------------------------------------------*/
146 DWORD WINAPI wrapCAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage) {
147 #ifdef HAVE_CAPI4LINUX
148     DWORD fret;
149
150     load_functions();
151     if (!pcapi20_get_message)
152         return 0x1109;
153     fret = pcapi20_get_message (ApplID, (unsigned char **)ppCAPIMessage);
154     TRACE ("(%lx) -> %lx\n", ApplID, fret);
155     return fret;
156 #else
157     return 0x1109;
158 #endif
159 }
160
161 /*---------------------------------------------------------------------------*\
162 \*---------------------------------------------------------------------------*/
163 DWORD WINAPI wrapCAPI_WAIT_FOR_SIGNAL (DWORD ApplID) {
164 #ifdef HAVE_CAPI4LINUX
165     TRACE ("(%lx)\n", ApplID);
166
167     load_functions();
168     if (!pcapi20_waitformessage)
169         return 0x1109;
170
171     return pcapi20_waitformessage (ApplID, NULL);
172 #else
173     return 0x1109;
174 #endif
175 }
176
177 /*---------------------------------------------------------------------------*\
178 \*---------------------------------------------------------------------------*/
179 DWORD WINAPI wrapCAPI_GET_MANUFACTURER (char *SzBuffer) {
180 #ifdef HAVE_CAPI4LINUX
181     DWORD fret;
182
183     load_functions();
184     if (!pcapi20_get_manufacturer)
185         return 0x1109;
186
187     fret = (pcapi20_get_manufacturer (0, (unsigned char *) SzBuffer) != 0) ? 0 : 0x1108;
188     if (!strncmp (SzBuffer, "AVM", 3)) {
189         strcpy (SzBuffer, "AVM-GmbH");
190     }
191     TRACE ("(%s) -> %lx\n", SzBuffer, fret);
192     return fret;
193 #else
194     return 0x1109;
195 #endif
196 }
197
198 /*---------------------------------------------------------------------------*\
199 \*---------------------------------------------------------------------------*/
200 DWORD WINAPI wrapCAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor) {
201 #ifdef HAVE_CAPI4LINUX
202     unsigned char version[4 * sizeof (unsigned)];
203     DWORD fret;
204
205     load_functions();
206     if (!pcapi20_get_version)
207         return 0x1109;
208     fret = (pcapi20_get_version (0, version) != 0) ? 0 : 0x1108;
209     *pCAPIMajor         = *(unsigned *)(version + 0 * sizeof (unsigned));
210     *pCAPIMinor         = *(unsigned *)(version + 1 * sizeof (unsigned));
211     *pManufacturerMajor = *(unsigned *)(version + 2 * sizeof (unsigned));
212     *pManufacturerMinor = *(unsigned *)(version + 3 * sizeof (unsigned));
213     TRACE ("(%lx.%lx,%lx.%lx) -> %lx\n", *pCAPIMajor, *pCAPIMinor, *pManufacturerMajor,
214              *pManufacturerMinor, fret);
215     return fret;
216 #else
217     return 0x1109;
218 #endif
219 }
220
221 /*---------------------------------------------------------------------------*\
222 \*---------------------------------------------------------------------------*/
223 DWORD WINAPI wrapCAPI_GET_SERIAL_NUMBER (char *SzBuffer) {
224 #ifdef HAVE_CAPI4LINUX
225     DWORD fret;
226
227     load_functions();
228     if (!pcapi20_get_serial_number)
229         return 0x1109;
230     fret = (pcapi20_get_serial_number (0, (unsigned char*) SzBuffer) != 0) ? 0 : 0x1108;
231     TRACE ("(%s) -> %lx\n", SzBuffer, fret);
232     return fret;
233 #else
234     return 0x1109;
235 #endif
236 }
237
238 /*---------------------------------------------------------------------------*\
239 \*---------------------------------------------------------------------------*/
240 DWORD WINAPI wrapCAPI_GET_PROFILE (PVOID SzBuffer, DWORD CtlrNr) {
241 #ifdef HAVE_CAPI4LINUX
242     DWORD fret;
243
244     load_functions();
245     if (!pcapi20_get_profile)
246         return 0x1109;
247
248     fret = pcapi20_get_profile (CtlrNr, SzBuffer);
249     TRACE ("(%lx,%x) -> %lx\n", CtlrNr, *(unsigned short *)SzBuffer, fret);
250     return fret;
251 #else
252     return 0x1109;
253 #endif
254 }
255
256 /*---------------------------------------------------------------------------*\
257 \*---------------------------------------------------------------------------*/
258 DWORD WINAPI wrapCAPI_INSTALLED (void) {
259 #ifdef HAVE_CAPI4LINUX
260     DWORD fret;
261
262     load_functions();
263     if (!pcapi20_isinstalled)
264         return 0x1109;
265     fret = pcapi20_isinstalled();
266     TRACE ("() -> %lx\n", fret);
267     return fret;
268 #else
269     return 0x1109;
270 #endif
271 }
272
273 /*---------------------------------------------------------------------------*\
274 \*---------------------------------------------------------------------------*/
275 DWORD WINAPI wrapCAPI_MANUFACTURER (DWORD Class, DWORD Function, DWORD Ctlr, PVOID pParams, DWORD ParamsLen) {
276     FIXME ("(), not supported!\n");
277     return 0x1109;
278 }
279
280 /*---------------------------------------------------------------------------*\
281 \*---------------------------------------------------------------------------*/