From c4bb23631b597752454f51262118d13e94ec964f Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Thu, 22 Jul 2010 16:13:02 +0000 Subject: [PATCH] Do not export nfc_parse_device_desc() in libnfc API. --- examples/nfc-list.c | 2 +- examples/nfc-utils.c | 42 ++++++++++++++++++++++++++++++++++++++++++ examples/nfc-utils.h | 5 +++++ include/nfc/nfc.h | 1 - libnfc/nfc.c | 42 ------------------------------------------ 5 files changed, 48 insertions(+), 44 deletions(-) diff --git a/examples/nfc-list.c b/examples/nfc-list.c index e591056..4658d95 100644 --- a/examples/nfc-list.c +++ b/examples/nfc-list.c @@ -53,7 +53,7 @@ int main(int argc, const char* argv[]) size_t szFound; size_t i; nfc_target_info_t nti; - nfc_device_desc_t *pnddDevices = nfc_parse_device_desc(argc, argv, &szFound); + nfc_device_desc_t *pnddDevices = parse_device_desc(argc, argv, &szFound); const char* acLibnfcVersion; if (argc > 1 && szFound == 0) { diff --git a/examples/nfc-utils.c b/examples/nfc-utils.c index 3b292ea..5796713 100644 --- a/examples/nfc-utils.c +++ b/examples/nfc-utils.c @@ -95,3 +95,45 @@ void print_nfc_iso14443a_info(const nfc_iso14443a_info_t nai) } } +/** + * @brief Tries to parse arguments to find device descriptions. + * @return Returns the list of found device descriptions. + */ +nfc_device_desc_t* parse_device_desc(int argc, const char *argv[], size_t* szFound) +{ + nfc_device_desc_t* pndd = 0; + *szFound = 0; + int arg; + + // Get commandline options + for (arg=1;arg arg+1) { + + pndd = malloc(sizeof(nfc_device_desc_t)); + + char buffer[256]; + strncpy(buffer, argv[++arg], 256); + + // Driver. + pndd->pcDriver = (char *)malloc(256); + strcpy(pndd->pcDriver, strtok(buffer, ":")); + + // Port. + pndd->pcPort = (char *)malloc(256); + strcpy(pndd->pcPort, strtok(NULL, ":")); + + // Speed. + sscanf(strtok(NULL, ":"), "%d", &pndd->uiSpeed); + + *szFound = 1; + } + break; + } + } + + return pndd; +} + diff --git a/examples/nfc-utils.h b/examples/nfc-utils.h index e7f849f..c672efd 100644 --- a/examples/nfc-utils.h +++ b/examples/nfc-utils.h @@ -24,9 +24,14 @@ #ifndef _EXAMPLES_NFC_UTILS_H_ #define _EXAMPLES_NFC_UTILS_H_ +#include +#include + + void print_hex(const byte_t* pbtData, const size_t szLen); void print_hex_bits(const byte_t* pbtData, const size_t szBits); void print_hex_par(const byte_t* pbtData, const size_t szBits, const byte_t* pbtDataPar); void print_nfc_iso14443a_info(const nfc_iso14443a_info_t nai); +nfc_device_desc_t* parse_device_desc(int argc, const char *argv[], size_t* szFound); #endif diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index 3fdcc87..3ac66be 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -85,7 +85,6 @@ NFC_EXPORT const char* nfc_device_name(nfc_device_t* pnd); NFC_EXPORT void iso14443a_crc(byte_t* pbtData, size_t szLen, byte_t* pbtCrc); NFC_EXPORT void append_iso14443a_crc(byte_t* pbtData, size_t szLen); NFC_EXPORT const char* nfc_version(void); -NFC_EXPORT nfc_device_desc_t* nfc_parse_device_desc(int argc, const char *argv[], size_t* szFound); #ifdef __cplusplus } diff --git a/libnfc/nfc.c b/libnfc/nfc.c index bbe4888..9f62179 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -1032,45 +1032,3 @@ const char* nfc_version(void) return PACKAGE_VERSION; #endif // SVN_REVISION } - -/** - * @brief Tries to parse arguments to find device descriptions. - * @return Returns the list of found device descriptions. - */ -nfc_device_desc_t* nfc_parse_device_desc(int argc, const char *argv[], size_t* szFound) -{ - nfc_device_desc_t* pndd = 0; - *szFound = 0; - int arg; - - // Get commandline options - for (arg=1;arg arg+1) { - - pndd = malloc(sizeof(nfc_device_desc_t)); - - char buffer[256]; - strncpy(buffer, argv[++arg], 256); - - // Driver. - pndd->pcDriver = (char *)malloc(256); - strcpy(pndd->pcDriver, strtok(buffer, ":")); - - // Port. - pndd->pcPort = (char *)malloc(256); - strcpy(pndd->pcPort, strtok(NULL, ":")); - - // Speed. - sscanf(strtok(NULL, ":"), "%d", &pndd->uiSpeed); - - *szFound = 1; - } - break; - } - } - - return pndd; -}