[asterisk-commits] rmudgett: branch rmudgett/mwi r255841 - /team/rmudgett/mwi/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 1 13:28:29 CDT 2010


Author: rmudgett
Date: Thu Apr  1 13:28:25 2010
New Revision: 255841

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=255841
Log:
Address Russell's review comments.

Modified:
    team/rmudgett/mwi/channels/sig_pri.c
    team/rmudgett/mwi/channels/sig_pri.h

Modified: team/rmudgett/mwi/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/mwi/channels/sig_pri.c?view=diff&rev=255841&r1=255840&r2=255841
==============================================================================
--- team/rmudgett/mwi/channels/sig_pri.c (original)
+++ team/rmudgett/mwi/channels/sig_pri.c Thu Apr  1 13:28:25 2010
@@ -4787,7 +4787,7 @@
 {
 	struct pri_party_id mailbox;
 
-	ast_log(LOG_DEBUG, "Send MWI indication for %s@%s num_messages:%d\n", mbox_number,
+	ast_debug(1, "Send MWI indication for %s@%s num_messages:%d\n", mbox_number,
 		mbox_context, num_messages);
 
 	memset(&mailbox, 0, sizeof(mailbox));
@@ -4849,7 +4849,7 @@
 	int num_messages;
 	struct ast_event *event;
 
-	for (idx = 0; idx < SIG_PRI_MAX_MWI_MAILBOXES; ++idx) {
+	for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
 		if (!pri->mbox[idx].sub) {
 			/* There are no more mailboxes on this span. */
 			break;
@@ -4886,7 +4886,7 @@
 #endif	/* defined(HAVE_PRI_MWI) */
 
 #if defined(HAVE_PRI_MWI)
-	for (idx = 0; idx < SIG_PRI_MAX_MWI_MAILBOXES; ++idx) {
+	for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
 		if (pri->mbox[idx].sub) {
 			pri->mbox[idx].sub = ast_event_unsubscribe(pri->mbox[idx].sub);
 		}
@@ -4907,7 +4907,7 @@
 
 #if defined(HAVE_PRI_MWI)
 	/* Prepare the mbox[] for use. */
-	for (i = 0; i < SIG_PRI_MAX_MWI_MAILBOXES; ++i) {
+	for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {
 		if (pri->mbox[i].sub) {
 			pri->mbox[i].sub = ast_event_unsubscribe(pri->mbox[i].sub);
 		}
@@ -4922,10 +4922,12 @@
 	 * mailbox_number[@context]{,mailbox_number[@context]}
 	 */
 	i = 0;
-	saveptr = NULL;/* So compiler will not complain about uninitialized variable. */
-	for (mbox_number = strtok_r(pri->mwi_mailboxes, ",", &saveptr);
-		mbox_number && i < SIG_PRI_MAX_MWI_MAILBOXES;
-		mbox_number = strtok_r(NULL, ",", &saveptr)) {
+	saveptr = pri->mwi_mailboxes;
+	while (i < ARRAY_LEN(pri->mbox)) {
+		mbox_number = strsep(&saveptr, ",");
+		if (!mbox_number) {
+			break;
+		}
 		/* Split the mailbox_number and context */
 		mbox_context = strchr(mbox_number, '@');
 		if (mbox_context) {

Modified: team/rmudgett/mwi/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/mwi/channels/sig_pri.h?view=diff&rev=255841&r1=255840&r2=255841
==============================================================================
--- team/rmudgett/mwi/channels/sig_pri.h (original)
+++ team/rmudgett/mwi/channels/sig_pri.h Thu Apr  1 13:28:25 2010
@@ -243,7 +243,19 @@
 
 #if defined(HAVE_PRI_MWI)
 /*! Maximum number of mailboxes per span. */
-#define SIG_PRI_MAX_MWI_MAILBOXES		8
+#define SIG_PRI_MAX_MWI_MAILBOXES			8
+/*! Typical maximum length of mwi mailbox number */
+#define SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN		10	/* digits in number */
+/*! Typical maximum length of mwi mailbox context */
+#define SIG_PRI_MAX_MWI_CONTEXT_LEN			10
+/*!
+ * \brief Maximum mwi_mailbox string length.
+ * \details
+ * max_length = #mailboxes * (mbox_number + '@' + context + ',')
+ * The last ',' is a null terminator instead.
+ */
+#define SIG_PRI_MAX_MWI_MAILBOX_STR		(SIG_PRI_MAX_MWI_MAILBOXES	\
+	* (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN + 1))
 
 struct sig_pri_mbox {
 	/*!
@@ -295,7 +307,7 @@
 	 * \note Format: mailbox_number[@context]{,mailbox_number[@context]}
 	 * \note String is split apart when span is started.
 	 */
-	char mwi_mailboxes[2 * AST_MAX_EXTENSION];
+	char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
 #endif	/* defined(HAVE_PRI_MWI) */
 	char msn_list[AST_MAX_EXTENSION];		/*!< Comma separated list of MSNs to handle.  Empty if disabled. */
 	char idleext[AST_MAX_EXTENSION];		/*!< Where to idle extra calls */




More information about the asterisk-commits mailing list