diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index dc5f8e18a15ea2333b5ad146b145641f1f20662f..1ba62ede3f7d4704bbd41820dc789ca73b50f6b7 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -37,7 +37,13 @@ static force_inline int ast_strlen_zero(const char *s) /*! \brief returns the equivalent of logic or for strings: * first one if not empty, otherwise second one. */ -#define S_OR(a, b) (!ast_strlen_zero(a) ? (a) : (b)) +#define S_OR(a, b) (!ast_strlen_zero(a) ? (a) : (b)) + +/*! \brief returns the equivalent of logic or for strings, with an additional boolean check: + * second one if not empty and first one is true, otherwise third one. + * example: S_COR(usewidget, widget, "<no widget>") + */ +#define S_COR(a, b, c) ((a && !ast_strlen_zero(b)) ? (b) : (c)) /*! \brief Gets a pointer to the first non-whitespace character in a string.