[Asterisk-cvs] asterisk/apps app_queue.c,1.42,1.43
martinp at lists.digium.com
martinp at lists.digium.com
Tue Feb 3 10:50:23 CST 2004
Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv26679/apps
Modified Files:
app_queue.c
Log Message:
Add "show queue <queue_name>" CLI command
Index: app_queue.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_queue.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- app_queue.c 3 Feb 2004 00:53:21 -0000 1.42
+++ app_queue.c 3 Feb 2004 16:59:04 -0000 1.43
@@ -1344,28 +1344,41 @@
ast_mutex_unlock(&qlock);
}
-static int queues_show(int fd, int argc, char **argv)
+static int __queues_show(int fd, int argc, char **argv, int queue_show)
{
- struct ast_call_queue *q;
+ struct ast_call_queue *q, tmpq;
struct queue_ent *qe;
struct member *mem;
int pos;
time_t now;
char max[80];
char calls[80];
-
time(&now);
- if (argc != 2)
+ if ((!queue_show && argc != 2) || (queue_show && argc != 3))
return RESULT_SHOWUSAGE;
ast_mutex_lock(&qlock);
q = queues;
if (!q) {
ast_mutex_unlock(&qlock);
- ast_cli(fd, "No queues.\n");
+ if (queue_show)
+ ast_cli(fd, "No such queue: %s.\n",argv[2]);
+ else
+ ast_cli(fd, "No queues.\n");
return RESULT_SUCCESS;
}
while(q) {
ast_mutex_lock(&q->lock);
+ if (queue_show) {
+ if (strcasecmp(q->name, argv[2]) != 0) {
+ q = q->next;
+ ast_mutex_unlock(&q->lock);
+ if (!q) {
+ ast_cli(fd, "No such queue: %s.\n",argv[2]);
+ break;
+ }
+ continue;
+ }
+ }
if (q->maxlen)
snprintf(max, sizeof(max), "%d", q->maxlen);
else
@@ -1400,11 +1413,41 @@
ast_cli(fd, "\n");
ast_mutex_unlock(&q->lock);
q = q->next;
+ if (queue_show)
+ break;
}
ast_mutex_unlock(&qlock);
return RESULT_SUCCESS;
}
+static int queues_show(int fd, int argc, char **argv)
+{
+ return __queues_show(fd, argc, argv, 0);
+}
+
+static int queue_show(int fd, int argc, char **argv)
+{
+ return __queues_show(fd, argc, argv, 1);
+}
+
+static char *complete_queue(char *line, char *word, int pos, int state)
+{
+ struct ast_call_queue *q;
+ int which=0;
+
+ ast_mutex_lock(&qlock);
+ q = queues;
+ while(q) {
+ if (!strncasecmp(word, q->name, strlen(word))) {
+ if (++which > state)
+ break;
+ }
+ q = q->next;
+ }
+ ast_mutex_unlock(&qlock);
+ return q ? strdup(q->name) : NULL;
+}
+
/* JDG: callback to display queues status in manager */
static int manager_queues_show( struct mansession *s, struct message *m )
{
@@ -1469,9 +1512,18 @@
{ "show", "queues", NULL }, queues_show,
"Show status of queues", show_queues_usage, NULL };
+static char show_queue_usage[] =
+"Usage: show queue\n"
+" Provides summary information on a specified queue.\n";
+
+static struct ast_cli_entry cli_show_queue = {
+ { "show", "queue", NULL }, queue_show,
+ "Show status of a specified queue", show_queue_usage, complete_queue };
+
int unload_module(void)
{
STANDARD_HANGUP_LOCALUSERS;
+ ast_cli_unregister(&cli_show_queue);
ast_cli_unregister(&cli_show_queues);
ast_manager_unregister( "Queues" );
ast_manager_unregister( "QueueStatus" );
@@ -1483,6 +1535,7 @@
int res;
res = ast_register_application(app, queue_exec, synopsis, descrip);
if (!res) {
+ ast_cli_register(&cli_show_queue);
ast_cli_register(&cli_show_queues);
ast_manager_register( "Queues", 0, manager_queues_show, "Queues" );
ast_manager_register( "QueueStatus", 0, manager_queues_status, "Queue Status" );
More information about the svn-commits
mailing list