summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Marchesin <stephane.marchesin@gmail.com>2010-05-07 00:41:32 -0700
committerStephane Marchesin <stephane.marchesin@gmail.com>2010-05-07 00:41:32 -0700
commita54e8e11f50279ac03273d047688d2681a059893 (patch)
treedb4d9e2e5468d8931b27554cc92bd0c46e3f642e
parente206b83d96d7c247c19df36e1083b69588f7473a (diff)
Add util.h
-rw-r--r--util.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/util.h b/util.h
new file mode 100644
index 0000000..6ae26a6
--- /dev/null
+++ b/util.h
@@ -0,0 +1,22 @@
+#ifndef _util_h_
+#define _util_h_
+
+#include <ctype.h>
+#include "xenon.h"
+
+#define min(a,b) ((a)<(b)?(a):(b))
+#define max(a,b) ((a)>(b)?(a):(b))
+
+static int inline hexval(char digit)
+{
+ if (!isxdigit(digit))
+ return 0;
+ if (isdigit(digit))
+ return digit - '0';
+ if (isalpha(digit))
+ return tolower(digit) - 'a' + 10;
+ return 0;
+}
+
+#endif
+