1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/*
* See copyright notice at end of file
*
* $Id: sectok.h,v 1.2 2001/06/07 20:19:43 rees Exp $
*/
/* SCPERF - performance evaluation */
#ifdef SCPERF
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#endif /* SCPERF */
/* open flags */
#define SCODSR 0x1 /* wait for dsr */
#define SCODCD 0x2 /* wait for dcd */
#define SCOHUP 0x4 /* send signal on card removal */
#define SCOXCTS 0x8 /* wait for no cts (todos reader) */
#define SCOXDTR 0x10 /* invert dtr (todos reader) */
#define SCOINVRT 0x20 /* inverse convention */
/* Reset flags */
#define SCRV 0x1 /* be verbose */
#define SCRLEN 0x2 /* determine length by examing atr */
#define SCRTODOS 0x4 /* Todos reader */
#define SCRFORCE 0x8 /* Talk to card even if atr is bad */
/* error codes */
#define SCEOK 0
#define SCENOTTY 1 /* no such tty */
#define SCENOMEM 2 /* malloc (or similar) failed */
#define SCTIMEO 3 /* time out */
#define SCESLAG 4 /* slag (no atr) */
#define SCENOSUPP 5 /* card type not supported */
#define SCENOCARD 6 /* no card in reader */
#define SCENOIMPL 7
#define SCEDRVR 8
#define SCECOMM 9
#define SCECLOSED 10
#define SCENOFILE 11 /* wrong config path or driver path */
#define SCECNFFILES 12 /* both config path and driver path are
specified. thus conflict. */
#define SCEUNKNOWN 13
/* Extra tags for things they forgot to put in the ifd interface */
#define SCTAG_IFD_ATRLEN 0x6601
#define SCTAG_IFD_CARDPRESENT 0x301
#define SCTAG_OPEN_FLAGS 0x800
#define SCTAG_RESET_FLAGS 0x801
extern char *scerrtab[];
extern struct scparam {
int t, etu, cwt, bwt, n;
} scparam[];
/* forward declarations */
int scopen(int ttyn, int flags, int *ep);
int scxopen(int ttyn, int flags, int *ep,
char *config_path, char *driver_path);
int scsetflags(int ttyn, int flags, int mask);
int scrw(int ttyn, int cla, int ins, int p1, int p2, int ilen, unsigned char *ibuf, int olen, unsigned char *obuf, int *sw1p, int *sw2p);
int scread(int ttyn, int cla, int ins, int p1, int p2, int p3, unsigned char *buf, int *sw1p, int *sw2p);
int scwrite(int ttyn, int cla, int ins, int p1, int p2, int p3, unsigned char *buf, int *sw1p, int *sw2p);
int sccardpresent(int ttyn);
int scdsr(int ttyn);
int scclose(int ttyn);
int screset(int ttyn, unsigned char *atr, int *ep);
int scxreset(int ttyn, int flags, unsigned char *atr, int *ep);
int scdtr(int ttyn, int cmd);
int scgetc(int ttyn, unsigned char *cp, int ms);
int scputc(int ttyn, int ic);
int scgetblk(int ttyn, unsigned char *bp, int n, int bwt, int cwt);
int scputblk(int ttyn, unsigned char *bp, int n);
void scsleep(int ms);
void scdrain(int ttyn);
int scioT1(int ttyn, int cla, int ins, int p1, int p2, int ilen, unsigned char *ibuf, int olen, unsigned char *obuf, int *sw1p, int *sw2p);
int scioT1Iblk(int ttyn, int ilen, unsigned char *ibuf, unsigned char *obuf);
int scioT1pkt(int ttyn, unsigned char *ibuf, unsigned char *obuf);
int parse_atr(int ttyn, int flags, unsigned char *atr, int len, struct scparam *param);
int parse_input(char *ibuf, unsigned char *obuf, int olen);
#ifndef __palmos__
int get_input(FILE *f, unsigned char *obuf, int omin, int olen);
int fdump_reply(FILE *f, unsigned char *p, int n, int r1, int r2);
int dump_reply(unsigned char *p, int n, int r1, int r2);
#endif
void print_r1r2(int r1, int r2);
char *get_r1r2s(int r1, int r2);
char *scr1r2s(int r1, int r2);
char *lookup_cmdname(int ins);
/* SCPERF - performance evaluation */
#ifdef SCPERF
#ifdef SCPERF_FIRST_APPEARANCE
#define MAX_EVENTS 1024
struct timeval perf_tv[MAX_EVENTS];
char *perf_buf[MAX_EVENTS];
int perf_num = 0;
void print_time ()
{
int i;
for (i = 0 ; i < perf_num ; i ++ ) {
printf ("%d.%06d: %s\n",
perf_tv[i].tv_sec, perf_tv[i].tv_usec, perf_buf[i]);
}
return;
}
#define SetTime(x) \
gettimeofday(&(perf_tv[perf_num]), NULL); \
perf_buf[perf_num] = x; \
perf_num++; \
if (perf_num >= MAX_EVENTS) {\
fprintf (stderr, "SetTime overflow %d\n", MAX_EVENTS); \
exit (1); \
}
#else /* !SCPERF_FIRST_APPEARANCE */
extern struct timeval perf_tv[];
extern char *perf_buf[];
extern int perf_num;
#define MAX_EVENTS 1024
#define SetTime(x) \
gettimeofday(&(perf_tv[perf_num]), NULL); \
perf_buf[perf_num] = x; \
perf_num++; \
if (perf_num >= MAX_EVENTS) {\
fprintf (stderr, "SetTime overflow %d\n", MAX_EVENTS); \
exit (1); \
}
#endif /* SCPERF_FIRST_APPEARANCE */
void print_time ();
#else /* !SCPERF */
#define SetTime(x)
#define print_time() ;
#endif /* SCPERF */
/* macros */
#ifdef SCFS
#define ADEBMISC 0x00000001 /* misc debugging */
#define MESSAGE1(x) arla_warnx (ADEBMISC,x)
#define MESSAGE2(x,y) arla_warnx (ADEBMISC,x,y)
#define MESSAGE3(x,y,z) arla_warnx (ADEBMISC,x,y,z)
#define MESSAGE4(x,y,z,u) arla_warnx (ADEBMISC,x,y,z,u)
#define MESSAGE5(x,y,z,u,v) arla_warnx (ADEBMISC,x,y,z,u,v)
#define MESSAGE6(x,y,z,u,v,w) arla_warnx (ADEBMISC,x,y,z,u,v,w)
#else
#define MESSAGE1(x) fprintf(stderr,x)
#define MESSAGE2(x,y) fprintf(stderr,x,y)
#define MESSAGE3(x,y,z) fprintf(stderr,x,y,z)
#define MESSAGE4(x,y,z,u) fprintf(stderr,x,y,z,u)
#define MESSAGE5(x,y,z,u,v) fprintf(stderr,x,y,z,u,v)
#define MESSAGE6(x,y,z,u,v,w) fprintf(stderr,x,y,z,u,v,w)
#endif /* SCFS */
/*
copyright 1997, 2000
the regents of the university of michigan
all rights reserved
permission is granted to use, copy, create derivative works
and redistribute this software and such derivative works
for any purpose, so long as the name of the university of
michigan is not used in any advertising or publicity
pertaining to the use or distribution of this software
without specific, written prior authorization. if the
above copyright notice or any other identification of the
university of michigan is included in any copy of any
portion of this software, then the disclaimer below must
also be included.
this software is provided as is, without representation
from the university of michigan as to its fitness for any
purpose, and without warranty by the university of
michigan of any kind, either express or implied, including
without limitation the implied warranties of
merchantability and fitness for a particular purpose. the
regents of the university of michigan shall not be liable
for any damages, including special, indirect, incidental, or
consequential damages, with respect to any claim arising
out of or in connection with the use of the software, even
if it has been or is hereafter advised of the possibility of
such damages.
*/
|