libnfc
1.8.0
libnfc
nfc-device.c
Go to the documentation of this file.
1
/*-
2
* Free/Libre Near Field Communication (NFC) library
3
*
4
* Libnfc historical contributors:
5
* Copyright (C) 2009 Roel Verdult
6
* Copyright (C) 2009-2013 Romuald Conty
7
* Copyright (C) 2010-2012 Romain Tartière
8
* Copyright (C) 2010-2013 Philippe Teuwen
9
* Copyright (C) 2012-2013 Ludovic Rousseau
10
* See AUTHORS file for a more comprehensive list of contributors.
11
* Additional contributors of this file:
12
*
13
* This program is free software: you can redistribute it and/or modify it
14
* under the terms of the GNU Lesser General Public License as published by the
15
* Free Software Foundation, either version 3 of the License, or (at your
16
* option) any later version.
17
*
18
* This program is distributed in the hope that it will be useful, but WITHOUT
19
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21
* more details.
22
*
23
* You should have received a copy of the GNU Lesser General Public License
24
* along with this program. If not, see <http://www.gnu.org/licenses/>
25
*/
26
32
#include <stdlib.h>
33
#include <string.h>
34
35
#ifdef HAVE_CONFIG_H
36
# include "config.h"
37
#endif
// HAVE_CONFIG_H
38
39
#include "
nfc-internal.h
"
40
41
nfc_device
*
42
nfc_device_new(
const
nfc_context
*context,
const
nfc_connstring
connstring)
43
{
44
nfc_device
*res = malloc(
sizeof
(*res));
45
46
if
(!res) {
47
return
NULL;
48
}
49
50
// Store associated context
51
res->context = context;
52
53
// Variables initiatialization
54
// Note: Actually, these initialization will be overwritten while the device
55
// will be setup. Putting them to _false_ while the default is _true_ ensure we
56
// send the command to the chip
57
res->
bCrc
=
false
;
58
res->
bPar
=
false
;
59
res->
bEasyFraming
=
false
;
60
res->
bInfiniteSelect
=
false
;
61
res->
bAutoIso14443_4
=
false
;
62
res->
last_error
= 0;
63
memcpy(res->
connstring
, connstring,
sizeof
(res->
connstring
));
64
res->driver_data = NULL;
65
res->chip_data = NULL;
66
67
return
res;
68
}
69
70
void
71
nfc_device_free(
nfc_device
*dev)
72
{
73
if
(dev) {
74
free(dev->driver_data);
75
free(dev);
76
}
77
}
nfc-internal.h
Internal defines and macros.
nfc_connstring
char nfc_connstring[NFC_BUFSIZE_CONNSTRING]
Definition:
nfc-types.h:63
nfc_context
NFC library context Struct which contains internal options, references, pointers, etc....
Definition:
nfc-internal.h:175
nfc_device
NFC device information.
Definition:
nfc-internal.h:190
nfc_device::last_error
int last_error
Definition:
nfc-internal.h:214
nfc_device::bEasyFraming
bool bEasyFraming
Definition:
nfc-internal.h:205
nfc_device::bPar
bool bPar
Definition:
nfc-internal.h:203
nfc_device::connstring
nfc_connstring connstring
Definition:
nfc-internal.h:199
nfc_device::bInfiniteSelect
bool bInfiniteSelect
Definition:
nfc-internal.h:207
nfc_device::bAutoIso14443_4
bool bAutoIso14443_4
Definition:
nfc-internal.h:210
nfc_device::bCrc
bool bCrc
Definition:
nfc-internal.h:201
Generated by
1.9.1