REORG: include: split common/regex.h into haproxy/regex{,-t}.h

Regex are essentially included for myregex_t but it turns out that
several of the C files didn't include it directly, relying on the
one included by their own .h. This has been cleanly addressed so
that only the type is included by H files which need it, and adding
the missing includes for the other ones.
diff --git a/include/haproxy/regex-t.h b/include/haproxy/regex-t.h
new file mode 100644
index 0000000..7b7fa03
--- /dev/null
+++ b/include/haproxy/regex-t.h
@@ -0,0 +1,78 @@
+/*
+ * include/haproxy/regex-t.h
+ * Types and macros definitions for regular expressions
+ *
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _HAPROXY_REGEX_T_H
+#define _HAPROXY_REGEX_T_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <haproxy/api.h>
+#include <haproxy/thread-t.h>
+
+#ifdef USE_PCRE
+#include <pcre.h>
+#include <pcreposix.h>
+
+/* For pre-8.20 PCRE compatibility */
+#ifndef PCRE_STUDY_JIT_COMPILE
+#define PCRE_STUDY_JIT_COMPILE 0
+#endif
+
+#elif USE_PCRE2
+#include <pcre2.h>
+#include <pcre2posix.h>
+
+#else /* no PCRE, nor PCRE2 */
+#include <regex.h>
+#endif
+
+struct my_regex {
+#ifdef USE_PCRE
+	pcre *reg;
+	pcre_extra *extra;
+#ifdef USE_PCRE_JIT
+#ifndef PCRE_CONFIG_JIT
+#error "The PCRE lib doesn't support JIT. Change your lib, or remove the option USE_PCRE_JIT."
+#endif
+#endif
+#elif USE_PCRE2
+	pcre2_code *reg;
+#else /* no PCRE */
+	regex_t regex;
+#endif
+};
+
+struct hdr_exp {
+    struct hdr_exp *next;
+    struct my_regex *preg;		/* expression to look for */
+    const char *replace;		/* expression to set instead */
+    void *cond;				/* a possible condition or NULL */
+};
+
+#endif /* _HAPROXY_REGEX_T_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
diff --git a/include/common/regex.h b/include/haproxy/regex.h
similarity index 78%
rename from include/common/regex.h
rename to include/haproxy/regex.h
index 79e54ff..6d84ea6 100644
--- a/include/common/regex.h
+++ b/include/haproxy/regex.h
@@ -1,8 +1,8 @@
 /*
- * include/common/regex.h
- * This file defines everything related to regular expressions.
+ * include/haproxy/regex.h
+ * Compatibility layer for various regular expression engines
  *
- * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -19,55 +19,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef _COMMON_REGEX_H
-#define _COMMON_REGEX_H
+#ifndef _HAPROXY_REGEX_H
+#define _HAPROXY_REGEX_H
 
 #include <stdlib.h>
 #include <string.h>
 
 #include <haproxy/api.h>
+#include <haproxy/regex-t.h>
 #include <haproxy/thread-t.h>
 
-#ifdef USE_PCRE
-#include <pcre.h>
-#include <pcreposix.h>
-
-/* For pre-8.20 PCRE compatibility */
-#ifndef PCRE_STUDY_JIT_COMPILE
-#define PCRE_STUDY_JIT_COMPILE 0
-#endif
-
-#elif USE_PCRE2
-#include <pcre2.h>
-#include <pcre2posix.h>
-
-#else /* no PCRE, nor PCRE2 */
-#include <regex.h>
-#endif
-
-struct my_regex {
-#ifdef USE_PCRE
-	pcre *reg;
-	pcre_extra *extra;
-#ifdef USE_PCRE_JIT
-#ifndef PCRE_CONFIG_JIT
-#error "The PCRE lib doesn't support JIT. Change your lib, or remove the option USE_PCRE_JIT."
-#endif
-#endif
-#elif USE_PCRE2
-	pcre2_code *reg;
-#else /* no PCRE */
-	regex_t regex;
-#endif
-};
-
-struct hdr_exp {
-    struct hdr_exp *next;
-    struct my_regex *preg;		/* expression to look for */
-    const char *replace;		/* expression to set instead */
-    void *cond;				/* a possible condition or NULL */
-};
-
 extern THREAD_LOCAL regmatch_t pmatch[MAX_MATCH];
 
 /* "str" is the string that contain the regex to compile.
@@ -83,10 +44,16 @@
 struct my_regex *regex_comp(const char *str, int cs, int cap, char **err);
 int exp_replace(char *dst, unsigned int dst_size, char *src, const char *str, const regmatch_t *matches);
 const char *check_replace_string(const char *str);
+int regex_exec_match(const struct my_regex *preg, const char *subject,
+                     size_t nmatch, regmatch_t pmatch[], int flags);
+int regex_exec_match2(const struct my_regex *preg, char *subject, int length,
+                      size_t nmatch, regmatch_t pmatch[], int flags);
+
 
 /* If the function doesn't match, it returns false, else it returns true.
  */
