aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-11-22 09:08:09 +0100
committerMartin Willi <martin@revosec.ch>2014-06-04 15:53:04 +0200
commit8e1c0d15a93a1862797b2c3d2eb164adcbfb5b01 (patch)
treeb0f3bb7e21c35c107b6299a659092c5e3df933f5
parentdf4341747cdba90212dc21784b391a605cd2b977 (diff)
downloadstrongswan-8e1c0d15a93a1862797b2c3d2eb164adcbfb5b01.tar.bz2
strongswan-8e1c0d15a93a1862797b2c3d2eb164adcbfb5b01.tar.xz
mysql: Add Windows support
As the mysql_config script is not available for Windows, we use a hardcoded library name and no additional CFLAGS. This builds fine against the binary MySQL Connector/C distribution.
-rw-r--r--configure.ac16
-rw-r--r--src/libstrongswan/plugins/mysql/mysql_database.c12
-rw-r--r--src/libstrongswan/plugins/mysql/mysql_database.h1
3 files changed, 19 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index 4eda8eec4..633e611dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -895,12 +895,18 @@ if test x$fast = xtrue; then
fi
if test x$mysql = xtrue; then
- AC_PATH_PROG([MYSQLCONFIG], [mysql_config], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
- if test x$MYSQLCONFIG = x; then
- AC_MSG_ERROR([mysql_config not found!])
+ if test "x$windows" = xtrue; then
+ AC_CHECK_HEADER([mysql.h],,[AC_MSG_ERROR([MySQL header file mysql.h not found!])])
+ AC_CHECK_LIB([mysql],[main],[LIBS="$LIBS"],[AC_MSG_ERROR([MySQL library not found!])],[])
+ AC_SUBST(MYSQLLIB, -lmysql)
+ else
+ AC_PATH_PROG([MYSQLCONFIG], [mysql_config], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
+ if test x$MYSQLCONFIG = x; then
+ AC_MSG_ERROR([mysql_config not found!])
+ fi
+ AC_SUBST(MYSQLLIB, `$MYSQLCONFIG --libs_r`)
+ AC_SUBST(MYSQLCFLAG, `$MYSQLCONFIG --cflags`)
fi
- AC_SUBST(MYSQLLIB, `$MYSQLCONFIG --libs_r`)
- AC_SUBST(MYSQLCFLAG, `$MYSQLCONFIG --cflags`)
fi
if test x$sqlite = xtrue; then
diff --git a/src/libstrongswan/plugins/mysql/mysql_database.c b/src/libstrongswan/plugins/mysql/mysql_database.c
index 373e9dc7c..871cc59a0 100644
--- a/src/libstrongswan/plugins/mysql/mysql_database.c
+++ b/src/libstrongswan/plugins/mysql/mysql_database.c
@@ -14,12 +14,12 @@
* for more details.
*/
+#include "mysql_database.h"
+
#define _GNU_SOURCE
#include <string.h>
#include <mysql.h>
-#include "mysql_database.h"
-
#include <utils/debug.h>
#include <utils/chunk.h>
#include <threading/thread_value.h>
@@ -730,7 +730,7 @@ static bool finalize_transaction(private_mysql_database_t *this,
return TRUE;
}
-METHOD(database_t, commit, bool,
+METHOD(database_t, commit_, bool,
private_mysql_database_t *this)
{
return finalize_transaction(this, FALSE);
@@ -768,7 +768,7 @@ static bool parse_uri(private_mysql_database_t *this, char *uri)
/**
* parse mysql://username:pass@host:port/database uri
*/
- username = strdupa(uri + 8);
+ username = strdup(uri + 8);
pos = strchr(username, ':');
if (pos)
{
@@ -800,10 +800,12 @@ static bool parse_uri(private_mysql_database_t *this, char *uri)
this->password = strdup(password);
this->database = strdup(database);
this->port = atoi(port);
+ free(username);
return TRUE;
}
}
}
+ free(username);
DBG1(DBG_LIB, "parsing MySQL database uri '%s' failed", uri);
return FALSE;
}
@@ -828,7 +830,7 @@ mysql_database_t *mysql_database_create(char *uri)
.query = _query,
.execute = _execute,
.transaction = _transaction,
- .commit = _commit,
+ .commit = _commit_,
.rollback = _rollback,
.get_driver = _get_driver,
.destroy = _destroy,
diff --git a/src/libstrongswan/plugins/mysql/mysql_database.h b/src/libstrongswan/plugins/mysql/mysql_database.h
index 98ddcad36..bbf6a33e9 100644
--- a/src/libstrongswan/plugins/mysql/mysql_database.h
+++ b/src/libstrongswan/plugins/mysql/mysql_database.h
@@ -21,6 +21,7 @@
#ifndef MYSQL_DATABASE_H_
#define MYSQL_DATABASE_H_
+#include <library.h>
#include <database/database.h>
typedef struct mysql_database_t mysql_database_t;