pcsc-lite  1.8.20
pcsclite.h
Go to the documentation of this file.
1 /*
2  * MUSCLE SmartCard Development ( http://pcsclite.alioth.debian.org/pcsclite.html )
3  *
4  * Copyright (C) 1999-2004
5  * David Corcoran <corcoran@musclecard.com>
6  * Copyright (C) 2002-2011
7  * Ludovic Rousseau <ludovic.rousseau@free.fr>
8  * Copyright (C) 2005
9  * Martin Paljak <martin@paljak.pri.ee>
10  *
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions
13 are met:
14 
15 1. Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20 3. The name of the author may not be used to endorse or promote products
21  derived from this software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
42 #ifndef __pcsclite_h__
43 #define __pcsclite_h__
44 
45 #include <wintypes.h>
46 
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif
51 
52 typedef LONG SCARDCONTEXT;
53 typedef SCARDCONTEXT *PSCARDCONTEXT;
54 typedef SCARDCONTEXT *LPSCARDCONTEXT;
55 typedef LONG SCARDHANDLE;
56 typedef SCARDHANDLE *PSCARDHANDLE;
57 typedef SCARDHANDLE *LPSCARDHANDLE;
58 
59 #define MAX_ATR_SIZE 33
61 /* Set structure elements aligment on bytes
62  * http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html */
63 #ifdef __APPLE__
64 #pragma pack(1)
65 #endif
66 
67 typedef struct
68 {
69  const char *szReader;
70  void *pvUserData;
71  DWORD dwCurrentState;
72  DWORD dwEventState;
73  DWORD cbAtr;
74  unsigned char rgbAtr[MAX_ATR_SIZE];
75 }
77 
79 typedef struct
80 {
81  unsigned long dwProtocol;
82  unsigned long cbPciLength;
83 }
85 
87 
89 
90 /* restore default structure elements alignment */
91 #ifdef __APPLE__
92 #pragma pack()
93 #endif
94 
95 #define SCARD_PCI_T0 (&g_rgSCardT0Pci)
96 #define SCARD_PCI_T1 (&g_rgSCardT1Pci)
97 #define SCARD_PCI_RAW (&g_rgSCardRawPci)
107 #define SCARD_S_SUCCESS ((LONG)0x00000000)
109 #define SCARD_F_INTERNAL_ERROR ((LONG)0x80100001)
111 #define SCARD_E_CANCELLED ((LONG)0x80100002)
113 #define SCARD_E_INVALID_HANDLE ((LONG)0x80100003)
115 #define SCARD_E_INVALID_PARAMETER ((LONG)0x80100004)
117 #define SCARD_E_INVALID_TARGET ((LONG)0x80100005)
119 #define SCARD_E_NO_MEMORY ((LONG)0x80100006)
121 #define SCARD_F_WAITED_TOO_LONG ((LONG)0x80100007)
123 #define SCARD_E_INSUFFICIENT_BUFFER ((LONG)0x80100008)
125 #define SCARD_E_UNKNOWN_READER ((LONG)0x80100009)
127 #define SCARD_E_TIMEOUT ((LONG)0x8010000A)
129 #define SCARD_E_SHARING_VIOLATION ((LONG)0x8010000B)
131 #define SCARD_E_NO_SMARTCARD ((LONG)0x8010000C)
133 #define SCARD_E_UNKNOWN_CARD ((LONG)0x8010000D)
135 #define SCARD_E_CANT_DISPOSE ((LONG)0x8010000E)
137 #define SCARD_E_PROTO_MISMATCH ((LONG)0x8010000F)
139 #define SCARD_E_NOT_READY ((LONG)0x80100010)
141 #define SCARD_E_INVALID_VALUE ((LONG)0x80100011)
143 #define SCARD_E_SYSTEM_CANCELLED ((LONG)0x80100012)
145 #define SCARD_F_COMM_ERROR ((LONG)0x80100013)
147 #define SCARD_F_UNKNOWN_ERROR ((LONG)0x80100014)
149 #define SCARD_E_INVALID_ATR ((LONG)0x80100015)
151 #define SCARD_E_NOT_TRANSACTED ((LONG)0x80100016)
153 #define SCARD_E_READER_UNAVAILABLE ((LONG)0x80100017)
155 #define SCARD_P_SHUTDOWN ((LONG)0x80100018)
157 #define SCARD_E_PCI_TOO_SMALL ((LONG)0x80100019)
159 #define SCARD_E_READER_UNSUPPORTED ((LONG)0x8010001A)
161 #define SCARD_E_DUPLICATE_READER ((LONG)0x8010001B)
163 #define SCARD_E_CARD_UNSUPPORTED ((LONG)0x8010001C)
165 #define SCARD_E_NO_SERVICE ((LONG)0x8010001D)
167 #define SCARD_E_SERVICE_STOPPED ((LONG)0x8010001E)
169 #define SCARD_E_UNEXPECTED ((LONG)0x8010001F)
171 #define SCARD_E_UNSUPPORTED_FEATURE ((LONG)0x8010001F)
173 #define SCARD_E_ICC_INSTALLATION ((LONG)0x80100020)
175 #define SCARD_E_ICC_CREATEORDER ((LONG)0x80100021)
177 /* #define SCARD_E_UNSUPPORTED_FEATURE ((LONG)0x80100022) / **< This smart card does not support the requested feature. */
178 
179 #define SCARD_E_DIR_NOT_FOUND ((LONG)0x80100023)
181 #define SCARD_E_FILE_NOT_FOUND ((LONG)0x80100024)
183 #define SCARD_E_NO_DIR ((LONG)0x80100025)
185 #define SCARD_E_NO_FILE ((LONG)0x80100026)
187 #define SCARD_E_NO_ACCESS ((LONG)0x80100027)
189 #define SCARD_E_WRITE_TOO_MANY ((LONG)0x80100028)
191 #define SCARD_E_BAD_SEEK ((LONG)0x80100029)
193 #define SCARD_E_INVALID_CHV ((LONG)0x8010002A)
195 #define SCARD_E_UNKNOWN_RES_MNG ((LONG)0x8010002B)
197 #define SCARD_E_NO_SUCH_CERTIFICATE ((LONG)0x8010002C)
199 #define SCARD_E_CERTIFICATE_UNAVAILABLE ((LONG)0x8010002D)
201 #define SCARD_E_NO_READERS_AVAILABLE ((LONG)0x8010002E)
203 #define SCARD_E_COMM_DATA_LOST ((LONG)0x8010002F)
205 #define SCARD_E_NO_KEY_CONTAINER ((LONG)0x80100030)
207 #define SCARD_E_SERVER_TOO_BUSY ((LONG)0x80100031)
210 #define SCARD_W_UNSUPPORTED_CARD ((LONG)0x80100065)
212 #define SCARD_W_UNRESPONSIVE_CARD ((LONG)0x80100066)
214 #define SCARD_W_UNPOWERED_CARD ((LONG)0x80100067)
216 #define SCARD_W_RESET_CARD ((LONG)0x80100068)
218 #define SCARD_W_REMOVED_CARD ((LONG)0x80100069)
221 #define SCARD_W_SECURITY_VIOLATION ((LONG)0x8010006A)
223 #define SCARD_W_WRONG_CHV ((LONG)0x8010006B)
225 #define SCARD_W_CHV_BLOCKED ((LONG)0x8010006C)
227 #define SCARD_W_EOF ((LONG)0x8010006D)
229 #define SCARD_W_CANCELLED_BY_USER ((LONG)0x8010006E)
231 #define SCARD_W_CARD_NOT_AUTHENTICATED ((LONG)0x8010006F)
233 #define SCARD_AUTOALLOCATE (DWORD)(-1)
234 #define SCARD_SCOPE_USER 0x0000
235 #define SCARD_SCOPE_TERMINAL 0x0001
236 #define SCARD_SCOPE_SYSTEM 0x0002
237 #define SCARD_SCOPE_GLOBAL 0x0003
239 #define SCARD_PROTOCOL_UNDEFINED 0x0000
240 #define SCARD_PROTOCOL_UNSET SCARD_PROTOCOL_UNDEFINED /* backward compat */
241 #define SCARD_PROTOCOL_T0 0x0001
242 #define SCARD_PROTOCOL_T1 0x0002
243 #define SCARD_PROTOCOL_RAW 0x0004
244 #define SCARD_PROTOCOL_T15 0x0008
246 #define SCARD_PROTOCOL_ANY (SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1)
248 #define SCARD_SHARE_EXCLUSIVE 0x0001
249 #define SCARD_SHARE_SHARED 0x0002
250 #define SCARD_SHARE_DIRECT 0x0003
252 #define SCARD_LEAVE_CARD 0x0000
253 #define SCARD_RESET_CARD 0x0001
254 #define SCARD_UNPOWER_CARD 0x0002
255 #define SCARD_EJECT_CARD 0x0003
257 #define SCARD_UNKNOWN 0x0001
258 #define SCARD_ABSENT 0x0002
259 #define SCARD_PRESENT 0x0004
260 #define SCARD_SWALLOWED 0x0008
261 #define SCARD_POWERED 0x0010
262 #define SCARD_NEGOTIABLE 0x0020
263 #define SCARD_SPECIFIC 0x0040
265 #define SCARD_STATE_UNAWARE 0x0000
266 #define SCARD_STATE_IGNORE 0x0001
267 #define SCARD_STATE_CHANGED 0x0002
268 #define SCARD_STATE_UNKNOWN 0x0004
269 #define SCARD_STATE_UNAVAILABLE 0x0008
270 #define SCARD_STATE_EMPTY 0x0010
271 #define SCARD_STATE_PRESENT 0x0020
272 #define SCARD_STATE_ATRMATCH 0x0040
273 #define SCARD_STATE_EXCLUSIVE 0x0080
274 #define SCARD_STATE_INUSE 0x0100
275 #define SCARD_STATE_MUTE 0x0200
276 #define SCARD_STATE_UNPOWERED 0x0400
278 #ifndef INFINITE
279 #define INFINITE 0xFFFFFFFF
280 #endif
281 
282 #define PCSCLITE_VERSION_NUMBER "1.8.20"
284 #define PCSCLITE_MAX_READERS_CONTEXTS 16
285 
286 #define MAX_READERNAME 128
287 
288 #ifndef SCARD_ATR_LENGTH
289 #define SCARD_ATR_LENGTH MAX_ATR_SIZE
290 #endif
291 
292 /*
293  * The message and buffer sizes must be multiples of 16.
294  * The max message size must be at least large enough
295  * to accomodate the transmit_struct
296  */
297 #define MAX_BUFFER_SIZE 264
298 #define MAX_BUFFER_SIZE_EXTENDED (4 + 3 + (1<<16) + 3 + 2)
300 /*
301  * Gets a stringified error response
302  */
303 const char *pcsc_stringify_error(const LONG);
304 
305 #ifdef __cplusplus
306 }
307 #endif
308 
309 #endif
unsigned long cbPciLength
Protocol Control Inf Length.
Definition: pcsclite.h:82
const SCARD_IO_REQUEST g_rgSCardRawPci
Protocol Control Information for raw access.
Definition: libpcscspy.c:724
LONG SCARDCONTEXT
hContext returned by SCardEstablishContext()
Definition: pcsclite.h:52
unsigned long dwProtocol
Protocol identifier.
Definition: pcsclite.h:81
LONG SCARDHANDLE
hCard returned by SCardConnect()
Definition: pcsclite.h:55
This keeps a list of Windows(R) types.
Protocol Control Information (PCI)
Definition: pcsclite.h:79
const char * pcsc_stringify_error(const LONG)
Returns a human readable text for the given PC/SC error code.
Definition: error.c:82
#define MAX_ATR_SIZE
Maximum ATR size.
Definition: pcsclite.h:59
const SCARD_IO_REQUEST g_rgSCardT1Pci
Protocol Control Information for T=1.
Definition: libpcscspy.c:723
const SCARD_IO_REQUEST g_rgSCardT0Pci
Protocol Control Information for T=0.
Definition: libpcscspy.c:722