70 #if defined(HAVE_REGEX) || defined(HAVE_PCRE) 72 int main(
int argc,
char **argv)
77 regmatch_t pmatch[REGEX_MAX_SUB_MATCH];
85 panic(0,
"Syntax: %s <os> <re> <sub>\n", argv[0]);
91 info(0,
"step 1: generic functions");
94 if ((regexp = gw_regex_comp(re, REG_EXTENDED)) == NULL)
95 panic(0,
"regex compilation failed!");
97 debug(
"regex",0,
"RE: regex <%s> has %ld subexpressions.",
101 rc = gw_regex_exec(regexp, os, REGEX_MAX_SUB_MATCH, &pmatch[0], 0);
102 if (rc == REG_NOMATCH) {
103 info(0,
"RE: regex <%s> did not match on string <%s>.",
105 }
else if (rc != 0) {
106 Octstr *err = gw_regex_error(rc, regexp);
107 error(0,
"RE: regex <%s> execution failed: %s",
114 debug(
"regex",0,
"RE: substring matches are:");
115 for (i = 0; i <= regexp->re_nsub; i++) {
116 if (pmatch[i].rm_so != -1 && pmatch[i].rm_eo != -1) {
123 REGEX_MAX_SUB_MATCH, &pmatch[0]);
124 debug(
"regex",0,
"RE: substituted string is <%s>.", rsub);
128 info(0,
"step 2: wrapper functions");
130 debug(
"regex",0,
"RE: regex_match <%s> on <%s> did: %s",
132 gw_regex_match(re, os) ?
"match" :
"NOT match");
134 debug(
"regex",0,
"RE: regex_match_pre on <%s> did: %s",
136 gw_regex_match_pre(regexp, os) ?
"match" :
"NOT match");
138 tmp = gw_regex_subst(re, os, sub);
139 debug(
"regex",0,
"RE: regex_subst <%s> on <%s> rule <%s>: %s",
144 tmp = gw_regex_subst_pre(regexp, os, sub);
145 debug(
"regex",0,
"RE: regex_subst_pre on <%s> rule <%s>: %s",
148 gw_regex_destroy(regexp);
void error(int err, const char *fmt,...)
void info(int err, const char *fmt,...)
#define octstr_get_cstr(ostr)
#define octstr_copy(ostr, from, len)
void octstr_destroy(Octstr *ostr)
int main(int argc, char **argv)
#define octstr_create(cstr)
void debug(const char *place, int err, const char *fmt,...)
void gwlib_shutdown(void)
int get_and_set_debugs(int argc, char **argv, int(*find_own)(int index, int argc, char **argv))