//#include "local_scan.h" //#include "macros.h" #include "exim.h" /************************************************* * Case-independent strcmp() function * *************************************************/ /* Arguments: s first string t second string Returns: < 0, = 0, or > 0, according to the comparison */ int strcmpic(const uschar *s, const uschar *t) { while (*s != 0) { int c = tolower(*s++) - tolower(*t++); if (c != 0) return c; } return *t; } /************************************************* * Case-independent strstr() function * *************************************************/ /* The third argument specifies whether whitespace is required to follow the matched string. Arguments: s string to search t substring to search for space_follows if TRUE, match only if whitespace follows Returns: pointer to substring in string, or NULL if not found */ uschar * strstric(uschar *s, uschar *t, BOOL space_follows) { uschar *p = t; uschar *yield = NULL; int cl = tolower(*p); int cu = toupper(*p); while (*s) { if (*s == cl || *s == cu) { if (yield == NULL) yield = s; if (*(++p) == 0) { if (!space_follows || s[1] == ' ' || s[1] == '\n' ) return yield; yield = NULL; p = t; } cl = tolower(*p); cu = toupper(*p); s++; } else if (yield != NULL) { yield = NULL; p = t; cl = tolower(*p); cu = toupper(*p); } else s++; } return NULL; }