libchipcard  5.1.0beta
chipcard.h
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Tue Dec 23 2003
3  copyright : (C) 2003 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 
11 #ifndef CHIPCARD_CHIPCARD_H
12 #define CHIPCARD_CHIPCARD_H
13 
14 #define CHIPCARD_SYS_IS_WINDOWS 0
15 
16 
17 #ifdef LCC_IS_SUBPROJECT
18 # define CHIPCARD_API
19 # define CHIPCARD_EXPORT
20 # define CHIPCARD_NOEXPORT
21 #else
22 # ifdef BUILDING_CHIPCARD
23  /* building Gwenhywfar */
24 # if CHIPCARD_SYS_IS_WINDOWS
25  /* for windows */
26 # ifdef __declspec
27 # define CHIPCARD_API __declspec (dllexport)
28 # else /* if __declspec */
29 # define CHIPCARD_API
30 # endif /* if NOT __declspec */
31 # else
32  /* for non-win32 */
33 # ifdef GCC_WITH_VISIBILITY_ATTRIBUTE
34 # define CHIPCARD_API __attribute__((visibility("default")))
35 # else
36 # define CHIPCARD_API
37 # endif
38 # endif
39 # else
40  /* not building Gwenhywfar */
41 # if CHIPCARD_SYS_IS_WINDOWS
42  /* for windows */
43 # ifdef __declspec
44 # define CHIPCARD_API __declspec (dllimport)
45 # else /* if __declspec */
46 # define CHIPCARD_API
47 # endif /* if NOT __declspec */
48 # else
49  /* for non-win32 */
50 # define CHIPCARD_API
51 # endif
52 # endif
53 
54 # ifdef GCC_WITH_VISIBILITY_ATTRIBUTE
55 # define CHIPCARD_EXPORT __attribute__((visibility("default")))
56 # define CHIPCARD_NOEXPORT __attribute__((visibility("hidden")))
57 # else
58 # define CHIPCARD_EXPORT
59 # define CHIPCARD_NOEXPORT
60 # endif
61 #endif
62 
63 
64 #if CHIPCARD_SYS_IS_WINDOWS
65 # define CHIPCARD_CB __stdcall
66 #else
67 # define CHIPCARD_CB
68 #endif
69 
70 
71 #ifndef CHIPCARD_NOWARN_DEPRECATED
72 # ifdef __GNUC__
73 # define CHIPCARD_DEPRECATED __attribute((__deprecated__))
74 # else
75 # define CHIPCARD_DEPRECATED
76 # endif
77 # else
78 # define CHIPCARD_DEPRECATED
79 #endif
80 
81 #include <gwenhywfar/db.h>
82 #include <gwenhywfar/xml.h>
83 
84 #include <inttypes.h>
85 
86 
87 #define LC_DEFAULT_PORT 7392 /* FIXME: make this adjustable by configure */
88 #define LC_DEFAULT_UDS_SOCK "/var/run/chipcard.comm"
89 
92 #define LC_ERROR_NONE 0x00000000
93 #define LC_ERROR_GENERIC 0x00000001
94 #define LC_ERROR_INVALID 0x00000002
95 #define LC_ERROR_CARD_REMOVED 0x00000003
96 #define LC_ERROR_CARD_NOT_OWNED 0x00000004
97 #define LC_ERROR_NOT_SUPPORTED 0x00000005
98 #define LC_ERROR_SETUP 0x00000006
99 #define LC_ERROR_NO_DATA 0x00000007
100 #define LC_ERROR_LOCKED_BY_OTHER 0x00000008
101 #define LC_ERROR_NOT_LOCKED 0x00000009
102 
103 #define LC_ERROR_BAD_RESPONSE 0x0000000a
104 #define LC_ERROR_NO_SLOTS_CONNECTED 0x0000000b
105 #define LC_ERROR_NO_SLOTS_DISCONNECTED 0x0000000c
106 #define LC_ERROR_NO_SLOTS_AVAILABLE 0x0000000d
107 #define LC_ERROR_BAD_PIN 0x0000000e
108 #define LC_ERROR_USER_ABORTED 0x0000000f
109 #define LC_ERROR_CARD_DESTROYED 0x00000010
110 #define LC_ERROR_READER_REMOVED 0x00000011
111 #define LC_ERROR_TIMEOUT 0x00000012
112 #define LC_ERROR_IPC 0x00000013
113 #define LC_ERROR_BUFFER_OVERFLOW 0x00000014
114 
115 const char *LC_Error_toString(uint32_t err);
116 
117 
118 #define LC_LOGDOMAIN "ccclient"
119 
122 #define LC_READER_FLAGS_KEYPAD 0x00010000
123 #define LC_READER_FLAGS_DISPLAY 0x00020000
124 #define LC_READER_FLAGS_NOINFO 0x00040000
125 #define LC_READER_FLAGS_REMOTE 0x00080000
126 #define LC_READER_FLAGS_AUTO 0x00100000
127 #define LC_READER_FLAGS_SUSPENDED_CHECKS 0x00200000
128 #define LC_READER_FLAGS_DRIVER_HAS_VERIFY 0x00400000
129 #define LC_READER_FLAGS_KEEP_RUNNING 0x00800000
130 #define LC_READER_FLAGS_LOW_WRITE_BOUNDARY 0x01000000
131 #define LC_READER_FLAGS_NO_MEMORY_SW 0x02000000
132 
135 uint32_t LC_ReaderFlags_fromXml(GWEN_XMLNODE *node, const char *name);
137 uint32_t LC_ReaderFlags_fromDb(GWEN_DB_NODE *db, const char *name);
138 CHIPCARD_API void LC_ReaderFlags_toDb(GWEN_DB_NODE *db,
139  const char *name,
140  uint32_t fl);
141 
143 #define LC_DRIVER_FLAGS_RUNTIME_MASK 0xffff0000
144 #define LC_DRIVER_FLAGS_AUTO 0x00010000
145 #define LC_DRIVER_FLAGS_REMOTE 0x00020000
146 #define LC_DRIVER_FLAGS_CONFIG 0x00040000
147 
148 #define LC_DRIVER_FLAGS_HAS_VERIFY_FN 0x00000001
149 #define LC_DRIVER_FLAGS_HAS_MODIFY_FN 0x00000002
150 
152 uint32_t LC_DriverFlags_fromDb(GWEN_DB_NODE *db, const char *name);
153 
155 int LC_DriverFlags_toDb(GWEN_DB_NODE *db,
156  const char *name,
157  uint32_t flags);
158 
159 
161 #define LC_SERVICE_FLAGS_RUNTIME_MASK (\
162  LC_SERVICE_FLAGS_CLIENT \
163  )
164 #define LC_SERVICE_FLAGS_CLIENT 0x00000001
165 #define LC_SERVICE_FLAGS_AUTOLOAD 0x00000002
166 #define LC_SERVICE_FLAGS_SILENT 0x00000004
167 
169 uint32_t LC_ServiceFlags_fromDb(GWEN_DB_NODE *db, const char *name);
170 CHIPCARD_API void LC_ServiceFlags_toDb(GWEN_DB_NODE *db,
171  const char *name,
172  uint32_t fl);
173 
174 
177 #define LC_NOTIFY_FLAGS_DRIVER_MASK 0x0000003f
178 #define LC_NOTIFY_FLAGS_DRIVER_START 0x00000001
179 #define LC_NOTIFY_FLAGS_DRIVER_UP 0x00000002
180 #define LC_NOTIFY_FLAGS_DRIVER_DOWN 0x00000004
181 #define LC_NOTIFY_FLAGS_DRIVER_ERROR 0x00000008
182 #define LC_NOTIFY_FLAGS_DRIVER_ADD 0x00000010
183 #define LC_NOTIFY_FLAGS_DRIVER_DEL 0x00000020
184 
185 #define LC_NOTIFY_FLAGS_READER_MASK 0x00000fc0
186 #define LC_NOTIFY_FLAGS_READER_START 0x00000040
187 #define LC_NOTIFY_FLAGS_READER_UP 0x00000080
188 #define LC_NOTIFY_FLAGS_READER_DOWN 0x00000100
189 #define LC_NOTIFY_FLAGS_READER_ERROR 0x00000200
190 #define LC_NOTIFY_FLAGS_READER_ADD 0x00000400
191 #define LC_NOTIFY_FLAGS_READER_DEL 0x00000800
192 
193 #define LC_NOTIFY_FLAGS_SERVICE_MASK 0x0000f000
194 #define LC_NOTIFY_FLAGS_SERVICE_START 0x00001000
195 #define LC_NOTIFY_FLAGS_SERVICE_UP 0x00002000
196 #define LC_NOTIFY_FLAGS_SERVICE_DOWN 0x00004000
197 #define LC_NOTIFY_FLAGS_SERVICE_ERROR 0x00008000
198 
199 #define LC_NOTIFY_FLAGS_CARD_MASK 0x000f0000
200 #define LC_NOTIFY_FLAGS_CARD_INSERTED 0x00010000
201 #define LC_NOTIFY_FLAGS_CARD_REMOVED 0x00020000
202 #define LC_NOTIFY_FLAGS_CARD_RFU1 0x00040000
203 #define LC_NOTIFY_FLAGS_CARD_RFU2 0x00080000
204 
205 #define LC_NOTIFY_FLAGS_CLIENT_MASK 0xfff00000
206 #define LC_NOTIFY_FLAGS_CLIENT_UP 0x00100000
207 #define LC_NOTIFY_FLAGS_CLIENT_DOWN 0x00200000
208 #define LC_NOTIFY_FLAGS_CLIENT_STARTWAIT 0x00400000
209 #define LC_NOTIFY_FLAGS_CLIENT_STOPWAIT 0x00800000
210 #define LC_NOTIFY_FLAGS_CLIENT_TAKECARD 0x01000000
211 #define LC_NOTIFY_FLAGS_CLIENT_GOTCARD 0x02000000
212 
213 #define LC_NOTIFY_FLAGS_CLIENT_CMDSEND 0x04000000
214 #define LC_NOTIFY_FLAGS_CLIENT_CMDRECV 0x08000000
215 
216 #define LC_NOTIFY_FLAGS_SINGLESHOT 0x80000000
217 
218 #define LC_NOTIFY_FLAGS_PRIVILEGED (\
219  LC_NOTIFY_FLAGS_CLIENT_CMDSEND |\
220  LC_NOTIFY_FLAGS_CLIENT_CMDRECV)
221 
223 uint32_t LC_NotifyFlags_fromDb(GWEN_DB_NODE *db, const char *name);
224 CHIPCARD_API void LC_NotifyFlags_toDb(GWEN_DB_NODE *db,
225  const char *name,
226  uint32_t fl);
227 
228 
237 #define LC_NOTIFY_TYPE_DRIVER "driver"
238 #define LC_NOTIFY_CODE_DRIVER_START "start"
239 #define LC_NOTIFY_CODE_DRIVER_UP "up"
240 #define LC_NOTIFY_CODE_DRIVER_DOWN "down"
241 #define LC_NOTIFY_CODE_DRIVER_ERROR "error"
242 #define LC_NOTIFY_CODE_DRIVER_ADD "add"
243 #define LC_NOTIFY_CODE_DRIVER_DEL "del"
244 
245 #define LC_NOTIFY_TYPE_READER "reader"
246 #define LC_NOTIFY_CODE_READER_START "start"
247 #define LC_NOTIFY_CODE_READER_UP "up"
248 #define LC_NOTIFY_CODE_READER_DOWN "down"
249 #define LC_NOTIFY_CODE_READER_ERROR "error"
250 #define LC_NOTIFY_CODE_READER_ADD "add"
251 #define LC_NOTIFY_CODE_READER_DEL "del"
252 
253 #define LC_NOTIFY_TYPE_SERVICE "service"
254 #define LC_NOTIFY_CODE_SERVICE_START "start"
255 #define LC_NOTIFY_CODE_SERVICE_UP "up"
256 #define LC_NOTIFY_CODE_SERVICE_DOWN "down"
257 #define LC_NOTIFY_CODE_SERVICE_ERROR "error"
258 
259 #define LC_NOTIFY_TYPE_CARD "card"
260 #define LC_NOTIFY_CODE_CARD_INSERTED "inserted"
261 #define LC_NOTIFY_CODE_CARD_REMOVED "removed"
262 #define LC_NOTIFY_CODE_CARD_RFU1 "rfu1"
263 #define LC_NOTIFY_CODE_CARD_RFU2 "rfu2"
264 
265 #define LC_NOTIFY_TYPE_CLIENT "client"
266 #define LC_NOTIFY_CODE_CLIENT_UP "up"
267 #define LC_NOTIFY_CODE_CLIENT_DOWN "down"
268 #define LC_NOTIFY_CODE_CLIENT_STARTWAIT "startwait"
269 #define LC_NOTIFY_CODE_CLIENT_STOPWAIT "stopwait"
270 #define LC_NOTIFY_CODE_CLIENT_TAKECARD "takecard"
271 #define LC_NOTIFY_CODE_CLIENT_GOTCARD "gotcard"
272 
273 #define LC_NOTIFY_CODE_CLIENT_CMDSEND "cmdsend"
274 #define LC_NOTIFY_CODE_CLIENT_CMDRECV "cmdrecv"
275 
280 typedef enum {
290 
293 
294 
295 typedef enum {
304  LC_ReaderStatusHwAdd=900, /* internal status code */
305  LC_ReaderStatusHwDel=901, /* internal status code */
308 
311 
312 
313 typedef enum {
324 
327 
328 
329 typedef enum {
333 
336 
337 
338 typedef enum {
342 } LC_CARD_TYPE;
343 
344 
345 #endif /* CHIPCARD_CHIPCARD_H */
CHIPCARD_API void LC_NotifyFlags_toDb(GWEN_DB_NODE *db, const char *name, uint32_t fl)
Definition: chipcard.h:314
Definition: chipcard.h:284
Definition: chipcard.h:322
LC_READER_STATUS
Definition: chipcard.h:295
Definition: chipcard.h:302
Definition: chipcard.h:303
LC_CARD_TYPE
Definition: chipcard.h:338
Definition: chipcard.h:301
CHIPCARD_API LC_SERVICE_STATUS LC_ServiceStatus_fromString(const char *s)
CHIPCARD_API LC_DRIVER_STATUS LC_DriverStatus_fromString(const char *s)
Definition: chipcard.h:330
LC_SERVICE_STATUS
Definition: chipcard.h:313
Definition: chipcard.h:332
Definition: chipcard.h:306
Definition: chipcard.h:318
Definition: chipcard.h:331
Definition: chipcard.h:281
CHIPCARD_API void LC_ReaderFlags_toDb(GWEN_DB_NODE *db, const char *name, uint32_t fl)
const char * LC_Error_toString(uint32_t err)
CHIPCARD_API uint32_t LC_DriverFlags_fromDb(GWEN_DB_NODE *db, const char *name)
Definition: chipcard.h:319
Definition: chipcard.h:285
Definition: chipcard.h:317
#define CHIPCARD_API
Definition: chipcard.h:50
Definition: chipcard.h:316
Definition: chipcard.h:341
Definition: chipcard.h:339
Definition: chipcard.h:296
CHIPCARD_API uint32_t LC_NotifyFlags_fromDb(GWEN_DB_NODE *db, const char *name)
CHIPCARD_API const char * LC_ServiceStatus_toString(LC_SERVICE_STATUS st)
Definition: chipcard.h:340
CHIPCARD_API uint32_t LC_ServiceFlags_fromDb(GWEN_DB_NODE *db, const char *name)
Definition: chipcard.h:283
Definition: chipcard.h:315
Definition: chipcard.h:305
CHIPCARD_API const char * LC_ReaderStatus_toString(LC_READER_STATUS rst)
Definition: chipcard.h:299
CHIPCARD_API uint32_t LC_ReaderFlags_fromXml(GWEN_XMLNODE *node, const char *name)
CHIPCARD_API void LC_ServiceFlags_toDb(GWEN_DB_NODE *db, const char *name, uint32_t fl)
Definition: chipcard.h:321
Definition: chipcard.h:304
Definition: chipcard.h:300
CHIPCARD_API int LC_DriverFlags_toDb(GWEN_DB_NODE *db, const char *name, uint32_t flags)
CHIPCARD_API const char * LC_DriverStatus_toString(LC_DRIVER_STATUS dst)
Definition: chipcard.h:287
CHIPCARD_API LC_READER_STATUS LC_ReaderStatus_fromString(const char *s)
Definition: chipcard.h:282
CHIPCARD_API uint32_t LC_ReaderFlags_fromDb(GWEN_DB_NODE *db, const char *name)
Definition: chipcard.h:298
Definition: chipcard.h:288
LC_CARD_STATUS
Definition: chipcard.h:329
Definition: chipcard.h:297
Definition: chipcard.h:320
LC_DRIVER_STATUS
Definition: chipcard.h:280
Definition: chipcard.h:286
Definition: chipcard.h:334