Blame winpr/libwinpr/smartcard/smartcard_pcsc.h

Packit Service fa4841
/**
Packit Service fa4841
 * WinPR: Windows Portable Runtime
Packit Service fa4841
 * Smart Card API
Packit Service fa4841
 *
Packit Service fa4841
 * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
Packit Service fa4841
 * Copyright 2020 Armin Novak <armin.novak@thincast.com>
Packit Service fa4841
 * Copyright 2020 Thincast Technologies GmbH
Packit Service fa4841
 *
Packit Service fa4841
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit Service fa4841
 * you may not use this file except in compliance with the License.
Packit Service fa4841
 * You may obtain a copy of the License at
Packit Service fa4841
 *
Packit Service fa4841
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit Service fa4841
 *
Packit Service fa4841
 * Unless required by applicable law or agreed to in writing, software
Packit Service fa4841
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit Service fa4841
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit Service fa4841
 * See the License for the specific language governing permissions and
Packit Service fa4841
 * limitations under the License.
Packit Service fa4841
 */
Packit Service fa4841
Packit Service fa4841
#ifndef WINPR_SMARTCARD_PCSC_PRIVATE_H
Packit Service fa4841
#define WINPR_SMARTCARD_PCSC_PRIVATE_H
Packit Service fa4841
Packit Service fa4841
#ifndef _WIN32
Packit Service fa4841
Packit Service fa4841
#include <winpr/platform.h>
Packit Service fa4841
#include <winpr/smartcard.h>
Packit Service fa4841
Packit Service fa4841
/**
Packit Service fa4841
 * On Windows, DWORD and ULONG are defined to unsigned long.
Packit Service fa4841
 * However, 64-bit Windows uses the LLP64 model which defines
Packit Service fa4841
 * unsigned long as a 4-byte type, while most non-Windows
Packit Service fa4841
 * systems use the LP64 model where unsigned long is 8 bytes.
Packit Service fa4841
 *
Packit Service fa4841
 * WinPR correctly defines DWORD and ULONG to be 4-byte types
Packit Service fa4841
 * regardless of LLP64/LP64, but this has the side effect of
Packit Service fa4841
 * breaking compatibility with the broken pcsc-lite types.
Packit Service fa4841
 *
Packit Service fa4841
 * To make matters worse, pcsc-lite correctly defines
Packit Service fa4841
 * the data types on OS X, but not on other platforms.
Packit Service fa4841
 */
Packit Service fa4841
Packit Service fa4841
#ifdef __APPLE__
Packit Service fa4841
Packit Service fa4841
#include <stdint.h>
Packit Service fa4841
Packit Service fa4841
#ifndef BYTE
Packit Service fa4841
typedef uint8_t PCSC_BYTE;
Packit Service fa4841
#endif
Packit Service fa4841
typedef uint8_t PCSC_UCHAR;
Packit Service fa4841
typedef PCSC_UCHAR* PCSC_PUCHAR;
Packit Service fa4841
typedef uint16_t PCSC_USHORT;
Packit Service fa4841
Packit Service fa4841
#ifndef __COREFOUNDATION_CFPLUGINCOM__
Packit Service fa4841
typedef uint32_t PCSC_ULONG;
Packit Service fa4841
typedef void* PCSC_LPVOID;
Packit Service fa4841
typedef int16_t PCSC_BOOL;
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
typedef PCSC_ULONG* PCSC_PULONG;
Packit Service fa4841
typedef const void* PCSC_LPCVOID;
Packit Service fa4841
typedef uint32_t PCSC_DWORD;
Packit Service fa4841
typedef PCSC_DWORD* PCSC_PDWORD;
Packit Service fa4841
typedef uint16_t PCSC_WORD;
Packit Service fa4841
typedef int32_t PCSC_LONG;
Packit Service fa4841
typedef const char* PCSC_LPCSTR;
Packit Service fa4841
typedef const PCSC_BYTE* PCSC_LPCBYTE;
Packit Service fa4841
typedef PCSC_BYTE* PCSC_LPBYTE;
Packit Service fa4841
typedef PCSC_DWORD* PCSC_LPDWORD;
Packit Service fa4841
typedef char* PCSC_LPSTR;
Packit Service fa4841
Packit Service fa4841
#else
Packit Service fa4841
Packit Service fa4841
#ifndef BYTE
Packit Service fa4841
typedef unsigned char PCSC_BYTE;
Packit Service fa4841
#endif
Packit Service fa4841
typedef unsigned char PCSC_UCHAR;
Packit Service fa4841
typedef PCSC_UCHAR* PCSC_PUCHAR;
Packit Service fa4841
typedef unsigned short PCSC_USHORT;
Packit Service fa4841
Packit Service fa4841
#ifndef __COREFOUNDATION_CFPLUGINCOM__
Packit Service fa4841
typedef unsigned long PCSC_ULONG;
Packit Service fa4841
typedef void* PCSC_LPVOID;
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
typedef const void* PCSC_LPCVOID;
Packit Service fa4841
typedef unsigned long PCSC_DWORD;
Packit Service fa4841
typedef PCSC_DWORD* PCSC_PDWORD;
Packit Service fa4841
typedef long PCSC_LONG;
Packit Service fa4841
typedef const char* PCSC_LPCSTR;
Packit Service fa4841
typedef const PCSC_BYTE* PCSC_LPCBYTE;
Packit Service fa4841
typedef PCSC_BYTE* PCSC_LPBYTE;
Packit Service fa4841
typedef PCSC_DWORD* PCSC_LPDWORD;
Packit Service fa4841
typedef char* PCSC_LPSTR;
Packit Service fa4841
Packit Service fa4841
/* these types were deprecated but still used by old drivers and
Packit Service fa4841
 * applications. So just declare and use them. */
