updates library examples to use libnfc 1.7.0 API
This commit is contained in:
parent
9fda402cd3
commit
3dd6edcb3a
14 changed files with 73 additions and 59 deletions
|
@ -1,4 +1,4 @@
|
||||||
AC_INIT([libfreefare],[0.3.4])
|
AC_INIT([libfreefare],[0.3.5])
|
||||||
|
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ AC_CHECK_LIB([crypto], [DES_ecb_encrypt], [], [AC_MSG_ERROR([Cannot find libcryp
|
||||||
AC_CHECK_HEADERS([openssl/aes.h openssl/des.h openssl/rand.h], [], [AC_MSG_ERROR([Cannot find openssl headers.])])
|
AC_CHECK_HEADERS([openssl/aes.h openssl/des.h openssl/rand.h], [], [AC_MSG_ERROR([Cannot find openssl headers.])])
|
||||||
|
|
||||||
# Checks for pkg-config modules.
|
# Checks for pkg-config modules.
|
||||||
LIBNFC_REQUIRED_VERSION="1.6.0"
|
LIBNFC_REQUIRED_VERSION="1.7.0"
|
||||||
PKG_CHECK_MODULES([LIBNFC], [libnfc >= $LIBNFC_REQUIRED_VERSION], [], [AC_MSG_ERROR([libnfc >= $LIBNFC_REQUIRED_VERSION is mandatory.])])
|
PKG_CHECK_MODULES([LIBNFC], [libnfc >= $LIBNFC_REQUIRED_VERSION], [], [AC_MSG_ERROR([libnfc >= $LIBNFC_REQUIRED_VERSION is mandatory.])])
|
||||||
|
|
||||||
PKG_CONFIG_REQUIRES="libnfc"
|
PKG_CONFIG_REQUIRES="libnfc"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*-
|
/*-
|
||||||
* Copyright (C) 2010, Romain Tartiere, Romuald Conty.
|
* Copyright (C) 2010, Romain Tartiere, Romuald Conty.
|
||||||
|
* Copyright (C) 2012, Romuald Conty.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
@ -165,14 +166,15 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -247,6 +249,6 @@ main(int argc, char *argv[])
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,14 +115,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count= nfc_list_devices (NULL, devices, 8);
|
device_count= nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -228,6 +229,6 @@ error:
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,14 +195,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -408,6 +409,6 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
free (card_write_keys);
|
free (card_write_keys);
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,14 +41,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -131,7 +132,7 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
} /* main() */
|
} /* main() */
|
||||||
|
|
||||||
|
|
|
@ -96,14 +96,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
|
@ -310,6 +311,6 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,14 +89,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -174,7 +175,7 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
} /* main() */
|
} /* main() */
|
||||||
|
|
||||||
|
|
|
@ -75,14 +75,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -247,6 +248,6 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,14 +85,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -203,7 +204,7 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
} /* main() */
|
} /* main() */
|
||||||
|
|
||||||
|
|
|
@ -85,14 +85,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -166,7 +167,7 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
} /* main() */
|
} /* main() */
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
|
@ -141,7 +142,7 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
} /* main() */
|
} /* main() */
|
||||||
|
|
||||||
|
|
|
@ -124,14 +124,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
|
@ -269,6 +270,6 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,14 +153,15 @@ main(int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init(NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, 8);
|
device_count = nfc_list_devices (context, devices, 8);
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found.");
|
errx (EXIT_FAILURE, "No NFC device found.");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
device = nfc_open (NULL, devices[d]);
|
device = nfc_open (context, devices[d]);
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
|
@ -292,6 +293,6 @@ main(int argc, char *argv[])
|
||||||
freefare_free_tags (tags);
|
freefare_free_tags (tags);
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
nfc_exit(NULL);
|
nfc_exit (context);
|
||||||
exit (error);
|
exit (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,14 +36,15 @@ main (int argc, char *argv[])
|
||||||
nfc_connstring devices[8];
|
nfc_connstring devices[8];
|
||||||
size_t device_count;
|
size_t device_count;
|
||||||
|
|
||||||
nfc_init (NULL);
|
nfc_context *context;
|
||||||
|
nfc_init (&context);
|
||||||
|
|
||||||
device_count = nfc_list_devices (NULL, devices, sizeof (devices) / sizeof (*devices));
|
device_count = nfc_list_devices (context, devices, sizeof (devices) / sizeof (*devices));
|
||||||
if (device_count <= 0)
|
if (device_count <= 0)
|
||||||
errx (EXIT_FAILURE, "No NFC device found");
|
errx (EXIT_FAILURE, "No NFC device found");
|
||||||
|
|
||||||
for (size_t d = 0; d < device_count; d++) {
|
for (size_t d = 0; d < device_count; d++) {
|
||||||
if (!(device = nfc_open (NULL, devices[d]))) {
|
if (!(device = nfc_open (context, devices[d]))) {
|
||||||
warnx ("nfc_open() failed.");
|
warnx ("nfc_open() failed.");
|
||||||
error = EXIT_FAILURE;
|
error = EXIT_FAILURE;
|
||||||
continue;
|
continue;
|
||||||
|
@ -85,6 +86,6 @@ main (int argc, char *argv[])
|
||||||
nfc_close (device);
|
nfc_close (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_exit (NULL);
|
nfc_exit (context);
|
||||||
exit(error);
|
exit(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue