- an empty string, always returns "false"
- the integer zero ('0'), always returns "false"
- a non-nul integer (e.g. '1'), always returns "true".
+ - a predicate optionally followed by argument(s) in parenthesis.
-Other patterns are not supported yet but the purpose is to bring a few
-functions to test for certain build options and supported features.
+The list of currently supported predicates is the following:
+
+ - defined(<name>) : returns true if an environment variable <name>
+ exists, regardless of its contents
+
+Example:
+
+ .if defined(HAPROXY_MWORKER)
+ listen mwcli_px
+ bind :1111
+ ...
+ .endif
Three other directives are provided to report some status:
/* supported conditional predicates for .if/.elif */
enum cond_predicate {
CFG_PRED_NONE, // none
+ CFG_PRED_DEFINED, // "defined"
};
struct cond_pred_kw {
/* supported condition predicates */
const struct cond_pred_kw cond_predicates[] = {
+ { "defined", CFG_PRED_DEFINED, ARG1(1, STR) },
{ NULL, CFG_PRED_NONE, 0 }
};
* arguments, placed in <argp> (which we'll need to free).
*/
switch (cond_pred->prd) {
+ case CFG_PRED_DEFINED: // checks if arg exists as an environment variable
+ ret = getenv(argp[0].data.str.area) != NULL;
+ goto done;
+
default:
memprintf(err, "internal error: unhandled conditional expression predicate '%s'", cond_pred->word);
if (errptr)