REORG: config: uninline warnifnotcap() and failifnotcap()
These ones are used by virtually every config parser. Not only they
provide no benefit in being inlined, but they imply a very deep
dependency starting at proxy.h, which results for example in task.c
including openssl.
Let's move these two functions to cfgparse.c.
diff --git a/include/haproxy/cfgparse.h b/include/haproxy/cfgparse.h
index 310da5e..6963522 100644
--- a/include/haproxy/cfgparse.h
+++ b/include/haproxy/cfgparse.h
@@ -27,6 +27,9 @@
#include <haproxy/proxy.h>
struct hap_cpuset;
+struct proxy;
+struct bind_conf;
+struct acl_cond;
/* configuration sections */
#define CFG_NONE 0
@@ -123,56 +126,8 @@
unsigned long parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, int comma_allowed, char **err);
void free_email_alert(struct proxy *p);
const char *cfg_find_best_match(const char *word, const struct list *list, int section, const char **extra);
-
-/*
- * Sends a warning if proxy <proxy> does not have at least one of the
- * capabilities in <cap>. An optional <hint> may be added at the end
- * of the warning to help the user. Returns 1 if a warning was emitted
- * or 0 if the condition is valid.
- */
-static inline int warnifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint)
-{
- char *msg;
-
- switch (cap) {
- case PR_CAP_BE: msg = "no backend"; break;
- case PR_CAP_FE: msg = "no frontend"; break;
- case PR_CAP_BE|PR_CAP_FE: msg = "neither frontend nor backend"; break;
- default: msg = "not enough"; break;
- }
-
- if (!(proxy->cap & cap)) {
- ha_warning("parsing [%s:%d] : '%s' ignored because %s '%s' has %s capability.%s\n",
- file, line, arg, proxy_type_str(proxy), proxy->id, msg, hint ? hint : "");
- return 1;
- }
- return 0;
-}
-
-/*
- * Sends an alert if proxy <proxy> does not have at least one of the
- * capabilities in <cap>. An optional <hint> may be added at the end
- * of the alert to help the user. Returns 1 if an alert was emitted
- * or 0 if the condition is valid.
- */
-static inline int failifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint)
-{
- char *msg;
-
- switch (cap) {
- case PR_CAP_BE: msg = "no backend"; break;
- case PR_CAP_FE: msg = "no frontend"; break;
- case PR_CAP_BE|PR_CAP_FE: msg = "neither frontend nor backend"; break;
- default: msg = "not enough"; break;
- }
-
- if (!(proxy->cap & cap)) {
- ha_alert("parsing [%s:%d] : '%s' not allowed because %s '%s' has %s capability.%s\n",
- file, line, arg, proxy_type_str(proxy), proxy->id, msg, hint ? hint : "");
- return 1;
- }
- return 0;
-}
+int warnifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint);
+int failifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint);
/* simplified way to define a section parser */
#define REGISTER_CONFIG_SECTION(name, parse, post) \
diff --git a/src/cfgparse.c b/src/cfgparse.c
index af72744..4b484bc 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -272,6 +272,56 @@
}
/*
+ * Sends a warning if proxy <proxy> does not have at least one of the
+ * capabilities in <cap>. An optional <hint> may be added at the end
+ * of the warning to help the user. Returns 1 if a warning was emitted
+ * or 0 if the condition is valid.
+ */
+int warnifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint)
+{
+ char *msg;
+
+ switch (cap) {
+ case PR_CAP_BE: msg = "no backend"; break;
+ case PR_CAP_FE: msg = "no frontend"; break;
+ case PR_CAP_BE|PR_CAP_FE: msg = "neither frontend nor backend"; break;
+ default: msg = "not enough"; break;
+ }
+
+ if (!(proxy->cap & cap)) {
+ ha_warning("parsing [%s:%d] : '%s' ignored because %s '%s' has %s capability.%s\n",
+ file, line, arg, proxy_type_str(proxy), proxy->id, msg, hint ? hint : "");
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * Sends an alert if proxy <proxy> does not have at least one of the
+ * capabilities in <cap>. An optional <hint> may be added at the end
+ * of the alert to help the user. Returns 1 if an alert was emitted
+ * or 0 if the condition is valid.
+ */
+int failifnotcap(struct proxy *proxy, int cap, const char *file, int line, const char *arg, const char *hint)
+{
+ char *msg;
+
+ switch (cap) {
+ case PR_CAP_BE: msg = "no backend"; break;
+ case PR_CAP_FE: msg = "no frontend"; break;
+ case PR_CAP_BE|PR_CAP_FE: msg = "neither frontend nor backend"; break;
+ default: msg = "not enough"; break;
+ }
+
+ if (!(proxy->cap & cap)) {
+ ha_alert("parsing [%s:%d] : '%s' not allowed because %s '%s' has %s capability.%s\n",
+ file, line, arg, proxy_type_str(proxy), proxy->id, msg, hint ? hint : "");
+ return 1;
+ }
+ return 0;
+}
+
+/*
* Report an error in <msg> when there are too many arguments. This version is
* intended to be used by keyword parsers so that the message will be included
* into the general error message. The index is the current keyword in args.