ntdll: Get rid of the rebuild_nt_name() helper.
[wine.git] / dlls / capi2032 / cap20wxx.c
blob6f22a020f3b8c057a57d876410cd18dd49ba277e
1 /*
2 * cap20wxx.c
4 * Copyright 2002-2003 AVM Computersysteme Vertriebs GmbH
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define __NO_CAPIUTILS__
24 #include "config.h"
25 #include "wine/port.h"
27 #include <stdio.h>
28 #include <sys/types.h>
29 #ifdef HAVE_UNISTD_H
30 # include <unistd.h>
31 #endif
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/debug.h"
41 #include "cap20wxx.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(capi);
45 #ifdef SONAME_LIBCAPI20
47 static unsigned (*pcapi20_register)(unsigned, unsigned, unsigned, unsigned *) = NULL;
48 static unsigned (*pcapi20_release)(unsigned) = NULL;
49 static unsigned (*pcapi20_put_message)(unsigned, unsigned char *) = NULL;
50 static unsigned (*pcapi20_get_message)(unsigned, unsigned char **) = NULL;
51 static unsigned (*pcapi20_waitformessage)(unsigned, struct timeval *) = NULL;
52 static unsigned (*pcapi20_isinstalled)(void) = NULL;
53 static unsigned (*pcapi20_get_profile)(unsigned, unsigned char *) = NULL;
54 static unsigned char *(*pcapi20_get_manufacturer)(unsigned, unsigned char *) = NULL;
55 static unsigned char *(*pcapi20_get_serial_number)(unsigned, unsigned char *) = NULL;
56 static unsigned char *(*pcapi20_get_version)(unsigned, unsigned char *) = NULL;
58 static void load_functions(void) {
59 void *capi_handle = NULL;
61 if (pcapi20_register) /* loaded already */
62 return;
63 capi_handle = dlopen(SONAME_LIBCAPI20, RTLD_NOW);
64 if(!capi_handle) {
65 FIXME("Wine cannot find the library %s, capi2032.dll not working.\n", SONAME_LIBCAPI20);
66 return;
68 #define LOAD_FUNCPTR(f) if((p##f = dlsym(capi_handle, #f)) == NULL){WARN("Can't find symbol %s\n", #f); return;}
69 LOAD_FUNCPTR(capi20_register);
70 LOAD_FUNCPTR(capi20_release);
71 LOAD_FUNCPTR(capi20_put_message);
72 LOAD_FUNCPTR(capi20_get_message);
73 LOAD_FUNCPTR(capi20_waitformessage);
74 LOAD_FUNCPTR(capi20_isinstalled);
75 LOAD_FUNCPTR(capi20_get_profile);
76 LOAD_FUNCPTR(capi20_get_manufacturer);
77 LOAD_FUNCPTR(capi20_get_serial_number);
78 LOAD_FUNCPTR(capi20_get_version);
79 #undef LOAD_FUNCPTR
82 #endif
84 /*===========================================================================*\
85 \*===========================================================================*/
87 DWORD WINAPI wrapCAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD *pApplID) {
88 #ifdef SONAME_LIBCAPI20
89 unsigned aid = 0;
90 DWORD fret;
92 load_functions();
93 if (!pcapi20_register)
94 return 0x1009;
95 fret = pcapi20_register (maxLogicalConnection, maxBDataBlocks, maxBDataLen, &aid);
96 *pApplID = aid;
97 TRACE ( "(%x) -> %x\n", *pApplID, fret);
98 return fret;
99 #else
100 FIXME ( "(), no CAPI4LINUX support compiled into WINE.\n" );
101 return 0x1009;
102 #endif
105 /*---------------------------------------------------------------------------*\
106 \*---------------------------------------------------------------------------*/
107 DWORD WINAPI wrapCAPI_RELEASE (DWORD ApplID) {
108 #ifdef SONAME_LIBCAPI20
109 DWORD fret;
111 load_functions();
112 if (!pcapi20_release)
113 return 0x1109;
114 fret = pcapi20_release (ApplID);
115 TRACE ("(%x) -> %x\n", ApplID, fret);
116 return fret;
117 #else
118 return 0x1109;
119 #endif
122 /*---------------------------------------------------------------------------*\
123 \*---------------------------------------------------------------------------*/
124 DWORD WINAPI wrapCAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage) {
125 #ifdef SONAME_LIBCAPI20
126 DWORD fret;
128 load_functions();
129 if (!pcapi20_put_message)
130 return 0x1109;
131 fret = pcapi20_put_message (ApplID, pCAPIMessage);
132 TRACE ("(%x) -> %x\n", ApplID, fret);
133 return fret;
134 #else
135 return 0x1109;
136 #endif
139 /*---------------------------------------------------------------------------*\
140 \*---------------------------------------------------------------------------*/
141 DWORD WINAPI wrapCAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage) {
142 #ifdef SONAME_LIBCAPI20
143 DWORD fret;
145 load_functions();
146 if (!pcapi20_get_message)
147 return 0x1109;
148 fret = pcapi20_get_message (ApplID, (unsigned char **)ppCAPIMessage);
149 TRACE ("(%x) -> %x\n", ApplID, fret);
150 return fret;
151 #else
152 return 0x1109;
153 #endif
156 /*---------------------------------------------------------------------------*\
157 \*---------------------------------------------------------------------------*/
158 DWORD WINAPI wrapCAPI_WAIT_FOR_SIGNAL (DWORD ApplID) {
159 #ifdef SONAME_LIBCAPI20
160 TRACE ("(%x)\n", ApplID);
162 load_functions();
163 if (!pcapi20_waitformessage)
164 return 0x1109;
166 return pcapi20_waitformessage (ApplID, NULL);
167 #else
168 return 0x1109;
169 #endif
172 /*---------------------------------------------------------------------------*\
173 \*---------------------------------------------------------------------------*/
174 DWORD WINAPI wrapCAPI_GET_MANUFACTURER (char *SzBuffer) {
175 #ifdef SONAME_LIBCAPI20
176 DWORD fret;
178 load_functions();
179 if (!pcapi20_get_manufacturer)
180 return 0x1109;
182 fret = (pcapi20_get_manufacturer (0, (unsigned char *) SzBuffer) != 0) ? 0 : 0x1108;
183 if (!strncmp (SzBuffer, "AVM", 3)) {
184 strcpy (SzBuffer, "AVM-GmbH");
186 TRACE ("(%s) -> %x\n", SzBuffer, fret);
187 return fret;
188 #else
189 return 0x1109;
190 #endif
193 /*---------------------------------------------------------------------------*\
194 \*---------------------------------------------------------------------------*/
195 DWORD WINAPI wrapCAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor) {
196 #ifdef SONAME_LIBCAPI20
197 unsigned char version[4 * sizeof (unsigned)];
198 DWORD fret;
200 load_functions();
201 if (!pcapi20_get_version)
202 return 0x1109;
203 fret = (pcapi20_get_version (0, version) != 0) ? 0 : 0x1108;
204 *pCAPIMajor = *(unsigned *)(version + 0 * sizeof (unsigned));
205 *pCAPIMinor = *(unsigned *)(version + 1 * sizeof (unsigned));
206 *pManufacturerMajor = *(unsigned *)(version + 2 * sizeof (unsigned));
207 *pManufacturerMinor = *(unsigned *)(version + 3 * sizeof (unsigned));
208 TRACE ("(%x.%x,%x.%x) -> %x\n", *pCAPIMajor, *pCAPIMinor, *pManufacturerMajor,
209 *pManufacturerMinor, fret);
210 return fret;
211 #else
212 return 0x1109;
213 #endif
216 /*---------------------------------------------------------------------------*\
217 \*---------------------------------------------------------------------------*/
218 DWORD WINAPI wrapCAPI_GET_SERIAL_NUMBER (char *SzBuffer) {
219 #ifdef SONAME_LIBCAPI20
220 DWORD fret;
222 load_functions();
223 if (!pcapi20_get_serial_number)
224 return 0x1109;
225 fret = (pcapi20_get_serial_number (0, (unsigned char*) SzBuffer) != 0) ? 0 : 0x1108;
226 TRACE ("(%s) -> %x\n", SzBuffer, fret);
227 return fret;
228 #else
229 return 0x1109;
230 #endif
233 /*---------------------------------------------------------------------------*\
234 \*---------------------------------------------------------------------------*/
235 DWORD WINAPI wrapCAPI_GET_PROFILE (PVOID SzBuffer, DWORD CtlrNr) {
236 #ifdef SONAME_LIBCAPI20
237 DWORD fret;
239 load_functions();
240 if (!pcapi20_get_profile)
241 return 0x1109;
243 fret = pcapi20_get_profile (CtlrNr, SzBuffer);
244 TRACE ("(%x,%x) -> %x\n", CtlrNr, *(unsigned short *)SzBuffer, fret);
245 return fret;
246 #else
247 return 0x1109;
248 #endif
251 /*---------------------------------------------------------------------------*\
252 \*---------------------------------------------------------------------------*/
253 DWORD WINAPI wrapCAPI_INSTALLED (void) {
254 #ifdef SONAME_LIBCAPI20
255 DWORD fret;
257 load_functions();
258 if (!pcapi20_isinstalled)
259 return 0x1109;
260 fret = pcapi20_isinstalled();
261 TRACE ("() -> %x\n", fret);
262 return fret;
263 #else
264 return 0x1109;
265 #endif
268 /*---------------------------------------------------------------------------*\
269 \*---------------------------------------------------------------------------*/
270 DWORD WINAPI wrapCAPI_MANUFACTURER (DWORD Class, DWORD Function, DWORD Ctlr, PVOID pParams, DWORD ParamsLen) {
271 FIXME ("(), not supported!\n");
272 return 0x1109;
275 /*---------------------------------------------------------------------------*\
276 \*---------------------------------------------------------------------------*/