ea6c0aaccbe327fe5e9a1482014d8ab2d7a61666
[librfid] / src / rfid.c
1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License version 2 
4  *  as published by the Free Software Foundation
5  *
6  *  This program is distributed in the hope that it will be useful,
7  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9  *  GNU General Public License for more details.
10  *
11  *  You should have received a copy of the GNU General Public License
12  *  along with this program; if not, write to the Free Software
13  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14  */
15 #include <stdio.h>
16 #include <string.h>
17
18 #include <librfid/rfid_reader_cm5121.h>
19 #include <librfid/rfid_reader_openpcd.h>
20 #include <librfid/rfid_protocol.h>
21 #include <librfid/rfid_protocol_tcl.h>
22 #include <librfid/rfid_protocol_mifare_ul.h>
23 #include <librfid/rfid_protocol_mifare_classic.h>
24
25 const char *
26 rfid_hexdump(const void *data, unsigned int len)
27 {
28         static char string[1024];
29         unsigned char *d = (unsigned char *) data;
30         unsigned int i, left;
31
32         string[0] = '\0';
33         left = sizeof(string);
34         for (i = 0; len--; i += 3) {
35                 if (i >= sizeof(string) -4)
36                         break;
37                 snprintf(string+i, 4, " %02x", *d++);
38         }
39         return string;
40 }
41
42 int rfid_init()
43 {
44         rfid_reader_register(&rfid_reader_cm5121);
45         rfid_reader_register(&rfid_reader_openpcd);
46         rfid_layer2_register(&rfid_layer2_iso14443a);
47         rfid_layer2_register(&rfid_layer2_iso14443b);
48         rfid_protocol_register(&rfid_protocol_tcl);
49         rfid_protocol_register(&rfid_protocol_mful);
50         rfid_protocol_register(&rfid_protocol_mfcl);
51
52         return 0;
53 }
54
55 void rfid_fini()
56 {
57         /* FIXME: implementation */
58 }