Main Page | Data Structures | File List | Globals

include/pre.h

00001 /* Regular expression functions which allocate in the pool.
00002  * By Richard W.M. Jones <rich@annexia.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the Free
00016  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  *
00018  * $Id: pre.h,v 1.1 2003/03/28 15:50:59 chappell Exp $
00019  */
00020 
00021 #ifndef PRE_H
00022 #define PRE_H
00023 
00024 #include <pcre.h>
00025 
00026 #include <pool.h>
00027 #include <vector.h>
00028 
00029 /* Function: precomp - Compile, match, substitute regular expressions.
00030  * Function: prematch
00031  * Function: presubst
00032  *
00033  * These functions are wrappers around the Perl Compatible
00034  * Regular Expressions (PCRE) library (see
00035  * @code{http://www.pcre.org/}).
00036  *
00037  * @code{precomp} compiles the regular expression @code{pattern}
00038  * returning a pointer to the opaque @code{pcre} structure. The
00039  * structure is allocated in @code{pool}. The @code{options} argument
00040  * is a list of PCRE options, passed directly to the
00041  * @code{pcre_compile} function (see @ref{pcre(3)}). You
00042  * should normally set @code{options} to 0.
00043  *
00044  * @code{prematch} matches the string @code{str} with the
00045  * compiled regular expression @code{pattern}.
00046  *
00047  * If there is no match, this returns @code{NULL}. If the string
00048  * matches, then this function returns a @code{vector} of @code{char *},
00049  * allocated in @code{pool}.  The first element of this vector is
00050  * the portion of the original string which matched the whole
00051  * pattern. The second and subsequent elements of this vector are
00052  * captured substrings. It is possible in rare circumstances for some
00053  * of these captured substrings to be @code{NULL} (see the
00054  * @ref{pcre(3)} manual page for an example).
00055  *
00056  * The @code{options} argument is passed directly to
00057  * @code{pcre_exec}. You should normally set @code{options} to 0.
00058  *
00059  * @code{presubst} substitutes @code{sub} for @code{pattern}
00060  * wherever @code{pattern} occurs in @code{str}. It is equivalent
00061  * to the @code{str =~ s/pat/sub/} function in Perl.
00062  *
00063  * Placeholders @code{$1}, @code{$2}, etc. in @code{sub} are
00064  * substituted for the matching substrings of @code{pattern}.
00065  * Placeholder substitution can be disabled completely by
00066  * including the @code{PRESUBST_NO_PLACEHOLDERS} flag in @code{options}.
00067  *
00068  * If the @code{PRESUBST_GLOBAL} flag is given, then all
00069  * matches are substituted. Otherwise only the first match
00070  * is substituted.
00071  *
00072  * The @code{options} argument is passed to @code{pcre_exec}
00073  * (after removing the @code{PRESUBST_*} flags).
00074  *
00075  * The return value from @code{presubst} is the string with
00076  * replacements.
00077  *
00078  * See also: @ref{pcre(3)}.
00079  */
00080 pcre *precomp (pool pool, const char *pattern, int options);
00081 vector prematch (pool pool, const char *str, const pcre *pattern, int options);
00082 const char *presubst (pool pool, const char *str, const pcre *pattern, const char *sub, int options);
00083 
00084 #define PRESUBST_NO_PLACEHOLDERS 0x10000000
00085 #define PRESUBST_GLOBAL          0x20000000
00086 
00087 #endif /* PRE_H */

Generated on Fri Feb 20 15:17:48 2004 for PPR Libraries by doxygen 1.3.5