+/** \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 */
+/****************************************************************************/
+
+/** \brief Converts an octal digit into an int.
+ * \param[in] c the octal char
+ * \return
+ * - 0–7 if c is a valid octal digit,
+ * - -1 on error.
+ */
+static inline int octval(int c) {
+ return !(c & ~127) && __m_strdigits[c] < 7 ? __m_strdigits[c] : -1;
+}
+
+/** \brief Converts an hexadecimal digit into an int.
+ * \param[in] c the hexadecimal char
+ * \return
+ * - 0–15 if c is a valid hexadecimal digit,
+ * - -1 on error.
+ */
+static inline int hexval(int c) {
+ return !(c & ~127) && __m_strdigits[c] < 16 ? __m_strdigits[c] : -1;
+}
+
+/** \brief Converts a base64 digit into an int.
+ * \param[in] c the base64 char
+ * \return
+ * - 0–15 if c is a valid base64 digit,
+ * - -1 on error.
+ */
+static inline int base64val(int c) {
+ return (c & ~127) ? -1 : __m_b64digits[c];
+}
+
+/** \brief Converts a string to lowercase.
+ * \param[in] p the string, shall not be \c NULL.
+ * \return a pointer to the terminating \c \\0.
+ */
+__attribute__((nonnull(1)))
+static inline char *m_strtolower(char *p) {
+ for (; *p; p++)
+ *p = tolower((unsigned char)*p);
+ return p;
+}
+
+/** \brief Converts a lower case ascii char to upper case.
+ * \param[in] c the character.
+ * \return the upper case character.
+ */
+static inline int ascii_toupper(int c) {
+ if ('a' <= c && c <= 'z')
+ return c & ~32;
+
+ return c;
+}
+
+/** \brief Converts a upper case ascii char to lower case.
+ * \param[in] c the character.
+ * \return the lower case character.
+ */
+static inline int ascii_tolower(int c) {
+ if ('A' <= c && c <= 'Z')
+ return c | 32;
+
+ return c;
+}