]> www.hackdaworld.org Git - rfid/librfid.git/blob - rfid.c
9f60bab952cac514a8ae423d327c7daaa040ca2d
[rfid/librfid.git] / 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(unsigned int id)
42 {
43         swicth(id) {
44         case RFID_READER_CM5121:
45                 rfid_reader_register(&rfid_reader_cm5121);
46                 break;
47         case RFID_READER_X501:
48                 rfid_reader_register(&rfid_reader_x501);
49                 break;
50         /*
51         case RFID_READER_PEGODA:
52                 rfid_reader_register(&rfid_reader_pegoda);
53                 break;
54         */
55         default:
56                 return -EINVAL;
57         }
58         rfid_layer2_register(&rfid_layer2_iso14443a);
59         rfid_layer2_register(&rfid_layer2_iso14443b);
60         rfid_protocol_register(&rfid_protocol_tcl);
61         rfid_protocol_register(&rfid_protocol_mful);
62         rfid_protocol_register(&rfid_protocol_mfcl);
63
64         return 0;
65 }
66
67 void rfid_fini()
68 {
69         /* FIXME: implementation */
70 }