summaryrefslogtreecommitdiffstats
path: root/ulogd/mysql
diff options
context:
space:
mode:
authorlaforge <laforge>2005-02-09 15:21:24 +0000
committerlaforge <laforge>2005-02-09 15:21:24 +0000
commitc781e3866950bf2c539b2f0bcd9ce422e038b82f (patch)
tree458c24eae97f82e059b5178c2ab313ae6fb3a594 /ulogd/mysql
parent8464a08c1a773d084adc1ff522726ba2ab653b8c (diff)
port Sven Schuster's patch to add user-specified mysql port number
Diffstat (limited to 'ulogd/mysql')
-rw-r--r--ulogd/mysql/ulogd_MYSQL.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/ulogd/mysql/ulogd_MYSQL.c b/ulogd/mysql/ulogd_MYSQL.c
index 894098f..0e46cc9 100644
--- a/ulogd/mysql/ulogd_MYSQL.c
+++ b/ulogd/mysql/ulogd_MYSQL.c
@@ -1,4 +1,4 @@
-/* ulogd_MYSQL.c, Version $Revision: 1.15 $
+/* ulogd_MYSQL.c, Version $Revision$
*
* ulogd output plugin for logging to a MySQL database
*
@@ -29,6 +29,8 @@
* See ulogd/doc/mysql.table.ipaddr-as-string as an example.
* BE WARNED: This has _WAY_ less performance during table searches.
*
+ * 09 Feb 2005, Sven Schuster <schuster.sven@gmx.de>:
+ * Added the "port" parameter to specify ports different from 3306
*/
#include <stdlib.h>
@@ -99,6 +101,12 @@ static config_entry_t table_ce = {
.options = CONFIG_OPT_MANDATORY,
};
+static config_entry_t port_ce = {
+ .next = &table_ce,
+ .key = "port",
+ .type = CONFIG_TYPE_INT,
+};
+
/* our main output function, called by ulogd */
static int mysql_output(ulog_iret_t *result)
{
@@ -314,13 +322,14 @@ static int mysql_get_columns(const char *table)
}
/* make connection and select database */
-static int mysql_open_db(char *server, char *user, char *pass, char *db)
+static int mysql_open_db(char *server, int port, char *user, char *pass,
+ char *db)
{
dbh = mysql_init(NULL);
if (!dbh)
return 1;
- if (!mysql_real_connect(dbh, server, user, pass, db, 0, NULL, 0))
+ if (!mysql_real_connect(dbh, server, user, pass, db, port, NULL, 0))
return 1;
return 0;
@@ -329,9 +338,9 @@ static int mysql_open_db(char *server, char *user, char *pass, char *db)
static int mysql_init(void)
{
/* have the opts parsed */
- config_parse_file("MYSQL", &table_ce);
+ config_parse_file("MYSQL", &port_ce);
- if (mysql_open_db(host_ce.u.string, user_ce.u.string,
+ if (mysql_open_db(host_ce.u.string, port_ce.u.value, user_ce.u.string,
pass_ce.u.string, db_ce.u.string)) {
ulogd_log(ULOGD_ERROR, "can't establish database connection\n");
return -1;