Import code to load configuration from file.

WARNING: This commit do not contains a fully cleaned code:
 - Only nfc-list have been tested
 - Some -commented- code is not used ATM
 - Some printf-as-debug remain in this commit
... but that a bit usable so... happy hacking ;-)
This commit is contained in:
Romuald Conty 2012-11-24 13:10:28 +01:00
parent 3ee77eb79e
commit 7963fdfc3b
9 changed files with 231 additions and 36 deletions

View file

@ -75,7 +75,8 @@ main(int argc, const char *argv[])
bool verbose = false;
int res = 0;
nfc_init(NULL);
nfc_context *context;
nfc_init(&context);
// Display libnfc version
acLibnfcVersion = nfc_version();
@ -97,7 +98,7 @@ main(int argc, const char *argv[])
/* Lazy way to open an NFC device */
#if 0
pnd = nfc_open(NULL, NULL);
pnd = nfc_open(context, NULL);
#endif
/* If specific device is wanted, i.e. an ARYGON device on /dev/ttyUSB0 */
@ -106,7 +107,7 @@ main(int argc, const char *argv[])
ndd.pcDriver = "ARYGON";
ndd.pcPort = "/dev/ttyUSB0";
ndd.uiSpeed = 115200;
pnd = nfc_open(NULL, &ndd);
pnd = nfc_open(context, &ndd);
#endif
/* If specific device is wanted, i.e. a SCL3711 on USB */
@ -114,10 +115,10 @@ main(int argc, const char *argv[])
nfc_device_desc_t ndd;
ndd.pcDriver = "PN533_USB";
strcpy(ndd.acDevice, "SCM Micro / SCL3711-NFC&RW");
pnd = nfc_open(NULL, &ndd);
pnd = nfc_open(context, &ndd);
#endif
nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t szDeviceFound = nfc_list_devices(NULL, connstrings, MAX_DEVICE_COUNT);
size_t szDeviceFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
if (szDeviceFound == 0) {
printf("No NFC device found.\n");
@ -125,7 +126,7 @@ main(int argc, const char *argv[])
for (i = 0; i < szDeviceFound; i++) {
nfc_target ant[MAX_TARGET_COUNT];
pnd = nfc_open(NULL, connstrings[i]);
pnd = nfc_open(context, connstrings[i]);
if (pnd == NULL) {
ERR("Unable to open NFC device: %s", connstrings[i]);