diff options
author | Edward Rudd | 2004-04-07 06:21:24 +0000 |
---|---|---|
committer | Edward Rudd | 2004-04-07 06:21:24 +0000 |
commit | 2d71c1472c64bc47348fc4c6337a2e903e2649b3 (patch) | |
tree | ebe00e37210aeb4727314a672b7bcbcb0daa3fdd /mod_log_sql_mysql.c | |
parent | 812bc70dae80637548a0ccfab649f8912a09faf5 (diff) |
Added registration function for database drivers
completely separated mysql driver
added optional server announce (LogSQLAnnouce On)
cleaned up internal names of Database parameters
added code to allow +/- of logged cookies,headers, and notes, as well as remhostignore, request allow and request ignore.
reorganized command_rec again
made bigger not about deprecated commands
updated documentation
Diffstat (limited to 'mod_log_sql_mysql.c')
-rw-r--r-- | mod_log_sql_mysql.c | 33 |
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 */ |
32 | logsql_opendb_ret log_sql_mysql_connect(server_rec *s, logsql_dbconnection *db) | 32 | static 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 */ |
66 | void log_sql_mysql_close(logsql_dbconnection *db) | 66 | static 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 | */ |
74 | const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p, | 74 | static 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 */ |
113 | logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *db, | 113 | static 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. */ |
150 | logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection *db, | 150 | static 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 | |||
235 | static char *supported_drivers[] = {"mysql",NULL}; | ||
236 | static 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 | |||
245 | LOGSQL_REGISTER(mysql) { | ||
246 | log_sql_register_driver(p,&mysql_driver); | ||
247 | LOGSQL_REGISTER_RETURN; | ||
248 | } | ||