Attached the patch that uses macro based solution. APLOG_USE_MODULE is used only in case of HTTPD 2.3.

Thanks & Regards,
Vijayaguru

On Wednesday 02 March 2011 12:20 AM, Stefan Sperling wrote:
On Tue, Mar 01, 2011 at 11:08:22PM +0530, Kamesh Jayachandran wrote:
On the whole I preferred the macro solution.
Me to prefer the orignal macro based solution.
OK. Let's go for that, then.

[[[
Update log_access_verdict to make it work with HTTPD trunk as well as older
server versions with reference to [1]. The function is being called
with APLOG_MARK in few places. The macro APLOG_MARK expands to 2 arguments 
till HTTPD-2.2.x but 3 arguments in HTTPD-2.3-dev, which causes failure 
while compiling with HTTPD-2.3-dev. So we need to handle both the cases.

case 1-HTTPD 2.3:
----------------
1.APLOG_USE_MODULE is used to indirectly set APLOG_MODULE_INDEX and APLOG_MARK. 
2.The macros LOG_ARGS_SIGNATURE and LOG_ARGS_CASCADE are expanded as formal and
actual arguments to log_access_verdict with respect to APLOG_MARK which has
one additonal parameter module_index through which we can take the advantage of
per-module loglevel configuration introduced in HTTPD 2.3. 

case 2-pre-HTTPD 2.3:
--------------------
The macros LOG_ARGS_SIGNATURE and LOG_ARGS_CASCADE exapnd to FILE and LINE to
make the code compatible with older server versions.

* subversion/mod_authz_svn/mod_authz_svn.c
  (log_access_verdict): Pass the macro LOG_ARGS_SIGNATURE as formal parameter
   and use LOG_ARGS_CASCADE as actual parameter.
 
[1] 
http://httpd.apache.org/docs/trunk/developer/new_api_2_4.html#upgrading_logging

Patch by: Vijayaguru G <vijay{_AT_}collab.net>
Suggested by: kameshj
]]]
                        

Index: subversion/mod_authz_svn/mod_authz_svn.c
===================================================================
--- subversion/mod_authz_svn/mod_authz_svn.c    (revision 1075316)
+++ subversion/mod_authz_svn/mod_authz_svn.c    (working copy)
@@ -30,8 +30,10 @@
 #include <http_request.h>
 #include <http_protocol.h>
 #include <http_log.h>
+#include <http_config.h>
 #include <ap_config.h>
 #include <ap_provider.h>
+#include <ap_mmn.h>
 #include <apr_uri.h>
 #include <apr_lib.h>
 #include <mod_dav.h>
@@ -48,6 +50,10 @@
 
 extern module AP_MODULE_DECLARE_DATA authz_svn_module;
 
+#ifdef APLOG_USE_MODULE
+APLOG_USE_MODULE(authz_svn);
+#endif
+
 typedef struct authz_svn_config_rec {
   int authoritative;
   int anonymous;
@@ -519,12 +525,26 @@
   return OK;
 }
 
+/* The macros LOG_ARGS_SIGNATURE and LOG_ARGS_CASCADE are expanded as formal
+ * and actual parameters to log_access_verdict with respect to HTTPD version.
+ */
+#if AP_MODULE_MAGIC_AT_LEAST(20100606,0)
+#define LOG_ARGS_SIGNATURE const char *file, int line, int module_index
+#define LOG_ARGS_CASCADE file, line, module_index
+#else
+#define LOG_ARGS_SIGNATURE const char *file, int line
+#define LOG_ARGS_CASCADE file, line
+#endif
+
 /* Log a message indicating the access control decision made about a
- * request.  FILE and LINE should be supplied via the APLOG_MARK macro.
- * ALLOWED is boolean.  REPOS_PATH and DEST_REPOS_PATH are information
+ * request.  The macro LOG_ARGS_SIGNATURE expands to FILE, LINE and
+ * MODULE_INDEX in HTTPD 2.3 as APLOG_MARK macro has been changed for
+ * per-module loglevel configuration.  It expands to FILE and LINE 
+ * in older server versions.  ALLOWED is boolean.  
+ * REPOS_PATH and DEST_REPOS_PATH are information
  * about the request.  DEST_REPOS_PATH may be NULL. */
 static void
-log_access_verdict(const char *file, int line,
+log_access_verdict(LOG_ARGS_SIGNATURE,
                    const request_rec *r, int allowed,
                    const char *repos_path, const char *dest_repos_path)
 {
@@ -534,22 +554,22 @@
   if (r->user)
     {
       if (dest_repos_path)
-        ap_log_rerror(file, line, level, 0, r,
+        ap_log_rerror(LOG_ARGS_CASCADE, level, 0, r,
                       "Access %s: '%s' %s %s %s", verdict, r->user,
                       r->method, repos_path, dest_repos_path);
       else
-        ap_log_rerror(file, line, level, 0, r,
+        ap_log_rerror(LOG_ARGS_CASCADE, level, 0, r,
                       "Access %s: '%s' %s %s", verdict, r->user,
                       r->method, repos_path);
     }
   else
     {
       if (dest_repos_path)
-        ap_log_rerror(file, line, level, 0, r,
+        ap_log_rerror(LOG_ARGS_CASCADE, level, 0, r,
                       "Access %s: - %s %s %s", verdict,
                       r->method, repos_path, dest_repos_path);
       else
-        ap_log_rerror(file, line, level, 0, r,
+        ap_log_rerror(LOG_ARGS_CASCADE, level, 0, r,
                       "Access %s: - %s %s", verdict,
                       r->method, repos_path);
     }

Reply via email to