FreeRDP
smartcard_pcsc.h
1 
22 #ifndef WINPR_SMARTCARD_PCSC_PRIVATE_H
23 #define WINPR_SMARTCARD_PCSC_PRIVATE_H
24 
25 #ifndef _WIN32
26 
27 #include <winpr/platform.h>
28 #include <winpr/smartcard.h>
29 
44 #ifdef __APPLE__
45 
46 #include <stdint.h>
47 
48 #ifndef BYTE
49 typedef uint8_t PCSC_BYTE;
50 #endif
51 typedef uint8_t PCSC_UCHAR;
52 typedef PCSC_UCHAR* PCSC_PUCHAR;
53 typedef uint16_t PCSC_USHORT;
54 
55 #ifndef __COREFOUNDATION_CFPLUGINCOM__
56 typedef uint32_t PCSC_ULONG;
57 typedef void* PCSC_LPVOID;
58 typedef int16_t PCSC_BOOL;
59 #endif
60 
61 typedef PCSC_ULONG* PCSC_PULONG;
62 typedef const void* PCSC_LPCVOID;
63 typedef uint32_t PCSC_DWORD;
64 typedef PCSC_DWORD* PCSC_PDWORD;
65 typedef uint16_t PCSC_WORD;
66 typedef int32_t PCSC_LONG;
67 typedef const char* PCSC_LPCSTR;
68 typedef const PCSC_BYTE* PCSC_LPCBYTE;
69 typedef PCSC_BYTE* PCSC_LPBYTE;
70 typedef PCSC_DWORD* PCSC_LPDWORD;
71 typedef char* PCSC_LPSTR;
72 
73 #else
74 
75 #ifndef BYTE
76 typedef unsigned char PCSC_BYTE;
77 #endif
78 typedef unsigned char PCSC_UCHAR;
79 typedef PCSC_UCHAR* PCSC_PUCHAR;
80 typedef unsigned short PCSC_USHORT;
81 
82 #ifndef __COREFOUNDATION_CFPLUGINCOM__
83 typedef unsigned long PCSC_ULONG;
84 typedef void* PCSC_LPVOID;
85 #endif
86 
87 typedef const void* PCSC_LPCVOID;
88 typedef unsigned long PCSC_DWORD;
89 typedef PCSC_DWORD* PCSC_PDWORD;
90 typedef long PCSC_LONG;
91 typedef const char* PCSC_LPCSTR;
92 typedef const PCSC_BYTE* PCSC_LPCBYTE;
93 typedef PCSC_BYTE* PCSC_LPBYTE;
94 typedef PCSC_DWORD* PCSC_LPDWORD;
95 typedef char* PCSC_LPSTR;
96 
97 /* these types were deprecated but still used by old drivers and
98  * applications. So just declare and use them. */
99 typedef PCSC_LPSTR PCSC_LPTSTR;
100 typedef PCSC_LPCSTR PCSC_LPCTSTR;
101 
102 /* types unused by pcsc-lite */
103 typedef short PCSC_BOOL;
104 typedef unsigned short PCSC_WORD;
105 typedef PCSC_ULONG* PCSC_PULONG;
106 
107 #endif
108 
109 #define PCSC_SCARD_UNKNOWN 0x0001
110 #define PCSC_SCARD_ABSENT 0x0002
111 #define PCSC_SCARD_PRESENT 0x0004
112 #define PCSC_SCARD_SWALLOWED 0x0008
113 #define PCSC_SCARD_POWERED 0x0010
114 #define PCSC_SCARD_NEGOTIABLE 0x0020
115 #define PCSC_SCARD_SPECIFIC 0x0040
116 
117 #define PCSC_SCARD_PROTOCOL_RAW 0x00000004u
118 #define PCSC_SCARD_PROTOCOL_T15 0x00000008u
119 
120 #define PCSC_MAX_BUFFER_SIZE 264
121 #define PCSC_MAX_BUFFER_SIZE_EXTENDED (4 + 3 + (1 << 16) + 3 + 2)
122 
123 #define PCSC_MAX_ATR_SIZE 33
124 
125 #define PCSC_SCARD_AUTOALLOCATE (PCSC_DWORD)(-1)
126 
127 #define PCSC_SCARD_CTL_CODE(code) (0x42000000 + (code))
128 #define PCSC_CM_IOCTL_GET_FEATURE_REQUEST PCSC_SCARD_CTL_CODE(3400)
129 
135 #ifdef __APPLE__
136 #pragma pack(push, 1)
137 #endif
138 
139 typedef struct
140 {
141  LPCSTR szReader;
142  LPVOID pvUserData;
143  PCSC_DWORD dwCurrentState;
144  PCSC_DWORD dwEventState;
145  PCSC_DWORD cbAtr;
146  BYTE rgbAtr[PCSC_MAX_ATR_SIZE]; /* WinSCard: 36, PCSC: 33 */
148 
149 typedef struct
150 {
151  PCSC_DWORD dwProtocol;
152  PCSC_DWORD cbPciLength;
154 
155 #ifdef __APPLE__
156 #pragma pack(pop)
157 #endif
158 
159 #pragma pack(push, 1)
160 
161 typedef struct
162 {
163  BYTE tag;
164  BYTE length;
165  UINT32 value;
167 
168 #pragma pack(pop)
169 
170 int PCSC_InitializeSCardApi(void);
171 const SCardApiFunctionTable* PCSC_GetSCardApiFunctionTable(void);
172 
173 #endif
174 
175 #endif /* WINPR_SMARTCARD_PCSC_PRIVATE_H */