提交 9782b8bb authored 作者: Travis Cross's avatar Travis Cross

Convert esl_true and esl_false to functions

Prior to this commit, an expression such as:

  esl_true("true") ? 42 : 0

...would return 1 rather than 42.
上级 9ebfd2f3
...@@ -81,28 +81,30 @@ extern "C" { ...@@ -81,28 +81,30 @@ extern "C" {
\param expr a string expression \param expr a string expression
\return true or false \return true or false
*/ */
#define esl_true(expr)\ static inline int esl_true(const char *expr) {
(expr && ( !strcasecmp(expr, "yes") ||\ return (expr && (!strcasecmp(expr, "yes")
!strcasecmp(expr, "on") ||\ || !strcasecmp(expr, "on")
!strcasecmp(expr, "true") ||\ || !strcasecmp(expr, "true")
!strcasecmp(expr, "enabled") ||\ || !strcasecmp(expr, "enabled")
!strcasecmp(expr, "active") ||\ || !strcasecmp(expr, "active")
!strcasecmp(expr, "allow") ||\ || !strcasecmp(expr, "allow")
atoi(expr))) ? 1 : 0 || atoi(expr)));
}
/*! /*!
\brief Evaluate the falsefullness of a string expression \brief Evaluate the falsefullness of a string expression
\param expr a string expression \param expr a string expression
\return true or false \return true or false
*/ */
#define esl_false(expr)\ static inline int esl_false(const char *expr) {
(expr && ( !strcasecmp(expr, "no") ||\ return (expr && (!strcasecmp(expr, "no")
!strcasecmp(expr, "off") ||\ || !strcasecmp(expr, "off")
!strcasecmp(expr, "false") ||\ || !strcasecmp(expr, "false")
!strcasecmp(expr, "disabled") ||\ || !strcasecmp(expr, "disabled")
!strcasecmp(expr, "inactive") ||\ || !strcasecmp(expr, "inactive")
!strcasecmp(expr, "disallow") ||\ || !strcasecmp(expr, "disallow")
!atoi(expr))) ? 1 : 0 || !atoi(expr)));
}
typedef struct esl_config esl_config_t; typedef struct esl_config esl_config_t;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论