[Asterisk-cvs] asterisk/channels chan_agent.c,1.115,1.116
mattf at lists.digium.com
mattf at lists.digium.com
Thu Feb 24 18:02:22 CST 2005
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv21584/channels
Modified Files:
chan_agent.c
Log Message:
Adding support to log off an agent from the console
Index: chan_agent.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_agent.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- chan_agent.c 18 Feb 2005 05:03:01 -0000 1.115
+++ chan_agent.c 25 Feb 2005 00:00:35 -0000 1.116
@@ -1422,6 +1422,55 @@
return RESULT_SUCCESS;
}
+static int agent_logoff(int fd, int argc, char **argv)
+{
+ struct agent_pvt *p = NULL;
+ char *line = NULL;
+ int res = 0;
+
+ /* Check args */
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+
+ line = argv[2];
+
+ ast_mutex_lock(&agentlock);
+ p = agents;
+ while (p) {
+ ast_mutex_lock(&p->lock);
+ res = strcmp(p->agent, line);
+
+ if (!res) {
+ /* Found him! Now we're going to kill him. */
+
+ if (ast_strlen_zero(p->loginchan)) {
+ ast_cli(fd, "Agent %s already logged off the system.\n", line);
+ ast_mutex_unlock(&p->lock);
+ break;
+ }
+
+ strcpy(p->loginchan, ""); /* Bang! Killed him */
+ ast_cli(fd, "Agent %s successfully logged off.\n", line);
+ ast_mutex_unlock(&p->lock);
+ break;
+ }
+
+ ast_mutex_unlock(&p->lock);
+ p = p->next;
+ }
+ ast_mutex_unlock(&agentlock);
+ if (res) ast_cli(fd, "Unable to find agent %s.\n", line);
+ return RESULT_SUCCESS;
+}
+
+static char agent_logoff_usage[] =
+"Usage: agent logoff <agentnum>\n"
+" Log an agent off the system that maybe forgot to log off, etc....\n";
+
+static struct ast_cli_entry cli_agent_logoff = {
+ { "agent", "logoff", NULL }, agent_logoff,
+ "Log an agent off of the system", agent_logoff_usage, NULL};
+
static char show_agents_usage[] =
"Usage: show agents\n"
" Provides summary information on agents.\n";
More information about the svn-commits
mailing list