Index: manager.c =================================================================== RCS file: /usr/cvsroot/asterisk/manager.c,v retrieving revision 1.35 diff -u -r1.35 manager.c --- manager.c 14 Jan 2004 09:31:24 -0000 1.35 +++ manager.c 17 Jan 2004 21:41:15 -0000 @@ -313,6 +313,43 @@ return 0; } + + +static int action_lookup(struct mansession *s, struct message *m) +{ + struct ast_channel *c = NULL; + char *name = astman_get_header(m, "Phone"); + char *startpoint; + if (!strlen(name)) { + astman_send_error(s, m, "No phone specified"); + return 0; + } + c = ast_channel_walk(NULL); + while(c) { + if( (startpoint=strchr( c->name, '/'))) { + startpoint++; + if (!strncasecmp( startpoint, name, strlen(name))) { + break; + } + } + c = ast_channel_walk(c); + } + if (!c) { + astman_send_error(s, m, "Extension is inactive"); + return 0; + } + else { + ast_cli(s->fd, "Response: Success\r\n" + "Channel: %s\r\n", c->name); + } + return 0; +} + + + + + + static int action_status(struct mansession *s, struct message *m) { char *id = astman_get_header(m,"ActionID"); @@ -871,6 +908,7 @@ ast_manager_register( "ExtensionState", EVENT_FLAG_CALL, action_extensionstate, "Check Extension Status" ); ast_manager_register( "AbsoluteTimeout", EVENT_FLAG_CALL, action_timeout, "Set Absolute Timeout" ); ast_manager_register( "MailboxCount", EVENT_FLAG_CALL, action_mailboxcount, "Check Mailbox Message Count" ); + ast_manager_register( "Lookup", EVENT_FLAG_CALL, action_lookup, "Lookup" ); ast_cli_register(&show_mancmds_cli); ast_cli_register(&show_manconn_cli);