fix missing gitignore
[RRG-proxmark3.git] / common / iso15693tools.c
blob5f6dd756718378d21054e2769e0faf272066f6bf
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // ISO15693 other commons
17 //-----------------------------------------------------------------------------
18 #include "iso15693tools.h"
20 #include <stdio.h>
23 #define ISO15693_SPRINTUID_BUFLEN (3 * 8 + 1)
25 // returns a string representation of the UID
26 // UID is transmitted and stored LSB first, displayed MSB first
27 // dest char* buffer, where to put the UID, if NULL a static buffer is returned
28 // uid[] the UID in transmission order
29 // return: ptr to string
30 char *iso15693_sprintUID(char *dest, uint8_t *uid) {
31 static char tempbuf[ISO15693_SPRINTUID_BUFLEN] = {0};
32 if (dest == NULL)
33 dest = tempbuf;
35 if (uid) {
36 #ifdef HAVE_SNPRINTF
37 snprintf(dest, ISO15693_SPRINTUID_BUFLEN,
38 #else
39 sprintf(dest,
40 #endif
41 "%02X %02X %02X %02X %02X %02X %02X %02X",
42 uid[7], uid[6], uid[5], uid[4],
43 uid[3], uid[2], uid[1], uid[0]
46 return dest;