-static inline int regex_exec(const struct my_regex *preg, char *subject) {
+static inline int regex_exec(const struct my_regex *preg, char *subject)
+{
 #if defined(USE_PCRE) || defined(USE_PCRE_JIT)
 	if (pcre_exec(preg->reg, preg->extra, subject, strlen(subject), 0, 0, NULL, 0) < 0)
 		return 0;
@@ -117,7 +84,8 @@
  *
  * If the function doesn't match, it returns false, else it returns true.
  */
-static inline int regex_exec2(const struct my_regex *preg, char *subject, int length) {
+static inline int regex_exec2(const struct my_regex *preg, char *subject, int length)
+{
 #if defined(USE_PCRE) || defined(USE_PCRE_JIT)
 	if (pcre_exec(preg->reg, preg->extra, subject, length, 0, 0, NULL, 0) < 0)
 		return 0;
@@ -145,12 +113,8 @@
 #endif
 }
 
-int regex_exec_match(const struct my_regex *preg, const char *subject,
-                     size_t nmatch, regmatch_t pmatch[], int flags);
-int regex_exec_match2(const struct my_regex *preg, char *subject, int length,
-                      size_t nmatch, regmatch_t pmatch[], int flags);
-
-static inline void regex_free(struct my_regex *preg) {
+static inline void regex_free(struct my_regex *preg)
+{
 	if (!preg)
 		return;
 #if defined(USE_PCRE) || defined(USE_PCRE_JIT)
@@ -171,7 +135,7 @@
 	free(preg);
 }
 
-#endif /* _COMMON_REGEX_H */
+#endif /* _HAPROXY_REGEX_H */
 
 /*
  * Local variables:
diff --git a/include/proto/http_htx.h b/include/proto/http_htx.h
index 77e4d67..d480be8 100644
--- a/include/proto/http_htx.h
+++ b/include/proto/http_htx.h
@@ -25,7 +25,7 @@
 
 #include <haproxy/buf.h>
 #include <import/ist.h>
-#include <common/regex.h>
+#include <haproxy/regex-t.h>
 
 #include <types/http_htx.h>
 
diff --git a/include/types/action.h b/include/types/action.h
index 00c37fa..a102b2b 100644
--- a/include/types/action.h
+++ b/include/types/action.h
@@ -22,7 +22,7 @@
 #ifndef _TYPES_ACTION_H
 #define _TYPES_ACTION_H
 
-#include <common/regex.h>
+#include <haproxy/regex-t.h>
 
 #include <types/applet.h>
 #include <types/stick_table.h>
diff --git a/include/types/checks.h b/include/types/checks.h
index 243a1ef..075e902 100644
--- a/include/types/checks.h
+++ b/include/types/checks.h
@@ -18,7 +18,7 @@
 
 #include <import/ist.h>
 #include <haproxy/list-t.h>
-#include <common/regex.h>
+#include <haproxy/regex-t.h>
 #include <haproxy/buf-t.h>
 
 #include <types/connection.h>
diff --git a/include/types/fcgi-app.h b/include/types/fcgi-app.h
index c88dda3..72219e9 100644
--- a/include/types/fcgi-app.h
+++ b/include/types/fcgi-app.h
@@ -26,7 +26,7 @@
 #include <import/ist.h>
 #include <common/fcgi.h>
 #include <haproxy/list-t.h>
-#include <common/regex.h>
+#include <haproxy/regex-t.h>
 
 #include <import/ebistree.h>
 
diff --git a/include/types/hlua.h b/include/types/hlua.h
index 28ed9bd..10a3303 100644
--- a/include/types/hlua.h
+++ b/include/types/hlua.h
@@ -6,7 +6,7 @@
 #include <lua.h>
 #include <lauxlib.h>
 
-#include <common/regex.h>
+#include <haproxy/regex-t.h>
 #include <common/xref.h>
 
 #include <types/http_ana.h>
diff --git a/include/types/pattern.h b/include/types/pattern.h
index aa3ab24..0baf3d7 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -24,7 +24,7 @@
 
 #include <haproxy/api-t.h>
 #include <haproxy/list-t.h>
-#include <common/regex.h>
+#include <haproxy/regex-t.h>
 
 #include <types/sample.h>
 
diff --git a/include/types/peers.h b/include/types/peers.h
index 4bd0680..8961d7e 100644
--- a/include/types/peers.h
+++ b/include/types/peers.h
@@ -29,7 +29,6 @@
 
 #include <haproxy/api-t.h>
 #include <haproxy/list-t.h>
-#include <common/regex.h>
 #include <import/eb32tree.h>
 
 #include <types/dict.h>
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 4e095ef..2e6a26c 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -31,7 +31,6 @@
 #include <haproxy/chunk.h>
 #include <common/http.h>
 #include <haproxy/list-t.h>
-#include <common/regex.h>
 #include <haproxy/thread.h>
 
 #include <import/eb32tree.h>