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