#include #include "bm.h" #define CALL(X) { \ bm_status_t status; \ status = X; \ if (status != bm_status_ok) { \ fprintf (stderr, "Bad status %d from %s.\n", \ status, #X); \ return -1; \ } \ } int main () { bm_t bm; const unsigned char * needle1 = (unsigned char *) "needle"; const unsigned char * haystack1 = (unsigned char *) "For your own ladies and pale-visag'd maids,\n" "Like Amazons, come tripping after drums,\n" "Their thimbles into armed gauntlets change,\n" "Their needles to lances, and their gentle hearts\n" "To fierce and bloody inclination.\n"; CALL (bm_prepare (& bm, needle1)); CALL (bm_search (& bm, haystack1)); if (bm.found) { printf ("Found at byte %d.\n", bm.offset); } else { printf ("Not found.\n"); } CALL (bm_free (& bm)); return 0; }