MINOR: cfgcond: Implement strstr condition expression
Implement a way to match a substring in a string. The strstr expresionn can
now be used to do so.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 3c60634..8aea55e 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -865,6 +865,7 @@
- streq(<str1>,<str2>) : returns true only if the two strings are equal
- strneq(<str1>,<str2>) : returns true only if the two strings differ
+ - strstr(<str1>,<str2>) : returns true only if the second string is found in the first one
- version_atleast(<ver>): returns true if the current haproxy version is
at least as recent as <ver> otherwise false. The
diff --git a/include/haproxy/cfgcond-t.h b/include/haproxy/cfgcond-t.h
index 1e09293..206ae06 100644
--- a/include/haproxy/cfgcond-t.h
+++ b/include/haproxy/cfgcond-t.h
@@ -48,6 +48,7 @@
CFG_PRED_FEATURE, // "feature"
CFG_PRED_STREQ, // "streq"
CFG_PRED_STRNEQ, // "strneq"
+ CFG_PRED_STRSTR, // "strstr"
CFG_PRED_VERSION_ATLEAST, // "version_atleast"
CFG_PRED_VERSION_BEFORE, // "version_before"
CFG_PRED_OSSL_VERSION_ATLEAST, // "openssl_version_atleast"
diff --git a/src/cfgcond.c b/src/cfgcond.c
index 5fb7069..b29fcbf 100644
--- a/src/cfgcond.c
+++ b/src/cfgcond.c
@@ -22,6 +22,7 @@
{ "feature", CFG_PRED_FEATURE, ARG1(1, STR) },
{ "streq", CFG_PRED_STREQ, ARG2(2, STR, STR) },
{ "strneq", CFG_PRED_STRNEQ, ARG2(2, STR, STR) },
+ { "strstr", CFG_PRED_STRSTR, ARG2(2, STR, STR) },
{ "version_atleast", CFG_PRED_VERSION_ATLEAST, ARG1(1, STR) },
{ "version_before", CFG_PRED_VERSION_BEFORE, ARG1(1, STR) },
{ "openssl_version_atleast", CFG_PRED_OSSL_VERSION_ATLEAST, ARG1(1, STR) },
@@ -225,6 +226,10 @@
ret = strcmp(term->args[0].data.str.area, term->args[1].data.str.area) != 0;
break;
+ case CFG_PRED_STRSTR: // checks if the 2nd arg is found in the first one
+ ret = strstr(term->args[0].data.str.area, term->args[1].data.str.area) != NULL;
+ break;
+
case CFG_PRED_VERSION_ATLEAST: // checks if the current version is at least this one
ret = compare_current_version(term->args[0].data.str.area) <= 0;
break;