Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

pcre.c File Reference

#include <ctype.h>
#include "gwlib/gwlib.h"
#include "pcre.h"

Include dependency graph for pcre.c:

Include dependency graph

Go to the source code of this file.

Functions

pcre * gw_pcre_comp_real (const Octstr *pattern, int cflags, const char *file, long line, const char *func)
int gw_pcre_exec_real (const pcre *preg, const Octstr *string, int start, int eflags, int *ovector, int oveccount, const char *file, long line, const char *func)
int gw_pcre_match_real (const Octstr *re, const Octstr *os, const char *file, long line, const char *func)
int gw_pcre_match_pre_real (const pcre *preg, const Octstr *os, const char *file, long line, const char *func)


Function Documentation

pcre* gw_pcre_comp_real const Octstr pattern,
int  cflags,
const char *  file,
long  line,
const char *  func
 

Definition at line 82 of file pcre.c.

References error(), file, and octstr_get_cstr.

Referenced by gw_pcre_match_real().

00084 {
00085     pcre *preg;
00086     const char *err;
00087     const char *pat;
00088     int erroffset;
00089 
00090     pat = pattern ? octstr_get_cstr(pattern) : NULL;
00091     if ((preg = pcre_compile(pat, cflags, &err, &erroffset, NULL)) == NULL) {
00092         error(0, "%s:%ld: %s: pcre compilation `%s' failed at offset %d: %s "
00093                  "(Called from %s:%ld:%s.)",
00094               __FILE__, (long) __LINE__, __func__, octstr_get_cstr(pattern), 
00095               erroffset, err, (file), (long) (line), (func));
00096     }
00097 
00098     return preg;
00099 }

Here is the call graph for this function:

int gw_pcre_exec_real const pcre *  preg,
const Octstr string,
int  start,
int  eflags,
int *  ovector,
int  oveccount,
const char *  file,
long  line,
const char *  func
 

Definition at line 102 of file pcre.c.

References error(), file, gw_assert, octstr_get_cstr, octstr_len(), and string.

Referenced by gw_pcre_match_pre_real(), and gw_pcre_match_real().

00105 {
00106     int rc;
00107     char *sub;
00108 
00109     gw_assert(preg != NULL);
00110 
00111     sub = string ? octstr_get_cstr(string) : NULL;
00112     rc = pcre_exec(preg, NULL, sub,  octstr_len(string), start, eflags,
00113                    ovector, oveccount);
00114 
00115     if (rc < 0 && rc != PCRE_ERROR_NOMATCH) {
00116         error(0, "%s:%ld: %s: pcre execution on `%s' failed with error %d "
00117                  "(Called from %s:%ld:%s.)",
00118               __FILE__, (long) __LINE__, __func__, octstr_get_cstr(string), rc,
00119               (file), (long) (line), (func));
00120     }
00121 
00122     return rc;
00123 }

Here is the call graph for this function:

int gw_pcre_match_pre_real const pcre *  preg,
const Octstr os,
const char *  file,
long  line,
const char *  func
 

Definition at line 154 of file pcre.c.

References file, gw_assert, and gw_pcre_exec_real().

00156 {
00157     int rc;
00158     int ovector[PCRE_OVECCOUNT];
00159 
00160     gw_assert(preg != NULL);
00161 
00162     /* execute and match */
00163     rc = gw_pcre_exec_real(preg, os, 0, 0, ovector, PCRE_OVECCOUNT,
00164                            file, line, func);
00165 
00166     return (rc > 0) ? 1 : 0;
00167 }

Here is the call graph for this function:

int gw_pcre_match_real const Octstr re,
const Octstr os,
const char *  file,
long  line,
const char *  func
 

Definition at line 134 of file pcre.c.

References file, gw_pcre_comp_real(), and gw_pcre_exec_real().

00136 {
00137     pcre *regexp;
00138     int rc;
00139     int ovector[PCRE_OVECCOUNT];
00140 
00141     /* compile */
00142     regexp = gw_pcre_comp_real(re, 0, file, line, func);
00143     if (regexp == NULL)
00144         return 0;
00145 
00146     /* execute and match */
00147     rc = gw_pcre_exec_real(regexp, os, 0, 0, ovector, PCRE_OVECCOUNT,
00148                            file, line, func);
00149 
00150     return (rc > 0) ? 1 : 0;
00151 }

Here is the call graph for this function:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.