Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

Guardian Native C Library Calls (n - r) regcomp(3)
subexpressions (delimited by a \( (backslash left parenthesis) and \) (backslash
right parenthesis) pair in basic regular expressions, or ( ) (parentheses) in
extended regular expressions) to the number found in the pattern parameter.
preg The structure that contains the compiled basic or extended regular expression.
errcode Identies the error code.
errbuf Points to the buffer where regerror() stores the message text.
errbuf_size Species the size of the errbuf buffer.
string Contains the data to be matched.
nmatch Contains the number of subexpressions to match.
pmatch Contains the array of offsets into the string parameter that match the correspond-
ing subexpression in the preg parameter.
eflags Contains the bitwise inclusive OR of zero or more of the ags controlling the
customizable behavior of the regexec function.
The eags parameter modies the interpretation of the contents of the string
parameter. The value for this parameter is formed by bitwise inclusive ORing
zero or more of the following ags, which are dened in the
/usr/include/regex.h le.
REG_NOTBOL
The rst character of the string pointed to by the string parameter is not the beginning
of the line. Therefore, the circumex character ˆ (circumex), when taken as a special
character, does not match the beginning of the string parameter.
REG_NOTEOL
The last character of the string pointed to by the string parameter is not the end of the
line. Therefore, the $ (dollar sign), when taken as a special character, does not match
the end of the string parameter.
DESCRIPTION
The regcomp(), regerror(), regexec(), and regfree() functions perform regular expression
matching. The regcomp() function compiles a regular expression and the regexec() function
compares the compiled regular expression to a string. The regerror() function returns text asso-
ciated with an error condition encountered by regcomp() or regexec(). The regfree() function
frees the internal storage allocated for the compiled regular expression.
The regcomp() function compiles the basic or extended regular expression specied by the pat-
tern parameter and places the output in the preg structure.
The regexec() function compares the NULL terminated string in the string parameter against the
compiled basic or extended regular expression in the preg parameter. If a match is found, the
regexec() function returns a value of 0 (zero). The regexec() function returns a nonzero value if
there is no match or if there is an error.
If the value of the nmatch parameter is 0 (zero), or if the REG_NOSUB ag was set on the call
to the regcomp() function, the regexec() function ignores the pmatch parameter. Otherwise, the
pmatch parameter points to an array of at least the number of elements specied by the nmatch
parameter. The regexec() function lls in the elements of the array pointed to by the pmatch
parameter with offsets of the substrings of the string parameter. The elements of the pmatch
array correspond to the parenthetic subexpressions of the original pattern parameter that was
specied to the regcomp() function. The pmatch[i].rm_so structure is the byte offset of the
beginning of the substring, and the pmatch[i].rm_eo structure is one greater than the byte offset
527192-005 Hewlett-Packard Company 561