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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 14 10:58:32 CST 2007


Author: russell
Date: Fri Dec 14 10:58:31 2007
New Revision: 92998

URL: http://svn.digium.com/view/asterisk?view=rev&rev=92998
Log:
reduce indentation of a huge block

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=92998&r1=92997&r2=92998
==============================================================================
--- team/russell/smdi-1.4/res/res_smdi.c (original)
+++ team/russell/smdi-1.4/res/res_smdi.c Fri Dec 14 10:58:31 2007
@@ -382,120 +382,120 @@
 		if (!start) {
 			if (c == 'M')
 				start = 1;
+			continue;
 		}
-		else { /* Determine if this is a MD or MWI message */
-			if(c == 'D') { /* MD message */
-				start = 0;
-
-				if (!(md_msg = ast_calloc(1, sizeof(*md_msg)))) {
-					ASTOBJ_UNREF(iface,ast_smdi_interface_destroy);
-					return NULL;
+		
+		if (c == 'D') { /* MD message */
+			start = 0;
+
+			if (!(md_msg = ast_calloc(1, sizeof(*md_msg)))) {
+				ASTOBJ_UNREF(iface,ast_smdi_interface_destroy);
+				return NULL;
+			}
+			
+			ASTOBJ_INIT(md_msg);
+
+			/* read the message desk number */
+			for(i = 0; i < SMDI_MESG_DESK_NUM_LEN; i++)
+				md_msg->mesg_desk_num[i] = fgetc(iface->file);
+
+			md_msg->mesg_desk_num[SMDI_MESG_DESK_NUM_LEN] = '\0';
+
+			/* read the message desk terminal number */
+			for(i = 0; i < SMDI_MESG_DESK_TERM_LEN; i++)
+				md_msg->mesg_desk_term[i] = fgetc(iface->file);
+
+			md_msg->mesg_desk_term[SMDI_MESG_DESK_TERM_LEN] = '\0';
+
+			/* read the message type */
+			md_msg->type = fgetc(iface->file);
+		   
+			/* read the forwarding station number (may be blank) */
+			cp = &md_msg->fwd_st[0];
+			for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
+				if((c = fgetc(iface->file)) == ' ') {
+					*cp = '\0';
+					break;
 				}
-				
-				ASTOBJ_INIT(md_msg);
-
-				/* read the message desk number */
-				for(i = 0; i < SMDI_MESG_DESK_NUM_LEN; i++)
-					md_msg->mesg_desk_num[i] = fgetc(iface->file);
-
-				md_msg->mesg_desk_num[SMDI_MESG_DESK_NUM_LEN] = '\0';
-
-				/* read the message desk terminal number */
-				for(i = 0; i < SMDI_MESG_DESK_TERM_LEN; i++)
-					md_msg->mesg_desk_term[i] = fgetc(iface->file);
-
-				md_msg->mesg_desk_term[SMDI_MESG_DESK_TERM_LEN] = '\0';
-
-				/* read the message type */
-				md_msg->type = fgetc(iface->file);
-			   
-				/* read the forwarding station number (may be blank) */
-				cp = &md_msg->fwd_st[0];
-				for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
-					if((c = fgetc(iface->file)) == ' ') {
-						*cp = '\0';
-						break;
-					}
-
-					/* store c in md_msg->fwd_st */
-					if( i >= iface->msdstrip)
-						*cp++ = c;
+
+				/* store c in md_msg->fwd_st */
+				if( i >= iface->msdstrip)
+					*cp++ = c;
+			}
+
+			/* make sure the value is null terminated, even if this truncates it */
+			md_msg->fwd_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
+			cp = NULL;
+			
+			/* read the calling station number (may be blank) */
+			cp = &md_msg->calling_st[0];
+			for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
+				if (!isdigit((c = fgetc(iface->file)))) {
+					*cp = '\0';
+					break;
 				}
 
-				/* make sure the value is null terminated, even if this truncates it */
-				md_msg->fwd_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
-				cp = NULL;
-				
-				/* read the calling station number (may be blank) */
-				cp = &md_msg->calling_st[0];
-				for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
-					if (!isdigit((c = fgetc(iface->file)))) {
-						*cp = '\0';
-						break;
-					}
-
-					/* store c in md_msg->calling_st */
-					if (i >= iface->msdstrip)
-						*cp++ = c;
+				/* store c in md_msg->calling_st */
+				if (i >= iface->msdstrip)
+					*cp++ = c;
+			}
+
+			/* make sure the value is null terminated, even if this truncates it */
+			md_msg->calling_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
+			cp = NULL;
+
+			/* add the message to the message queue */
+			md_msg->timestamp = ast_tvnow();
+			ast_smdi_md_message_push(iface, md_msg);
+			ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name);
+			
+			ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy);
+
+		} else if (c == 'W') { /* MWI message */
+			start = 0;
+
+			if (!(mwi_msg = ast_calloc(1, sizeof(*mwi_msg)))) {
+				ASTOBJ_UNREF(iface,ast_smdi_interface_destroy);
+				return NULL;
+			}
+
+			ASTOBJ_INIT(mwi_msg);
+
+			/* discard the 'I' (from 'MWI') */
+			fgetc(iface->file);
+			
+			/* read the forwarding station number (may be blank) */
+			cp = &mwi_msg->fwd_st[0];
+			for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
+				if ((c = fgetc(iface->file)) == ' ') {
+				*cp = '\0';
+					break;
 				}
 
-				/* make sure the value is null terminated, even if this truncates it */
-				md_msg->calling_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
-				cp = NULL;
-
-				/* add the message to the message queue */
-				md_msg->timestamp = ast_tvnow();
-				ast_smdi_md_message_push(iface, md_msg);
-				ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name);
-				
-				ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy);
-
-			} else if(c == 'W') { /* MWI message */
-				start = 0;
-
-				if (!(mwi_msg = ast_calloc(1, sizeof(*mwi_msg)))) {
-					ASTOBJ_UNREF(iface,ast_smdi_interface_destroy);
-					return NULL;
-				}
-
-				ASTOBJ_INIT(mwi_msg);
-
-				/* discard the 'I' (from 'MWI') */
-				fgetc(iface->file);
-				
-				/* read the forwarding station number (may be blank) */
-				cp = &mwi_msg->fwd_st[0];
-				for (i = 0; i < SMDI_MAX_STATION_NUM_LEN + 1; i++) {
-					if ((c = fgetc(iface->file)) == ' ') {
-						*cp = '\0';
-						break;
-					}
-
-					/* store c in md_msg->fwd_st */
-					if (i >= iface->msdstrip)
-						*cp++ = c;
-				}
-
-				/* make sure the station number is null terminated, even if this will truncate it */
-				mwi_msg->fwd_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
-				cp = NULL;
-				
-				/* read the mwi failure cause */
-				for (i = 0; i < SMDI_MWI_FAIL_CAUSE_LEN; i++)
-					mwi_msg->cause[i] = fgetc(iface->file);
-
-				mwi_msg->cause[SMDI_MWI_FAIL_CAUSE_LEN] = '\0';
-
-				/* add the message to the message queue */
-				mwi_msg->timestamp = ast_tvnow();
-				ast_smdi_mwi_message_push(iface, mwi_msg);
-				ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name);
-				
-				ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
-			} else {
-				ast_log(LOG_ERROR, "Unknown SMDI message type recieved on %s (M%c).\n", iface->name, c);
-				start = 0;
-			}
+				/* store c in md_msg->fwd_st */
+				if (i >= iface->msdstrip)
+					*cp++ = c;
+			}
+
+			/* make sure the station number is null terminated, even if this will truncate it */
+			mwi_msg->fwd_st[SMDI_MAX_STATION_NUM_LEN] = '\0';
+			cp = NULL;
+			
+			/* read the mwi failure cause */
+			for (i = 0; i < SMDI_MWI_FAIL_CAUSE_LEN; i++)
+				mwi_msg->cause[i] = fgetc(iface->file);
+
+			mwi_msg->cause[SMDI_MWI_FAIL_CAUSE_LEN] = '\0';
+
+			/* add the message to the message queue */
+			mwi_msg->timestamp = ast_tvnow();
+			ast_smdi_mwi_message_push(iface, mwi_msg);
+			ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name);
+			
+			ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
+		} else {
+			ast_log(LOG_ERROR, "Unknown SMDI message type recieved on %s (M%c).\n", iface->name, c);
+			start = 0;
 		}
 	}
 




More information about the asterisk-commits mailing list