+static const pcre *
+m_pcre_compile(const uschar * re, uschar ** errstr)
+{
+ const uschar * rerror;
+ int roffset;
+ const pcre * cre;
+
+ cre = pcre_compile(re, PCRE_COPT, (const char **)&rerror, &roffset, NULL);
+ if (!cre)
+ *errstr= string_sprintf("regular expression error in '%s': %s at offset %d",
+ re, rerror, roffset);
+ return cre;
+}
+
+uschar *
+m_pcre_exec(const pcre * cre, uschar * text)
+{
+ int ovector[10*3];
+ int i = pcre_exec(cre, NULL, CS text, Ustrlen(text), 0, 0,
+ ovector, nelements(ovector));
+ uschar * substr = NULL;
+ if (i >= 2) /* Got it */
+ pcre_get_substring(CS text, ovector, i, 1, (const char **) &substr);
+ return substr;
+}
+