+
+/** \brief \c NULL resistant strcasecmp.
+ * \param[in] a the first string.
+ * \param[in] b the second string.
+ * \return <tt>strcasecmp(a, b)</tt>, and treats \c NULL strings like \c ""
+ * ones, as if we were in the C locale.
+ */
+int ascii_strcasecmp(const char *a, const char *b)
+{
+ if (a == b)
+ return 0;
+ if (!a)
+ return -1;
+ if (!b)
+ return 1;
+
+ while (*a || *b) {
+ int i;
+ if ((i = ascii_tolower(*a++) - ascii_tolower(*b++)))
+ return i;
+ }
+
+ return 0;
+}
+
+/** \brief \c NULL resistant strncasecmp.
+ * \param[in] a the first string.
+ * \param[in] b the second string.
+ * \param[in] n the number of maximum chars to compare.
+ * \return <tt>strncasecmp(a, b)</tt>, and treats \c NULL strings like \c ""
+ * ones, as if we were in the C locale.
+ */
+int ascii_strncasecmp(const char *a, const char *b, ssize_t n)
+{
+ if (a == b)
+ return 0;
+ if (!a)
+ return -1;
+ if (!b)
+ return 1;
+
+ while ((*a || *b) && n > 0) {
+ int i;
+ if ((i = ascii_tolower(*a++) - ascii_tolower(*b++)))
+ return i;
+ n--;
+ }
+
+ return 0;
+}
+
+/*@}*/