[asterisk-commits] dlee: branch dlee/stasis-dtmf r385270 - in /team/dlee/stasis-dtmf: include/as...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 10 17:01:00 CDT 2013


Author: dlee
Date: Wed Apr 10 17:00:57 2013
New Revision: 385270

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385270
Log:
Extracted yes_no to an AST_YESNO macro in strings.h

Modified:
    team/dlee/stasis-dtmf/include/asterisk/cli.h
    team/dlee/stasis-dtmf/include/asterisk/strings.h
    team/dlee/stasis-dtmf/main/manager_channels.c

Modified: team/dlee/stasis-dtmf/include/asterisk/cli.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-dtmf/include/asterisk/cli.h?view=diff&rev=385270&r1=385269&r2=385270
==============================================================================
--- team/dlee/stasis-dtmf/include/asterisk/cli.h (original)
+++ team/dlee/stasis-dtmf/include/asterisk/cli.h Wed Apr 10 17:00:57 2013
@@ -28,6 +28,7 @@
 #endif
 
 #include "asterisk/linkedlists.h"
+#include "asterisk/strings.h"
 
 void ast_cli(int fd, const char *fmt, ...)
 	__attribute__((format(printf, 2, 3)));
@@ -57,12 +58,17 @@
  */
 #define ESS(x) ((x) == 1 ? "" : "s")
 
-/*! \brief return Yes or No depending on the argument.
- * This is used in many places in CLI command, having a function to generate
- * this helps maintaining a consistent output (and possibly emitting the
- * output in other languages, at some point).
- */
-#define AST_CLI_YESNO(x) (x) ? "Yes" : "No"
+/*!
+ * \brief Return Yes or No depending on the argument.
+ *
+ * Note that this should probably still be used for CLI commands instead of
+ * AST_YESNO(), in the off chance we someday want to translate the CLI.
+ *
+ * \param x Boolean value
+ * \return "Yes" if x is true (non-zero)
+ * \return "No" if x is false (zero)
+ */
+#define AST_CLI_YESNO(x) AST_YESNO(x) ? "Yes" : "No"
 
 /*! \brief return On or Off depending on the argument.
  * This is used in many places in CLI command, having a function to generate

Modified: team/dlee/stasis-dtmf/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-dtmf/include/asterisk/strings.h?view=diff&rev=385270&r1=385269&r2=385270
==============================================================================
--- team/dlee/stasis-dtmf/include/asterisk/strings.h (original)
+++ team/dlee/stasis-dtmf/include/asterisk/strings.h Wed Apr 10 17:00:57 2013
@@ -83,6 +83,18 @@
 #define S_COR(a, b, c) ({typeof(&((b)[0])) __x = (b); (a) && !ast_strlen_zero(__x) ? (__x) : (c);})
 
 /*!
+ * \brief return Yes or No depending on the argument.
+ *
+ * Note that this macro is used my AMI, where a literal "Yes" and "No" are
+ * expected, and translations would cause problems.
+ *
+ * \param x Boolean value
+ * \return "Yes" if x is true (non-zero)
+ * \return "No" if x is false (zero)
+ */
+#define AST_YESNO(x) ((x) ? "Yes" : "No")
+
+/*!
   \brief Gets a pointer to the first non-whitespace character in a string.
   \param str the input string
   \return a pointer to the first non-whitespace character

Modified: team/dlee/stasis-dtmf/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-dtmf/main/manager_channels.c?view=diff&rev=385270&r1=385269&r2=385270
==============================================================================
--- team/dlee/stasis-dtmf/main/manager_channels.c (original)
+++ team/dlee/stasis-dtmf/main/manager_channels.c Wed Apr 10 17:00:57 2013
@@ -231,20 +231,6 @@
 		</managerEventInstance>
 	</managerEvent>
  ***/
-
-/*!
- * \brief Convert a boolean to a Yes or No.
- * \param v Boolean value
- * \return "Yes" if v is true (non-zero)
- * \return "No" if v is false (zero)
- */
-static const char *yes_no(int v)
-{
-	if (v) {
-		return "Yes";
-	}
-	return "No";
-}
 
 /*!
  * \brief Generate the AMI message body from a channel snapshot
@@ -744,7 +730,7 @@
 		      "Begin: %s\r\n"
 		      "End: %s\r\n",
 		      ast_str_buffer(channel_event_string),
-		      digit, direction, yes_no(begin), yes_no(end));
+		      digit, direction, AST_YESNO(begin), AST_YESNO(end));
 }
 
 /*!




More information about the asterisk-commits mailing list