Index: channels/chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.319 diff -u -r1.319 chan_zap.c --- channels/chan_zap.c 1 Aug 2004 02:39:32 -0000 1.319 +++ channels/chan_zap.c 18 Aug 2004 18:08:40 -0000 @@ -6377,7 +6377,79 @@ iflist = p; return p; } - + +static int handle_zap_set_mailbox(int fd, int argc, char *argv[]) +{ + /* zap set mailbox 123 123@default */ + struct zt_pvt *tmp = NULL; + int channel; + + if (argc != 5) { + return RESULT_SHOWUSAGE; + } + channel = atoi(argv[3]); + tmp = iflist; + while (tmp) { + if (tmp->channel == channel) { + strncpy(tmp->mailbox, argv[4], sizeof(tmp->mailbox)); + return RESULT_SUCCESS; + } + tmp = tmp->next; + } + return RESULT_FAILURE; +} + +static char zap_set_mailbox_cmd_usage[] = +"Usage: zap set mailbox [@context]\n"; + +static struct ast_cli_entry cli_zap_set_mailbox = { + { "zap", "set", "mailbox", NULL }, handle_zap_set_mailbox, + "Sets the mailbox for MWI", zap_set_mailbox_cmd_usage, NULL }; + +static int handle_zap_show_mailbox(int fd, int argc, char *argv[]) +{ + struct zt_pvt *tmp = NULL; + int seenheader=0; + + if ((argc < 3) || (argc > 4)) { + return RESULT_SHOWUSAGE; + } + + for (tmp = iflist; tmp; tmp = tmp->next) { + int print=0; + if (argc == 3) { + print = 1; + } else { + int channel = atoi(argv[3]); + if (channel == tmp->channel) { + print = 1; + } + } + + if (print && (!ast_strlen_zero(tmp->mailbox))) { + char *format="%-8.8s %-20.20s\n"; + char *format2="Zap/%-4d %-20.20s\n"; + if (!seenheader) { + ast_cli(fd, format, "Channel", "Mailbox"); + seenheader = 1; + } + ast_cli(fd, format2, tmp->channel, tmp->mailbox); + } + } + if (seenheader) { + return RESULT_SUCCESS; + } else { + ast_cli(fd, "No mailboxes defined\n"); + return RESULT_FAILURE; + } +} + +static char zap_show_mailbox_cmd_usage[] = +"Usage: zap show mailbox []\n"; + +static struct ast_cli_entry cli_zap_show_mailbox = { + { "zap", "show", "mailbox", NULL }, handle_zap_show_mailbox, + "Lists MWI mailboxes for Zap channels", zap_show_mailbox_cmd_usage, NULL }; #ifdef ZAPATA_PRI static int pri_find_empty_chan(struct zt_pri *pri, int backwards) @@ -8520,6 +8592,8 @@ ast_cli_unregister(&r2_debug); ast_cli_unregister(&r2_no_debug); #endif + ast_cli_unregister(&cli_zap_set_mailbox); + ast_cli_unregister(&cli_zap_show_mailbox); ast_cli_unregister(&cli_show_channels); ast_cli_unregister(&cli_show_channel); ast_cli_unregister(&cli_destroy_channel); @@ -9299,6 +9371,7 @@ ast_cli_register(&cli_show_channel); ast_cli_register(&cli_destroy_channel); ast_cli_register(&zap_show_cadences_cli); + ast_cli_register(&cli_zap_show_mailbox); + ast_cli_register_&cli_zap_set_mailbox); ast_register_application(app_callingpres, change_callingpres, synopsis_callingpres, descrip_callingpres); memset(round_robin, 0, sizeof(round_robin));