+static APR_INLINE char *strcase(char *string, int case_type)
+{
+#ifndef CASE_LOWER
+# define CASE_LOWER 1
+#endif
+#ifndef CASE_UPPER
+# define CASE_UPPER 2
+#endif
+
+ char *ptr = string;
+
+ switch (case_type)
+ {
+ case CASE_LOWER:
+ while (*ptr) {
+ apr_tolower(*ptr++);
+ }
+ break;
+
+ case CASE_UPPER:
+ while (*ptr) {
+ apr_toupper(*ptr++);
+ }
+ break;
+
+ default:
+ break;
+ }
+ return string;
+}
+
+static APR_INLINE int strmatch(char *match, char *string, char **begin, char **end)
+{
+ *begin = *end = NULL;
+
+ while (*match)
+ {
+ switch (*match)
+ {
+ case '*':
+ while (*match == '*' || *match == '?') {
+ ++match;
+ }
+
+ if (!*begin) {
+ *begin = string;
+ }
+
+ if (!*match) {
+ *end = string + strlen(string);
+ return 1;
+ }
+
+ if (!(string = strchr(string, *match))) {
+ *end = string;
+ return 0;
+ }
+ break;
+
+ case '?':
+ if (!*begin) {
+ *begin = string;
+ }
+ ++string;
+ ++match;
+ break;
+
+ default:
+ if (*match == *string) {
+ if (!*begin) {
+ *begin = string;
+ }
+ ++match;
+ } else {
+ if (*begin) {
+ *end = string - 1;
+ return 0;
+ }
+ }
+ ++string;
+ break;
+ }
+ }
+
+ *end = string;
+ return 1;
+}
+
+static APR_INLINE char *struniqchr(char *string, char uniq)
+{
+ char *ptr = string;
+
+ while (*ptr) {
+ if (*ptr == uniq && *(ptr + 1) == uniq) {
+ char *pos = ptr + 1;
+
+ while (*(pos + 1) == uniq) {
+ ++pos;
+ }
+
+ memmove(ptr, pos, strlen(pos) + 1);
+ }
+ ++ptr;
+ }
+
+ return string;
+}
+