summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorEdward Rudd <urkle@outoforder.cc>2004-01-20 20:33:20 (GMT)
committer Edward Rudd <urkle@outoforder.cc>2004-01-20 20:33:20 (GMT)
commita5d838fab50df5d39396470b2bc9bf25e81cad53 (patch)
tree01968c890dc1c74ec00dd650646a3adf65b4c3e8
parentccd1b379bfc208c34ad61fc42cac4a797af6d153 (diff)
Added item registration function and added functions to new system header mod_log_sql.h
Registered core item functions in pre_config
-rw-r--r--Makefile.in22
-rw-r--r--m4/apache.m46
-rw-r--r--mod_log_sql.c88
-rw-r--r--mod_log_sql.h33
-rw-r--r--mod_log_sql.prj8
-rw-r--r--mod_log_sql_ssl.c6
6 files changed, 105 insertions, 58 deletions
diff --git a/Makefile.in b/Makefile.in
index 27ba01f..5b1d1ec 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -5,7 +5,11 @@ SUBDIRS = Documentation
5SOURCES = \ 5SOURCES = \
6 @PACKAGE_NAME@.c 6 @PACKAGE_NAME@.c
7 7
8HEADERS = 8HEADERS = functions.h \
9 functions13.h \
10 functions20.h \
11 apache13.h \
12 apache20.h
9 13
10CFLAGS = -Wc,-Wall -Wc,-Werror -Wc,-fno-strict-aliasing 14CFLAGS = -Wc,-Wall -Wc,-Werror -Wc,-fno-strict-aliasing
11 15
@@ -15,7 +19,7 @@ LDADD = @MYSQL_LDFLAGS@ @MYSQL_LIBS@
15 19
16EXTRA_DIST = INSTALL LICENSE CHANGELOG make_combined_log.pl 20EXTRA_DIST = INSTALL LICENSE CHANGELOG make_combined_log.pl
17 21
18TARGET = @APACHE_OUTPUT_NAME@ 22TARGET = @PACKAGE_NAME@@APXS_EXTENSION@
19 23
20#Don't modify anything below here 24#Don't modify anything below here
21 25
@@ -59,7 +63,7 @@ all-subdirs install-subdirs activate-subdirs clean-subdirs distclean-subdirs:
59 fi; \ 63 fi; \
60 done; 64 done;
61 65
62$(TARGET): 66$(TARGET): $(SOURCES) $(HEADERS)
63 @@APXS_BIN@ -c -o $(TARGET) $(INCLUDES) @MOD_SSL_CFLAGS@ $(CFLAGS) \ 67 @@APXS_BIN@ -c -o $(TARGET) $(INCLUDES) @MOD_SSL_CFLAGS@ $(CFLAGS) \
64 $(LDADD) @DEFS@ @APACHE_DEFS@ $(SOURCES) 68 $(LDADD) @DEFS@ @APACHE_DEFS@ $(SOURCES)
65 69
@@ -74,7 +78,7 @@ activate: activate-subdirs
74 @@APXS_BIN@ -i -a $(TARGET) 78 @@APXS_BIN@ -i -a $(TARGET)
75 79
76clean: clean-subdirs 80clean: clean-subdirs
77 $(RM) $(OBJ) $(SLO) $(LO) $(TARGET) .deps 81 $(RM) $(OBJ) $(SLO) $(LO) $(TARGET)
78 $(RM) -r .libs 82 $(RM) -r .libs
79 83
80distclean: clean distclean-subdirs 84distclean: clean distclean-subdirs
@@ -110,16 +114,6 @@ local-dist: $(DISTFILES)
110 @mkdir -p $(DESTDIR); \ 114 @mkdir -p $(DESTDIR); \
111 cp -dp --parents $(DISTFILES) $(DESTDIR); 115 cp -dp --parents $(DISTFILES) $(DESTDIR);
112 116
113$(builddir)/.deps: depend
114
115depend: $(SOURCES) $(HEADERS)
116 if test -n "`ls $(srcdir)/*.c 2> /dev/null`"; then \
117 $(CC) -MM -I@APACHE_INCDIR@ @MOD_SSL_CFLAGS@ $(INCLUDES) @DEFS@ \
118 @APACHE_DEFS@ $(srcdir)/*.c > $(builddir)/.deps || true; \
119 fi
120
121include $(builddir)/.deps
122
123.PHONY: include all-subdirs activate-subdirs install-subdirs \ 117.PHONY: include all-subdirs activate-subdirs install-subdirs \
124 clean-subdirs distclean-subdirs dist 118 clean-subdirs distclean-subdirs dist
125 119
diff --git a/m4/apache.m4 b/m4/apache.m4
index 93319e3..a72343c 100644
--- a/m4/apache.m4
+++ b/m4/apache.m4
@@ -139,7 +139,7 @@ AC_ARG_ENABLE(
139 AC_MSG_RESULT(yes) 139 AC_MSG_RESULT(yes)
140 AC_DEFINE(WITH_APACHE20,1,[Define to 1 if we are compiling with Apache 2.0.x]) 140 AC_DEFINE(WITH_APACHE20,1,[Define to 1 if we are compiling with Apache 2.0.x])
141 APACHE_VERSION="20" 141 APACHE_VERSION="20"
142 APACHE_OUTPUT_NAME=$PACKAGE_NAME.la 142 APXS_EXTENSION=.la
143 APACHE_DEFS="-DWITH_APACHE20" 143 APACHE_DEFS="-DWITH_APACHE20"
144 ifelse([$4], , , $4), 144 ifelse([$4], , , $4),
145 AC_MSG_RESULT(no) 145 AC_MSG_RESULT(no)
@@ -154,7 +154,7 @@ AC_ARG_ENABLE(
154 AC_MSG_RESULT(yes) 154 AC_MSG_RESULT(yes)
155 AC_DEFINE(WITH_APACHE13,1,[Define to 1 if we are compiling with Apache 1.3.x]) 155 AC_DEFINE(WITH_APACHE13,1,[Define to 1 if we are compiling with Apache 1.3.x])
156 APACHE_VERSION="13" 156 APACHE_VERSION="13"
157 APACHE_OUTPUT_NAME=$PACKAGE_NAME.so 157 APXS_EXTENSION=.so
158 APACHE_DEFS="-DWITH_APACHE13" 158 APACHE_DEFS="-DWITH_APACHE13"
159 ifelse([$3], , , $3), 159 ifelse([$3], , , $3),
160 AC_MSG_RESULT(no) 160 AC_MSG_RESULT(no)
@@ -167,6 +167,6 @@ AC_ARG_ENABLE(
167 AC_SUBST(APACHE_INCDIR) 167 AC_SUBST(APACHE_INCDIR)
168 AC_SUBST(APACHE_MODDIR) 168 AC_SUBST(APACHE_MODDIR)
169 AC_SUBST(APACHE_VERSION) 169 AC_SUBST(APACHE_VERSION)
170 AC_SUBST(APACHE_OUTPUT_NAME) 170 AC_SUBST(APXS_EXTENSION)
171 fi 171 fi
172]) 172])
diff --git a/mod_log_sql.c b/mod_log_sql.c
index 1ce4a44..95c8c62 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.8 2004/01/20 19:38:08 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.9 2004/01/20 20:33:20 urkle Exp $ */
2/* --------* 2/* --------*
3 * DEFINES * 3 * DEFINES *
4 * --------*/ 4 * --------*/
@@ -43,6 +43,7 @@
43#include <limits.h> 43#include <limits.h>
44#endif 44#endif
45 45
46#include "mod_log_sql.h"
46 47
47/* Configuratino Defaults */ 48/* Configuratino Defaults */
48#define DEFAULT_TRANSFER_LOG_FMT "AbHhmRSsTUuv" 49#define DEFAULT_TRANSFER_LOG_FMT "AbHhmRSsTUuv"
@@ -83,8 +84,6 @@ typedef struct {
83 84
84static global_config_t global_config; 85static global_config_t global_config;
85 86
86typedef const char *(*item_key_func) (request_rec *, char *);
87
88/* But the contents of this structure will vary by virtual server. 87/* But the contents of this structure will vary by virtual server.
89 * This permits each virtual server to vary its configuration slightly 88 * This permits each virtual server to vary its configuration slightly
90 * for per-server customization. 89 * for per-server customization.
@@ -116,6 +115,30 @@ typedef struct {
116 115
117static int safe_create_tables(logsql_state *cls, request_rec *r); 116static int safe_create_tables(logsql_state *cls, request_rec *r);
118 117
118typedef struct {
119 log_sql_item_func *func; /* its extraction function */
120 const char *sql_field_name; /* its column in SQL */
121 int want_orig_default; /* if it requires the original request prior to internal redirection */
122 int string_contents; /* if it returns a string */
123} log_sql_item;
124
125apr_hash_t *log_sql_hash;
126
127/* Registration Function for extract functions */
128LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char *key,
129 log_sql_item_func *func, const char *sql_field_name,
130 int want_orig_default, int string_contents)
131{
132 log_sql_item *item = apr_palloc(p, sizeof(log_sql_item));
133 /*item->key = */
134 item->func = func;
135 item->sql_field_name = sql_field_name;
136 item->want_orig_default = want_orig_default;
137 item->string_contents = string_contents;
138 /* TODO: find apache 13 way of doing this */
139 apr_hash_set(log_sql_hash, key, APR_HASH_KEY_STRING, item);
140}
141
119/* Include all the extract functions */ 142/* Include all the extract functions */
120#include "functions.h" 143#include "functions.h"
121#if defined(WITH_APACHE13) 144#if defined(WITH_APACHE13)
@@ -124,40 +147,6 @@ static int safe_create_tables(logsql_state *cls, request_rec *r);
124# include "functions20.h" 147# include "functions20.h"
125#endif 148#endif
126 149
127struct log_sql_item_list {
128 char ch; /* its letter code */
129 item_key_func func; /* its extraction function */
130 const char *sql_field_name; /* its column in SQL */
131 int want_orig_default; /* if it requires the original request prior to internal redirection */
132 int string_contents; /* if it returns a string */
133 } static log_sql_item_keys[] = {
134
135 { 'A', extract_agent, "agent", 1, 1 },
136 { 'a', extract_request_args, "request_args", 1, 1 },
137 { 'b', extract_bytes_sent, "bytes_sent", 0, 0 },
138 { 'c', extract_cookie, "cookie", 0, 1 },
139 { 'e', extract_env_var, "env_var", 0, 1 },
140 { 'f', extract_request_file, "request_file", 0, 1 },
141 { 'H', extract_request_protocol, "request_protocol", 0, 1 },
142 { 'h', extract_remote_host, "remote_host", 0, 1 },
143 { 'I', extract_unique_id, "id", 0, 1 },
144 { 'l', extract_remote_logname, "remote_logname", 0, 1 },
145 { 'm', extract_request_method, "request_method", 0, 1 },
146 { 'M', extract_machine_id, "machine_id", 0, 1 },
147 { 'P', extract_child_pid, "child_pid", 0, 0 },
148 { 'p', extract_server_port, "server_port", 0, 0 },
149 { 'R', extract_referer, "referer", 1, 1 },
150 { 'r', extract_request_line, "request_line", 1, 1 },
151 { 'S', extract_request_timestamp, "time_stamp", 0, 0 },
152 { 's', extract_status, "status", 1, 0 },
153 { 'T', extract_request_duration, "request_duration", 1, 0 },
154 { 't', extract_request_time, "request_time", 0, 1 },
155 { 'u', extract_remote_user, "remote_user", 0, 1 },
156 { 'U', extract_request_uri, "request_uri", 1, 1 },
157 { 'v', extract_virtual_host, "virtual_host", 0, 1 },
158 {'\0'}
159};
160
161/* Routine to escape the 'dangerous' characters that would otherwise 150/* Routine to escape the 'dangerous' characters that would otherwise
162 * corrupt the INSERT string: ', \, and " 151 * corrupt the INSERT string: ', \, and "
163 */ 152 */
@@ -700,6 +689,31 @@ static void log_sql_pre_config(server_rec *s, apr_pool_t *p)
700 if (!global_config.tcpport) 689 if (!global_config.tcpport)
701 global_config.tcpport = 3306; 690 global_config.tcpport = 3306;
702 691
692 /* Register handlers */
693 log_sql_register_item(p,"A", extract_agent, "agent", 1, 1);
694 log_sql_register_item(p,"a", extract_request_args, "request_args", 1, 1);
695 log_sql_register_item(p,"b", extract_bytes_sent, "bytes_sent", 0, 0);
696 log_sql_register_item(p,"c", extract_cookie, "cookie", 0, 1);
697 log_sql_register_item(p,"e", extract_env_var, "env_var", 0, 1);
698 log_sql_register_item(p,"f", extract_request_file, "request_file", 0, 1);
699 log_sql_register_item(p,"H", extract_request_protocol, "request_protocol", 0, 1);
700 log_sql_register_item(p,"h", extract_remote_host, "remote_host", 0, 1);
701 log_sql_register_item(p,"I", extract_unique_id, "id", 0, 1);
702 log_sql_register_item(p,"l", extract_remote_logname, "remote_logname", 0, 1);
703 log_sql_register_item(p,"m", extract_request_method, "request_method", 0, 1);
704 log_sql_register_item(p,"M", extract_machine_id, "machine_id", 0, 1);
705 log_sql_register_item(p,"P", extract_child_pid, "child_pid", 0, 0);
706 log_sql_register_item(p,"p", extract_server_port, "server_port", 0, 0);
707 log_sql_register_item(p,"R", extract_referer, "referer", 1, 1);
708 log_sql_register_item(p,"r", extract_request_line, "request_line", 1, 1);
709 log_sql_register_item(p,"S", extract_request_timestamp, "time_stamp", 0, 0);
710 log_sql_register_item(p,"s", extract_status, "status", 1, 0);
711 log_sql_register_item(p,"T", extract_request_duration, "request_duration", 1, 0);
712 log_sql_register_item(p,"t", extract_request_time, "request_time", 0, 1);
713 log_sql_register_item(p,"u", extract_remote_user, "remote_user", 0, 1);
714 log_sql_register_item(p,"U", extract_request_uri, "request_uri", 1, 1);
715 log_sql_register_item(p,"v", extract_virtual_host, "virtual_host", 0, 1);
716
703#if defined(WITH_APACHE20) 717#if defined(WITH_APACHE20)
704 return OK; 718 return OK;
705#endif 719#endif
diff --git a/mod_log_sql.h b/mod_log_sql.h
new file mode 100644
index 0000000..90f4c06
--- /dev/null
+++ b/mod_log_sql.h
@@ -0,0 +1,33 @@
1/* $Header: /home/cvs/mod_log_sql/mod_log_sql.h,v 1.1 2004/01/20 20:33:20 urkle Exp $ */
2#ifndef MOD_LOG_SQL_H
3#define MOD_LOG_SQL_H
4
5/* Create a set of LOGSQL_DECLARE(type), LOGSQL_DECLARE_NONSTD(type) and
6 * LOGSQL_DECLARE_DATA with appropriate export and import tags for the platform
7 */
8#if !defined(WIN32)
9#define LOGSQL_DECLARE(type) type
10#define LOGSQL_DECLARE_NONSTD(type) type
11#define LOGSQL_DECLARE_DATA
12#elif defined(LOGSQL_DECLARE_STATIC)
13#define LOGSQL_DECLARE(type) type __stdcall
14#define LOGSQL_DECLARE_NONSTD(type) type
15#define LOGSQL_DECLARE_DATA
16#elif defined(LOGSQL_DECLARE_EXPORT)
17#define LOGSQL_DECLARE(type) __declspec(dllexport) type __stdcall
18#define LOGSQL_DECLARE_NONSTD(type) __declspec(dllexport) type
19#define LOGSQL_DECLARE_DATA __declspec(dllexport)
20#else
21#define LOGSQL_DECLARE(type) __declspec(dllimport) type __stdcall
22#define LOGSQL_DECLARE_NONSTD(type) __declspec(dllimport) type
23#define LOGSQL_DECLARE_DATA __declspec(dllimport)
24#endif
25
26typedef const char *log_sql_item_func(request_rec *r, char *a);
27
28/* Registration Function for extract functions */
29LOGSQL_DECLARE(void) log_sql_register_item(apr_pool_t *p, char *key,
30 log_sql_item_func *func, const char *sql_field_name,
31 int want_orig_default, int string_contents);
32
33#endif /* MOD_LOG_SQL_H */
diff --git a/mod_log_sql.prj b/mod_log_sql.prj
index 7fa3b1b..571d182 100644
--- a/mod_log_sql.prj
+++ b/mod_log_sql.prj
@@ -53,7 +53,13 @@ anjuta.program.arguments=
53module.include.name=. 53module.include.name=.
54module.include.type= 54module.include.type=
55module.include.expanded=0 55module.include.expanded=0
56module.include.files= 56module.include.files=\
57 apache13.h\
58 apache20.h\
59 functions.h\
60 functions13.h\
61 functions20.h\
62 mod_log_sql.h
57 63
58module.source.name=. 64module.source.name=.
59module.source.type= 65module.source.type=
diff --git a/mod_log_sql_ssl.c b/mod_log_sql_ssl.c
index 3346d2f..c1901a0 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.1 2004/01/20 19:38:08 urkle Exp $ */ 1/* $Header: /home/cvs/mod_log_sql/mod_log_sql_ssl.c,v 1.2 2004/01/20 20:33:20 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,8 @@ static const char *extract_ssl_cipher(request_rec *r, char *a)
93 } 93 }
94} 94}
95 95
96#ifdef WANT_SSL_LOGGING 96
97
97 { 'q', extract_ssl_keysize, "ssl_keysize", 0, 1 }, 98 { 'q', extract_ssl_keysize, "ssl_keysize", 0, 1 },
98 { 'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1 }, 99 { 'Q', extract_ssl_maxkeysize, "ssl_maxkeysize", 0, 1 },
99 { 'z', extract_ssl_cipher, "ssl_cipher", 0, 1 }, 100 { 'z', extract_ssl_cipher, "ssl_cipher", 0, 1 },
100#endif