move some decoding functions right into the str module, with a bit more
[apps/madmutt.git] / lib-lib / str.h
index 973e0be..01e6c62 100644 (file)
 #define SHORT_STRING    128
 
 #define NONULL(x) (x?x:"")
-# define ISSPACE(c) isspace((unsigned char)c)
+#define ISSPACE(c) isspace((unsigned char)c)
+
+extern unsigned char const __m_strdigits[128];
+extern signed char const __m_b64digits[128];
+
+/****************************************************************************/
+/* char related                                                             */
+/****************************************************************************/
+
+static inline int hexval(int c) {
+    int v = __m_strdigits[c];
+    return !(c & ~127) && v < 16 ? v : -1;
+}
+
+static inline int base64val(int c) {
+    return (c & ~127) ? -1 : __m_b64digits[c];
+}
 
 /****************************************************************************/
 /* length related                                                           */