2 * definitions etc. for regexp(3) routines
4 * caveat: this is V8 regexp(3) [actually, a reimplementation thereof], not the System V one
6 * 11/04/02 (seiwald) - const-ing for string literals
8 #ifndef HEADER_LIBHSRX_H
9 #define HEADER_LIBHSRX_H
19 * The "internal use only" fields in regexp.h are present to pass info from
20 * compile to execute that permits the execute phase to run lots faster on
21 * simple cases. They are:
23 * regstart char that must begin a match; '\0' if none obvious
24 * reganch is the match anchored (at beginning-of-line only)?
25 * regmust string (pointer into program) that match must include, or NULL
26 * regmlen length of regmust string
28 * Regstart and reganch permit very fast decisions on suitable starting points
29 * for a match, cutting down the work a lot. Regmust permits fast rejection
30 * of lines that cannot possibly match. The regmust tests are costly enough
31 * that hsrxCompile() supplies a regmust only if the r.e. contains something
32 * potentially expensive (at present, the only such thing detected is * or +
33 * at the start of the r.e., which can involve a lot of backup). Regmlen is
34 * supplied because the test in hsrxExec() needs it and hsrxCompile() is computing
43 typedef struct HSRegExp
{
45 int re_nsub
; /* number of parenthesized subexpressions */
47 int cflags
; /* flags used when compiling */
48 int err
; /* any error which occurred during compile */
49 int regstart
; /* internal use only */
50 int reganch
; /* internal use only */
51 int regmust
; /* internal use only */
52 int regmlen
; /* internal use only */
53 int *program
; /* allocated */
54 /* working state - compile */
55 const char *regparse
; /* input-scan pointer */
56 int p
; /* current output pos in program */
57 int proglen
; /* allocated program size */
58 /* working state - exec */
59 int eflags
; /* flags used when executing */
60 const char *start
; /* initial string pointer */
61 const char *reginput
; /* current input pointer */
62 const char *regbol
; /* beginning of input, for ^ check */
63 /* input to hsrxExec() */
64 HSRxMatch
*pmatch
; /* submatches will be stored here */
65 int nmatch
; /* size of pmatch[] */
66 HSRxMatch
*bmatch
; /* submatches for backtracing */
81 HSRX_NOERROR
, /* success */
82 HSRX_NOMATCH
, /* didn't find a match (for hsrxExec) */
83 HSRX_BADPAT
, /* >= HSRX_BADPAT is an error */
84 HSRX_ERR_NULL_ARGUMENT
,
88 HSRX_ERR_TOO_MANY_PAREN
,
89 HSRX_ERR_UNMATCHED_PAREN
,
90 HSRX_ERR_UNMATCHED_BRACES
,
93 HSRX_ERR_OPERAND_COULD_BE_EMPTY
,
94 HSRX_ERR_NESTED_COUNT
,
96 HSRX_ERR_COUNT_FOLLOWS_NOTHING
,
97 HSRX_ERR_TRAILING_BACKSLASH
,
100 HSRX_ERR_INVALID_BACKREF
,
105 extern int hsrxCompile (HSRegExp
*preg
, const char *regex
, int cflags
);
106 extern int hsrxExec (HSRegExp
*preg
, const char *string
, size_t nmatch
, HSRxMatch pmatch
[], int eflags
);
110 extern size_t hsrxError (int errcode
, const HSRegExp
*preg
, char *errbuf
, size_t errbuf_size
);
111 extern void hsrxFree (HSRegExp
*preg
);
115 extern int hsrxNarrate
;
116 extern void hsrxDump (HSRegExp
*preg
);