1 /**********************************************************************
2 *
3 * This file is part of Cardpeek, the smartcard reader utility.
4 *
5 * Copyright 2009 by 'L1L1'
6 *
7 * Cardpeek is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Cardpeek is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Cardpeek. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22
null_error(cardreader_t * cr)23 static int null_error(cardreader_t *cr)
24 {
25 UNUSED(cr);
26
27 log_printf(LOG_ERROR,"Operation failed: no connected reader selected");
28 return 0;
29 }
30
null_connect(cardreader_t * cr,unsigned prefered_protocol)31 static int null_connect(cardreader_t *cr, unsigned prefered_protocol)
32 {
33 UNUSED(prefered_protocol);
34
35 return null_error(cr);
36 }
37
null_transmit(cardreader_t * cr,const bytestring_t * command,bytestring_t * result)38 static unsigned short null_transmit(cardreader_t* cr,
39 const bytestring_t* command,
40 bytestring_t* result)
41 {
42 UNUSED(command);
43 UNUSED(result);
44
45 null_error(cr);
46 return CARDPEEK_ERROR_SW;
47 }
48
null_last_atr(cardreader_t * cr)49 static const bytestring_t* null_last_atr(cardreader_t* cr)
50 {
51 return cr->atr;
52 }
53
null_fail(cardreader_t * cr)54 static int null_fail(cardreader_t* cr)
55 {
56 UNUSED(cr);
57
58 return 1;
59 }
60
null_finalize(cardreader_t * cr)61 static void null_finalize(cardreader_t* cr)
62 {
63 /* null_error(cr); */
64 }
65
null_initialize(cardreader_t * reader)66 static int null_initialize(cardreader_t *reader)
67 {
68 reader->connect = null_connect;
69 reader->disconnect = null_error;
70 reader->reset = null_error;
71 reader->transmit = null_transmit;
72 reader->last_atr = null_last_atr;
73 reader->fail = null_fail;
74 reader->finalize = null_finalize;
75 return 1;
76 }
77
78