Commit 85b063af authored by Alexandre Julliard's avatar Alexandre Julliard

capi2032: Move libcapi20.so interface to a separate Unix library.

parent eab0f52e
...@@ -3,6 +3,6 @@ IMPORTLIB = capi2032 ...@@ -3,6 +3,6 @@ IMPORTLIB = capi2032
EXTRALIBS = $(CAPI20_LIBS) EXTRALIBS = $(CAPI20_LIBS)
EXTRAINCL = $(CAPI20_CFLAGS) EXTRAINCL = $(CAPI20_CFLAGS)
EXTRADLLFLAGS = -mcygwin C_SRCS = \
cap20wxx.c \
C_SRCS = cap20wxx.c unixlib.c
...@@ -21,83 +21,93 @@ ...@@ -21,83 +21,93 @@
#define __NO_CAPIUTILS__ #define __NO_CAPIUTILS__
#include "config.h"
#include "wine/port.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> #include "unixlib.h"
#endif
#define __user
#ifdef HAVE_LINUX_CAPI_H
# include <linux/capi.h>
#endif
#ifdef HAVE_CAPI20_H
# include <capi20.h>
#endif
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(capi); WINE_DEFAULT_DEBUG_CHANNEL(capi);
/*===========================================================================*\ static unixlib_handle_t capi_handle;
#define CAPI_CALL( func, params ) __wine_unix_call( capi_handle, unix_ ## func, params )
BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, LPVOID reserved )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( instance );
return !NtQueryVirtualMemory( GetCurrentProcess(), instance, MemoryWineUnixFuncs,
&capi_handle, sizeof(capi_handle), NULL );
}
return TRUE;
}
/*===========================================================================* \
\*===========================================================================*/ \*===========================================================================*/
DWORD WINAPI wrapCAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD *pApplID) { DWORD WINAPI CAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD *pApplID) {
unsigned aid = 0; struct register_params params = { MessageBufferSize, maxLogicalConnection,
maxBDataBlocks, maxBDataLen, pApplID };
DWORD fret; DWORD fret;
fret = capi20_register (maxLogicalConnection, maxBDataBlocks, maxBDataLen, &aid); fret = CAPI_CALL( register, &params );
*pApplID = aid;
TRACE ( "(%x) -> %x\n", *pApplID, fret); TRACE ( "(%x) -> %x\n", *pApplID, fret);
return fret; return fret;
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_RELEASE (DWORD ApplID) { DWORD WINAPI CAPI_RELEASE (DWORD ApplID) {
struct release_params params = { ApplID };
DWORD fret; DWORD fret;
fret = capi20_release (ApplID); fret = CAPI_CALL( release, &params );
TRACE ("(%x) -> %x\n", ApplID, fret); TRACE ("(%x) -> %x\n", ApplID, fret);
return fret; return fret;
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage) { DWORD WINAPI CAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage) {
struct put_message_params params = { ApplID, pCAPIMessage };
DWORD fret; DWORD fret;
fret = capi20_put_message (ApplID, pCAPIMessage); fret = CAPI_CALL( put_message, &params );
TRACE ("(%x) -> %x\n", ApplID, fret); TRACE ("(%x) -> %x\n", ApplID, fret);
return fret; return fret;
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage) { DWORD WINAPI CAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage) {
struct get_message_params params = { ApplID, ppCAPIMessage };
DWORD fret; DWORD fret;
fret = capi20_get_message (ApplID, (unsigned char **)ppCAPIMessage); fret = CAPI_CALL( get_message, &params );
TRACE ("(%x) -> %x\n", ApplID, fret); TRACE ("(%x) -> %x\n", ApplID, fret);
return fret; return fret;
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_WAIT_FOR_SIGNAL (DWORD ApplID) { DWORD WINAPI CAPI_WAIT_FOR_SIGNAL (DWORD ApplID) {
struct waitformessage_params params = { ApplID };
TRACE ("(%x)\n", ApplID); TRACE ("(%x)\n", ApplID);
return capi20_waitformessage (ApplID, NULL); return CAPI_CALL( waitformessage, &params );
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_MANUFACTURER (char *SzBuffer) { DWORD WINAPI CAPI_GET_MANUFACTURER (char *SzBuffer) {
struct get_manufacturer_params params = { SzBuffer };
DWORD fret; DWORD fret;
fret = (capi20_get_manufacturer (0, (unsigned char *) SzBuffer) != 0) ? 0 : 0x1108; fret = CAPI_CALL( get_manufacturer, &params );
if (!strncmp (SzBuffer, "AVM", 3)) { if (!strncmp (SzBuffer, "AVM", 3)) {
strcpy (SzBuffer, "AVM-GmbH"); strcpy (SzBuffer, "AVM-GmbH");
} }
...@@ -107,15 +117,11 @@ DWORD WINAPI wrapCAPI_GET_MANUFACTURER (char *SzBuffer) { ...@@ -107,15 +117,11 @@ DWORD WINAPI wrapCAPI_GET_MANUFACTURER (char *SzBuffer) {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor) { DWORD WINAPI CAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor) {
unsigned char version[4 * sizeof (unsigned)]; struct get_version_params params = { pCAPIMajor, pCAPIMinor, pManufacturerMajor, pManufacturerMinor };
DWORD fret; DWORD fret;
fret = (capi20_get_version (0, version) != 0) ? 0 : 0x1108; fret = CAPI_CALL( get_version, &params );
*pCAPIMajor = *(unsigned *)(version + 0 * sizeof (unsigned));
*pCAPIMinor = *(unsigned *)(version + 1 * sizeof (unsigned));
*pManufacturerMajor = *(unsigned *)(version + 2 * sizeof (unsigned));
*pManufacturerMinor = *(unsigned *)(version + 3 * sizeof (unsigned));
TRACE ("(%x.%x,%x.%x) -> %x\n", *pCAPIMajor, *pCAPIMinor, *pManufacturerMajor, TRACE ("(%x.%x,%x.%x) -> %x\n", *pCAPIMajor, *pCAPIMinor, *pManufacturerMajor,
*pManufacturerMinor, fret); *pManufacturerMinor, fret);
return fret; return fret;
...@@ -123,37 +129,39 @@ DWORD WINAPI wrapCAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD * ...@@ -123,37 +129,39 @@ DWORD WINAPI wrapCAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_SERIAL_NUMBER (char *SzBuffer) { DWORD WINAPI CAPI_GET_SERIAL_NUMBER (char *SzBuffer) {
struct get_serial_number_params params = { SzBuffer };
DWORD fret; DWORD fret;
fret = (capi20_get_serial_number (0, (unsigned char*) SzBuffer) != 0) ? 0 : 0x1108; fret = CAPI_CALL( get_serial_number, &params );
TRACE ("(%s) -> %x\n", SzBuffer, fret); TRACE ("(%s) -> %x\n", SzBuffer, fret);
return fret; return fret;
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_PROFILE (PVOID SzBuffer, DWORD CtlrNr) { DWORD WINAPI CAPI_GET_PROFILE (PVOID SzBuffer, DWORD CtlrNr) {
struct get_profile_params params = { SzBuffer, CtlrNr };
DWORD fret; DWORD fret;
fret = capi20_get_profile (CtlrNr, SzBuffer); fret = CAPI_CALL( get_profile, &params );
TRACE ("(%x,%x) -> %x\n", CtlrNr, *(unsigned short *)SzBuffer, fret); TRACE ("(%x,%x) -> %x\n", CtlrNr, *(unsigned short *)SzBuffer, fret);
return fret; return fret;
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_INSTALLED (void) { DWORD WINAPI CAPI_INSTALLED (void) {
DWORD fret; DWORD fret;
fret = capi20_isinstalled(); fret = CAPI_CALL( isinstalled, NULL );
TRACE ("() -> %x\n", fret); TRACE ("() -> %x\n", fret);
return fret; return fret;
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_MANUFACTURER (DWORD Class, DWORD Function, DWORD Ctlr, PVOID pParams, DWORD ParamsLen) { DWORD WINAPI CAPI_MANUFACTURER (DWORD Class, DWORD Function, DWORD Ctlr, PVOID pParams, DWORD ParamsLen) {
FIXME ("(), not supported!\n"); FIXME ("(), not supported!\n");
return 0x1109; return 0x1109;
} }
......
1 stdcall CAPI_REGISTER (long long long long ptr) wrapCAPI_REGISTER 1 stdcall CAPI_REGISTER(long long long long ptr)
2 stdcall CAPI_RELEASE (long) wrapCAPI_RELEASE 2 stdcall CAPI_RELEASE(long)
3 stdcall CAPI_PUT_MESSAGE (long ptr) wrapCAPI_PUT_MESSAGE 3 stdcall CAPI_PUT_MESSAGE(long ptr)
4 stdcall CAPI_GET_MESSAGE (long ptr) wrapCAPI_GET_MESSAGE 4 stdcall CAPI_GET_MESSAGE(long ptr)
5 stdcall CAPI_WAIT_FOR_SIGNAL (long) wrapCAPI_WAIT_FOR_SIGNAL 5 stdcall CAPI_WAIT_FOR_SIGNAL(long)
6 stdcall CAPI_GET_MANUFACTURER (str) wrapCAPI_GET_MANUFACTURER 6 stdcall CAPI_GET_MANUFACTURER(ptr)
7 stdcall CAPI_GET_VERSION (ptr ptr ptr ptr) wrapCAPI_GET_VERSION 7 stdcall CAPI_GET_VERSION(ptr ptr ptr ptr)
8 stdcall CAPI_GET_SERIAL_NUMBER (str) wrapCAPI_GET_SERIAL_NUMBER 8 stdcall CAPI_GET_SERIAL_NUMBER(ptr)
9 stdcall CAPI_GET_PROFILE (ptr long) wrapCAPI_GET_PROFILE 9 stdcall CAPI_GET_PROFILE(ptr long)
10 stdcall CAPI_INSTALLED () wrapCAPI_INSTALLED 10 stdcall CAPI_INSTALLED()
99 stdcall CAPI_MANUFACTURER (long long long ptr long) wrapCAPI_MANUFACTURER 99 stdcall CAPI_MANUFACTURER(long long long ptr long)
/*
* capi20 Unix library
*
* Copyright 2002-2003 AVM Computersysteme Vertriebs GmbH
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#if 0
#pragma makedep unix
#endif
#define __NO_CAPIUTILS__
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#define __user
#ifdef HAVE_LINUX_CAPI_H
# include <linux/capi.h>
#endif
#ifdef HAVE_CAPI20_H
# include <capi20.h>
#endif
#include "unixlib.h"
static NTSTATUS capi_register( void *args )
{
struct register_params *params = args;
return capi20_register( params->maxLogicalConnection, params->maxBDataBlocks, params->maxBDataLen,
(unsigned int *)params->pApplID );
}
static NTSTATUS capi_release( void *args )
{
struct release_params *params = args;
return capi20_release( params->ApplID );
}
static NTSTATUS capi_put_message( void *args )
{
struct put_message_params *params = args;
return capi20_put_message( params->ApplID, params->pCAPIMessage );
}
static NTSTATUS capi_get_message( void *args )
{
struct get_message_params *params = args;
/* FIXME: allocate buffers based on capi_register sizes and copy returned data */
return capi20_get_message( params->ApplID, (unsigned char **)params->ppCAPIMessage );
}
static NTSTATUS capi_waitformessage( void *args )
{
struct waitformessage_params *params = args;
return capi20_waitformessage( params->ApplID, NULL );
}
static NTSTATUS capi_get_manufacturer( void *args )
{
struct get_manufacturer_params *params = args;
return capi20_get_manufacturer( 0, (unsigned char *)params->SzBuffer ) ? 0 : 0x1108;
}
static NTSTATUS capi_get_version( void *args )
{
struct get_version_params *params = args;
unsigned int version[4];
if (!capi20_get_version( 0, (unsigned char *)version )) return 0x1108;
*params->pCAPIMajor = version[0];
*params->pCAPIMinor = version[1];
*params->pManufacturerMajor = version[2];
*params->pManufacturerMinor = version[3];
return 0;
}
static NTSTATUS capi_get_serial_number( void *args )
{
struct get_serial_number_params *params = args;
return capi20_get_serial_number( 0, (unsigned char*)params->SzBuffer ) ? 0 : 0x1108;
}
static NTSTATUS capi_get_profile( void *args )
{
struct get_profile_params *params = args;
return capi20_get_profile( params->CtlrNr, params->SzBuffer );
}
static NTSTATUS capi_isinstalled( void *args )
{
return capi20_isinstalled();
}
unixlib_entry_t __wine_unix_call_funcs[] =
{
capi_register,
capi_release,
capi_put_message,
capi_get_message,
capi_waitformessage,
capi_get_manufacturer,
capi_get_version,
capi_get_serial_number,
capi_get_profile,
capi_isinstalled,
};
/*
* capi20 Unix library
*
* Copyright 2021 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "wine/unixlib.h"
struct register_params
{
DWORD MessageBufferSize;
DWORD maxLogicalConnection;
DWORD maxBDataBlocks;
DWORD maxBDataLen;
DWORD *pApplID;
};
struct release_params
{
DWORD ApplID;
};
struct put_message_params
{
DWORD ApplID;
PVOID pCAPIMessage;
};
struct get_message_params
{
DWORD ApplID;
PVOID *ppCAPIMessage;
};
struct waitformessage_params
{
DWORD ApplID;
};
struct get_manufacturer_params
{
char *SzBuffer;
};
struct get_version_params
{
DWORD *pCAPIMajor;
DWORD *pCAPIMinor;
DWORD *pManufacturerMajor;
DWORD *pManufacturerMinor;
};
struct get_serial_number_params
{
char *SzBuffer;
};
struct get_profile_params
{
PVOID SzBuffer;
DWORD CtlrNr;
};
enum capi20_funcs
{
unix_register,
unix_release,
unix_put_message,
unix_get_message,
unix_waitformessage,
unix_get_manufacturer,
unix_get_version,
unix_get_serial_number,
unix_get_profile,
unix_isinstalled,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment