4 * Copyright 2007 Christian Eggers
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
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ctapi32
);
33 #define FALLBACK_LIBCTAPI "libctapi.so"
35 #define CTAPI_CALL( func, params ) WINE_UNIX_CALL( unix_ ## func, params )
38 static BOOL
load_functions(void) {
39 char soname
[MAX_PATH
] = FALLBACK_LIBCTAPI
;
43 /* Try to get name of low level library from registry */
44 /* @@ Wine registry key: HKCU\Software\Wine\ctapi32 */
45 result
= RegOpenKeyExW(HKEY_CURRENT_USER
, L
"Software\\Wine\\ctapi32", 0, KEY_READ
, &key_handle
);
46 if (result
== ERROR_SUCCESS
) {
48 WCHAR buffer_w
[MAX_PATH
];
50 size
= sizeof(buffer_w
) - sizeof(WCHAR
); /* Leave space for null termination */
51 result
= RegQueryValueExW(key_handle
, L
"library", NULL
, &type
, (LPBYTE
)buffer_w
, &size
);
52 if ((result
== ERROR_SUCCESS
) && (type
== REG_SZ
)) {
53 /* Null termination */
54 buffer_w
[size
/ sizeof(WCHAR
)] = '\0';
55 WideCharToMultiByte(CP_UNIXCP
, 0, buffer_w
, -1, soname
, sizeof(soname
), NULL
, NULL
);
57 RegCloseKey(key_handle
);
60 TRACE("Loading library '%s'\n", soname
);
61 if (!CTAPI_CALL( attach
, soname
)) return TRUE
;
63 MESSAGE("Wine cannot find any usable hardware library, ctapi32.dll not working.\n");
64 MESSAGE("Please create the key \"HKEY_CURRENT_USER\\Software\\Wine\\ctapi32\" in your registry\n");
65 MESSAGE("and set the value \"library\" to your library name (e.g. \"libctapi-cyberjack.so.1\" or \"/usr/lib/readers/libctapi.so\").\n");
70 * ct-API specific functions
73 IS8 WINAPI
CT_init(IU16 ctn
, IU16 pn
)
75 struct ct_init_params params
= { ctn
, pn
};
77 return CTAPI_CALL( ct_init
, ¶ms
);
80 IS8 WINAPI
CT_data(IU16 ctn
, IU8
*dad
, IU8
*sad
, IU16 lenc
, IU8
*command
, IU16
*lenr
, IU8
*response
)
82 struct ct_data_params params
= { ctn
, dad
, sad
, lenc
, command
, lenr
, response
};
84 return CTAPI_CALL( ct_data
, ¶ms
);
87 IS8 WINAPI
CT_close(IU16 ctn
)
89 struct ct_close_params params
= { ctn
};
91 return CTAPI_CALL( ct_close
, ¶ms
);
97 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
99 TRACE("%p,%lx,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
103 case DLL_PROCESS_ATTACH
:
104 DisableThreadLibraryCalls(hinstDLL
);
105 if (__wine_init_unix_call())
107 if (!load_functions())
110 case DLL_PROCESS_DETACH
:
111 if (lpvReserved
) break;
112 CTAPI_CALL( detach
, NULL
);