]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3911 --resolve patch applied
authorRaymond Chandler <intralanman@gmail.com>
Wed, 10 Jul 2013 14:52:40 +0000 (10:52 -0400)
committerRaymond Chandler <intralanman@gmail.com>
Wed, 10 Jul 2013 14:53:41 +0000 (10:53 -0400)
src/mod/applications/mod_commands/mod_commands.c

index 2d0d02d7fe785f667b5e2141023815b2b0523e90..183732835664db05bddbdf0ab90562677553d22b 100644 (file)
@@ -4390,7 +4390,11 @@ static int show_as_json_callback(void *pArg, int argc, char **argv, char **colum
        }
 
        if (holder->justcount) {
-               holder->count++;
+               if (zstr(argv[0])) {
+                       holder->count = 0;
+               } else {
+                       holder->count = (uint32_t) atoi(argv[0]);
+               }
                return 0;
        }
 
@@ -4430,7 +4434,11 @@ static int show_as_xml_callback(void *pArg, int argc, char **argv, char **column
        }
 
        if (holder->justcount) {
-               holder->count++;
+               if (zstr(argv[0])) {
+                       holder->count = 0;
+               } else {
+                       holder->count = (uint32_t) atoi(argv[0]);
+               }
                return 0;
        }
 
@@ -4468,7 +4476,11 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
        int x;
 
        if (holder->justcount) {
-               holder->count++;
+               if (zstr(argv[0])) {
+                       holder->count = 0;
+               } else {
+                       holder->count = (uint32_t) atoi(argv[0]);
+               }
                return 0;
        }
 
@@ -4704,6 +4716,7 @@ SWITCH_STANDARD_API(show_function)
                if (!strcasecmp(command, "calls")) {
                        sprintf(sql, "select * from basic_calls where hostname='%s' order by call_created_epoch", hostname);
                        if (argv[1] && !strcasecmp(argv[1], "count")) {
+                               sprintf(sql, "select count(*) from basic_calls where hostname='%s'", hostname);
                                holder.justcount = 1;
                                if (argv[3] && !strcasecmp(argv[2], "as")) {
                                        as = argv[3];
@@ -4712,6 +4725,7 @@ SWITCH_STANDARD_API(show_function)
                } else if (!strcasecmp(command, "registrations")) {
                        sprintf(sql, "select * from registrations where hostname='%s'", hostname);
                        if (argv[1] && !strcasecmp(argv[1], "count")) {
+                               sprintf(sql, "select count(*) from registrations where hostname='%s'", hostname);
                                holder.justcount = 1;
                                if (argv[3] && !strcasecmp(argv[2], "as")) {
                                        as = argv[3];
@@ -4743,6 +4757,7 @@ SWITCH_STANDARD_API(show_function)
                } else if (!strcasecmp(command, "channels")) {
                        sprintf(sql, "select * from channels where hostname='%s' order by created_epoch", hostname);
                        if (argv[1] && !strcasecmp(argv[1], "count")) {
+                               sprintf(sql, "select count(*) from channels where hostname='%s'", hostname);
                                holder.justcount = 1;
                                if (argv[3] && !strcasecmp(argv[2], "as")) {
                                        as = argv[3];