MINOR: cfgcond: Implement enabled condition expression

Implement a way to test if some options are enabled at run-time. For now,
following options may be detected:

  POLL, EPOLL, KQUEUE, EVPORTS, SPLICE, GETADDRINFO, REUSEPORT,
  FAST-FORWARD, SERVER-SSL-VERIFY-NONE

These options are those that can be disabled on the command line. This way
it is possible, from a reg-test for instance, to know if a feature is
supported or not :

  feature cmd "$HAPROXY_PROGRAM -cc '!(globa.tune & GTUNE_NO_FAST_FWD)'"
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 8aea55e..370b960 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -877,6 +877,12 @@
                             version syntax is the same as shown by "haproxy -v"
                             and missing components are assumed as being zero.
 
+  - enabled(<opt>)        : returns true if the option <opt> is enabled at
+                            run-time. Only a subset of options are supported:
+			        POLL, EPOLL, KQUEUE, EVPORTS, SPLICE,
+				GETADDRINFO, REUSEPORT, FAST-FORWARD,
+				SERVER-SSL-VERIFY-NONE
+
 Example:
 
    .if defined(HAPROXY_MWORKER)
diff --git a/include/haproxy/cfgcond-t.h b/include/haproxy/cfgcond-t.h
index 206ae06..00fc126 100644
--- a/include/haproxy/cfgcond-t.h
+++ b/include/haproxy/cfgcond-t.h
@@ -54,6 +54,7 @@
 	CFG_PRED_OSSL_VERSION_ATLEAST,   // "openssl_version_atleast"
 	CFG_PRED_OSSL_VERSION_BEFORE,    // "openssl_version_before"
 	CFG_PRED_SSLLIB_NAME_STARTSWITH, // "ssllib_name_startswith"
+	CFG_PRED_ENABLED,                // "enabled"
 };
 
 /* types for condition terms */
diff --git a/src/cfgcond.c b/src/cfgcond.c
index b29fcbf..89036ad 100644
--- a/src/cfgcond.c
+++ b/src/cfgcond.c
@@ -28,6 +28,7 @@
 	{ "openssl_version_atleast", CFG_PRED_OSSL_VERSION_ATLEAST,   ARG1(1, STR)         },
 	{ "openssl_version_before",  CFG_PRED_OSSL_VERSION_BEFORE,    ARG1(1, STR)         },
 	{ "ssllib_name_startswith",  CFG_PRED_SSLLIB_NAME_STARTSWITH, ARG1(1, STR)         },
+	{ "enabled",                 CFG_PRED_ENABLED,                ARG1(1, STR)         },
 	{ NULL, CFG_PRED_NONE, 0 }
 };
 
@@ -175,6 +176,33 @@
 	return -1;
 }
 
+/* evaluate a "enabled" expression. Only a subset of options are matched. It
+ * returns 1 if the option is enabled. 0 is returned is the option is not
+ * enabled or if it is not recognized.
+ */
+static int cfg_eval_cond_enabled(const char *str)
+{
+	if (strcmp(str, "POLL") == 0)
+		return !!(global.tune.options & GTUNE_USE_POLL);
+	else if (strcmp(str, "EPOLL") == 0)
+		return !!(global.tune.options & GTUNE_USE_EPOLL);
+	else if (strcmp(str, "KQUEUE") == 0)
+		return !!(global.tune.options & GTUNE_USE_EPOLL);
+	else if (strcmp(str, "EVPORTS") == 0)
+		return !!(global.tune.options & GTUNE_USE_EVPORTS);
+	else if (strcmp(str, "SPLICE") == 0)
+		return !!(global.tune.options & GTUNE_USE_SPLICE);
+	else if (strcmp(str, "GETADDRINFO") == 0)
+		return !!(global.tune.options & GTUNE_USE_GAI);
+	else if (strcmp(str, "REUSEPORT") == 0)
+		return !!(global.tune.options & GTUNE_USE_REUSEPORT);
+	else if (strcmp(str, "FAST-FORWARD") == 0)
+		return !!(global.tune.options & GTUNE_USE_FAST_FWD);
+	else if (strcmp(str, "SERVER-SSL-VERIFY-NONE") == 0)
+		return !!(global.ssl_server_verify == SSL_SERVER_VERIFY_NONE);
+	return 0;
+}
+
 /* evaluate a condition term on a .if/.elif line. The condition was already
  * parsed in <term>. Returns -1 on error (in which case err is filled with a
  * message, and only in this case), 0 if the condition is false, 1 if it's
@@ -260,6 +288,10 @@
 			ret = openssl_compare_current_name(term->args[0].data.str.area) == 0;
 			break;
 		}
+		case CFG_PRED_ENABLED: { // checks if the arg matches on a subset of enabled options
+			ret = cfg_eval_cond_enabled(term->args[0].data.str.area) != 0;
+			break;
+		}
 		default:
 			memprintf(err, "internal error: unhandled conditional expression predicate '%s'", term->pred->word);
 			break;