MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / reg_match

Function reg_match

regexp.c:84–101  ·  view source on GitHub ↗

! \brief Match pattern against string and store result in pmatch */

Source from the content-addressed store, hash-verified

82
83/*! \brief Match pattern against string and store result in pmatch */
84int reg_match(char *pattern, char *string, regmatch_t *pmatch)
85{
86 regex_t preg;
87
88 if (regcomp(&preg, pattern, REG_EXTENDED | REG_NEWLINE)) {
89 return -1;
90 }
91 if (preg.re_nsub > MAX_MATCH) {
92 regfree(&preg);
93 return -2;
94 }
95 if (regexec(&preg, string, MAX_MATCH, pmatch, 0)) {
96 regfree(&preg);
97 return -3;
98 }
99 regfree(&preg);
100 return 0;
101}
102
103
104/*! \brief Match pattern against string and, if match succeeds, and replace string

Callers 1

reg_replaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected