Przeglądaj źródła

further changes after the db name change
- update INSTALL file
- fix Makefile skip modules variable
- fix module Makefile, lib name
- change db_bind_mod to add the db prefix in the function
- change db url defines in db_berkeley and db_text
- change database modules names in module struct
- fix debian packaging
- fix tests


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3642 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt 17 lat temu
rodzic
commit
72b0651d35
1 zmienionych plików z 12 dodań i 7 usunięć
  1. 12 7
      lib/srdb1/db.c

+ 12 - 7
lib/srdb1/db.c

@@ -78,25 +78,30 @@ int db_bind_mod(const str* mod, db_func_t* mydbf)
 		LM_ERR("SQL URL too long\n");
 		return 0;
 	}
+	// add the prefix
+	char * name = pkg_malloc(mod->len + 4);
+	char * prefix = "db_";
+	memcpy(name, prefix, 3);
+	memcpy(name+3, mod->s, mod->len);
+
 	/* for safety we initialize mydbf with 0 (this will cause
 	 *  a segfault immediately if someone tries to call a function
-	 *  from it without checking the return code from bind_dbmod -- andrei */
+	 *  from it without checking the return code from bind_dbmod */
 	memset((void*)mydbf, 0, sizeof(db_func_t));
 
-	p = strchr(mod->s, ':');
+	p = strchr(name, ':');
 	if (p) {
-		len = p - mod->s;
-		tmp = (char*)pkg_malloc(len + 1);
+		len = p - name;
+		tmp = (char*)pkg_malloc(len + 4);
 		if (!tmp) {
 			LM_ERR("no private memory left\n");
 			return -1;
 		}
-		memcpy(tmp, mod->s, len);
+		memcpy(tmp, name, len);
 		tmp[len] = '\0';
 	} else {
-		tmp = mod->s;
+		tmp = name;
 	}
-
 	dbf.cap = 0;
 
 	/* All modules must export db_use_table */