Run make style to indent macros

This commit is contained in:
Romain Tartière 2017-06-29 12:25:53 +02:00
parent c54e3d981c
commit 69bf99b33d
30 changed files with 272 additions and 272 deletions

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <ctype.h> #include <ctype.h>
@ -8,15 +8,15 @@
#include <unistd.h> #include <unistd.h>
#if defined(HAVE_SYS_ENDIAN_H) #if defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#if defined(HAVE_ENDIAN_H) #if defined(HAVE_ENDIAN_H)
# include <endian.h> #include <endian.h>
#endif #endif
#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) #if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H)
# include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#endif #endif
#include <nfc/nfc.h> #include <nfc/nfc.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -14,7 +14,7 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <err.h> #include <err.h>

View file

@ -8,7 +8,7 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <assert.h> #include <assert.h>
@ -18,7 +18,7 @@
#include <sys/types.h> #include <sys/types.h>
#ifdef WITH_DEBUG #ifdef WITH_DEBUG
# include <libutil.h> #include <libutil.h>
#endif #endif
#include <freefare.h> #include <freefare.h>

View file

@ -1,5 +1,5 @@
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <stdlib.h> #include <stdlib.h>

View file

@ -279,11 +279,11 @@ bit 0: PICC master key frozen (reversible with configuration change or when form
*/ */
#define MDMK_SETTINGS(picc_master_key_settings_changeable,free_create_delete_application,free_listing_apps_and_key_settings,picc_master_key_changeable) ( \ #define MDMK_SETTINGS(picc_master_key_settings_changeable,free_create_delete_application,free_listing_apps_and_key_settings,picc_master_key_changeable) ( \
(picc_master_key_settings_changeable << 3) | \ (picc_master_key_settings_changeable << 3) | \
(free_create_delete_application << 2) | \ (free_create_delete_application << 2) | \
(free_listing_apps_and_key_settings << 1) | \ (free_listing_apps_and_key_settings << 1) | \
(picc_master_key_changeable) \ (picc_master_key_changeable) \
) )
/* Mifare DESFire EV1 Application crypto operations */ /* Mifare DESFire EV1 Application crypto operations */
@ -300,21 +300,21 @@ bit 0: PICC master key frozen (reversible with configuration change or when form
*/ */
#define MDAPP_SETTINGS(key_no_for_key_changing,config_changeable,free_create_delete_files,free_listing_contents,app_master_key_changeable) ( \ #define MDAPP_SETTINGS(key_no_for_key_changing,config_changeable,free_create_delete_files,free_listing_contents,app_master_key_changeable) ( \
(key_no_for_key_changing << 4) | \ (key_no_for_key_changing << 4) | \
(config_changeable << 3) | \ (config_changeable << 3) | \
(free_create_delete_files << 2) | \ (free_create_delete_files << 2) | \
(free_listing_contents << 1) | \ (free_listing_contents << 1) | \
(app_master_key_changeable) \ (app_master_key_changeable) \
) )
/* Access right */ /* Access right */
#define MDAR(read,write,read_write,change_access_rights) ( \ #define MDAR(read,write,read_write,change_access_rights) ( \
(read << 12) | \ (read << 12) | \
(write << 8) | \ (write << 8) | \
(read_write << 4) | \ (read_write << 4) | \
(change_access_rights) \ (change_access_rights) \
) )
#define MDAR_READ(ar) (((ar) >> 12) & 0x0f) #define MDAR_READ(ar) (((ar) >> 12) & 0x0f)
#define MDAR_WRITE(ar) (((ar) >> 8) & 0x0f) #define MDAR_WRITE(ar) (((ar) >> 8) & 0x0f)

View file

