| iMatix home page
| << | < | > | >>
Version 2.11



#include "sflfind.h"
char *
strfind (const char *string,            /*  String containing data           */
         const char *pattern,           /*  Pattern to search for            */
         Bool repeat_find)              /*  Same pattern as last time        */


Searches for a pattern in a string using the Boyer-Moore- Horspool-Sunday algorithm. The string and pattern are null- terminated strings. Returns a pointer to the pattern if found within the string, or NULL if the pattern was not found. If you repeatedly scan for the same pattern, use the repeat_find argument. If this is TRUE, the function does not re-parse the pattern. You must of course call the function with repeat_find equal to FALSE the first time. This function is meant to handle character data, and is most effective when you work with large strings. To search binary data use memfind(). Will not work on multibyte characters.


    char *result;

    result = strfind ("abracadabra", "cad", FALSE);
    if (result)
        puts (result);

Source Code - (sflfind.c)

    static size_t
        searchbuf [256];                /*  Fixed search buffer              */

    ASSERT (string);                    /*  Expect non-NULL pointers, but    */
    ASSERT (pattern);                   /*  fall through if not debugging    */

    return (char *) memfind rb (string,    strlen (string),
                                pattern,   strlen (pattern),
                                searchbuf, &repeat_find);

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation