00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#ifndef CTDRIVER_H
00029
#define CTDRIVER_H
00030
00031
#ifdef __cplusplus
00032
extern "C" {
00033
#endif
00034
00035
00036
#include <chameleon/error.h>
00037
#include <chameleon/conf.h>
00038
#include <ctcore_public.h>
00039
00040 #define CT_READERS_PER_CLIENT 16
00041
00042
00043
00044 typedef struct CTREADERSTRUCT CTREADERTABLE;
00045 typedef struct CTDRIVERSTRUCT CTDRIVERTABLE;
00046 typedef struct CTCLIENTSTRUCT CTCLIENTTABLE;
00047 typedef struct CTCORESTRUCT CTCORETABLE;
00048
00049
00050
00051 typedef ERRORCODE (*
CTDRIVER_ALLOCTERMPTR)(
CTREADERTABLE *rt);
00052 typedef ERRORCODE (*
CTDRIVER_RELEASETERMPTR)(
CTREADERTABLE *rt);
00053 typedef ERRORCODE (*
CTDRIVER_CONNTERMPTR)(
CTREADERTABLE *rt,
00054
char *atrbuffer,
00055
int *atrbufferlen);
00056 typedef ERRORCODE (*
CTDRIVER_DISCONNTERMPTR)(
CTREADERTABLE *rt);
00057 typedef ERRORCODE (*
CTDRIVER_STATUSPTR)(
CTREADERTABLE *rt,
00058
char *atrbuffer,
00059
int *atrbufferlen);
00060 typedef ERRORCODE (*
CTDRIVER_COMMANDPTR)(
CTREADERTABLE *rt,
00061
const char *sendBuffer,
00062
int sendBufferLength,
00063
char *recvBuffer,
00064
int *recvBufferLength);
00065
00066 typedef CTREADERDESCRIPTION* (*CTDRIVER_ENUMTERMSPTR)(
CTDRIVERTABLE *dt);
00067 typedef ERRORCODE (*
CTDRIVER_CLOSEPTR)(
CTDRIVERTABLE *dt);
00068
00069
00070
00071 struct CTREADERSTRUCT {
00072 CTREADERTABLE *
next;
00073 int lockedByClient;
00074 int usageCount;
00075 int openCount;
00076 unsigned int lastStatus;
00077 unsigned int deltaStatus;
00078 unsigned int softDeltaStatus;
00079 int cardChanged;
00080 char atr[256];
00081 int atrlen;
00082 CTREADERDESCRIPTION *
descr;
00083 CTDRIVERTABLE *
driver;
00084 void *
driverData;
00085 unsigned int cardId;
00086 unsigned int lockedSince;
00087 };
00088
00089
00090 struct CTDRIVERSTRUCT {
00091 CTDRIVERTABLE *
next;
00092 int usageCount;
00093 char name[256];
00094 void *
driverData;
00095 CONFIGGROUP *
driverDescription;
00096 CTDRIVER_CLOSEPTR closeDriver;
00097 CTDRIVER_ALLOCTERMPTR allocTerm;
00098 CTDRIVER_RELEASETERMPTR releaseTerm;
00099 CTDRIVER_STATUSPTR statTerm;
00100 CTDRIVER_CONNTERMPTR connectTerm;
00101 CTDRIVER_DISCONNTERMPTR disconnectTerm;
00102 CTDRIVER_ENUMTERMSPTR enumTerms;
00103 CTDRIVER_COMMANDPTR commandTerm;
00104 };
00105
00106
00107 struct CTCLIENTSTRUCT {
00108 CTCLIENTTABLE *
next;
00109 int id;
00110 CTREADERTABLE*
readers[
CT_READERS_PER_CLIENT];
00111 };
00112
00113
00114 struct CTCORESTRUCT {
00115 int nextReaderId;
00116 int nextClientId;
00117 CTREADERDESCRIPTION *
readerDescriptions;
00118 CTCLIENTTABLE *
clients;
00119 CTDRIVERTABLE *
drivers;
00120 CTREADERTABLE *
readers;
00121 CONFIGGROUP *
driverDescriptions;
00122 };
00123
00124
00125
00126
00127
00128
00129
CTREADERTABLE *
CTCore_Reader_new();
00130
void CTCore_Reader_free(CTREADERTABLE *rt);
00131
00132
CTDRIVERTABLE *
CTCore_Driver_new();
00133
void CTCore_Driver_free(CTDRIVERTABLE *dt);
00134
00135
CTCLIENTTABLE *
CTCore_Client_new();
00136
void CTCore_Client_free(CTCLIENTTABLE *ct);
00137
00138
CTCORETABLE *
CTCore_new();
00139
void CTCore_free(CTCORETABLE *ct);
00140
00141
00142
00143
00144
int CTCore_RegisterClient(CTCORETABLE *ct);
00145
void CTCore_UnregisterClient(CTCORETABLE *ct,
int id);
00146
00147
00148
int CTCore_GetClientReaderId(CTCORETABLE *ct,
int id,
int tid);
00149
00150
00154
int CTCore_AllocTerminal(CTCORETABLE *ct,
int cid,
int tid,
00155 CTREADERDESCRIPTION **descr);
00156
void CTCore_ReleaseTerminal(CTCORETABLE *ct,
int cid,
int tid);
00157
00158
ERRORCODE CTCore_ConnectTerminal(CTCORETABLE *ct,
int cid,
int tid,
00159
char *atrbuffer,
00160
int *atrbufferlen);
00161
ERRORCODE CTCore_DisconnectTerminal(CTCORETABLE *ct,
int cid,
int tid);
00162
00163
ERRORCODE CTCore_CommandTerminal(CTCORETABLE *ct,
int cid,
int tid,
00164
const char *sendBuffer,
00165
int sendBufferLength,
00166
char *recvBuffer,
00167
int *recvBufferLength);
00168
00172
ERRORCODE CTCore_Init(CTCORETABLE *ct, CONFIGGROUP *driverDescriptions);
00173
ERRORCODE CTCore_Fini(CTCORETABLE *ct);
00174
00181
ERRORCODE CTCore_AddReader(CTCORETABLE *ct, CTREADERDESCRIPTION *rd);
00182
00183
00188
ERRORCODE CTCore_ModuleInit();
00189
00194
ERRORCODE CTCore_ModuleFini();
00195
00201
void CTCore_WalkTerminals(CTCORETABLE *ct);
00202
00207
ERRORCODE CTCore_CheckReaderStatus(CTCORETABLE *ct,
int cid,
int tid,
00208
unsigned int *status,
00209
char *atrbuffer,
00210
int *atrbufferlen);
00211
00216
ERRORCODE CTCore_GetReaderStatus(CTCORETABLE *ct,
int cid,
int tid,
00217
unsigned int *status,
00218
char *atrbuffer,
00219
int *atrbufferlen);
00220
00221
00222
#ifdef __cplusplus
00223
}
00224
#endif
00225
00226
00227
#endif
00228
00229