Packit Service fa4841
typedef PCSC_LPSTR PCSC_LPTSTR;
Packit Service fa4841
typedef PCSC_LPCSTR PCSC_LPCTSTR;
Packit Service fa4841
Packit Service fa4841
/* types unused by pcsc-lite */
Packit Service fa4841
typedef short PCSC_BOOL;
Packit Service fa4841
typedef unsigned short PCSC_WORD;
Packit Service fa4841
typedef PCSC_ULONG* PCSC_PULONG;
Packit Service fa4841
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#define PCSC_SCARD_UNKNOWN 0x0001
Packit Service fa4841
#define PCSC_SCARD_ABSENT 0x0002
Packit Service fa4841
#define PCSC_SCARD_PRESENT 0x0004
Packit Service fa4841
#define PCSC_SCARD_SWALLOWED 0x0008
Packit Service fa4841
#define PCSC_SCARD_POWERED 0x0010
Packit Service fa4841
#define PCSC_SCARD_NEGOTIABLE 0x0020
Packit Service fa4841
#define PCSC_SCARD_SPECIFIC 0x0040
Packit Service fa4841
Packit Service fa4841
#define PCSC_SCARD_PROTOCOL_RAW 0x00000004u
Packit Service fa4841
#define PCSC_SCARD_PROTOCOL_T15 0x00000008u
Packit Service fa4841
Packit Service fa4841
#define PCSC_MAX_BUFFER_SIZE 264
Packit Service fa4841
#define PCSC_MAX_BUFFER_SIZE_EXTENDED (4 + 3 + (1 << 16) + 3 + 2)
Packit Service fa4841
Packit Service fa4841
#define PCSC_MAX_ATR_SIZE 33
Packit Service fa4841
Packit Service fa4841
#define PCSC_SCARD_AUTOALLOCATE (PCSC_DWORD)(-1)
Packit Service fa4841
Packit Service fa4841
#define PCSC_SCARD_CTL_CODE(code) (0x42000000 + (code))
Packit Service fa4841
#define PCSC_CM_IOCTL_GET_FEATURE_REQUEST PCSC_SCARD_CTL_CODE(3400)
Packit Service fa4841
Packit Service fa4841
/**
Packit Service fa4841
 * pcsc-lite defines SCARD_READERSTATE, SCARD_IO_REQUEST as packed
Packit Service fa4841
 * on Mac OS X only and uses default packing everywhere else.
Packit Service fa4841
 */
Packit Service fa4841
Packit Service fa4841
#ifdef __APPLE__
Packit Service fa4841
#pragma pack(push, 1)
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
typedef struct
Packit Service fa4841
{
Packit Service fa4841
	LPCSTR szReader;
Packit Service fa4841
	LPVOID pvUserData;
Packit Service fa4841
	PCSC_DWORD dwCurrentState;
Packit Service fa4841
	PCSC_DWORD dwEventState;
Packit Service fa4841
	PCSC_DWORD cbAtr;
Packit Service fa4841
	BYTE rgbAtr[PCSC_MAX_ATR_SIZE]; /* WinSCard: 36, PCSC: 33 */
Packit Service fa4841
} PCSC_SCARD_READERSTATE;
Packit Service fa4841
Packit Service fa4841
typedef struct
Packit Service fa4841
{
Packit Service fa4841
	PCSC_DWORD dwProtocol;
Packit Service fa4841
	PCSC_DWORD cbPciLength;
Packit Service fa4841
} PCSC_SCARD_IO_REQUEST;
Packit Service fa4841
Packit Service fa4841
#ifdef __APPLE__
Packit Service fa4841
#pragma pack(pop)
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#pragma pack(push, 1)
Packit Service fa4841
Packit Service fa4841
typedef struct
Packit Service fa4841
{
Packit Service fa4841
	BYTE tag;
Packit Service fa4841
	BYTE length;
Packit Service fa4841
	UINT32 value;
Packit Service fa4841
} PCSC_TLV_STRUCTURE;
Packit Service fa4841
Packit Service fa4841
#pragma pack(pop)
Packit Service fa4841
Packit Service fa4841
int PCSC_InitializeSCardApi(void);
Packit Service fa4841
const SCardApiFunctionTable* PCSC_GetSCardApiFunctionTable(void);
Packit Service fa4841
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#endif /* WINPR_SMARTCARD_PCSC_PRIVATE_H */