X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/45c48ae428c0afb18a9bc086c7570415307c829b..1772cf8bdd474f64c8d3c4d306150c2bebbf757e:/client/util.c diff --git a/client/util.c b/client/util.c index b2ac82ae..f70b5aed 100644 --- a/client/util.c +++ b/client/util.c @@ -12,8 +12,7 @@ #define MAX_BIN_BREAK_LENGTH (3072+384+1) #ifndef _WIN32 -#include -#include +#include int ukbhit(void) { int cnt = 0; @@ -38,7 +37,6 @@ int ukbhit(void) { } #else -#include int ukbhit(void) { return kbhit(); } @@ -63,7 +61,10 @@ void AddLogLine(char *file, char *extData, char *c) { fprintf(f, "%s", extData); fprintf(f, "%s\n", c); fflush(f); - fclose(f); + if (f) { + fclose(f); + f = NULL; + } } void AddLogHex(char *fileName, char *extData, const uint8_t * data, const size_t len){ @@ -186,7 +187,7 @@ char *sprint_hex_ascii(const uint8_t *data, const size_t len) { void num_to_bytes(uint64_t n, size_t len, uint8_t* dest) { while (len--) { - dest[len] = (uint8_t) n; + dest[len] = n & 0xFF; n >>= 8; } } @@ -280,7 +281,6 @@ int param_getptr(const char *line, int *bg, int *en, int paramnum) return 0; } - char param_getchar(const char *line, int paramnum) { int bg, en;