aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/strings.h
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-24 15:06:42 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-24 15:06:42 +0000
commitdbd425a39fd534ed795b775379dd0ae06c8b174c (patch)
treebd3206c23fad62af73cc7236e44c4ba9e016b843 /include/asterisk/strings.h
parent03817f45e8110893e3480ff51a2f4fda32699fab (diff)
as discussed on the -dev list, introduce a macro to simplify the
writing of common constructs like chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; (or the if/then/else form) into chan = S_OR(cdr->channel, "<unknown>"); The name can be changed if we find a better (and not too long) one; currently, it is S as String, OR as it mimics the behaviour of the || operator, but applied to strings. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@14747 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/strings.h')
-rw-r--r--include/asterisk/strings.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index c9015544a..13bb970ef 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -35,6 +35,11 @@ static force_inline int ast_strlen_zero(const char *s)
return (!s || (*s == '\0'));
}
+/*! \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))
+
/*!
\brief Gets a pointer to the first non-whitespace character in a string.
\param ast_skip_blanks function being used