// Perform a simple string search, supporting wildcards, // case-insensitive searches, and specifiable start locations in the buffer. // The parameter 'table' is ignored. char *bm_needleinhaystack_skipnchars(char *needle, size_t needle_len, char *haystack, size_t haystack_len, size_t table[UCHAR_MAX + 1], int casesensitive, int start_pos) { register int i, j, go; if(needle_len == 0) { return haystack; } for(i = start_pos; i < haystack_len; i++) { go = 1; j = 0; while (go) { go = (i + j) < haystack_len && j < needle_len && charactersMatch(needle[j], haystack[i + j], casesensitive); j++; } if(j > needle_len) { return haystack + i; } } return NULL; }
// memwildcardcmp is a memcmp() clone, except that single // character wildcards are supported. The default wildcard character is '?', // but this can be redefined in the configuration file. A wildcard in s1 will // match any single character in s2. int memwildcardcmp(const void *s1, const void *s2, size_t n,int caseSensitive){ if (n != 0) { register const unsigned char *p1 = s1, *p2 = s2; do { if (!charactersMatch(*p1++, *p2++, caseSensitive)) { return (*--p1 - *--p2); } } while (--n !=0); } return 0; }