summaryrefslogtreecommitdiffstats
path: root/mod_log_sql_mysql.c
diff options
context:
space:
mode:
Diffstat (limited to 'mod_log_sql_mysql.c')
-rw-r--r--mod_log_sql_mysql.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/mod_log_sql_mysql.c b/mod_log_sql_mysql.c
index a3f8bbc..5a654f3 100644
--- a/mod_log_sql_mysql.c
+++ b/mod_log_sql_mysql.c
@@ -29,13 +29,13 @@
29#define MYSQL_ERROR(mysql) ((mysql)?(mysql_error(mysql)):"MySQL server has gone away") 29#define MYSQL_ERROR(mysql) ((mysql)?(mysql_error(mysql)):"MySQL server has gone away")
30 30
31/* Connect to the MYSQL database */ 31/* Connect to the MYSQL database */
32logsql_opendb_ret log_sql_mysql_connect(server_rec *s, logsql_dbconnection *db) 32static logsql_opendb_ret log_sql_mysql_connect(server_rec *s, logsql_dbconnection *db)
33{ 33{
34 const char *host = apr_table_get(db->parms,"host"); 34 const char *host = apr_table_get(db->parms,"hostname");
35 const char *user = apr_table_get(db->parms,"user"); 35 const char *user = apr_table_get(db->parms,"username");
36 const char *passwd = apr_table_get(db->parms,"passwd"); 36 const char *passwd = apr_table_get(db->parms,"password");
37 const char *database = apr_table_get(db->parms,"database"); 37 const char *database = apr_table_get(db->parms,"database");
38 const char *s_tcpport = apr_table_get(db->parms,"tcpport"); 38 const char *s_tcpport = apr_table_get(db->parms,"port");
39 unsigned int tcpport = (s_tcpport)?atoi(s_tcpport):3306; 39 unsigned int tcpport = (s_tcpport)?atoi(s_tcpport):3306;
40 const char *socketfile = apr_table_get(db->parms,"socketfile"); 40 const char *socketfile = apr_table_get(db->parms,"socketfile");
41 MYSQL *dblink = db->handle; 41 MYSQL *dblink = db->handle;
@@ -63,7 +63,7 @@ logsql_opendb_ret log_sql_mysql_connect(server_rec *s, logsql_dbconnection *db)
63} 63}
64 64
65/* Close the DB link */ 65/* Close the DB link */
66void log_sql_mysql_close(logsql_dbconnection *db) 66static void log_sql_mysql_close(logsql_dbconnection *db)
67{ 67{
68 mysql_close((MYSQL *)db->handle); 68 mysql_close((MYSQL *)db->handle);
69} 69}
@@ -71,7 +71,7 @@ void log_sql_mysql_close(logsql_dbconnection *db)
71/* Routine to escape the 'dangerous' characters that would otherwise 71/* Routine to escape the 'dangerous' characters that would otherwise
72 * corrupt the INSERT string: ', \, and " 72 * corrupt the INSERT string: ', \, and "
73 */ 73 */
74const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p, 74static const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p,
75 logsql_dbconnection *db) 75 logsql_dbconnection *db)
76{ 76{
77 if (!from_str) 77 if (!from_str)
@@ -110,7 +110,7 @@ const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p,
110} 110}
111 111
112/* Run a mysql insert query and return a categorized error or success */ 112/* Run a mysql insert query and return a categorized error or success */
113logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *db, 113static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *db,
114 const char *query) 114 const char *query)
115{ 115{
116 int retval; 116 int retval;
@@ -147,7 +147,7 @@ logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *db,
147} 147}
148 148
149/* Create table table_name of type table_type. */ 149/* Create table table_name of type table_type. */
150logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection *db, 150static logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection *db,
151 logsql_tabletype table_type, const char *table_name) 151 logsql_tabletype table_type, const char *table_name)
152{ 152{
153 int retval; 153 int retval;
@@ -231,3 +231,18 @@ logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection *db,
231 signal(SIGPIPE, handler); 231 signal(SIGPIPE, handler);
232 return LOGSQL_TABLE_SUCCESS; 232 return LOGSQL_TABLE_SUCCESS;
233} 233}
234
235static char *supported_drivers[] = {"mysql",NULL};
236static logsql_dbdriver mysql_driver = {
237 supported_drivers,
238 log_sql_mysql_connect, /* open DB connection */
239 log_sql_mysql_close, /* close DB connection */
240 log_sql_mysql_escape, /* escape query */
241 log_sql_mysql_query, /* insert query */
242 log_sql_mysql_create /* create table */
243};
244
245LOGSQL_REGISTER(mysql) {
246 log_sql_register_driver(p,&mysql_driver);
247 LOGSQL_REGISTER_RETURN;
248}