updated win32 support for MINGW32-compiler/cross-compiler
[librfid] / src / rfid.c
1 /* librfid core 
2  *  (C) 2005-2006 by Harald Welte <laforge@gnumonks.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License version 2 
6  *  as published by the Free Software Foundation
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17 #include <stdio.h>
18 #include <string.h>
19
20 #include <librfid/rfid.h>
21 #include <librfid/rfid_reader.h>
22 #include <librfid/rfid_protocol.h>
23 #include <librfid/rfid_protocol_tcl.h>
24 #include <librfid/rfid_protocol_mifare_ul.h>
25 #include <librfid/rfid_protocol_mifare_classic.h>
26
27 #ifdef LIBRFID_STATIC
28 struct rfid_asic_handle rfid_ah;
29 struct rfid_layer2_handle rfid_l2h;
30 struct rfid_protocol_handle rfid_ph;
31 struct rfid_asic_transport_handle rfid_ath;
32 struct rfid_reader_handle rfid_rh;
33 #endif
34
35 #ifndef LIBRFID_FIRMWARE
36 #ifdef  LIBRFID_DEBUG
37 const char *
38 rfid_hexdump(const void *data, unsigned int len)
39 {
40         static char string[1024];
41         unsigned char *d = (unsigned char *) data;
42         unsigned int i, left;
43
44         string[0] = '\0';
45         left = sizeof(string);
46         for (i = 0; len--; i += 3) {
47                 if (i >= sizeof(string) -4)
48                         break;
49                 snprintf(string+i, 4, " %02x", *d++);
50         }
51         return string;
52 }
53 #endif/*LIBRFID_DEBUG*/
54 #else
55 #define rfid_hexdump(x, y) hexdump(x, y)
56 #endif
57
58 #if 0
59 int rfid_setopt(struct rfid_handle *rh, unsigned int level,
60                 unsigned int optname,
61                 const void *opt, unsigned int *optlen)
62 {
63         switch (level) {
64         case RFID_LEVEL_ASIC:
65         case RFID_LEVEL_READER:
66                 return -EINVAL;
67                 break;
68         case RFID_LEVEL_LAYER2:
69                 return rfid_layer2_setopt(optname, opt, optlen);
70                 break;
71         case RFID_LEVEL_LAYER3:
72                 return rfid_layer3_setopt(optname, opt, optlen);
73                 break;
74         default:
75                 return -EINVAL;
76                 break;
77         }
78
79         return 0;
80 }
81
82 int rfid_getopt(struct rfid_handle *rh, unsigned int level,
83                 unsigned int optname,
84                 void *opt, unsigned int *optlen)
85 {
86         switch (level) {
87         case RFID_LEVEL_ASIC:
88         case RFID_LEVEL_READER:
89                 return -EINVAL;
90                 break;
91         case RFID_LEVEL_LAYER2:
92                 return rfid_layer2_getopt(optname, opt, optlen);
93                 break;
94         case RFID_LEVEL_LAYER3:
95                 return rfid_layer3_getopt(optname, opt, optlen);
96                 break;
97         default:
98                 return -EINVAL;
99                 break;
100         }
101
102         return 0;
103 }
104 #endif
105
106 int rfid_init()
107 {
108         return 0;
109 }
110
111 void rfid_fini()
112 {
113         /* FIXME: implementation */
114 }