-
Notifications
You must be signed in to change notification settings - Fork 117
/
replay.h
98 lines (76 loc) · 2.31 KB
/
replay.h
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
/**********************************************************************
*
* This file is part of Cardpeek, the smart card reader utility.
*
* Copyright 2009-2013 by Alain Pannetrat <[email protected]>
*
* Cardpeek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cardpeek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cardpeek. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef REPLAY_H
#define REPLAY_H
#include "bytestring.h"
enum {
CARDREPLAY_COMMAND,
CARDREPLAY_RESET
};
enum {
CARDREPLAY_ERROR,
CARDREPLAY_OK
};
typedef struct _anyreplay_t {
struct _anyreplay_t *next;
unsigned type;
} anyreplay_t;
typedef struct _comreplay_t {
anyreplay_t *next;
unsigned type;
bytestring_t *query;
unsigned sw;
bytestring_t *response;
} comreplay_t;
typedef struct _resreplay_t {
anyreplay_t *next;
unsigned type;
bytestring_t *atr;
} resreplay_t;
typedef union {
anyreplay_t *any;
comreplay_t *com;
resreplay_t *res;
} replay_t;
typedef struct _cardreplay_t {
int count;
replay_t start;
replay_t pos;
replay_t atr;
} cardreplay_t;
int cardreplay_add_command(cardreplay_t* ce,
const bytestring_t* command,
unsigned sw, const bytestring_t* result);
int cardreplay_add_reset(cardreplay_t* ce, const bytestring_t* atr);
cardreplay_t* cardreplay_new(void);
void cardreplay_free(cardreplay_t* ce);
anyreplay_t* cardreplay_after_atr(cardreplay_t* ce);
int cardreplay_run_command(cardreplay_t* ce,
const bytestring_t* command,
unsigned short *sw,
bytestring_t *response);
int cardreplay_run_cold_reset(cardreplay_t* ce);
int cardreplay_run_warm_reset(cardreplay_t* ce);
int cardreplay_run_last_atr(const cardreplay_t* ce, bytestring_t *atr);
int cardreplay_save_to_file(const cardreplay_t* ce, const char *filename);
cardreplay_t* cardreplay_new_from_file(const char *filename);
int cardreplay_count_records(const cardreplay_t* ce);
#endif