1 /***************************************************************************
2     begin       : Mon Mar 01 2004
3     copyright   : (C) 2004-2010 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_CLIENT_CLIENT_H
12 #define CHIPCARD_CLIENT_CLIENT_H
13 
14 
15 /** @addtogroup chipcardc_client_app
16  */
17 /*@{*/
18 
19 #include <gwenhywfar/inherit.h>
20 #include <chipcard/chipcard.h>
21 
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define LC_DEFAULT_SHORT_TIMEOUT     10
28 #define LC_DEFAULT_LONG_TIMEOUT      30
29 #define LC_DEFAULT_VERY_LONG_TIMEOUT 60
30 
31 
32 
33 typedef struct LC_CLIENT LC_CLIENT;
34 GWEN_INHERIT_FUNCTION_LIB_DEFS(LC_CLIENT, CHIPCARD_API)
35 
36 
37 /**
38  * Result codes for operations.
39  */
40 typedef enum {
41   LC_Client_ResultOk=0,
42   LC_Client_ResultWait,
43   LC_Client_ResultIpcError,
44   LC_Client_ResultCmdError,
45   LC_Client_ResultDataError,
46   LC_Client_ResultAborted,
47   LC_Client_ResultInvalid,
48   LC_Client_ResultInternal,
49   LC_Client_ResultGeneric,
50   LC_Client_ResultNoData,
51   LC_Client_ResultCardRemoved,
52   LC_Client_ResultNotSupported,
53   LC_Client_ResultCfgError,
54   LC_Client_ResultNotFound,
55   LC_Client_ResultIoError,
56   LC_Client_ResultBadPin,
57   LC_Client_ResultDontExecute,
58 } LC_CLIENT_RESULT;
59 
60 
61 /**
62  * Targets for commands (used by @ref LC_Card_ExecApdu)
63  */
64 typedef enum {
65   LC_Client_CmdTargetCard=0,
66   LC_Client_CmdTargetReader
67 } LC_CLIENT_CMDTARGET;
68 
69 
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 
76 #include <chipcard/card.h>
77 
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83 
84 /** @name Main API
85  *
86  * To work with this API you'll need to create a client object first.
87  * This is normally done by @ref LC_Client_new.
88  */
89 /*@{*/
90 
91 /**
92  * This function creates a libchipcard client.
93  * @param programName name of the program which wants to create the client
94  * @param programVersion version string of that program
95  */
96 CHIPCARD_API
97 LC_CLIENT *LC_Client_new(const char *programName, const char *programVersion);
98 
99 /**
100  * Release all ressources associated with Libchipcard3. This must be called
101  * at the end of the application to avoid memory leaks.
102  */
103 CHIPCARD_API
104 void LC_Client_free(LC_CLIENT *cl);
105 
106 /**
107  * Init Libchipcard. This functions reads the configuration file and
108  * the card command description files. It does not allocate the readers
109  * (see @ref LC_Client_Start), so it is perfectly save to call this function
110  * upon startup of the application.
111  */
112 CHIPCARD_API
113 LC_CLIENT_RESULT LC_Client_Init(LC_CLIENT *cl);
114 
115 /**
116  * Deinit Libchipcard. Unloads all data files.
117  *
118  */
119 CHIPCARD_API
120 LC_CLIENT_RESULT LC_Client_Fini(LC_CLIENT *cl);
121 
122 
123 
124 CHIPCARD_API
125 LC_CLIENT_RESULT LC_Client_Start(LC_CLIENT *cl);
126 
127 CHIPCARD_API
128 LC_CLIENT_RESULT LC_Client_Stop(LC_CLIENT *cl);
129 
130 
131 CHIPCARD_API
132 LC_CLIENT_RESULT LC_Client_GetNextCard(LC_CLIENT *cl, LC_CARD **pCard, int timeout);
133 
134 CHIPCARD_API
135 LC_CLIENT_RESULT LC_Client_ReleaseCard(LC_CLIENT *cl, LC_CARD *card);
136 
137 
138 /*@}*/
139 
140 
141 /** @name Informational Functions
142  *
143  */
144 /*{@*/
145 CHIPCARD_API
146 const char *LC_Client_GetProgramName(const LC_CLIENT *cl);
147 
148 CHIPCARD_API
149 const char *LC_Client_GetProgramVersion(const LC_CLIENT *cl);
150 
151 /*@}*/
152 
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 
159 /*@}*/
160 
161 #endif /* CHIPCARD_CLIENT_CLIENT_H */
162 
163 
164 
165