aboutsummaryrefslogtreecommitdiff
path: root/include/hex_conversion.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/hex_conversion.h')
-rw-r--r--include/hex_conversion.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/hex_conversion.h b/include/hex_conversion.h
index 540472d..bb0fab1 100644
--- a/include/hex_conversion.h
+++ b/include/hex_conversion.h
@@ -16,6 +16,7 @@
int convert_line(char *s);
int ishex(unsigned char c);
+int ishex_string(const char *s, size_t l);
unsigned char *convert_to_binary(char *hex, unsigned char *out);
char *convert_from_binary(unsigned char *bin, size_t l, char *out);
@@ -42,6 +43,19 @@ inline int ishex(unsigned char c) {
return 0;
};
+inline int ishex_string(const char *s, size_t l) {
+ size_t i = 0;
+ if (s == 0)
+ return 0;
+ if (l == 0)
+ l = strlen(s);
+ for (; i<l; i++) {
+ if ( ! ishex_macro(s[i]) )
+ return 0;
+ }
+ return 1;
+}
+
inline unsigned char *convert_to_binary(char *hex, unsigned char *out) {
char tmp[3] = {0,0,0};
size_t length, i;