Browse Source

Backport from xs.

default 2 years ago
parent
commit
74098ec443
2 changed files with 14 additions and 1 deletions
  1. 13 0
      xs_encdec.h
  2. 1 1
      xs_version.h

+ 13 - 0
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 */
 {

+ 1 - 1
xs_version.h

@@ -1 +1 @@
-/* b4afa5f823a998a263159ebfe9be67b81a8cc774 */
+/* 69d6e64d31491688ba4411e71c55e6c25482b17e */