4 /* Implementation of the Knuth-Morris-Pratt fast searching algorithm
5 * from http://www-igm.univ-mlv.fr/~lecroq/string/node8.html
8 typedef int getblock_function(const char **text, void *cookie);
11 * Searches for an exact string match for 'x' of length 'm' in a stream
12 * Using the Knuth-Morris-Pratt algorith.
14 * 'getter' returns one character at a time from the stream
15 * and EOF at end of file. 'cookie' is passed to 'getter'.
17 * If a match is found, returns the offset character JUST PAST THE END OF THE MATCH.
18 * e.g. KMP("abc", "xxabcyy") will return 5.
19 * The input stream will be read to this point.
21 * Returns -1 if the string is not found.
23 int KMP(const char *x, int m, getblock_function *getter, void *cookie);