X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/daf8b85cdaed21ace94bae1a49526d09ea389c73..edc9ce00b320b867d5eaab1ad6e4473128ab295e:/client/util.c?ds=sidebyside diff --git a/client/util.c b/client/util.c index 9f2142c6..5e9fce85 100644 --- a/client/util.c +++ b/client/util.c @@ -333,7 +333,28 @@ int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt) return 0; } +int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt) +{ + int bg, en, temp, i; + + //if (hexcnt % 2) + // return 1; + + if (param_getptr(line, &bg, &en, paramnum)) return 1; + + *hexcnt = en - bg + 1; + if (*hexcnt % 2) //error if not complete hex bytes + return 1; + for(i = 0; i < *hexcnt; i += 2) { + if (!(isxdigit(line[bg + i]) && isxdigit(line[bg + i + 1])) ) return 1; + + sscanf((char[]){line[bg + i], line[bg + i + 1], 0}, "%X", &temp); + data[i / 2] = temp & 0xff; + } + + return 0; +} int param_getstr(const char *line, int paramnum, char * str) { int bg, en;