@ -2,7 +2,7 @@
#define __FREEFARE_INTERNAL_H__ #define __FREEFARE_INTERNAL_H__
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <openssl/des.h> #include <openssl/des.h>
@ -25,55 +25,55 @@
*/ */
#if !defined(le32toh) && defined(letoh32) #if !defined(le32toh) && defined(letoh32)
# define le32toh(x) letoh32(x) #define le32toh(x) letoh32(x)
# define be32toh(x) betoh32(x) #define be32toh(x) betoh32(x)
#endif #endif
#if !defined(le16toh) && defined(letoh16) #if !defined(le16toh) && defined(letoh16)
# define le16toh(x) letoh16(x) #define le16toh(x) letoh16(x)
# define be16toh(x) betoh16(x) #define be16toh(x) betoh16(x)
#endif #endif
#if !defined(le32toh) && defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) #if !defined(le32toh) && defined(HAVE_COREFOUNDATION_COREFOUNDATION_H)
# define be32toh(x) CFSwapInt32BigToHost(x) #define be32toh(x) CFSwapInt32BigToHost(x)
# define htobe32(x) CFSwapInt32HostToBig(x) #define htobe32(x) CFSwapInt32HostToBig(x)
# define le32toh(x) CFSwapInt32LittleToHost(x) #define le32toh(x) CFSwapInt32LittleToHost(x)
# define htole32(x) CFSwapInt32HostToLittle(x) #define htole32(x) CFSwapInt32HostToLittle(x)
#endif #endif
#if !defined(le16toh) && defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) #if !defined(le16toh) && defined(HAVE_COREFOUNDATION_COREFOUNDATION_H)
# define be16toh(x) CFSwapInt16BigToHost(x) #define be16toh(x) CFSwapInt16BigToHost(x)
# define htobe16(x) CFSwapInt16HostToBig(x) #define htobe16(x) CFSwapInt16HostToBig(x)
# define le16toh(x) CFSwapInt16LittleToHost(x) #define le16toh(x) CFSwapInt16LittleToHost(x)
# define htole16(x) CFSwapInt16HostToLittle(x) #define htole16(x) CFSwapInt16HostToLittle(x)
#endif #endif
#if !defined(le32toh) && defined(bswap_32) #if !defined(le32toh) && defined(bswap_32)
# if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
# define be32toh(x) bswap_32(x) #define be32toh(x) bswap_32(x)
# define htobe32(x) bswap_32(x) #define htobe32(x) bswap_32(x)
# define le32toh(x) (x) #define le32toh(x) (x)
# define htole32(x) (x) #define htole32(x) (x)
# else #else
# define be32toh(x) (x) #define be32toh(x) (x)
# define htobe32(x) (x) #define htobe32(x) (x)
# define le32toh(x) bswap_32(x) #define le32toh(x) bswap_32(x)
# define htole32(x) bswap_32(x) #define htole32(x) bswap_32(x)
# endif #endif
#endif #endif
#if !defined(htole16) && defined(bswap_16) #if !defined(htole16) && defined(bswap_16)
# if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
# define be16toh(x) (bswap_16(x)) #define be16toh(x) (bswap_16(x))
# define htobe16(x) (bswap_16(x)) #define htobe16(x) (bswap_16(x))
# define htole16(x) (x) #define htole16(x) (x)
# define le16toh(x) (x) #define le16toh(x) (x)
# else #else
# define be16toh(x) (x) #define be16toh(x) (x)
# define htobe16(x) (x) #define htobe16(x) (x)
# define htole16(x) (bswap_16(x)) #define htole16(x) (bswap_16(x))
# define le16toh(x) (bswap_16(x)) #define le16toh(x) (bswap_16(x))
# endif #endif
#endif #endif
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b))
@ -276,11 +276,11 @@ struct ntag21x_key {
#define TB_AB(ab) ((ab == C_DEFAULT) ? C_100 : ab) #define TB_AB(ab) ((ab == C_DEFAULT) ? C_100 : ab)
#ifdef WITH_DEBUG #ifdef WITH_DEBUG
#define DEBUG_FUNCTION() do { printf("*** \033[033;1m%s\033[0m ***\n", __FUNCTION__); } while (0) #define DEBUG_FUNCTION() do { printf("*** \033[033;1m%s\033[0m ***\n", __FUNCTION__); } while (0)
#define DEBUG_XFER(data, nbytes, hint) do { hexdump (data, nbytes, hint, 0); } while (0) #define DEBUG_XFER(data, nbytes, hint) do { hexdump (data, nbytes, hint, 0); } while (0)
#else #else
#define DEBUG_FUNCTION() do {} while (0) #define DEBUG_FUNCTION() do {} while (0)
#define DEBUG_XFER(data, nbytes, hint) do {} while (0) #define DEBUG_XFER(data, nbytes, hint) do {} while (0)
#endif #endif
@ -328,7 +328,7 @@ struct ntag21x_key {
*/ */
#define BUFFER_APPEND(buffer_name, data) \ #define BUFFER_APPEND(buffer_name, data) \
do { \ do { \
buffer_name[__##buffer_name##_n++] = data; \ buffer_name[__##buffer_name##_n++] = data; \
} while (0) } while (0)
/* /*
@ -336,10 +336,10 @@ struct ntag21x_key {
*/ */
#define BUFFER_APPEND_BYTES(buffer_name, data, size) \ #define BUFFER_APPEND_BYTES(buffer_name, data, size) \
do { \ do { \
size_t __n = 0; \ size_t __n = 0; \
while (__n < size) { \ while (__n < size) { \
buffer_name[__##buffer_name##_n++] = ((uint8_t *)data)[__n++]; \ buffer_name[__##buffer_name##_n++] = ((uint8_t *)data)[__n++]; \
} \ } \
} while (0) } while (0)
/* /*
@ -354,17 +354,17 @@ struct ntag21x_key {
#if defined(_BYTE_ORDER) && (_BYTE_ORDER != _LITTLE_ENDIAN) #if defined(_BYTE_ORDER) && (_BYTE_ORDER != _LITTLE_ENDIAN)
#define BUFFER_APPEND_LE(buffer, data, data_size, field_size) \ #define BUFFER_APPEND_LE(buffer, data, data_size, field_size) \
do { \ do { \
size_t __data_size = data_size; \ size_t __data_size = data_size; \
size_t __field_size = field_size; \ size_t __field_size = field_size; \
while (__field_size--, __data_size--) { \ while (__field_size--, __data_size--) { \
buffer[__##buffer##_n++] = ((uint8_t *)&data)[__field_size]; \ buffer[__##buffer##_n++] = ((uint8_t *)&data)[__field_size]; \
} \ } \
} while (0) } while (0)
#else #else
#define BUFFER_APPEND_LE(buffer, data, data_size, field_size) \ #define BUFFER_APPEND_LE(buffer, data, data_size, field_size) \
do { \ do { \
memcpy (buffer + __##buffer##_n, &data, data_size); \ memcpy (buffer + __##buffer##_n, &data, data_size); \
__##buffer##_n += data_size; \ __##buffer##_n += data_size; \
} while (0) } while (0)
#endif #endif

View file

@ -12,7 +12,7 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <sys/types.h> #include <sys/types.h>

View file

@ -6,7 +6,7 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#include <errno.h> #include <errno.h>

View file

@ -20,27 +20,27 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#if defined(HAVE_SYS_TYPES_H) #if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h> #include <sys/types.h>
#endif #endif
#if defined(HAVE_SYS_ENDIAN_H) #if defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#if defined(HAVE_ENDIAN_H) #if defined(HAVE_ENDIAN_H)
# include <endian.h> #include <endian.h>
#endif #endif
#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) #if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H)
# include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#endif #endif
#if defined(HAVE_BYTESWAP_H) #if defined(HAVE_BYTESWAP_H)
# include <byteswap.h> #include <byteswap.h>
#endif #endif
#include <errno.h> #include <errno.h>
@ -49,7 +49,7 @@
#include <strings.h> #include <strings.h>
#ifdef WITH_DEBUG #ifdef WITH_DEBUG
# include <libutil.h> #include <libutil.h>
#endif #endif
#include <freefare.h> #include <freefare.h>
@ -70,19 +70,19 @@
#define CLASSIC_TRANSCEIVE_EX(tag, msg, res, disconnect) \ #define CLASSIC_TRANSCEIVE_EX(tag, msg, res, disconnect) \
do { \ do { \
errno = 0; \ errno = 0; \
DEBUG_XFER (msg, __##msg##_n, "===> "); \ DEBUG_XFER (msg, __##msg##_n, "===> "); \
int _res; \ int _res; \
if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \ if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \
if (disconnect) { \ if (disconnect) { \
tag->active = false; \ tag->active = false; \
} \ } \
if (_res == NFC_EMFCAUTHFAIL) \ if (_res == NFC_EMFCAUTHFAIL) \
return errno = EACCES, -1; \ return errno = EACCES, -1; \
return errno = EIO, -1; \ return errno = EIO, -1; \
} \ } \
__##res##_n = _res; \ __##res##_n = _res; \
DEBUG_XFER (res, __##res##_n, "<=== "); \ DEBUG_XFER (res, __##res##_n, "<=== "); \
} while (0) } while (0)

View file

@ -13,27 +13,27 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#if defined(HAVE_SYS_TYPES_H) #if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h> #include <sys/types.h>
#endif #endif
#if defined(HAVE_SYS_ENDIAN_H) #if defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#if defined(HAVE_ENDIAN_H) #if defined(HAVE_ENDIAN_H)
# include <endian.h> #include <endian.h>
#endif #endif
#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) #if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H)
# include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#endif #endif
#if defined(HAVE_BYTESWAP_H) #if defined(HAVE_BYTESWAP_H)
# include <byteswap.h> #include <byteswap.h>
#endif #endif
#include <errno.h> #include <errno.h>
@ -42,7 +42,7 @@
#include <strings.h> #include <strings.h>
#ifdef WITH_DEBUG #ifdef WITH_DEBUG
# include <libutil.h> #include <libutil.h>
#endif #endif
#include <openssl/rand.h> #include <openssl/rand.h>
@ -93,9 +93,9 @@ static ssize_t read_data(FreefareTag tag, uint8_t command, uint8_t file_no, off
#define ASSERT_AUTHENTICATED(tag) \ #define ASSERT_AUTHENTICATED(tag) \
do { \ do { \
if (MIFARE_DESFIRE (tag)->authenticated_key_no == NOT_YET_AUTHENTICATED) { \ if (MIFARE_DESFIRE (tag)->authenticated_key_no == NOT_YET_AUTHENTICATED) { \
return errno = EINVAL, -1;\ return errno = EINVAL, -1;\
} \ } \
} while (0) } while (0)
/* /*
@ -104,20 +104,20 @@ static ssize_t read_data(FreefareTag tag, uint8_t command, uint8_t file_no, off
*/ */
#define ASSERT_CS(cs) \ #define ASSERT_CS(cs) \
do { \ do { \
if (cs < 0) { \ if (cs < 0) { \
return errno = EINVAL, -1; \ return errno = EINVAL, -1; \
} else if (cs == 0x02) { \ } else if (cs == 0x02) { \
return errno = EINVAL, -1; \ return errno = EINVAL, -1; \
} else if (cs > 0x03) { \ } else if (cs > 0x03) { \
return errno = EINVAL, -1; \ return errno = EINVAL, -1; \
} \ } \
} while (0) } while (0)
#define ASSERT_NOT_NULL(argument) \ #define ASSERT_NOT_NULL(argument) \
do { \ do { \
if (!argument) { \ if (!argument) { \
return errno = EINVAL, -1; \ return errno = EINVAL, -1; \
} \ } \
} while (0) } while (0)
@ -149,38 +149,38 @@ static ssize_t read_data(FreefareTag tag, uint8_t command, uint8_t file_no, off
*/ */
#define DESFIRE_TRANSCEIVE2(tag, msg, msg_len, res) \ #define DESFIRE_TRANSCEIVE2(tag, msg, msg_len, res) \
do { \ do { \
DEBUG_FUNCTION(); \ DEBUG_FUNCTION(); \
static uint8_t __msg[MAX_CAPDU_SIZE + 5] = { 0x90, 0x00, 0x00, 0x00, 0x00, /* ..., */ 0x00 }; \ static uint8_t __msg[MAX_CAPDU_SIZE + 5] = { 0x90, 0x00, 0x00, 0x00, 0x00, /* ..., */ 0x00 }; \
/* CLA INS P1 P2 Lc PAYLOAD LE*/ \ /* CLA INS P1 P2 Lc PAYLOAD LE*/ \
static uint8_t __res[MAX_RAPDU_SIZE + 1]; \ static uint8_t __res[MAX_RAPDU_SIZE + 1]; \
size_t __len = 5; \ size_t __len = 5; \
errno = 0; \ errno = 0; \
if (!msg) return errno = EINVAL, -1; \ if (!msg) return errno = EINVAL, -1; \
__msg[1] = msg[0]; \ __msg[1] = msg[0]; \
if (msg_len > 1) { \ if (msg_len > 1) { \
__len += msg_len; \ __len += msg_len; \
__msg[4] = msg_len - 1; \ __msg[4] = msg_len - 1; \
memcpy (__msg + 5, msg + 1, msg_len - 1); \ memcpy (__msg + 5, msg + 1, msg_len - 1); \
} \ } \
/* reply length */ \ /* reply length */ \
__msg[__len-1] = 0x00; \ __msg[__len-1] = 0x00; \
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK; \ MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK; \
MIFARE_DESFIRE (tag)->last_pcd_error = OPERATION_OK; \ MIFARE_DESFIRE (tag)->last_pcd_error = OPERATION_OK; \
DEBUG_XFER (__msg, __len, "===> "); \ DEBUG_XFER (__msg, __len, "===> "); \
int _res; \ int _res; \
if ((_res = nfc_initiator_transceive_bytes (tag->device, __msg, __len, __res, __##res##_size + 1, 0)) < 0) { \ if ((_res = nfc_initiator_transceive_bytes (tag->device, __msg, __len, __res, __##res##_size + 1, 0)) < 0) { \
return errno = EIO, -1; \ return errno = EIO, -1; \
} \ } \
__##res##_n = _res; \ __##res##_n = _res; \
DEBUG_XFER (__res, __##res##_n, "<=== "); \ DEBUG_XFER (__res, __##res##_n, "<=== "); \
res[__##res##_n-2] = __res[__##res##_n-1]; \ res[__##res##_n-2] = __res[__##res##_n-1]; \
__##res##_n--; \ __##res##_n--; \
if ((1 == __##res##_n) && (ADDITIONAL_FRAME != res[__##res##_n-1]) && (OPERATION_OK != res[__##res##_n-1])) { \ if ((1 == __##res##_n) && (ADDITIONAL_FRAME != res[__##res##_n-1]) && (OPERATION_OK != res[__##res##_n-1])) { \
if (res[0] == AUTHENTICATION_ERROR) \ if (res[0] == AUTHENTICATION_ERROR) \
errno = EACCES; \ errno = EACCES; \
return MIFARE_DESFIRE (tag)->last_picc_error = res[0], -1; \ return MIFARE_DESFIRE (tag)->last_picc_error = res[0], -1; \
} \ } \
memcpy (res, __res, __##res##_n - 1); \ memcpy (res, __res, __##res##_n - 1); \
} while (0) } while (0)

View file

@ -8,27 +8,27 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#if defined(HAVE_SYS_TYPES_H) #if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h> #include <sys/types.h>
#endif #endif
#if defined(HAVE_SYS_ENDIAN_H) #if defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#if defined(HAVE_ENDIAN_H) #if defined(HAVE_ENDIAN_H)
# include <endian.h> #include <endian.h>
#endif #endif
#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) #if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H)
# include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#endif #endif
#if defined(HAVE_BYTESWAP_H) #if defined(HAVE_BYTESWAP_H)
# include <byteswap.h> #include <byteswap.h>
#endif #endif
#include <errno.h> #include <errno.h>

View file

@ -8,32 +8,32 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#if defined(HAVE_SYS_TYPES_H) #if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h> #include <sys/types.h>
#endif #endif
#if defined(HAVE_SYS_ENDIAN_H) #if defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#if defined(HAVE_ENDIAN_H) #if defined(HAVE_ENDIAN_H)
# include <endian.h> #include <endian.h>
#endif #endif
#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) #if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H)
# include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#endif #endif
#if defined(HAVE_BYTESWAP_H) #if defined(HAVE_BYTESWAP_H)
# include <byteswap.h> #include <byteswap.h>
#endif #endif
#if defined(HAVE_SYS_TYPES_H) #if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h> #include <sys/types.h>
#endif #endif
#include <openssl/aes.h> #include <openssl/aes.h>
@ -45,7 +45,7 @@
#include <strings.h> #include <strings.h>
#ifdef WITH_DEBUG #ifdef WITH_DEBUG
# include <libutil.h> #include <libutil.h>
#endif #endif
#include <freefare.h> #include <freefare.h>

View file

@ -10,11 +10,11 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#if defined(HAVE_SYS_TYPES_H) #if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h> #include <sys/types.h>
#endif #endif
#include <errno.h> #include <errno.h>
@ -22,7 +22,7 @@
#include <string.h> #include <string.h>
#ifdef WITH_DEBUG #ifdef WITH_DEBUG
# include <libutil.h> #include <libutil.h>
#endif #endif
#include <freefare.h> #include <freefare.h>
@ -30,48 +30,48 @@
#define ASSERT_VALID_PAGE(tag, page, mode_write) \ #define ASSERT_VALID_PAGE(tag, page, mode_write) \
do { \ do { \
if (is_mifare_ultralightc (tag)) { \ if (is_mifare_ultralightc (tag)) { \
if (mode_write) { \ if (mode_write) { \
if (page >= MIFARE_ULTRALIGHT_C_PAGE_COUNT) return errno = EINVAL, -1; \ if (page >= MIFARE_ULTRALIGHT_C_PAGE_COUNT) return errno = EINVAL, -1; \
} else { \ } else { \
if (page >= MIFARE_ULTRALIGHT_C_PAGE_COUNT_READ) return errno = EINVAL, -1; \ if (page >= MIFARE_ULTRALIGHT_C_PAGE_COUNT_READ) return errno = EINVAL, -1; \
} \ } \
} else { \ } else { \
if (page >= MIFARE_ULTRALIGHT_PAGE_COUNT) return errno = EINVAL, -1; \ if (page >= MIFARE_ULTRALIGHT_PAGE_COUNT) return errno = EINVAL, -1; \
} \ } \
} while (0) } while (0)
#define ULTRALIGHT_TRANSCEIVE(tag, msg, res) \ #define ULTRALIGHT_TRANSCEIVE(tag, msg, res) \
do { \ do { \
errno = 0; \ errno = 0; \
DEBUG_XFER (msg, __##msg##_n, "===> "); \ DEBUG_XFER (msg, __##msg##_n, "===> "); \
int _res; \ int _res; \
if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \ if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \
return errno = EIO, -1; \ return errno = EIO, -1; \
} \ } \
__##res##_n = _res; \ __##res##_n = _res; \
DEBUG_XFER (res, __##res##_n, "<=== "); \ DEBUG_XFER (res, __##res##_n, "<=== "); \
} while (0) } while (0)
#define ULTRALIGHT_TRANSCEIVE_RAW(tag, msg, res) \ #define ULTRALIGHT_TRANSCEIVE_RAW(tag, msg, res) \
do { \ do { \
errno = 0; \ errno = 0; \
if (nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, false) < 0) { \ if (nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, false) < 0) { \
errno = EIO; \ errno = EIO; \
return -1; \ return -1; \
} \ } \
DEBUG_XFER (msg, __##msg##_n, "===> "); \ DEBUG_XFER (msg, __##msg##_n, "===> "); \
int _res; \ int _res; \
if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \ if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \
nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, true); \ nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, true); \
return errno = EIO, -1; \ return errno = EIO, -1; \
} \ } \
__##res##_n = _res; \ __##res##_n = _res; \
DEBUG_XFER (res, __##res##_n, "<=== "); \ DEBUG_XFER (res, __##res##_n, "<=== "); \
if (nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, true) < 0) { \ if (nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, true) < 0) { \
errno = EIO; \ errno = EIO; \
return -1; \ return -1; \
} \ } \
} while (0) } while (0)
static bool static bool

View file

@ -15,11 +15,11 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#if defined(HAVE_SYS_TYPES_H) #if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h> #include <sys/types.h>
#endif #endif
#include <errno.h> #include <errno.h>
@ -27,7 +27,7 @@
#include <string.h> #include <string.h>
#ifdef WITH_DEBUG #ifdef WITH_DEBUG
# include <libutil.h> #include <libutil.h>
#endif #endif
#include <freefare.h> #include <freefare.h>
@ -35,56 +35,56 @@
#define NTAG_ASSERT_VALID_PAGE(tag, page, mode_write) \ #define NTAG_ASSERT_VALID_PAGE(tag, page, mode_write) \
do { \ do { \
if (mode_write) { \ if (mode_write) { \
if (page<=0x02) \ if (page<=0x02) \
{return errno = EINVAL, -1;} \ {return errno = EINVAL, -1;} \
else if(NTAG_21x(tag)->subtype == NTAG_213&&page>0x2C) \ else if(NTAG_21x(tag)->subtype == NTAG_213&&page>0x2C) \
{return errno = EINVAL, -1;} \ {return errno = EINVAL, -1;} \
else if(NTAG_21x(tag)->subtype == NTAG_215&&page>0x86) \ else if(NTAG_21x(tag)->subtype == NTAG_215&&page>0x86) \
{return errno = EINVAL, -1;} \ {return errno = EINVAL, -1;} \
else if(NTAG_21x(tag)->subtype == NTAG_216&&page>0xE6) \ else if(NTAG_21x(tag)->subtype == NTAG_216&&page>0xE6) \
{return errno = EINVAL, -1;} \ {return errno = EINVAL, -1;} \
} else { \ } else { \
if(NTAG_21x(tag)->subtype == NTAG_213&&page>0x2C) \ if(NTAG_21x(tag)->subtype == NTAG_213&&page>0x2C) \
{return errno = EINVAL, -1;} \ {return errno = EINVAL, -1;} \
else if(NTAG_21x(tag)->subtype == NTAG_215&&page>0x86) \ else if(NTAG_21x(tag)->subtype == NTAG_215&&page>0x86) \
{return errno = EINVAL, -1;} \ {return errno = EINVAL, -1;} \
else if(NTAG_21x(tag)->subtype == NTAG_216&&page>0xE6) \ else if(NTAG_21x(tag)->subtype == NTAG_216&&page>0xE6) \
{return errno = EINVAL, -1;} \ {return errno = EINVAL, -1;} \
} \ } \
} while (0) } while (0)
#define NTAG_TRANSCEIVE(tag, msg, res) \ #define NTAG_TRANSCEIVE(tag, msg, res) \
do { \ do { \
errno = 0; \ errno = 0; \
DEBUG_XFER (msg, __##msg##_n, "===> "); \ DEBUG_XFER (msg, __##msg##_n, "===> "); \
int _res; \ int _res; \
if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \ if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \
return errno = EIO, -1; \ return errno = EIO, -1; \
} \ } \
__##res##_n = _res; \ __##res##_n = _res; \
DEBUG_XFER (res, __##res##_n, "<=== "); \ DEBUG_XFER (res, __##res##_n, "<=== "); \
} while (0) } while (0)
#define NTAG_TRANSCEIVE_RAW(tag, msg, res) \ #define NTAG_TRANSCEIVE_RAW(tag, msg, res) \
do { \ do { \
errno = 0; \ errno = 0; \
if (nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, false) < 0) { \ if (nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, false) < 0) { \
errno = EIO; \ errno = EIO; \
return -1; \ return -1; \
} \ } \
DEBUG_XFER (msg, __##msg##_n, "===> "); \ DEBUG_XFER (msg, __##msg##_n, "===> "); \
int _res; \ int _res; \
if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \ if ((_res = nfc_initiator_transceive_bytes (tag->device, msg, __##msg##_n, res, __##res##_size, 0)) < 0) { \
nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, true); \ nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, true); \
return errno = EIO, -1; \ return errno = EIO, -1; \
} \ } \
__##res##_n = _res; \ __##res##_n = _res; \
DEBUG_XFER (res, __##res##_n, "<=== "); \ DEBUG_XFER (res, __##res##_n, "<=== "); \
if (nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, true) < 0) { \ if (nfc_device_set_property_bool (tag->device, NP_EASY_FRAMING, true) < 0) { \
errno = EIO; \ errno = EIO; \
return -1; \ return -1; \
} \ } \
} while (0) } while (0)

View file

@ -8,27 +8,27 @@
*/ */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)
# include "config.h" #include "config.h"
#endif #endif
#if defined(HAVE_SYS_TYPES_H) #if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h> #include <sys/types.h>
#endif #endif
#if defined(HAVE_SYS_ENDIAN_H) #if defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#if defined(HAVE_ENDIAN_H) #if defined(HAVE_ENDIAN_H)
# include <endian.h> #include <endian.h>
#endif #endif
#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) #if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H)
# include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#endif #endif
#if defined(HAVE_BYTESWAP_H) #if defined(HAVE_BYTESWAP_H)
# include <byteswap.h> #include <byteswap.h>
#endif #endif
#include <stdlib.h> #include <stdlib.h>

