diff --git a/xs_encdec.h b/xs_encdec.h index 5966583..b88736e 100644 --- a/xs_encdec.h +++ b/xs_encdec.h @@ -6,6 +6,7 @@ xs_str *xs_hex_enc(const xs_val *data, int size); xs_val *xs_hex_dec(const xs_str *hex, int *size); + int xs_is_hex(const char *str); xs_str *xs_base64_enc(const xs_val *data, int sz); xs_val *xs_base64_dec(const xs_str *data, int *size); xs_str *xs_utf8_enc(xs_str *str, unsigned int cpoint); @@ -65,6 +66,18 @@ xs_val *xs_hex_dec(const xs_str *hex, int *size) } +int xs_is_hex(const char *str) +/* returns 1 if str is an hex string */ +{ + while (*str) { + if (strchr("0123456789abcdefABCDEF", *str++) == NULL) + return 0; + } + + return 1; +} + + xs_str *xs_base64_enc(const xs_val *data, int sz) /* encodes data to base64 */ { diff --git a/xs_version.h b/xs_version.h index 559fab6..eff4ddf 100644 --- a/xs_version.h +++ b/xs_version.h @@ -1 +1 @@ -/* b4afa5f823a998a263159ebfe9be67b81a8cc774 */ +/* 69d6e64d31491688ba4411e71c55e6c25482b17e */