[Freeswitch-svn] [commit] r1992 - freeswitch/trunk/src/mod/applications/mod_commands

Freeswitch SVN anthm at freeswitch.org
Wed Jul 19 15:16:42 EDT 2006


Author: anthm
Date: Wed Jul 19 15:16:42 2006
New Revision: 1992

Modified:
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c

Log:
add a count to show

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Wed Jul 19 15:16:42 2006
@@ -184,20 +184,28 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+struct holder {
+	switch_stream_handle_t *stream;
+	uint32_t count;
+};
+
+
+
 static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
-	switch_stream_handle_t *stream = (switch_stream_handle_t *) pArg;
+	struct holder *holder = (struct holder *) pArg;
 
-	stream->write_function(stream, "%s|%s\n", argv[0], argv[1] ? argv[1] : "NULL");
+	holder->stream->write_function(holder->stream, "%s|%s\n", argv[0], argv[1] ? argv[1] : "NULL");
+	holder->count++;
 	return 0;
 }
 
-
 static switch_status_t show_function(char *cmd, switch_stream_handle_t *stream)
 {
 	char sql[1024];
 	char *errmsg;
 	switch_core_db_t *db = switch_core_db_handle();
-
+	struct holder holder;
+	
     if (!cmd) {
         sprintf (sql, "select * from interfaces");
     }
@@ -220,12 +228,17 @@
         return SWITCH_STATUS_SUCCESS;
     }
     
-	switch_core_db_exec(db, sql, show_callback, stream, &errmsg);
+	holder.stream = stream;
+	holder.count = 0;
 
+	switch_core_db_exec(db, sql, show_callback, &holder, &errmsg);
+
 	if (errmsg) {
 		stream->write_function(stream, "SQL ERR [%s]\n",errmsg);
 		switch_core_db_free(errmsg);
 		errmsg = NULL;
+	} else {
+		stream->write_function(stream, "%u total.\n", holder.count);
 	}
 
 	switch_core_db_close(db);



More information about the Freeswitch-svn mailing list