Found the problem.

Its in the library that initializes the sql connection. 

Right now it only allows connection to mysql, since is the first that
the program will attempt to connect. 
The code in sqlbox_sql.c it should have a switch type, so the user can
set witch to use.

I attach a possible patch that make it possible to select between the
different types of db.
This patch adds the possibility to put in the configuration for the
sqlbox, the option "db-storage", witch can be one of the supported DB
engines.



 _________________________

António Silva

E-mail:asi...@wirelessmundi.com
diff -rNu sqlbox-0.7.2-orig//gw/sqlbox-cfg.def sqlbox-0.7.2/gw/sqlbox-cfg.def
--- sqlbox-0.7.2-orig//gw/sqlbox-cfg.def	2008-11-03 20:33:15.000000000 +0100
+++ sqlbox-0.7.2/gw/sqlbox-cfg.def	2012-11-07 16:06:01.000000000 +0100
@@ -21,4 +21,5 @@
     OCTSTR(ssl-server-cert-file)
     OCTSTR(ssl-server-key-file)
     OCTSTR(ssl-trusted-ca-file)
+    OCTSTR(db_storage)
 )
diff -rNu sqlbox-0.7.2-orig//gw/sqlbox_sql.c sqlbox-0.7.2/gw/sqlbox_sql.c
--- sqlbox-0.7.2-orig//gw/sqlbox_sql.c	2009-05-19 17:08:35.000000000 +0200
+++ sqlbox-0.7.2/gw/sqlbox_sql.c	2012-11-07 16:10:28.000000000 +0100
@@ -3,49 +3,74 @@
 
 struct server_type *sqlbox_init_sql(Cfg *cfg)
 {
+    CfgGroup *grp;
+    Octstr *db_storage;
+    char *type;
     struct server_type *res = NULL;
 
+
+    if (!(grp = cfg_get_single_group(cfg, octstr_imm("sqlbox"))))
+		panic(0, "SQLBOX: SQL INIT: group 'sqlbox' is not specified!");
+	/* fetch database type, default to mysql if not configured */
+	if (!(db_storage = cfg_get( grp, octstr_imm("db_storage"))))
+		db_storage = octstr_create("mysql");
+
+
+	if (octstr_compare(db_storage, octstr_imm("mssql")) == 0) {
 #ifdef HAVE_MSSQL
-    res = (struct server_type *)sqlbox_init_mssql(cfg);
-    if (res) {
-        return res;
-    }
-#endif
-#ifdef HAVE_MYSQL
-    res = (struct server_type *)sqlbox_init_mysql(cfg);
-    if (res) {
-        return res;
-    }
+		 res = (struct server_type *)sqlbox_init_mssql(cfg);
+		 if (res) {
+		     return res;
+		 }
 #endif
+	}
+	else if (octstr_compare(db_storage, octstr_imm("oracle")) == 0) {
 #ifdef HAVE_ORACLE
-    res = (struct server_type *)sqlbox_init_oracle(cfg);
-    if (res) {
-        return res;
-    }
+		 res = (struct server_type *)sqlbox_init_oracle(cfg);
+		 if (res) {
+		     return res;
+		 }
 #endif
+	}
+	else if (octstr_compare(db_storage, octstr_imm("pgsql")) == 0) {
 #ifdef HAVE_PGSQL
-    res = (struct server_type *)sqlbox_init_pgsql(cfg);
-    if (res) {
-        return res;
-    }
+		 res = (struct server_type *)sqlbox_init_pgsql(cfg);
+		 if (res) {
+		     return res;
+		 }
 #endif
+	}
+	else if (octstr_compare(db_storage, octstr_imm("sdb")) == 0) {
 #ifdef HAVE_SDB
-    res = (struct server_type *)sqlbox_init_sdb(cfg);
-    if (res) {
-        return res;
-    }
+		 res = (struct server_type *)sqlbox_init_sdb(cfg);
+		 if (res) {
+		     return res;
+		 }
 #endif
+	}
+	else if (octstr_compare(db_storage, octstr_imm("sqlite")) == 0) {
 #ifdef HAVE_SQLITE
-    res = (struct server_type *)sqlbox_init_sqlite(cfg);
-    if (res) {
-        return res;
-    }
+		 res = (struct server_type *)sqlbox_init_sqlite(cfg);
+		 if (res) {
+		     return res;
+		 }
 #endif
+	}
+	else if (octstr_compare(db_storage, octstr_imm("sqlite3")) == 0) {
 #ifdef HAVE_SQLITE3
-    res = (struct server_type *)sqlbox_init_sqlite3(cfg);
-    if (res) {
-        return res;
-    }
+		 res = (struct server_type *)sqlbox_init_sqlite3(cfg);
+		 if (res) {
+		     return res;
+		 }
+#endif
+	}
+	else {
+#ifdef HAVE_MYSQL
+		 res = (struct server_type *)sqlbox_init_mysql(cfg);
+		 if (res) {
+		     return res;
+		 }
 #endif
+	}
     return res;
 }

Reply via email to