[Asterisk-cvs] asterisk config.c,1.56,1.57

markster at lists.digium.com markster at lists.digium.com
Thu Feb 10 15:14:05 CST 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv1210

Modified Files:
	config.c 
Log Message:
Separate IAX and SIP tables for users/peers


Index: config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/config.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- config.c	2 Feb 2005 19:48:53 -0000	1.56
+++ config.c	10 Feb 2005 21:14:11 -0000	1.57
@@ -751,12 +751,47 @@
 	ast_mutex_unlock(&config_lock);
 }
 
+static int append_mapping(char *name, char *driver, char *database, char *table)
+{
+	struct ast_config_map *map;
+	int length;
+
+	length = sizeof(*map);
+	length += strlen(name) + 1;
+	length += strlen(driver) + 1;
+	length += strlen(database) + 1;
+	if (table)
+		length += strlen(table) + 1;
+	map = malloc(length);
+
+	if (!map)
+		return -1;
+
+	memset(map, 0, length);
+	map->name = map->stuff;
+	strcpy(map->name, name);
+	map->driver = map->name + strlen(map->name) + 1;
+	strcpy(map->driver, driver);
+	map->database = map->driver + strlen(map->driver) + 1;
+	strcpy(map->database, database);
+	if (table) {
+		map->table = map->database + strlen(map->database) + 1;
+		strcpy(map->table, table);
+	}
+	map->next = config_maps;
+
+	if (option_verbose > 1)
+		ast_verbose(VERBOSE_PREFIX_2 "Binding %s to %s/%s/%s\n",
+			    map->name, map->driver, map->database, map->table ? map->table : map->name);
+
+	config_maps = map;
+	return 0;
+}
+
 void read_config_maps(void) 
 {
 	struct ast_config *config;
 	struct ast_variable *v;
-	struct ast_config_map *map;
-	int length;
 	char *driver, *table, *database, *stringp;
 
 	clear_config_maps();
@@ -780,36 +815,16 @@
 
 		if (!driver || !database)
 			continue;
-
-		length = sizeof(*map);
-		length += strlen(v->name) + 1;
-		length += strlen(driver) + 1;
-		length += strlen(database) + 1;
-		if (table)
-			length += strlen(table) + 1;
-		map = malloc(length);
-
-		if (!map)
-			continue;
-
-		memset(map, 0, length);
-		map->name = map->stuff;
-		strcpy(map->name, v->name);
-		map->driver = map->name + strlen(map->name) + 1;
-		strcpy(map->driver, driver);
-		map->database = map->driver + strlen(map->driver) + 1;
-		strcpy(map->database, database);
-		if (table) {
-			map->table = map->database + strlen(map->database) + 1;
-			strcpy(map->table, table);
-		}
-		map->next = config_maps;
-
-		if (option_verbose > 1)
-			ast_verbose(VERBOSE_PREFIX_2 "Binding %s to %s/%s/%s\n",
-				    map->name, map->driver, map->database, map->table ? map->table : map->name);
-
-		config_maps = map;
+		if (!strcasecmp(v->name, "sipfriends")) {
+			ast_log(LOG_WARNING, "The 'sipfriends' table is obsolete, update your config to use sipusers and sippeers, though they can point to the same table.\n");
+			append_mapping("sipusers", driver, database, table ? table : "sipfriends");
+			append_mapping("sippeers", driver, database, table ? table : "sipfriends");
+		} else if (!strcasecmp(v->name, "iaxfriends")) {
+			ast_log(LOG_WARNING, "The 'iaxfriends' table is obsolete, update your config to use iaxusers and iaxpeers, though they can point to the same table.\n");
+			append_mapping("iaxusers", driver, database, table ? table : "iaxfriends");
+			append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends");
+		} else 
+			append_mapping(v->name, driver, database, table);
 	}
 		
 	ast_config_destroy(config);




More information about the svn-commits mailing list