X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/f397b5cc874ac7d658173199d92c30f3f717a300..18d4eec685bba58f60c19cd7ad6fdf60000e73ba:/client/util.c diff --git a/client/util.c b/client/util.c index 8e7ef01b..be947b8a 100644 --- a/client/util.c +++ b/client/util.c @@ -14,7 +14,9 @@ #include #include "util.h" -#ifdef __linux__ +#ifndef WIN32 +#include +#include int ukbhit(void) { int cnt = 0; @@ -87,6 +89,10 @@ uint64_t bytes_to_num(uint8_t* src, size_t len) return num; } +// ------------------------------------------------------------------------- +// string parameters lib +// ------------------------------------------------------------------------- + // ------------------------------------------------------------------------- // line - param line // bg, en - symbol numbers in param line of beginning an ending parameter @@ -160,7 +166,7 @@ uint64_t param_get64ex(const char *line, int paramnum, int deflt, int base) int bg, en; if (!param_getptr(line, &bg, &en, paramnum)) - return strtol(&line[bg], NULL, base); + return strtoll(&line[bg], NULL, base); else return deflt; @@ -188,3 +194,15 @@ int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt) return 0; } + +int param_getstr(const char *line, int paramnum, char * str) +{ + int bg, en; + + if (param_getptr(line, &bg, &en, paramnum)) return 0; + + memcpy(str, line + bg, en - bg + 1); + str[en - bg + 1] = 0; + + return en - bg + 1; +}