[asterisk-commits] russell: branch russell/smdi-1.4 r103865 - /team/russell/smdi-1.4/res/res_smdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 20 13:49:48 CST 2008


Author: russell
Date: Wed Feb 20 13:49:47 2008
New Revision: 103865

URL: http://svn.digium.com/view/asterisk?view=rev&rev=103865
Log:
Adding a bunch of debug for parsing MD messages

Modified:
    team/russell/smdi-1.4/res/res_smdi.c

Modified: team/russell/smdi-1.4/res/res_smdi.c
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/res/res_smdi.c?view=diff&rev=103865&r1=103864&r2=103865
==============================================================================
--- team/russell/smdi-1.4/res/res_smdi.c (original)
+++ team/russell/smdi-1.4/res/res_smdi.c Wed Feb 20 13:49:47 2008
@@ -487,14 +487,18 @@
 
 		/* check if this is the start of a message */
 		if (!start) {
-			if (c == 'M')
+			if (c == 'M') {
+				ast_log(LOG_DEBUG, "Read an 'M' to start an SMDI message\n");
 				start = 1;
+			}
 			continue;
 		}
 		
 		if (c == 'D') { /* MD message */
 			start = 0;
 
+			ast_log(LOG_DEBUG, "Read a 'D' ... it's an MD message.\n");
+
 			if (!(md_msg = ast_calloc(1, sizeof(*md_msg)))) {
 				ASTOBJ_UNREF(iface, ast_smdi_interface_destroy);
 				return NULL;
@@ -503,37 +507,54 @@
 			ASTOBJ_INIT(md_msg);
 
 			/* read the message desk number */
-			for (i = 0; i < sizeof(md_msg->mesg_desk_num) - 1; i++)
+			for (i = 0; i < sizeof(md_msg->mesg_desk_num) - 1; i++) {
 				md_msg->mesg_desk_num[i] = fgetc(iface->file);
+				ast_log(LOG_DEBUG, "Read a '%c'\n", md_msg->mesg_desk_num[i]);
+			}
 
 			md_msg->mesg_desk_num[sizeof(md_msg->mesg_desk_num) - 1] = '\0';
+			
+			ast_log(LOG_DEBUG, "The message desk number is '%s'\n", md_msg->mesg_desk_num);
 
 			/* read the message desk terminal number */
-			for (i = 0; i < sizeof(md_msg->mesg_desk_term) - 1; i++)
+			for (i = 0; i < sizeof(md_msg->mesg_desk_term) - 1; i++) {
 				md_msg->mesg_desk_term[i] = fgetc(iface->file);
+				ast_log(LOG_DEBUG, "Read a '%c'\n", md_msg->mesg_desk_term[i]);
+			}
 
 			md_msg->mesg_desk_term[sizeof(md_msg->mesg_desk_term) - 1] = '\0';
+
+			ast_log(LOG_DEBUG, "The message desk terminal is '%s'\n", md_msg->mesg_desk_term);
 
 			/* read the message type */
 			md_msg->type = fgetc(iface->file);
-		   
+		 
+			ast_log(LOG_DEBUG, "Message type is '%c'\n", md_msg->type);
+
 			/* read the forwarding station number (may be blank) */
 			cp = &md_msg->fwd_st[0];
 			for (i = 0; i < sizeof(md_msg->fwd_st) - 1; i++) {
 				if ((c = fgetc(iface->file)) == ' ') {
 					*cp = '\0';
+					ast_log(LOG_DEBUG, "Read a space, done looking for the forwarding station\n");
 					break;
 				}
 
 				/* store c in md_msg->fwd_st */
-				if (i >= iface->msdstrip)
+				if (i >= iface->msdstrip) {
+					ast_log(LOG_DEBUG, "Read a '%c' and stored it in the forwarding station buffer\n", c);
 					*cp++ = c;
+				} else {
+					ast_log(LOG_DEBUG, "Read a '%c', but didn't store it in the fwd station buffer, because of the msdstrip setting (%d < %d)\n", c, i, iface->msdstrip);
+				}
 			}
 
 			/* make sure the value is null terminated, even if this truncates it */
 			md_msg->fwd_st[sizeof(md_msg->fwd_st) - 1] = '\0';
 			cp = NULL;
-		
+
+			ast_log(LOG_DEBUG, "The forwarding station is '%s'\n", md_msg->fwd_st);
+
 			/* Put the fwd_st in the name field so that we can use ASTOBJ_FIND to look
 			 * up a message on this field */
 			ast_copy_string(md_msg->name, md_msg->fwd_st, sizeof(md_msg->name));
@@ -543,17 +564,24 @@
 			for (i = 0; i < sizeof(md_msg->calling_st) - 1; i++) {
 				if (!isdigit((c = fgetc(iface->file)))) {
 					*cp = '\0';
+					ast_log(LOG_DEBUG, "Read a '%c', but didn't store it in the calling station buffer because it's not a digit\n", c);
 					break;
 				}
 
 				/* store c in md_msg->calling_st */
-				if (i >= iface->msdstrip)
+				if (i >= iface->msdstrip) {
+					ast_log(LOG_DEBUG, "Read a '%c' and stored it in the calling station buffer\n", c);
 					*cp++ = c;
+				} else {
+					ast_log(LOG_DEBUG, "Read a '%c', but didn't store it in the calling station buffer, because of the msdstrip setting (%d < %d)\n", c, i, iface->msdstrip);
+				}
 			}
 
 			/* make sure the value is null terminated, even if this truncates it */
 			md_msg->calling_st[sizeof(md_msg->calling_st) - 1] = '\0';
 			cp = NULL;
+
+			ast_log(LOG_DEBUG, "The calling station is '%s'\n", md_msg->calling_st);
 
 			/* add the message to the message queue */
 			md_msg->timestamp = ast_tvnow();
@@ -564,6 +592,8 @@
 
 		} else if (c == 'W') { /* MWI message */
 			start = 0;
+
+			ast_log(LOG_DEBUG, "Read a 'W', it's an MWI message. (No more debug coming for MWI messages)\n");
 
 			if (!(mwi_msg = ast_calloc(1, sizeof(*mwi_msg)))) {
 				ASTOBJ_UNREF(iface,ast_smdi_interface_destroy);




More information about the asterisk-commits mailing list