nfc-utils.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. * Additional contributors of this file:
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. * 1) Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * 2 )Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  24. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. * POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * Note that this license only applies on the examples, NFC library itself is under LGPL
  33. *
  34. */
  35. /**
  36. * @file nfc-utils.h
  37. * @brief Provide some examples shared functions like print, parity calculation, options parsing.
  38. */
  39. #ifndef _EXAMPLES_NFC_UTILS_H_
  40. # define _EXAMPLES_NFC_UTILS_H_
  41. # include <stdlib.h>
  42. # include <string.h>
  43. # define DBG(...) {}
  44. #ifndef MIN
  45. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  46. #endif
  47. #ifndef MAX
  48. #define MAX(a,b) (((a) > (b)) ? (a) : (b))
  49. #endif
  50. uint8_t oddparity(const uint8_t bt);
  51. void oddparity_bytes_ts(const uint8_t *pbtData, const size_t szLen, uint8_t *pbtPar);
  52. void print_hex(const uint8_t *pbtData, const size_t szLen);
  53. void print_hex_bits(const uint8_t *pbtData, const size_t szBits);
  54. void print_hex_par(const uint8_t *pbtData, const size_t szBits, const uint8_t *pbtDataPar);
  55. void print_nfc_target(const nfc_target *pnt, bool verbose);
  56. #endif