View file

@ -11,8 +11,8 @@
#define cut_assert_success(last_command) \ #define cut_assert_success(last_command) \
do { \ do { \
cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \ cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \
cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \ cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \
} while (0) } while (0)
void void

View file

@ -11,8 +11,8 @@
#define cut_assert_success(last_command) \ #define cut_assert_success(last_command) \
do { \ do { \
cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \ cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \
cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \ cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \
} while (0) } while (0)
void void

View file

@ -11,8 +11,8 @@
#define cut_assert_success(last_command) \ #define cut_assert_success(last_command) \
do { \ do { \
cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \ cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \
cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \ cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \
} while (0) } while (0)
void void

View file

@ -11,8 +11,8 @@
#define cut_assert_success(last_command) \ #define cut_assert_success(last_command) \
do { \ do { \
cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \ cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \
cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \ cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \
} while (0) } while (0)
void void

View file

@ -11,8 +11,8 @@
#define cut_assert_success(last_command) \ #define cut_assert_success(last_command) \
do { \ do { \
cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \ cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \
cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \ cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \
} while (0) } while (0)
void void

View file

@ -8,8 +8,8 @@
#define cut_assert_success(last_command) \ #define cut_assert_success(last_command) \
do { \ do { \
cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \ cut_assert_equal_int (OPERATION_OK, mifare_desfire_last_picc_error (tag), cut_message ("PICC replied %s", mifare_desfire_error_lookup (mifare_desfire_last_picc_error (tag)))); \
cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \ cut_assert_not_equal_int (-1, res, cut_message ("Wrong return value")); \
} while (0) } while (0)
void void