+#define NONULL(x) (x ? x : "") /**< \brief replace \c NULL strings
+ with emtpy strings */
+#define ISSPACE(c) isspace((unsigned char)c) /**< \brief safe isspace */
+
+/** \brief Convert ascii digits into ints.
+ *
+ * Convert ascii digits into its integer value in base 36.
+ * Non convertible values are converted to 255.
+ *
+ * Translating a digit \c c into its numerical value in base \c x is just doing:
+ * \code
+ * return (c & ~127) && __m_strdigits[c] < x ? __m_strdigits[c] : -1;
+ * \endcode
+ */
+extern unsigned char const __m_strdigits[128];
+/** \brief Convert an ascii base64 digit into ints.
+ *
+ * Convert an a char base64 digit into its int value.
+ * Used by base64val(). Unlike #__m_strdigits, the invalid values are set to
+ * -1 instead of 255.
+ */
+extern signed char const __m_b64digits[128];
+
+/** \brief Convert ints from 0–64 into the corresponding base64 digit. */
+extern char const __m_b64chars[64];
+/** \brief Convert ints from 0–36 into a base36 lowercase digit. */
+extern char const __m_b36chars_lower[36];
+/** \brief Convert ints from 0–36 into a base36 uppercase digit. */
+extern char const __m_b36chars_upper[36];
+
+/****************************************************************************/
+/* conversions */
+/****************************************************************************/
+
+static inline int hexval(int c) {
+ return !(c & ~127) && __m_strdigits[c] < 16 ? __m_strdigits[c] : -1;
+}
+
+static inline int base64val(int c) {
+ return (c & ~127) ? -1 : __m_b64digits[c];
+}
+
+static inline void m_strtolower(char *p) {
+ for (; *p; p++)
+ *p = tolower((unsigned char)*p);
+}
+
+static inline int ascii_toupper(int c) {
+ if ('a' <= c && c <= 'z')
+ return c & ~32;
+
+ return c;
+}
+
+static inline int ascii_tolower(int c) {
+ if ('A' <= c && c <= 'Z')
+ return c | 32;
+
+ return c;
+}
+
+/****************************************************************************/
+/* length related */
+/****************************************************************************/
+
+static inline int m_strisempty(const char *s) {
+ return !s || !*s;
+}