fix various compile warnings. code cleanup
[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.h>
19 #include <librfid/rfid_reader_cm5121.h>
20 #include <librfid/rfid_reader_openpcd.h>
21 #include <librfid/rfid_protocol.h>
22 #include <librfid/rfid_protocol_tcl.h>
23 #include <librfid/rfid_protocol_mifare_ul.h>
24 #include <librfid/rfid_protocol_mifare_classic.h>
25
26 const char *
27 rfid_hexdump(const void *data, unsigned int len)
28 {
29         static char string[1024];
30         unsigned char *d = (unsigned char *) data;
31         unsigned int i, left;
32
33         string[0] = '\0';
34         left = sizeof(string);
35         for (i = 0; len--; i += 3) {
36                 if (i >= sizeof(string) -4)
37                         break;
38                 snprintf(string+i, 4, " %02x", *d++);
39         }
40         return string;
41 }
42
43 int rfid_init()
44 {
45         rfid_reader_register(&rfid_reader_cm5121);
46         rfid_reader_register(&rfid_reader_openpcd);
47         rfid_layer2_register(&rfid_layer2_iso14443a);
48         rfid_layer2_register(&rfid_layer2_iso14443b);
49         rfid_protocol_register(&rfid_protocol_tcl);
50         rfid_protocol_register(&rfid_protocol_mful);
51         rfid_protocol_register(&rfid_protocol_mfcl);
52
53         return 0;
54 }
55
56 void rfid_fini()
57 {
58         /* FIXME: implementation */
59 }