[asterisk-commits] rizzo: branch rizzo/astobj2 r76522 - /team/rizzo/astobj2/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 23 08:39:06 CDT 2007
Author: rizzo
Date: Mon Jul 23 08:39:06 2007
New Revision: 76522
URL: http://svn.digium.com/view/asterisk?view=rev&rev=76522
Log:
more merge from trunk.
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=76522&r1=76521&r2=76522
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Mon Jul 23 08:39:06 2007
@@ -11429,7 +11429,7 @@
ast_localtime(&iterator->regtime, &tm, NULL);
ast_strftime(tmpdat, sizeof(tmpdat), "%a, %d %b %Y %T", &tm);
} else
- tmpdat[0] = 0;
+ tmpdat[0] = '\0';
ast_cli(fd, FORMAT, host, iterator->username, iterator->refresh, regstate2str(iterator->regstate), tmpdat);
ASTOBJ_UNLOCK(iterator);
counter++;
@@ -11453,8 +11453,12 @@
return RESULT_SHOWUSAGE;
if ((peer = find_peer(argv[2], NULL, load_realtime))) {
- expire_register(peer);
- ast_cli(fd, "Unregistered peer \'%s\'\n\n", argv[2]);
+ if (peer->expire > 0) {
+ expire_register(peer);
+ ast_cli(fd, "Unregistered peer \'%s\'\n\n", argv[2]);
+ } else {
+ ast_cli(fd, "Peer %s not registered\n", argv[2]);
+ }
} else {
ast_cli(fd, "Peer unknown: \'%s\'. Not unregistered.\n", argv[2]);
}
@@ -11702,7 +11706,11 @@
return 0; /* don't care, we scan all channels */
}
-/*! \brief CLI for show channels or subscriptions */
+/*! \brief CLI for show channels or subscriptions.
+ * This is a new-style CLI handler so a single function contains
+ * the prototype for the function, the 'generator' to produce multiple
+ * entries in case it is required, and the actual handler for the command.
+ */
static char *sip_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct sip_pvt *cur;
@@ -11726,6 +11734,8 @@
ast_cli(arg.fd, FORMAT2, "Peer", "User/ANR", "Call ID", "Seq (Tx/Rx)", "Format", "Hold", "Last Message");
else
ast_cli(arg.fd, FORMAT3, "Peer", "User", "Call ID", "Extension", "Last state", "Type", "Mailbox");
+
+ /* iterate on the container and invoke the callback on each item */
#ifdef USE_AO2
cur = NULL; /* silence compiler */
ao2_callback(dialogs, OBJ_MULTIPLE|OBJ_NODATA, show_channels_cb, &arg);
@@ -11736,9 +11746,11 @@
}
dialoglist_unlock();
#endif
+
+ /* print summary information */
ast_cli(arg.fd, "%d active SIP %s%s\n", arg.numchans,
- (arg.subscriptions ? "subscription" : "channel"),
- ESS(arg.numchans));
+ (arg.subscriptions ? "subscription" : "channel"),
+ ESS(arg.numchans)); /* ESS(n) returns an "s" if n>1 */
return CLI_SUCCESS;
#undef FORMAT
#undef FORMAT2
@@ -17619,6 +17631,7 @@
}
ASTOBJ_UNMARK(peer);
+
ast_free_ha(oldha);
if (!ast_strlen_zero(callback)) { /* build string from peer info */
char *reg_string;
More information about the asterisk-commits
mailing list