Create an SLsearch_Type object
SLsearch_Type *SLsearch_new (SLuchar_Type *key, int search_flags)
The SLsearch_new function instantiates an SLsearch_Type
object for use in ordinary searches (non-regular expression) by the
functions in the SLsearch interface. The first argument key
is a pointer to a null terminated string that specifies the character
string to be searched. This character string may not contain any
embedded null characters.
The second argument search_flags is used to specify how the
search is to be performed. It is a bit-mapped integer whose value is
constructed by the bitwise-or of zero or more of the following:
SLSEARCH_CASELESS
The search shall be performed in a case-insensitive manner.
SLSEARCH_UTF8
Both the search string and the text to be searched is UTF-8
encoded.
Upon sucess, the function returns the newly created object, and NULL
otherwise. When the search object is nolonger needed, it should be
freed via the SLsearch_delete function.
SLsearch_delete, SLsearch_forward, SLsearch_backward
Free the memory associated with a SLsearch_Type object
SLsearch_delete (SLsearch_Type *)
This function should be called to free the memory associated with a
SLsearch_Type object created by the SLsearch_new
function. Failure to do so will result in a memory leak.
SLsearch_new, SLsearch_forward, SLsearch_backward
Search forward in a buffer
SLuchar_Type SLsearch_forward (st, pmin, pmax)
SLsearch_Type *st;
SLuchar_Type *pmin, *pmax;
The SLsearch_forward function searches forward in the buffer
defined by the pointers pmin and pmax. The
starting point for the search is at the beginning of the buffer at
pmin. At no point will the bytes at pmax and beyond
be examined. The first parameter st, obtained by a prior call to
SLsearch_new, specifies the object to found.
be found from a previous call to SLsearch_new.
If the object was found, the pointer to the beginning of it will be
returned. Otherwise, SLsearch_forward will return NULL.
The length of the object may be obtained via the
SLsearch_match_len function.
This function uses the Boyer-Moore search algorithm when possible.
SLsearch_new, SLsearch_backward, SLsearch_delete, SLsearch_match_len
Search backward in a buffer
SLuchar_Type SLsearch_forward (st, pmin, pstart, pmax)
SLsearch_Type *st;
SLuchar_Type *pmin, *pstart, *pmax;
The SLsearch_forward function searches backward in the buffer
defined by the pointers pmin and pmax. The starting
point for the search is at the position pstart. At no point
will the bytes at pmax and beyond be examined. The first
parameter st, obtained by a prior call to
SLsearch_new, specifies the object to found.
If the object was found, the pointer to the beginning of it will be
returned. Otherwise, SLsearch_forward will return NULL.
The length of the object may be obtained via the
SLsearch_match_len function.
This function uses the Boyer-Moore search algorithm when possible.
It is possible for the end of match to appear after the point where
the search began (pstart).
SLsearch_new, SLsearch_forward, SLsearch_delete, SLsearch_match_len
Get the length of the previous match
unsigned int SLsearch_match_len (SLsearch_Type *st)
The SLsearch_match_len function returns the length of the
match from the most recent search involving the specified
SLsearch_Type object. If the most recent search was
unsuccessful, the function will return 0.
SLsearch_forward, SLsearch_backward, SLsearch_new, SLsearch_delete