mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
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.
This commit is contained in:
parent
760a3841bd
commit
a1fdad784b
@ -865,6 +865,7 @@ The list of currently supported predicates is the following:
|
|||||||
|
|
||||||
- streq(<str1>,<str2>) : returns true only if the two strings are equal
|
- streq(<str1>,<str2>) : returns true only if the two strings are equal
|
||||||
- strneq(<str1>,<str2>) : returns true only if the two strings differ
|
- 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
|
- version_atleast(<ver>): returns true if the current haproxy version is
|
||||||
at least as recent as <ver> otherwise false. The
|
at least as recent as <ver> otherwise false. The
|
||||||
|
@ -48,6 +48,7 @@ enum cond_predicate {
|
|||||||
CFG_PRED_FEATURE, // "feature"
|
CFG_PRED_FEATURE, // "feature"
|
||||||
CFG_PRED_STREQ, // "streq"
|
CFG_PRED_STREQ, // "streq"
|
||||||
CFG_PRED_STRNEQ, // "strneq"
|
CFG_PRED_STRNEQ, // "strneq"
|
||||||
|
CFG_PRED_STRSTR, // "strstr"
|
||||||
CFG_PRED_VERSION_ATLEAST, // "version_atleast"
|
CFG_PRED_VERSION_ATLEAST, // "version_atleast"
|
||||||
CFG_PRED_VERSION_BEFORE, // "version_before"
|
CFG_PRED_VERSION_BEFORE, // "version_before"
|
||||||
CFG_PRED_OSSL_VERSION_ATLEAST, // "openssl_version_atleast"
|
CFG_PRED_OSSL_VERSION_ATLEAST, // "openssl_version_atleast"
|
||||||
|
@ -22,6 +22,7 @@ const struct cond_pred_kw cond_predicates[] = {
|
|||||||
{ "feature", CFG_PRED_FEATURE, ARG1(1, STR) },
|
{ "feature", CFG_PRED_FEATURE, ARG1(1, STR) },
|
||||||
{ "streq", CFG_PRED_STREQ, ARG2(2, STR, STR) },
|
{ "streq", CFG_PRED_STREQ, ARG2(2, STR, STR) },
|
||||||
{ "strneq", CFG_PRED_STRNEQ, 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_atleast", CFG_PRED_VERSION_ATLEAST, ARG1(1, STR) },
|
||||||
{ "version_before", CFG_PRED_VERSION_BEFORE, ARG1(1, STR) },
|
{ "version_before", CFG_PRED_VERSION_BEFORE, ARG1(1, STR) },
|
||||||
{ "openssl_version_atleast", CFG_PRED_OSSL_VERSION_ATLEAST, ARG1(1, STR) },
|
{ "openssl_version_atleast", CFG_PRED_OSSL_VERSION_ATLEAST, ARG1(1, STR) },
|
||||||
@ -225,6 +226,10 @@ int cfg_eval_cond_term(const struct cfg_cond_term *term, char **err)
|
|||||||
ret = strcmp(term->args[0].data.str.area, term->args[1].data.str.area) != 0;
|
ret = strcmp(term->args[0].data.str.area, term->args[1].data.str.area) != 0;
|
||||||
break;
|
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
|
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;
|
ret = compare_current_version(term->args[0].data.str.area) <= 0;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user