More mysql patches
authorMark Spencer <markster@digium.com>
Thu, 4 Sep 2003 04:20:43 +0000 (04:20 +0000)
committerMark Spencer <markster@digium.com>
Thu, 4 Sep 2003 04:20:43 +0000 (04:20 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1472 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/Makefile
apps/app_voicemail2.c

index cf728cf..1fec5c1 100755 (executable)
 # the GNU General Public License
 #
 
 # the GNU General Public License
 #
 
-USE_MYSQL_VM_INTERFACE=0
+USE_MYSQL_VM_INTERFACE=1
 
 MLFLAGS=
 ifeq ($(USE_MYSQL_VM_INTERFACE),1)
 
 MLFLAGS=
 ifeq ($(USE_MYSQL_VM_INTERFACE),1)
+CFLAGS+=-DUSEMYSQLVM
 CFLAGS+=$(shell if [ -d /usr/local/mysql/include ]; then echo "-I/usr/local/mysql/include"; fi)
 CFLAGS+=$(shell if [ -d /usr/include/mysql ]; then echo "-I/usr/include/mysql"; fi)
 CFLAGS+=$(shell if [ -d /usr/local/include/mysql ]; then echo "-I/usr/local/include/mysql"; fi)
 CFLAGS+=$(shell if [ -d /usr/local/mysql/include ]; then echo "-I/usr/local/mysql/include"; fi)
 CFLAGS+=$(shell if [ -d /usr/include/mysql ]; then echo "-I/usr/include/mysql"; fi)
 CFLAGS+=$(shell if [ -d /usr/local/include/mysql ]; then echo "-I/usr/local/include/mysql"; fi)
@@ -65,7 +66,11 @@ app_todd.so: app_todd.o
        $(CC) -shared -Xlinker -x -o $@ $< -L/usr/local/ssl/lib -lssl -lcrypto
 
 app_voicemail2.so : app_voicemail2.o
        $(CC) -shared -Xlinker -x -o $@ $< -L/usr/local/ssl/lib -lssl -lcrypto
 
 app_voicemail2.so : app_voicemail2.o
+ifeq ($(USE_MYSQL_VM_INTERFACE),1)
+       $(CC) -shared -Xlinker -x -o $@ $(MLFLAGS) $< -lmysqlclient -lz
+else
        $(CC) -shared -Xlinker -x -o $@ $(MLFLAGS) $<
        $(CC) -shared -Xlinker -x -o $@ $(MLFLAGS) $<
+endif
 
 app_sql_postgres.o: app_sql_postgres.c
        $(CC) -pipe -I/usr/local/pgsql/include $(CFLAGS) -c -o app_sql_postgres.o app_sql_postgres.c
 
 app_sql_postgres.o: app_sql_postgres.c
        $(CC) -pipe -I/usr/local/pgsql/include $(CFLAGS) -c -o app_sql_postgres.o app_sql_postgres.c
index 9e00869..7fb3b43 100755 (executable)
@@ -35,7 +35,7 @@
 #include <sys/stat.h>
 #include <time.h>
 #ifdef USEMYSQLVM
 #include <sys/stat.h>
 #include <time.h>
 #ifdef USEMYSQLVM
-#include <mysql/mysql.h>
+#include <mysql.h>
 #endif
 
 #include <pthread.h>
 #endif
 
 #include <pthread.h>
@@ -186,6 +186,7 @@ MYSQL *dbhandler=NULL;
 ast_mutex_t mysqllock;
 char dbuser[80];
 char dbpass[80];
 ast_mutex_t mysqllock;
 char dbuser[80];
 char dbpass[80];
+char dbhost[80];
 char dbname[80];
 
 static int mysql_login(void)
 char dbname[80];
 
 static int mysql_login(void)
@@ -193,11 +194,11 @@ static int mysql_login(void)
        ast_verbose( VERBOSE_PREFIX_3 "Logging into database with user %s, password %s, and database %s\n", dbuser, dbpass, dbname);
 
        dbhandler=mysql_init(NULL);
        ast_verbose( VERBOSE_PREFIX_3 "Logging into database with user %s, password %s, and database %s\n", dbuser, dbpass, dbname);
 
        dbhandler=mysql_init(NULL);
-       if (!mysql_real_connect(dbhandler, NULL, dbuser, dbpass, dbname, 0, NULL, 0)) {
+       if (!mysql_real_connect(dbhandler, dbhost[0] ? dbhost : NULL, dbuser, dbpass, dbname, 0, NULL, 0)) {
                ast_log(LOG_WARNING, "Error Logging into database\n");
                return(-1);
        }
                ast_log(LOG_WARNING, "Error Logging into database\n");
                return(-1);
        }
-       ast_mutex_init(&mysqllock, NULL);
+       ast_mutex_init(&mysqllock);
        return(0);
 }
 
        return(0);
 }
 
@@ -2968,6 +2969,11 @@ static int load_config(void)
                } else {
                        strcpy(dbpass, s);
                }
                } else {
                        strcpy(dbpass, s);
                }
+               if (!(s=ast_variable_retrieve(cfg, "general", "dbhost"))) {
+                       strcpy(dbhost, "");
+               } else {
+                       strcpy(dbhost, s);
+               }
                if (!(s=ast_variable_retrieve(cfg, "general", "dbname"))) {
                        strcpy(dbname, "vmdb");
                } else {
                if (!(s=ast_variable_retrieve(cfg, "general", "dbname"))) {
                        strcpy(dbname, "vmdb");
                } else {