2003-11-06 00:26:43 +00:00
|
|
|
/*
|
|
|
|
* cap20wxx.c
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define __NO_CAPIUTILS__
|
|
|
|
|
|
|
|
#include "config.h"
|
2005-01-07 15:33:02 +00:00
|
|
|
#include "wine/port.h"
|
2003-11-06 00:26:43 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
2004-02-20 20:19:23 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2003-11-06 00:26:43 +00:00
|
|
|
|
2004-08-17 22:08:43 +00:00
|
|
|
#define __user
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_LINUX_CAPI_H
|
|
|
|
# include <linux/capi.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_CAPI20_H
|
|
|
|
# include <capi20.h>
|
|
|
|
#endif
|
2005-01-07 15:33:02 +00:00
|
|
|
#include "wine/library.h"
|
2003-11-06 00:26:43 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "cap20wxx.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(capi);
|
|
|
|
|
2005-01-07 15:33:02 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
|
|
|
|
|
|
|
#ifndef SONAME_LIBCAPI20
|
|
|
|
#define SONAME_LIBCAPI20 "libcapi20.so"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static unsigned (*pcapi20_register)(unsigned, unsigned, unsigned, unsigned *) = NULL;
|
|
|
|
static unsigned (*pcapi20_release)(unsigned) = NULL;
|
|
|
|
static unsigned (*pcapi20_put_message)(unsigned, unsigned char *) = NULL;
|
|
|
|
static unsigned (*pcapi20_get_message)(unsigned, unsigned char **) = NULL;
|
|
|
|
static unsigned (*pcapi20_waitformessage)(unsigned, struct timeval *) = NULL;
|
|
|
|
static unsigned (*pcapi20_isinstalled)() = NULL;
|
|
|
|
static unsigned (*pcapi20_get_profile)(unsigned, unsigned char *) = NULL;
|
|
|
|
static unsigned char *(*pcapi20_get_manufacturer)(unsigned, unsigned char *) = NULL;
|
|
|
|
static unsigned char *(*pcapi20_get_serial_number)(unsigned, unsigned char *) = NULL;
|
|
|
|
static unsigned char *(*pcapi20_get_version)(unsigned, unsigned char *) = NULL;
|
|
|
|
|
|
|
|
static void load_functions() {
|
|
|
|
void *capi_handle = NULL;
|
|
|
|
|
|
|
|
if (pcapi20_register) /* loaded already */
|
|
|
|
return;
|
|
|
|
capi_handle = wine_dlopen(SONAME_LIBCAPI20, RTLD_NOW, NULL, 0);
|
|
|
|
if(!capi_handle) {
|
|
|
|
FIXME("Wine cannot find the library %s, capi2032.dll not working.\n", SONAME_LIBCAPI20);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(capi_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); return;}
|
|
|
|
LOAD_FUNCPTR(capi20_register);
|
|
|
|
LOAD_FUNCPTR(capi20_release);
|
|
|
|
LOAD_FUNCPTR(capi20_put_message);
|
|
|
|
LOAD_FUNCPTR(capi20_get_message);
|
|
|
|
LOAD_FUNCPTR(capi20_waitformessage);
|
|
|
|
LOAD_FUNCPTR(capi20_isinstalled);
|
|
|
|
LOAD_FUNCPTR(capi20_get_profile);
|
|
|
|
LOAD_FUNCPTR(capi20_get_manufacturer);
|
|
|
|
LOAD_FUNCPTR(capi20_get_serial_number);
|
|
|
|
LOAD_FUNCPTR(capi20_get_version);
|
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2003-11-06 00:26:43 +00:00
|
|
|
/*===========================================================================*\
|
|
|
|
\*===========================================================================*/
|
|
|
|
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD *pApplID) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
|
|
|
unsigned aid = 0;
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_register)
|
|
|
|
return 0x1009;
|
|
|
|
fret = pcapi20_register (maxLogicalConnection, maxBDataBlocks, maxBDataLen, &aid);
|
2003-11-06 00:26:43 +00:00
|
|
|
*pApplID = aid;
|
|
|
|
TRACE ( "(%lx) -> %lx\n", *pApplID, fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
2003-11-13 20:51:49 +00:00
|
|
|
FIXME ( "(), no CAPI4LINUX support compiled into WINE.\n" );
|
2003-11-06 00:26:43 +00:00
|
|
|
return 0x1009;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_RELEASE (DWORD ApplID) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_release)
|
|
|
|
return 0x1109;
|
|
|
|
fret = pcapi20_release (ApplID);
|
2003-11-06 00:26:43 +00:00
|
|
|
TRACE ("(%lx) -> %lx\n", ApplID, fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_put_message)
|
|
|
|
return 0x1109;
|
|
|
|
fret = pcapi20_put_message (ApplID, pCAPIMessage);
|
2003-11-06 00:26:43 +00:00
|
|
|
TRACE ("(%lx) -> %lx\n", ApplID, fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_get_message)
|
|
|
|
return 0x1109;
|
|
|
|
fret = pcapi20_get_message (ApplID, (unsigned char **)ppCAPIMessage);
|
2003-11-06 00:26:43 +00:00
|
|
|
TRACE ("(%lx) -> %lx\n", ApplID, fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_WAIT_FOR_SIGNAL (DWORD ApplID) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
|
|
|
TRACE ("(%lx)\n", ApplID);
|
2005-01-07 15:33:02 +00:00
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_waitformessage)
|
|
|
|
return 0x1109;
|
|
|
|
|
|
|
|
return pcapi20_waitformessage (ApplID, NULL);
|
2003-11-06 00:26:43 +00:00
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_GET_MANUFACTURER (char *SzBuffer) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_get_manufacturer)
|
|
|
|
return 0x1109;
|
|
|
|
|
|
|
|
fret = (pcapi20_get_manufacturer (0, SzBuffer) != 0) ? 0 : 0x1108;
|
2003-11-06 00:26:43 +00:00
|
|
|
if (!strncmp (SzBuffer, "AVM", 3)) {
|
|
|
|
strcpy (SzBuffer, "AVM-GmbH");
|
|
|
|
}
|
|
|
|
TRACE ("(%s) -> %lx\n", SzBuffer, fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
|
|
|
unsigned char version[4 * sizeof (unsigned)];
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_get_version)
|
|
|
|
return 0x1109;
|
|
|
|
fret = (pcapi20_get_version (0, version) != 0) ? 0 : 0x1108;
|
2003-11-06 00:26:43 +00:00
|
|
|
*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 ("(%lx.%lx,%lx.%lx) -> %lx\n", *pCAPIMajor, *pCAPIMinor, *pManufacturerMajor,
|
|
|
|
*pManufacturerMinor, fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_GET_SERIAL_NUMBER (char *SzBuffer) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_get_serial_number)
|
|
|
|
return 0x1109;
|
|
|
|
fret = (pcapi20_get_serial_number (0, SzBuffer) != 0) ? 0 : 0x1108;
|
2003-11-06 00:26:43 +00:00
|
|
|
TRACE ("(%s) -> %lx\n", SzBuffer, fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_GET_PROFILE (PVOID SzBuffer, DWORD CtlrNr) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_get_profile)
|
|
|
|
return 0x1109;
|
|
|
|
|
|
|
|
fret = pcapi20_get_profile (CtlrNr, SzBuffer);
|
2003-11-06 00:26:43 +00:00
|
|
|
TRACE ("(%lx,%x) -> %lx\n", CtlrNr, *(unsigned short *)SzBuffer, fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_INSTALLED (void) {
|
2003-11-06 00:26:43 +00:00
|
|
|
#ifdef HAVE_CAPI4LINUX
|
2005-01-07 15:33:02 +00:00
|
|
|
DWORD fret;
|
|
|
|
|
|
|
|
load_functions();
|
|
|
|
if (!pcapi20_isinstalled)
|
|
|
|
return 0x1109;
|
|
|
|
fret = pcapi20_isinstalled();
|
2003-11-06 00:26:43 +00:00
|
|
|
TRACE ("() -> %lx\n", fret);
|
|
|
|
return fret;
|
|
|
|
#else
|
|
|
|
return 0x1109;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2004-02-20 20:19:23 +00:00
|
|
|
DWORD WINAPI wrapCAPI_MANUFACTURER (DWORD Class, DWORD Function, DWORD Ctlr, PVOID pParams, DWORD ParamsLen) {
|
2003-11-06 00:26:43 +00:00
|
|
|
FIXME ("(), not supported!\n");
|
|
|
|
return 0x1109;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
\*---------------------------------------------------------------------------*/
|