From 45220bcc856d6fa4b86e3f36eeaebd63d994f03f Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Thu, 05 Feb 2004 21:59:47 +0000 Subject: synchronized extract_* functions with latest apache 1.3 and 2.0. Added some more recent extract_* functions.. still need to assign format letters cleanup/audit of extract_* functions release 1.95 --- diff --git a/apache13.h b/apache13.h index 1c262d7..8181c43 100644 --- a/apache13.h +++ b/apache13.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.3 2004/01/22 05:26:56 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/apache13.h,v 1.4 2004/02/05 21:59:46 urkle Exp $ */ #ifndef APACHE13_H #define APACHE13_H @@ -41,6 +41,8 @@ /* Functions */ #define ap_get_remote_host(a,b,c,d) ap_get_remote_host(a,b,c) +#define apr_uri_unparse ap_unparse_uri_components + #define apr_pool_create(a,b) *(a) = ap_make_sub_pool(b) #define apr_palloc ap_palloc #define apr_pcalloc ap_pcalloc diff --git a/configure.ac b/configure.ac index 7e9ccb8..fb036ce 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl Required initializer -AC_INIT(mod_log_sql, 1.94) +AC_INIT(mod_log_sql, 1.95) AC_PREREQ(2.53) AC_CONFIG_HEADERS(config.h) diff --git a/functions.h b/functions.h index 60d08b5..917a1f9 100644 --- a/functions.h +++ b/functions.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvs/mod_log_sql/functions.h,v 1.1 2004/01/20 19:38:08 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/functions.h,v 1.2 2004/02/05 21:59:46 urkle Exp $ */ /* Begin the individual functions that, given a request r, * extract the needed information from it and return the * value to the calling entity. @@ -9,6 +9,20 @@ static const char *extract_remote_host(request_rec *r, char *a) return (char *) ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL); } +static const char *extract_remote_address(request_rec *r, char *a) __attribute__((unused)); + +static const char *extract_remote_address(request_rec *r, char *a) +{ + return r->connection->remote_ip; +} + +static const char *extract_local_address(request_rec *r, char *a) __attribute__((unused)); + +static const char *extract_local_address(request_rec *r, char *a) +{ + return r->connection->local_ip; +} + static const char *extract_remote_logname(request_rec *r, char *a) { return (char *) ap_get_remote_logname(r); @@ -29,19 +43,21 @@ static const char *extract_remote_user(request_rec *r, char *a) return rvalue; } -static const char *extract_request_method(request_rec *r, char *a) -{ - return r->method; -} - -static const char *extract_request_protocol(request_rec *r, char *a) -{ - return r->protocol; -} - static const char *extract_request_line(request_rec *r, char *a) { - return r->the_request; + /* Upddated to mod_log_config logic */ + /* NOTE: If the original request contained a password, we + * re-write the request line here to contain XXXXXX instead: + * (note the truncation before the protocol string for HTTP/0.9 requests) + * (note also that r->the_request contains the unmodified request) + */ + return (r->parsed_uri.password) + ? apr_pstrcat(r->pool, r->method, " ", + apr_uri_unparse(r->pool, + &r->parsed_uri, 0), + r->assbackwards ? NULL : " ", + r->protocol, NULL) + : r->the_request; } static const char *extract_request_file(request_rec *r, char *a) @@ -54,47 +70,31 @@ static const char *extract_request_uri(request_rec *r, char *a) return r->uri; } -static const char *extract_request_args(request_rec *r, char *a) -{ - return r->args; -} - -static const char *extract_status(request_rec *r, char *a) +static const char *extract_request_method(request_rec *r, char *a) { - if (r->status <= 0) { - return "-"; - } else { - return apr_psprintf(r->pool, "%d", r->status); - } + return r->method; } -static const char *extract_bytes_sent(request_rec *r, char *a) +static const char *extract_request_protocol(request_rec *r, char *a) { - if (!r->sent_bodyct || !r->bytes_sent) { - return "-"; - } else { - return apr_psprintf(r->pool, "%" APR_OFF_T_FMT, r->bytes_sent); - } + return r->protocol; } -/* -static const char *extract_header_in(request_rec *r, char *a) +static const char *extract_request_query(request_rec *r, char *a) { - return table_get(r->headers_in, a); + return (r->args) ? apr_pstrcat(r->pool, "?", + r->args, NULL) + : ""; } -static const char *extract_header_out(request_rec *r, char *a) +static const char *extract_status(request_rec *r, char *a) { - const char *cp = table_get(r->headers_out, a); - if (!strcasecmp(a, "Content-type") && r->content_type) { - cp = r->content_type; - } - if (cp) { - return cp; + if (r->status <= 0) { + return "-"; + } else { + return apr_psprintf(r->pool, "%d", r->status); } - return table_get(r->err_headers_out, a); } -*/ static const char *extract_virtual_host(request_rec *r, char *a) { @@ -115,6 +115,15 @@ static const char *extract_server_port(request_rec *r, char *a) r->server->port ? r->server->port : ap_default_port(r)); } +/* This respects the setting of UseCanonicalName so that + * the dynamic mass virtual hosting trick works better. + */ +static const char *log_server_name(request_rec *r, char *a) __attribute__((unused)); +static const char *log_server_name(request_rec *r, char *a) +{ + return ap_get_server_name(r); +} + static const char *extract_child_pid(request_rec *r, char *a) { if (*a == '\0' || !strcmp(a, "pid")) { @@ -158,83 +167,6 @@ static const char *extract_agent(request_rec *r, char *a) } } -static const char *extract_cookie(request_rec *r, char *a) -{ - const char *cookiestr; - char *cookieend; - char *isvalid; - char *cookiebuf; - - logsql_state *cls = ap_get_module_config(r->server->module_config, - &log_sql_module); - - if (cls->cookie_name != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG, r->server, - "watching for cookie '%s'", cls->cookie_name); - #endif - - /* Fetch out the cookie header */ - cookiestr = (char *)apr_table_get(r->headers_in, "cookie2"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG, r->server, - "Cookie2: [%s]", cookiestr); - #endif - /* Does the cookie string contain one with our name? */ - isvalid = strstr(cookiestr, cls->cookie_name); - if (isvalid != NULL) { - /* Move past the cookie name and equal sign */ - isvalid += strlen(cls->cookie_name) + 1; - /* Duplicate it into the pool */ - cookiebuf = apr_pstrdup(r->pool, isvalid); - /* Segregate just this cookie out of the string - * with a terminating nul at the first semicolon */ - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - - cookiestr = (char *)apr_table_get(r->headers_in, "cookie"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,r->server, - "Cookie: [%s]", cookiestr); - #endif - isvalid = strstr(cookiestr, cls->cookie_name); - if (isvalid != NULL) { - isvalid += strlen(cls->cookie_name) + 1; - cookiebuf = apr_pstrdup(r->pool, isvalid); - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - - cookiestr = apr_table_get(r->headers_out, "set-cookie"); - if (cookiestr != NULL) { - #ifdef DEBUG - log_error(APLOG_MARK,APLOG_DEBUG,r->server, - "Set-Cookie: [%s]", cookiestr); - #endif - isvalid = strstr(cookiestr, cls->cookie_name); - if (isvalid != NULL) { - isvalid += strlen(cls->cookie_name) + 1; - cookiebuf = apr_pstrdup(r->pool, isvalid); - cookieend = strchr(cookiebuf, ';'); - if (cookieend != NULL) - *cookieend = '\0'; - return cookiebuf; - } - } - } - - return "-"; -} - static const char *extract_specific_cookie(request_rec *r, char *a) { const char *cookiestr; @@ -309,18 +241,12 @@ static const char *extract_specific_cookie(request_rec *r, char *a) return "-"; } - -/* -static const char *extract_note(request_rec *r, char *a) +static const char *extract_cookie(request_rec *r, char *a) { - return apr_table_get(r->notes, a); - -} -*/ + logsql_state *cls = ap_get_module_config(r->server->module_config, + &log_sql_module); -static const char *extract_env_var(request_rec *r, char *a) -{ - return apr_table_get(r->subprocess_env, a); + return extract_specific_cookie(r, (char *)cls->cookie_name); } static const char *extract_unique_id(request_rec *r, char *a) diff --git a/functions13.h b/functions13.h index 1b85d0e..7fe8850 100644 --- a/functions13.h +++ b/functions13.h @@ -1,4 +1,17 @@ -/* $Header: /home/cvs/mod_log_sql/functions13.h,v 1.2 2004/01/20 19:38:08 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/functions13.h,v 1.3 2004/02/05 21:59:46 urkle Exp $ */ + +static const char *extract_bytes_sent(request_rec *r, char *a) +{ + if (!r->sent_bodyct) { + return "-"; + } + else { + long int bs; + ap_bgetopt(r->connection->client, BO_BYTECT, &bs); + return ap_psprintf(r->pool, "%ld", bs); + } +} + static const char *extract_request_time(request_rec *r, char *a) { int timz; @@ -24,16 +37,22 @@ static const char *extract_request_time(request_rec *r, char *a) static const char *extract_request_duration(request_rec *r, char *a) { - char duration[22]; /* Long enough for 2^64 */ - - ap_snprintf(duration, sizeof(duration), "%ld", (long) time(NULL) - r->request_time); - return ap_pstrdup(r->pool, duration); + return ap_psprintf(r->pool, "%ld", time(NULL) - r->request_time); } static const char *extract_request_timestamp(request_rec *r, char *a) { - char tstr[32]; - - ap_snprintf(tstr, 32, "%ld", (long) time(NULL)); - return ap_pstrdup(r->pool, tstr); + return ap_psprintf(r->pool, "%ld", (long) time(NULL)); +} +static const char *extract_connection_status(request_rec *r, char *a) __attribute__((unused)); +static const char *extract_connection_status(request_rec *r, char *a) +{ + if (r->connection->aborted) + return "X"; + + if ((r->connection->keepalive) && + ((r->server->keep_alive_max - r->connection->keepalives) > 0)) { + return "+"; + } + return "-"; } diff --git a/functions20.h b/functions20.h index c8701a2..31d9e4b 100644 --- a/functions20.h +++ b/functions20.h @@ -1,5 +1,14 @@ -/* $Header: /home/cvs/mod_log_sql/functions20.h,v 1.2 2004/01/20 19:38:08 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/functions20.h,v 1.3 2004/02/05 21:59:46 urkle Exp $ */ /* functions */ +static const char *extract_bytes_sent(request_rec *r, char *a) +{ + if (!r->sent_bodyct || !r->bytes_sent) { + return "-"; + } else { + return apr_psprintf(r->pool, "%" APR_OFF_T_FMT, r->bytes_sent); + } +} + static const char *extract_request_time_custom(request_rec *r, char *a, apr_time_exp_t *xt) { @@ -91,3 +100,17 @@ static const char *extract_request_timestamp(request_rec *r, char *a) { return apr_psprintf(r->pool, "%"APR_TIME_T_FMT, apr_time_sec(apr_time_now())); } + +static const char *extract_connection_status(request_rec *r, char *a) __attribute__((unused)); +static const char *extract_connection_status(request_rec *r, char *a) +{ + if (r->connection->aborted) + return "X"; + + if (r->connection->keepalive == AP_CONN_KEEPALIVE && + (!r->server->keep_alive_max || + (r->server->keep_alive_max - r->connection->keepalives) > 0)) { + return "+"; + } + return "-"; +} diff --git a/m4/mod_ssl.m4 b/m4/mod_ssl.m4 index a8c6103..c431bce 100644 --- a/m4/mod_ssl.m4 +++ b/m4/mod_ssl.m4 @@ -18,6 +18,7 @@ AC_ARG_WITH( db-inc, [AC_HELP_STRING([--with-db-inc=DIR],[Location of DB header files])], db_incdir="$withval", + db_incdir="/usr/include/db1" ) if test "x$ssl_val" = "xyes"; then diff --git a/mod_log_sql.c b/mod_log_sql.c index f4b8c16..7320f66 100644 --- a/mod_log_sql.c +++ b/mod_log_sql.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.13 2004/02/04 02:16:33 urkle Exp $ */ +/* $Header: /home/cvs/mod_log_sql/mod_log_sql.c,v 1.14 2004/02/05 21:59:46 urkle Exp $ */ /* --------* * DEFINES * * --------*/ @@ -717,12 +717,13 @@ static void log_sql_module_init(server_rec *s, apr_pool_t *p) if (!global_config.tcpport) global_config.tcpport = 3306; + /* TODO: Add local_address, remote_address, server_name, connection_status */ /* Register handlers */ log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1); - log_sql_register_item(s,p,'a', extract_request_args, "request_args", 1, 1); + log_sql_register_item(s,p,'a', extract_request_query, "request_args", 1, 1); log_sql_register_item(s,p,'b', extract_bytes_sent, "bytes_sent", 0, 0); log_sql_register_item(s,p,'c', extract_cookie, "cookie", 0, 1); - log_sql_register_item(s,p,'e', extract_env_var, "env_var", 0, 1); + /* TODO: Document */ log_sql_register_item(s,p,'f', extract_request_file, "request_file", 0, 1); log_sql_register_item(s,p,'H', extract_request_protocol, "request_protocol", 0, 1); log_sql_register_item(s,p,'h', extract_remote_host, "remote_host", 0, 1); diff --git a/mod_log_sql.prj b/mod_log_sql.prj index 9193940..ad294d5 100644 --- a/mod_log_sql.prj +++ b/mod_log_sql.prj @@ -52,7 +52,7 @@ anjuta.program.arguments= module.include.name=. module.include.type= -module.include.expanded=0 +module.include.expanded=1 module.include.files=\ apache13.h\ apache20.h\ @@ -98,7 +98,8 @@ module.doc.files=\ INSTALL\ Documentation/documentation.lyx\ CHANGELOG\ - LICENSE + LICENSE\ + AUTHORS module.po.expanded=0 module.po.files= -- cgit v0.9.2