diff options
author | Stephane Marchesin <stephane.marchesin@gmail.com> | 2010-05-07 00:41:32 -0700 |
---|---|---|
committer | Stephane Marchesin <stephane.marchesin@gmail.com> | 2010-05-07 00:41:32 -0700 |
commit | a54e8e11f50279ac03273d047688d2681a059893 (patch) | |
tree | db4d9e2e5468d8931b27554cc92bd0c46e3f642e | |
parent | e206b83d96d7c247c19df36e1083b69588f7473a (diff) |
Add util.h
-rw-r--r-- | util.h | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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 + |