summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Edward Rudd 2004-01-21 04:34:21 +0000
committerGravatar Edward Rudd 2004-01-21 04:34:21 +0000
commitb19a5851171395e196ed686977482d79d7140cfd (patch)
tree5e8edc605c5aca8cb95252fbb30ea008b40dd78f
parentf26e43417ed614aa5e6c328f1610f1fca4708e99 (diff)
fixed log_error function1.93
finished ssl split into separate module added item registration function. (for ssl sub-module) release 1.93
-rw-r--r--CHANGELOG5
-rw-r--r--Makefile.in3
-rw-r--r--apache20.h6
-rw-r--r--configure.ac2
-rw-r--r--mod_log_sql.c203
-rw-r--r--mod_log_sql.h4
-rw-r--r--mod_log_sql_ssl.c55
7 files changed, 162 insertions, 116 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 5b30bcb..eb3bafc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,4 @@
1$Id: CHANGELOG,v 1.7 2004/01/20 19:38:07 urkle Exp $ 1$Id: CHANGELOG,v 1.8 2004/01/21 04:34:21 urkle Exp $
2 2
3TODO: 3TODO:
4* Port connection portion to other DBMS? Genericize the module? Start with 4* Port connection portion to other DBMS? Genericize the module? Start with
@@ -18,6 +18,8 @@ TODO:
18 apache version specific code already split into separate files. 18 apache version specific code already split into separate files.
19* add document building to Makefile.in 19* add document building to Makefile.in
20* investigate thread safety issues (libmysqlclient_r) 20* investigate thread safety issues (libmysqlclient_r)
21 Add thread locks if using standard mysqlclient
22* rewrite main core logging function to optimize for speed.
21 23
22CHANGES: 24CHANGES:
231.93: 2004-01-20 251.93: 2004-01-20
@@ -29,6 +31,7 @@ CHANGES:
29 and assign defines as to which version was found. 31 and assign defines as to which version was found.
30* made install default to not activate module in configuration files. 32* made install default to not activate module in configuration files.
31 (use make activate) 33 (use make activate)
34* split SSL logging to separate module (still needs to be finished)
32 35
331.92: 2004-01-05 361.92: 2004-01-05
34* fixed compilation issue with mysql 4.x where mysql_error returns const char * 37* fixed compilation issue with mysql 4.x where mysql_error returns const char *
diff --git a/Makefile.in b/Makefile.in
index 5b1d1ec..ce99082 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -5,7 +5,8 @@ SUBDIRS = Documentation
5SOURCES = \ 5SOURCES = \
6 @PACKAGE_NAME@.c 6 @PACKAGE_NAME@.c
7 7
8HEADERS = functions.h \ 8HEADERS = mod_log_sql.h \
9 functions.h \
9 functions13.h \ 10 functions13.h \
10 functions20.h \ 11 functions20.h \
11 apache13.h \ 12 apache13.h \
diff --git a/apache20.h b/apache20.h
index 8a34643..1b54858 100644
--- a/apache20.h
+++ b/apache20.h
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/apache20.h,v 1.2 2004/01/20 19:38:07 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/apache20.h,v 1.3 2004/01/21 04:34:21 urkle Exp $ */
2#ifndef APACHE20_H 2#ifndef APACHE20_H
3#define APACHE20_H 3#define APACHE20_H
4 4
@@ -23,9 +23,11 @@
23static void log_error(char *file, int line, int level, const server_rec *s, const char *fmt, ...) __attribute__ ((format (printf, 5,6))); 23static void log_error(char *file, int line, int level, const server_rec *s, const char *fmt, ...) __attribute__ ((format (printf, 5,6)));
24static inline void log_error(char *file, int line, int level, const server_rec *s, const char *fmt, ...) 24static inline void log_error(char *file, int line, int level, const server_rec *s, const char *fmt, ...)
25{ 25{
26 static char buff[MAX_STRING_LEN];
26 va_list args; 27 va_list args;
27 va_start(args, fmt); 28 va_start(args, fmt);
28 ap_log_error(file,line,level,0,s,fmt,args); 29 apr_vsnprintf(buff,MAX_STRING_LEN, fmt,args);
30 ap_log_error(file,line,level,0,s,"%s",buff);
29 va_end(args); 31 va_end(args);
30} 32}
31 33
diff --git a/configure.ac b/configure.ac
index 63b71db..808d1fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
1dnl Required initializer 1dnl Required initializer
2AC_INIT(mod_log_sql, 1.92) 2AC_INIT(mod_log_sql, 1.93)
3AC_PREREQ(2.53) 3AC_PREREQ(2.53)
4AC_CONFIG_HEADERS(config.h) 4AC_CONFIG_HEADERS(config.h)
5 5
diff --git a/mod_log_sql.c b/mod_log_sql.c
index 498e717..abebd04 100644
--- a/mod_log_sql.c
+++ b/mod_log_sql.c
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.10 2004/01/20 20:36:41 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.11 2004/01/21 04:34:21 urkle Exp $ */
2/* --------* 2/* --------*
3 * DEFINES * 3 * DEFINES *
4 * --------*/ 4 * --------*/
@@ -116,27 +116,38 @@ typedef struct {
116static int safe_create_tables(logsql_state *cls, request_rec *r); 116static int safe_create_tables(logsql_state *cls, request_rec *r);
117 117
118typedef struct { 118typedef struct {
119 log_sql_item_func *func; /* its extraction function */ 119 char key; /* item letter character */
120 const char *sql_field_name; /* its column in SQL */ 120 log_sql_item_func *func; /* its extraction function */
121 int want_orig_default; /* if it requires the original request prior to internal redirection */ 121 const char *sql_field_name; /* its column in SQL */
122 int string_contents; /* if it returns a string */ 122 int want_orig_default; /* if it requires the original request prior to internal redirection */
123 int string_contents; /* if it returns a string */
123} log_sql_item; 124} log_sql_item;
124 125
125static apr_hash_t *log_sql_hash; 126static apr_array_header_t *log_sql_item_list;
126 127
127/* Registration Function for extract functions */ 128/* Registration Function for extract functions */
128LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char *key, 129LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char key,
129 log_sql_item_func *func, const char *sql_field_name, 130 log_sql_item_func *func, const char *sql_field_name,
130 int want_orig_default, int string_contents) 131 int want_orig_default, int string_contents)
131{ 132{
132 log_sql_item *item = apr_palloc(p, sizeof(log_sql_item)); 133 log_sql_item *item = apr_array_push(log_sql_item_list);
133 /*item->key = */ 134 item->key = key;
134 item->func = func; 135 item->func = func;
135 item->sql_field_name = sql_field_name; 136 item->sql_field_name = sql_field_name;
136 item->want_orig_default = want_orig_default; 137 item->want_orig_default = want_orig_default;
137 item->string_contents = string_contents; 138 item->string_contents = string_contents;
138 /* TODO: find apache 13 way of doing this */ 139}
139 apr_hash_set(log_sql_hash, key, APR_HASH_KEY_STRING, item); 140
141/* Search through item array */
142static inline log_sql_item *log_sql_get_item(char key)
143{
144 int itr;
145 for(itr=0; itr<log_sql_item_list->nelts; itr++) {
146 if (((log_sql_item *)log_sql_item_list->elts)[itr].key == key) {
147 return &((log_sql_item *)log_sql_item_list->elts)[itr];
148 }
149 }
150 return NULL;
140} 151}
141 152
142/* Include all the extract functions */ 153/* Include all the extract functions */
@@ -613,7 +624,7 @@ static const char *set_log_sql_tcp_port(cmd_parms *parms, void *dummy, const cha
613 * Apache-specific hooks into the module code * 624 * Apache-specific hooks into the module code *
614 * that are defined in the array 'mysql_lgog_module' (at EOF) * 625 * that are defined in the array 'mysql_lgog_module' (at EOF) *
615 *------------------------------------------------------------*/ 626 *------------------------------------------------------------*/
616 627/* Closing mysql link: child_exit(1.3), pool registration(2.0) */
617#if defined(WITH_APACHE20) 628#if defined(WITH_APACHE20)
618static apr_status_t log_sql_close_link(void *data) 629static apr_status_t log_sql_close_link(void *data)
619{ 630{
@@ -626,14 +637,8 @@ static void log_sql_child_exit(server_rec *s, apr_pool_t *p)
626 mysql_close(global_config.server_p); 637 mysql_close(global_config.server_p);
627} 638}
628#endif 639#endif
629/* 640
630 * This function is called during server initialisation when an heavy-weight 641/* Child Init */
631 * process (such as a child) is being initialised. As with the
632 * module-initialisation function, any information that needs to be recorded
633 * must be in static cells, since there's no configuration record.
634 *
635 * There is no return value.
636 */
637#if defined(WITH_APACHE20) 642#if defined(WITH_APACHE20)
638static void log_sql_child_init(apr_pool_t *p, server_rec *s) 643static void log_sql_child_init(apr_pool_t *p, server_rec *s)
639{ 644{
@@ -680,7 +685,7 @@ void *log_sql_initializer(server_rec *main_server, apr_pool_t *p)
680#if defined(WITH_APACHE20) 685#if defined(WITH_APACHE20)
681static int log_sql_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) 686static int log_sql_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
682#elif defined(WITH_APACHE13) 687#elif defined(WITH_APACHE13)
683static void log_sql_pre_config(server_rec *s, apr_pool_t *p) 688static void log_sql_module_init(server_rec *s, apr_pool_t *p)
684#endif 689#endif
685{ 690{
686 /* Initialize Global configuration */ 691 /* Initialize Global configuration */
@@ -688,33 +693,33 @@ static void log_sql_pre_config(server_rec *s, apr_pool_t *p)
688 global_config.socketfile = "/tmp/mysql.sock"; 693 global_config.socketfile = "/tmp/mysql.sock";
689 if (!global_config.tcpport) 694 if (!global_config.tcpport)
690 global_config.tcpport = 3306; 695 global_config.tcpport = 3306;
691 if (!log_sql_hash) 696 if (!log_sql_item_list)
692 log_sql_hash = apr_hash_make(p); 697 log_sql_item_list = apr_array_make(p,10,sizeof(log_sql_item));
693 698
694 /* Register handlers */ 699 /* Register handlers */
695 log_sql_register_item(p,"A", extract_agent, "agent", 1, 1); 700 log_sql_register_item(p,'A', extract_agent, "agent", 1, 1);
696 log_sql_register_item(p,"a", extract_request_args, "request_args", 1, 1); 701 log_sql_register_item(p,'a', extract_request_args, "request_args", 1, 1);
697 log_sql_register_item(p,"b", extract_bytes_sent, "bytes_sent", 0, 0); 702 log_sql_register_item(p,'b', extract_bytes_sent, "bytes_sent", 0, 0);
698 log_sql_register_item(p,"c", extract_cookie, "cookie", 0, 1); 703 log_sql_register_item(p,'c', extract_cookie, "cookie", 0, 1);
699 log_sql_register_item(p,"e", extract_env_var, "env_var", 0, 1); 704 log_sql_register_item(p,'e', extract_env_var, "env_var", 0, 1);
700 log_sql_register_item(p,"f", extract_request_file, "request_file", 0, 1); 705 log_sql_register_item(p,'f', extract_request_file, "request_file", 0, 1);
701 log_sql_register_item(p,"H", extract_request_protocol, "request_protocol", 0, 1); 706 log_sql_register_item(p,'H', extract_request_protocol, "request_protocol", 0, 1);
702 log_sql_register_item(p,"h", extract_remote_host, "remote_host", 0, 1); 707 log_sql_register_item(p,'h', extract_remote_host, "remote_host", 0, 1);
703 log_sql_register_item(p,"I", extract_unique_id, "id", 0, 1); 708 log_sql_register_item(p,'I', extract_unique_id, "id", 0, 1);
704 log_sql_register_item(p,"l", extract_remote_logname, "remote_logname", 0, 1); 709 log_sql_register_item(p,'l', extract_remote_logname, "remote_logname", 0, 1);
705 log_sql_register_item(p,"m", extract_request_method, "request_method", 0, 1); 710 log_sql_register_item(p,'m', extract_request_method, "request_method", 0, 1);
706 log_sql_register_item(p,"M", extract_machine_id, "machine_id", 0, 1); 711 log_sql_register_item(p,'M', extract_machine_id, "machine_id", 0, 1);
707 log_sql_register_item(p,"P", extract_child_pid, "child_pid", 0, 0); 712 log_sql_register_item(p,'P', extract_child_pid, "child_pid", 0, 0);
708 log_sql_register_item(p,"p", extract_server_port, "server_port", 0, 0); 713 log_sql_register_item(p,'p', extract_server_port, "server_port", 0, 0);
709 log_sql_register_item(p,"R", extract_referer, "referer", 1, 1); 714 log_sql_register_item(p,'R', extract_referer, "referer", 1, 1);
710 log_sql_register_item(p,"r", extract_request_line, "request_line", 1, 1); 715 log_sql_register_item(p,'r', extract_request_line, "request_line", 1, 1);
711 log_sql_register_item(p,"S", extract_request_timestamp, "time_stamp", 0, 0); 716 log_sql_register_item(p,'S', extract_request_timestamp, "time_stamp", 0, 0);
712 log_sql_register_item(p,"s", extract_status, "status", 1, 0); 717 log_sql_register_item(p,'s', extract_status, "status", 1, 0);
713 log_sql_register_item(p,"T", extract_request_duration, "request_duration", 1, 0); 718 log_sql_register_item(p,'T', extract_request_duration, "request_duration", 1, 0);
714 log_sql_register_item(p,"t", extract_request_time, "request_time", 0, 1); 719 log_sql_register_item(p,'t', extract_request_time, "request_time", 0, 1);
715 log_sql_register_item(p,"u", extract_remote_user, "remote_user", 0, 1); 720 log_sql_register_item(p,'u', extract_remote_user, "remote_user", 0, 1);
716 log_sql_register_item(p,"U", extract_request_uri, "request_uri", 1, 1); 721 log_sql_register_item(p,'U', extract_request_uri, "request_uri", 1, 1);
717 log_sql_register_item(p,"v", extract_virtual_host, "virtual_host", 0, 1); 722 log_sql_register_item(p,'v', extract_virtual_host, "virtual_host", 0, 1);
718 723
719#if defined(WITH_APACHE20) 724#if defined(WITH_APACHE20)
720 return OK; 725 return OK;
@@ -822,21 +827,23 @@ static int log_sql_transaction(request_rec *orig)
822 logsql_state *cls = ap_get_module_config(orig->server->module_config, &log_sql_module); 827 logsql_state *cls = ap_get_module_config(orig->server->module_config, &log_sql_module);
823 const char *access_query; 828 const char *access_query;
824 request_rec *r; 829 request_rec *r;
830 char *transfer_tablename = cls->transfer_table_name;
831 char *notes_tablename = cls->notes_table_name;
832 char *hout_tablename = cls->hout_table_name;
833 char *hin_tablename = cls->hin_table_name;
834 char *cookie_tablename = cls->cookie_table_name;
825 835
826 /* We handle mass virtual hosting differently. Dynamically determine the name 836 /* We handle mass virtual hosting differently. Dynamically determine the name
827 * of the table from the virtual server's name, and flag it for creation. 837 * of the table from the virtual server's name, and flag it for creation.
828 */ 838 */
829 if (global_config.massvirtual) { 839 if (global_config.massvirtual) {
840 /* TODO: Make these configurable? */
830 char *access_base = "access_"; 841 char *access_base = "access_";
831 char *notes_base = "notes_"; 842 char *notes_base = "notes_";
832 char *hout_base = "headout_"; 843 char *hout_base = "headout_";
833 char *hin_base = "headin_"; 844 char *hin_base = "headin_";
834 char *cookie_base = "cookies_"; 845 char *cookie_base = "cookies_";
835 char *a_tablename; 846
836 char *n_tablename;
837 char *i_tablename;
838 char *o_tablename;
839 char *c_tablename;
840 847
841 /* Determint the hostname and convert it to all lower-case; */ 848 /* Determint the hostname and convert it to all lower-case; */
842 char *servername = apr_pstrdup(orig->pool,(char *)ap_get_server_name(orig)); 849 char *servername = apr_pstrdup(orig->pool,(char *)ap_get_server_name(orig));
@@ -848,25 +855,21 @@ static int log_sql_transaction(request_rec *orig)
848 } 855 }
849 856
850 /* Find memory long enough to hold the table name + \0. */ 857 /* Find memory long enough to hold the table name + \0. */
851 a_tablename = apr_pstrcat(orig->pool, access_base, servername, NULL); 858 transfer_tablename = apr_pstrcat(orig->pool, access_base, servername, NULL);
852 n_tablename = apr_pstrcat(orig->pool, notes_base, servername, NULL); 859 notes_tablename = apr_pstrcat(orig->pool, notes_base, servername, NULL);
853 i_tablename = apr_pstrcat(orig->pool, hin_base, servername, NULL); 860 hin_tablename = apr_pstrcat(orig->pool, hin_base, servername, NULL);
854 o_tablename = apr_pstrcat(orig->pool, hout_base, servername, NULL); 861 hout_tablename = apr_pstrcat(orig->pool, hout_base, servername, NULL);
855 c_tablename = apr_pstrcat(orig->pool, cookie_base, servername, NULL); 862 cookie_tablename = apr_pstrcat(orig->pool, cookie_base, servername, NULL);
856 863
857 /* Tell this virtual server its transfer table name, and 864 /* Tell this virtual server its transfer table name, and
858 * turn on create_tables, which is implied by massvirtual. 865 * turn on create_tables, which is implied by massvirtual.
859 */ 866 */
860 cls->transfer_table_name = a_tablename; 867
861 cls->notes_table_name = n_tablename;
862 cls->hout_table_name = o_tablename;
863 cls->hin_table_name = i_tablename;
864 cls->cookie_table_name = c_tablename;
865 global_config.createtables = 1; 868 global_config.createtables = 1;
866 } 869 }
867 870
868 /* Do we have enough info to log? */ 871 /* Do we have enough info to log? */
869 if (!cls->transfer_table_name) { 872 if (!transfer_tablename) {
870 return DECLINED; 873 return DECLINED;
871 } else { 874 } else {
872 const char *thehost; 875 const char *thehost;
@@ -879,7 +882,8 @@ static int log_sql_transaction(request_rec *orig)
879 char *cookie_query = NULL; 882 char *cookie_query = NULL;
880 const char *unique_id; 883 const char *unique_id;
881 const char *formatted_item; 884 const char *formatted_item;
882 int i, j, length; 885 char *s;
886 int i;
883 int proceed; 887 int proceed;
884 888
885 for (r = orig; r->next; r = r->next) { 889 for (r = orig; r->next; r = r->next) {
@@ -925,42 +929,34 @@ static int log_sql_transaction(request_rec *orig)
925 } 929 }
926 } 930 }
927 931
928 length = strlen(cls->transfer_log_format);
929 932
930 /* Iterate through the format characters and set up the INSERT string according to 933 /* Iterate through the format characters and set up the INSERT string according to
931 * what the user has configured. */ 934 * what the user has configured. */
932 for (i = 0; i < length; i++) { 935 i = 0;
933 j = 0; 936 for (s = cls->transfer_log_format; *s != '\0' ; s++) {
934 937 log_sql_item *item = log_sql_get_item(*s);
935 while (log_sql_item_keys[j].ch) { 938
936 939 /* Yes, this key is one of the configured keys.
937 if (log_sql_item_keys[j].ch == cls->transfer_log_format[i]) { 940 * Call the key's function and put the returned value into 'formatted_item' */
938 /* Yes, this key is one of the configured keys. 941 formatted_item = item->func(item->want_orig_default ? orig : r, "");
939 * Call the key's function and put the returned value into 'formatted_item' */ 942
940 formatted_item = log_sql_item_keys[j].func(log_sql_item_keys[j].want_orig_default ? orig : r, ""); 943 /* Massage 'formatted_item' for proper SQL eligibility... */
941 944 if (!formatted_item) {
942 /* Massage 'formatted_item' for proper SQL eligibility... */ 945 formatted_item = "";
943 if (!formatted_item) { 946 } else if (formatted_item[0] == '-' && formatted_item[1] == '\0' && !item->string_contents) {
944 formatted_item = ""; 947 /* If apache tried to log a '-' character for a numeric field, convert that to a zero
945 } else if (formatted_item[0] == '-' && formatted_item[1] == '\0' && !log_sql_item_keys[j].string_contents) { 948 * because the database expects a numeral and will reject the '-' character. */
946 /* If apache tried to log a '-' character for a numeric field, convert that to a zero 949 formatted_item = "0";
947 * because the database expects a numeral and will reject the '-' character. */
948 formatted_item = "0";
949 }
950
951 /* Append the fieldname and value-to-insert to the appropriate strings, quoting stringvals with ' as appropriate */
952 fields = apr_pstrcat(r->pool, fields, (i > 0 ? "," : ""),
953 log_sql_item_keys[j].sql_field_name, NULL);
954
955 values = apr_pstrcat(r->pool, values, (i > 0 ? "," : ""),
956 (log_sql_item_keys[j].string_contents ? "'" : ""),
957 escape_query(formatted_item, r->pool),
958 (log_sql_item_keys[j].string_contents ? "'" : ""), NULL);
959 break;
960 }
961 j++;
962
963 } 950 }
951
952 /* Append the fieldname and value-to-insert to the appropriate strings, quoting stringvals with ' as appropriate */
953 fields = apr_pstrcat(r->pool, fields, (i ? "," : ""),
954 item->sql_field_name, NULL);
955 values = apr_pstrcat(r->pool, values, (i ? "," : ""),
956 (item->string_contents ? "'" : ""),
957 escape_query(formatted_item, r->pool),
958 (item->string_contents ? "'" : ""), NULL);
959 i = 1;
964 } 960 }
965 961
966 /* Work through the list of notes defined by LogSQLWhichNotes */ 962 /* Work through the list of notes defined by LogSQLWhichNotes */
@@ -986,7 +982,7 @@ static int log_sql_transaction(request_rec *orig)
986 } 982 }
987 if ( itemsets != "" ) { 983 if ( itemsets != "" ) {
988 note_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", 984 note_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s",
989 global_config.insertdelayed?"delayed":"", cls->notes_table_name, itemsets); 985 global_config.insertdelayed?"delayed":"", notes_tablename, itemsets);
990 986
991 #ifdef DEBUG 987 #ifdef DEBUG
992 log_error(APLOG_MARK,APLOG_DEBUG,orig->server,"mod_log_sql: note string: %s", note_query); 988 log_error(APLOG_MARK,APLOG_DEBUG,orig->server,"mod_log_sql: note string: %s", note_query);
@@ -1016,7 +1012,7 @@ static int log_sql_transaction(request_rec *orig)
1016 } 1012 }
1017 if ( itemsets != "" ) { 1013 if ( itemsets != "" ) {
1018 hout_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", 1014 hout_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s",
1019 global_config.insertdelayed?"delayed":"", cls->hout_table_name, itemsets); 1015 global_config.insertdelayed?"delayed":"", hout_tablename, itemsets);
1020 1016
1021 #ifdef DEBUG 1017 #ifdef DEBUG
1022 log_error(APLOG_MARK,APLOG_DEBUG,orig->server,"mod_log_sql: header_out string: %s", hout_query); 1018 log_error(APLOG_MARK,APLOG_DEBUG,orig->server,"mod_log_sql: header_out string: %s", hout_query);
@@ -1047,7 +1043,7 @@ static int log_sql_transaction(request_rec *orig)
1047 } 1043 }
1048 if ( itemsets != "" ) { 1044 if ( itemsets != "" ) {
1049 hin_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", 1045 hin_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s",
1050 global_config.insertdelayed?"delayed":"", cls->hin_table_name, itemsets); 1046 global_config.insertdelayed?"delayed":"", hin_tablename, itemsets);
1051 1047
1052 #ifdef DEBUG 1048 #ifdef DEBUG
1053 log_error(APLOG_MARK,APLOG_DEBUG,orig->server,"mod_log_sql: header_in string: %s", hin_query); 1049 log_error(APLOG_MARK,APLOG_DEBUG,orig->server,"mod_log_sql: header_in string: %s", hin_query);
@@ -1079,7 +1075,7 @@ static int log_sql_transaction(request_rec *orig)
1079 } 1075 }
1080 if ( itemsets != "" ) { 1076 if ( itemsets != "" ) {
1081 cookie_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s", 1077 cookie_query = apr_psprintf(r->pool, "insert %s into `%s` (id, item, val) values %s",
1082 global_config.insertdelayed?"delayed":"", cls->cookie_table_name, itemsets); 1078 global_config.insertdelayed?"delayed":"", cookie_tablename, itemsets);
1083 1079
1084 #ifdef DEBUG 1080 #ifdef DEBUG
1085 log_error(APLOG_MARK,APLOG_DEBUG,orig->server,"mod_log_sql: cookie string: %s", cookie_query); 1081 log_error(APLOG_MARK,APLOG_DEBUG,orig->server,"mod_log_sql: cookie string: %s", cookie_query);
@@ -1089,7 +1085,7 @@ static int log_sql_transaction(request_rec *orig)
1089 1085
1090 /* Set up the actual INSERT statement */ 1086 /* Set up the actual INSERT statement */
1091 access_query = apr_psprintf(r->pool, "insert %s into `%s` (%s) values (%s)", 1087 access_query = apr_psprintf(r->pool, "insert %s into `%s` (%s) values (%s)",
1092 global_config.insertdelayed?"delayed":"", cls->transfer_table_name, fields, values); 1088 global_config.insertdelayed?"delayed":"", transfer_tablename, fields, values);
1093 1089
1094 #ifdef DEBUG 1090 #ifdef DEBUG
1095 log_error(APLOG_MARK,APLOG_DEBUG,r->server,"mod_log_sql: access string: %s", access_query); 1091 log_error(APLOG_MARK,APLOG_DEBUG,r->server,"mod_log_sql: access string: %s", access_query);
@@ -1168,8 +1164,6 @@ static int log_sql_transaction(request_rec *orig)
1168} 1164}
1169 1165
1170 1166
1171
1172
1173/* Setup of the available httpd.conf configuration commands. 1167/* Setup of the available httpd.conf configuration commands.
1174 * Structure: command, function called, NULL, where available, how many arguments, verbose description 1168 * Structure: command, function called, NULL, where available, how many arguments, verbose description
1175 */ 1169 */
@@ -1274,8 +1268,8 @@ static const command_rec log_sql_cmds[] = {
1274 , 1268 ,
1275 {NULL} 1269 {NULL}
1276}; 1270};
1277#if defined(WITH_APACHE20)
1278/* The configuration array that sets up the hooks into the module. */ 1271/* The configuration array that sets up the hooks into the module. */
1272#if defined(WITH_APACHE20)
1279static void register_hooks(apr_pool_t *p) { 1273static void register_hooks(apr_pool_t *p) {
1280 ap_hook_pre_config(log_sql_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST); 1274 ap_hook_pre_config(log_sql_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
1281 ap_hook_child_init(log_sql_child_init, NULL, NULL, APR_HOOK_MIDDLE); 1275 ap_hook_child_init(log_sql_child_init, NULL, NULL, APR_HOOK_MIDDLE);
@@ -1293,10 +1287,9 @@ module AP_MODULE_DECLARE_DATA log_sql_module = {
1293 register_hooks /* register hooks */ 1287 register_hooks /* register hooks */
1294}; 1288};
1295#elif defined(WITH_APACHE13) 1289#elif defined(WITH_APACHE13)
1296/* The configuration array that sets up the hooks into the module. */
1297module log_sql_module = { 1290module log_sql_module = {
1298 STANDARD_MODULE_STUFF, 1291 STANDARD_MODULE_STUFF,
1299 log_sql_pre_config, /* module initializer */ 1292 log_sql_module_init, /* module initializer */
1300 NULL, /* create per-dir config */ 1293 NULL, /* create per-dir config */
1301 NULL, /* merge per-dir config */ 1294 NULL, /* merge per-dir config */
1302 log_sql_make_state, /* create server config */ 1295 log_sql_make_state, /* create server config */
diff --git a/mod_log_sql.h b/mod_log_sql.h
index 90f4c06..8093cee 100644
--- a/mod_log_sql.h
+++ b/mod_log_sql.h
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.h,v 1.1 2004/01/20 20:33:20 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.h,v 1.2 2004/01/21 04:34:21 urkle Exp $ */
2#ifndef MOD_LOG_SQL_H 2#ifndef MOD_LOG_SQL_H
3#define MOD_LOG_SQL_H 3#define MOD_LOG_SQL_H
4 4
@@ -26,7 +26,7 @@
26typedef const char *log_sql_item_func(request_rec *r, char *a); 26typedef const char *log_sql_item_func(request_rec *r, char *a);
27 27
28/* Registration Function for extract functions */ 28/* Registration Function for extract functions */
29LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char *key, 29LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char key,
30 log_sql_item_func *func, const char *sql_field_name, 30 log_sql_item_func *func, const char *sql_field_name,
31 int want_orig_default, int string_contents); 31 int want_orig_default, int string_contents);
32 32
diff --git a/mod_log_sql_ssl.c b/mod_log_sql_ssl.c
index c1901a0..92e0684 100644
--- a/mod_log_sql_ssl.c
+++ b/mod_log_sql_ssl.c
@@ -1,4 +1,4 @@
1/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.2 2004/01/20 20:33:20 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.3 2004/01/21 04:34:21 urkle Exp $ */
2/* mod_log_sql_ssl */ 2/* mod_log_sql_ssl */
3 3
4#if defined(WITH_APACHE20) 4#if defined(WITH_APACHE20)
@@ -93,8 +93,55 @@ static const char *extract_ssl_cipher(request_rec *r, char *a)
93 } 93 }
94} 94}
95 95
96#if defined(WITH_APACHE20)
97static int pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
98#elif defined(WITH_APACHE13)
99static void module_init(server_rec *s, apr_pool_t *p)
100#endif
101{
102 log_sql_register_item(p,'q', extract_ssl_keysize, "ssl_keysize", 0, 1);
103 log_sql_register_item(p,'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1);
104 log_sql_register_item(p,'z', extract_ssl_cipher, "ssl_cipher", 0, 1);
105}
96 106
107/* The configuration array that sets up the hooks into the module. */
108#if defined(WITH_APACHE20)
109static void register_hooks(apr_pool_t *p) {
110 ap_hook_pre_config(pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
111}
97 112
98 { 'q', extract_ssl_keysize, "ssl_keysize", 0, 1 }, 113module AP_MODULE_DECLARE_DATA log_sql_module = {
99 { 'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1 }, 114 STANDARD20_MODULE_STUFF,
100 { 'z', extract_ssl_cipher, "ssl_cipher", 0, 1 }, 115 NULL, /* create per-directory config structures */
116 NULL, /* merge per-directory config structures */
117 NULL, /* create per-server config structures */
118 NULL, /* merge per-server config structures */
119 NULL, /* command handlers */
120 register_hooks /* register hooks */
121};
122#elif defined(WITH_APACHE13)
123module log_sql_ssl_module = {
124 STANDARD_MODULE_STUFF,
125 module_init, /* module initializer */
126 NULL, /* create per-dir config */
127 NULL, /* merge per-dir config */
128 NULL, /* create server config */
129 NULL, /* merge server config */
130 log_sql_cmds, /* config directive table */
131 NULL, /* [9] content handlers */
132 NULL, /* [2] URI-to-filename translation */
133 NULL, /* [5] check/validate user_id */
134 NULL, /* [6] check authorization */
135 NULL, /* [4] check access by host */
136 NULL, /* [7] MIME type checker/setter */
137 NULL, /* [8] fixups */
138 log_sql_transaction, /* [10] logger */
139 NULL /* [3] header parser */
140#if MODULE_MAGIC_NUMBER >= 19970728 /* 1.3-dev or later support these additionals... */
141 ,log_sql_child_init, /* child process initializer */
142 log_sql_child_exit, /* process exit/cleanup */
143 NULL /* [1] post read-request */
144#endif
145
146};
147#endif