[asterisk-commits] russell: branch russell/func_devstate r54174 - in
 /team/russell/func_devstate...
    asterisk-commits at lists.digium.com 
    asterisk-commits at lists.digium.com
       
    Tue Feb 13 04:15:22 MST 2007
    
    
  
Author: russell
Date: Tue Feb 13 05:15:21 2007
New Revision: 54174
URL: http://svn.digium.com/view/asterisk?view=rev&rev=54174
Log:
Make a second function to convert device state to a string, using a format
that is more dialplan friendly.
Modified:
    team/russell/func_devstate/funcs/func_devstate.c
    team/russell/func_devstate/include/asterisk/devicestate.h
    team/russell/func_devstate/main/devicestate.c
Modified: team/russell/func_devstate/funcs/func_devstate.c
URL: http://svn.digium.com/view/asterisk/team/russell/func_devstate/funcs/func_devstate.c?view=diff&rev=54174&r1=54173&r2=54174
==============================================================================
--- team/russell/func_devstate/funcs/func_devstate.c (original)
+++ team/russell/func_devstate/funcs/func_devstate.c Tue Feb 13 05:15:21 2007
@@ -51,7 +51,7 @@
 
 static int devstate_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
-	ast_copy_string(buf, devstate2str(ast_device_state(data)), len);
+	ast_copy_string(buf, ast_devstate_str(ast_device_state(data)), len);
 
 	return 0;
 }
Modified: team/russell/func_devstate/include/asterisk/devicestate.h
URL: http://svn.digium.com/view/asterisk/team/russell/func_devstate/include/asterisk/devicestate.h?view=diff&rev=54174&r1=54173&r2=54174
==============================================================================
--- team/russell/func_devstate/include/asterisk/devicestate.h (original)
+++ team/russell/func_devstate/include/asterisk/devicestate.h Tue Feb 13 05:15:21 2007
@@ -52,6 +52,11 @@
  * \param devstate Current device state 
  */
 const char *devstate2str(enum ast_device_state devstate);
+
+/*! \brief Convert device state to text string that is easier to parse 
+ * \param devstate Current device state 
+ */
+const char *ast_devstate_str(enum ast_device_state devstate);
 
 /*! \brief Convert device state from text to integer value
  * \param The text representing the device state.  Valid values are anything
Modified: team/russell/func_devstate/main/devicestate.c
URL: http://svn.digium.com/view/asterisk/team/russell/func_devstate/main/devicestate.c?view=diff&rev=54174&r1=54173&r2=54174
==============================================================================
--- team/russell/func_devstate/main/devicestate.c (original)
+++ team/russell/func_devstate/main/devicestate.c Tue Feb 13 05:15:21 2007
@@ -182,6 +182,42 @@
 const char *devstate2str(enum ast_device_state devstate) 
 {
 	return devstatestring[devstate];
+}
+
+const char *ast_devstate_str(enum ast_device_state state)
+{
+	const char *res = "UNKNOWN";
+
+	switch (state) {
+	case AST_DEVICE_UNKNOWN:
+		break;
+	case AST_DEVICE_NOT_INUSE:
+		res = "NOT_INUSE";
+		break;
+	case AST_DEVICE_INUSE:
+		res = "INUSE";
+		break;
+	case AST_DEVICE_BUSY:
+		res = "BUSY";
+		break;
+	case AST_DEVICE_INVALID:
+		res = "INVALID";
+		break;
+	case AST_DEVICE_UNAVAILABLE:
+		res = "UNAVAILABLE";
+		break;
+	case AST_DEVICE_RINGING:
+		res = "RINGING";
+		break;
+	case AST_DEVICE_RINGINUSE:
+		res = "RINGINUSE";
+		break;
+	case AST_DEVICE_ONHOLD:
+		res = "ONHOLD";
+		break;
+	}
+
+	return res;
 }
 
 enum ast_device_state ast_devstate_val(const char *val)
    
    
More information about the asterisk-commits
mailing list