[asterisk-commits] branch crichter/config-update - r7837 /team/crichter/config-update/channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jan 6 04:20:51 CST 2006


Author: crichter
Date: Fri Jan  6 04:20:49 2006
New Revision: 7837

URL: http://svn.digium.com/view/asterisk?rev=7837&view=rev
Log:
some more code adjustments

Modified:
    team/crichter/config-update/channels/chan_misdn_config.c

Modified: team/crichter/config-update/channels/chan_misdn_config.c
URL: http://svn.digium.com/view/asterisk/team/crichter/config-update/channels/chan_misdn_config.c?rev=7837&r1=7836&r2=7837&view=diff
==============================================================================
--- team/crichter/config-update/channels/chan_misdn_config.c (original)
+++ team/crichter/config-update/channels/chan_misdn_config.c Fri Jan  6 04:20:49 2006
@@ -513,67 +513,51 @@
 static int _parse (union misdn_cfg_pt *dest, char *value, enum misdn_cfg_type type, int boolint_def)
 {
 	int re = 0;
+	int len, tmp;
+	char *valtmp;
 
 	switch (type) {
 	case MISDN_CTYPE_STR:
-		{
-			int len;
-			if ((len = strlen(value))) {
-				dest->str = (char *)malloc((len + 1) * sizeof(char));
-				strncpy(dest->str, value, len);
-				dest->str[len] = 0;
-			} else
-				re = -1;
-		}
+		if ((len = strlen(value))) {
+			dest->str = (char *)malloc((len + 1) * sizeof(char));
+			strncpy(dest->str, value, len);
+			dest->str[len] = 0;
+		} else
+			re = -1;
 		break;
 	case MISDN_CTYPE_INT:
-		{
-			int tmp;
-			if (sscanf(value, "%d", &tmp)) {
-				dest->num = (int *)malloc(sizeof(int));
-				memcpy(dest->num, &tmp, sizeof(int));
-			} else {
-				re = -1;
-			}
-		}
+		if (sscanf(value, "%d", &tmp)) {
+			dest->num = (int *)malloc(sizeof(int));
+			memcpy(dest->num, &tmp, sizeof(int));
+		} else
+			re = -1;
 		break;
 	case MISDN_CTYPE_BOOL:
-		{
-			dest->num = (int *)malloc(sizeof(int));
-			*(dest->num) = (ast_true(value) ? 1 : 0);
-		}
+		dest->num = (int *)malloc(sizeof(int));
+		*(dest->num) = (ast_true(value) ? 1 : 0);
 		break;
 	case MISDN_CTYPE_BOOLINT:
-		{
-			int tmp;
-			dest->num = (int *)malloc(sizeof(int));
-			if (sscanf(value, "%d", &tmp)) {
-				memcpy(dest->num, &tmp, sizeof(int));
-			} else {
-				*(dest->num) = (ast_true(value) ? boolint_def : 0);
-			}
+		dest->num = (int *)malloc(sizeof(int));
+		if (sscanf(value, "%d", &tmp)) {
+			memcpy(dest->num, &tmp, sizeof(int));
+		} else {
+			*(dest->num) = (ast_true(value) ? boolint_def : 0);
 		}
 		break;
 	case MISDN_CTYPE_MSNLIST:
-		{
-			char *valtmp;
-			int l;
-			for (valtmp = strsep(&value, ","); valtmp; valtmp = strsep(&value, ",")) {
-				if ((l = strlen(valtmp))) {
-					struct msn_list *ml = (struct msn_list *)malloc(sizeof(struct msn_list));
-					ml->msn = (char *)calloc(l+1, sizeof(char));
-					strncpy(ml->msn, valtmp, l);
-					ml->next = dest->ml;
-					dest->ml = ml;
-				}
+		for (valtmp = strsep(&value, ","); valtmp; valtmp = strsep(&value, ",")) {
+			if ((len = strlen(valtmp))) {
+				struct msn_list *ml = (struct msn_list *)malloc(sizeof(struct msn_list));
+				ml->msn = (char *)calloc(len+1, sizeof(char));
+				strncpy(ml->msn, valtmp, len);
+				ml->next = dest->ml;
+				dest->ml = ml;
 			}
 		}
 		break;
 	case MISDN_CTYPE_ASTGROUP:
-		{
-			dest->grp = (ast_group_t *)malloc(sizeof(ast_group_t));
-			*(dest->grp) = ast_get_group(value);
-		}
+		dest->grp = (ast_group_t *)malloc(sizeof(ast_group_t));
+		*(dest->grp) = ast_get_group(value);
 		break;
 	}
 



More information about the asterisk-commits mailing list