<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE> S-Lang Library C Programmer's Guide, V1.4.0: Searching Functions</TITLE>
<LINK HREF="cslang-8.html" REL=next>
<LINK HREF="cslang-6.html" REL=previous>
<LINK HREF="cslang.html#toc7" REL=contents>
</HEAD>
<BODY>
<A HREF="cslang-8.html">Next</A>
<A HREF="cslang-6.html">Previous</A>
<A HREF="cslang.html#toc7">Contents</A>
<HR>
<H2><A NAME="s7">7. Searching Functions</A></H2>

<P> 
<P>The S-Lang library incorporates two types of searches: Regular expression
pattern matching and ordinary searching.
<P>
<H2><A NAME="ss7.1">7.1 Regular Expressions</A>
</H2>

<P> 
<P>!!! No documentation available yet !!!
<P>
<P>
<H2><A NAME="ss7.2">7.2 Simple Searches</A>
</H2>

<P> 
The routines for ordinary searching are defined in the
<CODE>slsearch.c</CODE> file.
To use these routines, simply include "slang.h" in your program and simply
call the appropriate routines.
<P>The searches can go in either a forward or backward direction and can
either be case or case insensitive.  The region that is searched may
contain null characters (ASCII 0) however, the search string cannot in the
current implementation.  In addition the length of the string to be found
is currently limited to 256 characters.
<P>Before searching, the function <CODE>SLsearch_init</CODE> must first be called to
<CODE>`preprocess</CODE>' the search string.
<P>
<P>
<H2><A NAME="ss7.3">7.3 Initialization</A>
</H2>

<P> 
The function <CODE>SLsearch_init</CODE> must be called before a search can take place.
Its prototype is:
<BLOCKQUOTE><CODE>
<PRE>
    int SLsearch_init (char *key, int dir, int case_sens, SLsearch_Type *st);
</PRE>
</CODE></BLOCKQUOTE>

Here <CODE>key</CODE> is the string to be searched for.  <CODE>dir</CODE> specifies the direction
of the search: a value greater than zero is used for searching forward and
a value less than zero is used for searching backward.  The parameter
<CODE>case_sens</CODE> specifies whether the search is case sensitive or not.  A
non-zero value indicates that case is important.  <CODE>st</CODE> is a pointer to a
structure of type <CODE>SLsearch_Type</CODE> defined in "slang.h".  This structure is
initialized by this routine and must be passed to <CODE>SLsearch</CODE> when the
search is actually performed.
<P>This routine returns the length of the string to be searched for.
<P>
<P>
<H2><A NAME="ss7.4">7.4 SLsearch</A>
</H2>

<P> 
<P>
<BLOCKQUOTE><CODE>
<PRE>
      Prototype: unsigned char *SLsearch (unsigned char *pmin, 
                                          unsigned char *pmax, 
                                          SLsearch_Type *st);
</PRE>
</CODE></BLOCKQUOTE>
<P>This function performs the search defined by a previous call to
<CODE>SLsearch_init</CODE> over a region specified by the pointers
<CODE>pmin</CODE> and <CODE>pmax</CODE>.
<P>It returns a pointer to the start of the match if successful or it will
return <CODE>NULL</CODE> if a match was not found.
<P>
<P>
<P>
<P>
<HR>
<A HREF="cslang-8.html">Next</A>
<A HREF="cslang-6.html">Previous</A>
<A HREF="cslang.html#toc7">Contents</A>
</BODY>
</HTML>
