kmp_search provides a binary exact string search utility.
kmp_search is an extremely fast exact string search utility that can be used to search for exact strings or patterns in binary and text files and devices.
It can search for multiple strings concurrently, but is much faster when searching for strings one-by-one.
The starting byte offset of each match is reported to stdout.
Because it is extremely fast, it can be used in a data recovery process after a multi-gigabyte file system crash.
The Knuth-Morris-Pratt algorithm is used for the search, which gives a total time of O(file length + pattern length).
# gcc-3.0 -O9 -mcpu=i686 -o kmp_search_fast -W -Wall kmp_search.c