diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/hex_conversion.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/hex_conversion.h b/include/hex_conversion.h index 4b97d6d..e232b8e 100644 --- a/include/hex_conversion.h +++ b/include/hex_conversion.h @@ -15,9 +15,9 @@ #define ishex_macro(c) ((c>='0' && c <= '9') || (c>='A' && c <= 'F') || (c>='a' && c <= 'f')) int convert_line(char *s); -int ishex(char c); -char *convert_to_binary(char *hex, char *out); -char *convert_from_binary(char *bin, size_t l, char *out); +int ishex(unsigned char c); +unsigned char *convert_to_binary(char *hex, unsigned char *out); +char *convert_from_binary(unsigned char *bin, size_t l, char *out); /* short inline functions are fine in header */ inline int convert_line(char *s) { @@ -35,14 +35,14 @@ inline int convert_line(char *s) { return 0; } -inline int ishex(char c) { +inline int ishex(unsigned char c) { if ((c>='0' && c <= '9') || (c>='A' && c <= 'F') || (c>='a' && c <= 'f')) { return 1; } return 0; }; -inline char *convert_to_binary(char *hex, char *out) { +inline unsigned char *convert_to_binary(char *hex, unsigned char *out) { char tmp[3] = {0,0,0}; size_t length, i; if (hex == NULL) return NULL; @@ -65,14 +65,14 @@ inline char *convert_to_binary(char *hex, char *out) { for (i=0;i<length;i+=2) { tmp[0] = hex[i]; tmp[1] = hex[i+1]; - out[i/2] = (char) strtol(tmp, NULL, 16); + out[i/2] = (unsigned char) strtol(tmp, NULL, 16); } return out; } /* Use a large buffer and complex method, as with a simple * way there regularly were corrupt results with gcc -O2. */ -inline char *convert_from_binary(char *bin, size_t l, char *out) { +inline char *convert_from_binary(unsigned char *bin, size_t l, char *out) { char tmp[24]; size_t i,pos; if (bin == NULL || l == 0) return NULL; |
