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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 5 08:50:43 CST 2006


Author: crichter
Date: Thu Jan  5 08:50:41 2006
New Revision: 7816

URL: http://svn.digium.com/view/asterisk?rev=7816&view=rev
Log:
added missing mutex lockings && some more code finalizing

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=7816&r1=7815&r2=7816&view=diff
==============================================================================
--- team/crichter/config-update/channels/chan_misdn_config.c (original)
+++ team/crichter/config-update/channels/chan_misdn_config.c Thu Jan  5 08:50:41 2006
@@ -220,7 +220,8 @@
 	memset(free_list, 0, sizeof(free_list));
 	free_list[0] = port_cfg[0];
 	for (i = 1; i <= max_ports; ++i) {
-		if (port_cfg[i][gn].str) { /* we always have a groupname in the non-default case */
+		if (port_cfg[i][gn].str) {
+			/* we always have a groupname in the non-default case, so this is fine */
 			for (j = 1; j <= max_ports; ++j) {
 				if (free_list[j] && free_list[j][gn].str == port_cfg[i][gn].str)
 					break;
@@ -231,7 +232,6 @@
 			}
 		}
 	}
-
 	for (j = 0; free_list[j]; ++j) {
 		for (i = 0; i < NUM_PORT_ELEMENTS; ++i) {
 			if (free_list[j][i].any) {
@@ -283,10 +283,10 @@
 				}
 				break;
 			default:
-				if (port_cfg[port][place].num)
-					memcpy(buf, port_cfg[port][place].num, bufsize);
-				else if (port_cfg[0][place].num)
-					memcpy(buf, port_cfg[0][place].num, bufsize);
+				if (port_cfg[port][place].any)
+					memcpy(buf, port_cfg[port][place].any, bufsize);
+				else if (port_cfg[0][place].any)
+					memcpy(buf, port_cfg[0][place].any, bufsize);
 				else
 					memset(buf, 0, bufsize);
 			}
@@ -299,8 +299,8 @@
 				memset(buf, 0, 1);
 			break;
 		default:
-			if (general_cfg[place].num)
-				memcpy(buf, general_cfg[place].num, bufsize);
+			if (general_cfg[place].any)
+				memcpy(buf, general_cfg[place].any, bufsize);
 			else
 				memset(buf, 0, bufsize);
 		}
@@ -320,7 +320,6 @@
 	}
 
 	misdn_cfg_lock();
-
 	if (port_cfg[port][MISDN_CFG_MSNS-1].ml)
 		iter = port_cfg[port][MISDN_CFG_MSNS-1].ml;
 	else
@@ -330,7 +329,6 @@
 			misdn_cfg_unlock();
 			return 1;
 		}
-
 	misdn_cfg_unlock();
 
 	return 0;
@@ -347,7 +345,6 @@
 	char *method = NULL;
 
 	misdn_cfg_lock();
-
 	for (i = 1; i <= max_ports; i++) {
 		if (port_cfg[i]) {
 			if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group))
@@ -355,7 +352,6 @@
 						  port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str);
 		}
 	}
-
 	if (method) {
 		switch (meth) {
 		case METHOD_STANDARD:		re = !strcasecmp(method, "standard");
@@ -364,7 +360,6 @@
 									break;
 		}
 	}
-
 	misdn_cfg_unlock();
 
 	return re;
@@ -669,28 +664,32 @@
 {
 	char misdn_init[BUFFERSIZE];
 	char line[BUFFERSIZE];
+	FILE *fp;
+	char *tok, *p, *end;
+	int port;
 
 	misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init));
 
 	if (misdn_init) {
-		FILE *fp = fopen(misdn_init,"r");
+		fp = fopen(misdn_init, "r");
 		if (fp) {
 			while(fgets(line, sizeof(line), fp)) {
-				if (!strncmp(line,"nt_ptp",6)) {
-					char *tok, *p;
+				if (!strncmp(line, "nt_ptp", 6)) {
 					for (tok = strtok_r(line,",=", &p);
 						 tok;
-						 tok = strtok_r( NULL,",=", &p)) {
-						char *p;
-						int port = strtol(tok, &p,10);
-						if (p != tok)
+						 tok = strtok_r(NULL,",=", &p)) {
+						port = strtol(tok, &end, 10);
+						if (end != tok && misdn_cfg_is_port_valid(port)) {
+							misdn_cfg_lock();
 							ptp[port] = 1;
+							misdn_cfg_unlock();
+						}
 					}
 				}
 			}
 			fclose(fp);
 		} else {
-			ast_log(LOG_WARNING,"Couldn't open %s because: %s\n", misdn_init, strerror(errno));
+			ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno));
 		}
 	}
 }
@@ -700,11 +699,11 @@
 	int i;
 
 	for (i = 0; i < NUM_PORT_ELEMENTS; ++i) {
-		if (!port_cfg[0][i].num && strcasecmp(port_spec[i].def, NO_DEFAULT))
+		if (!port_cfg[0][i].any && strcasecmp(port_spec[i].def, NO_DEFAULT))
 			_parse(&(port_cfg[0][i]), (char *)port_spec[i].def, port_spec[i].type, port_spec[i].boolint_def);
 	}
 	for (i = 0; i < NUM_GEN_ELEMENTS; ++i) {
-		if (!general_cfg[i].num && strcasecmp(port_spec[i].def, NO_DEFAULT))
+		if (!general_cfg[i].any && strcasecmp(port_spec[i].def, NO_DEFAULT))
 			_parse(&(general_cfg[i]), (char *)gen_spec[i].def, gen_spec[i].type, port_spec[i].boolint_def);
 	}
 }



More information about the asterisk-commits mailing list