ben 99/07/31 02:31:28
Modified: mpm/src/include ap_hooks.h
mpm/src/main http_config.c http_connection.c http_protocol.c
http_request.c
Log:
Break out the hook implementations into three kinds, thus avoiding null macro
arguments. Gates made me do it!
Revision Changes Path
1.10 +55 -18 apache-2.0/mpm/src/include/ap_hooks.h
Index: ap_hooks.h
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/include/ap_hooks.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ap_hooks.h 1999/07/27 21:16:36 1.9
+++ ap_hooks.h 1999/07/31 09:31:17 1.10
@@ -21,7 +21,7 @@
#define HOOK_LINK(name) \
array_header *link_##name;
-#define
IMPLEMENT_HOOK_BASE(ret,rv_decl,sv,rv,name,args,args2,run_all,term1,term2,rv_final)
\
+#define IMPLEMENT_HOOK_BASE(name) \
void ap_hook_##name(HOOK_##name *pf,const char * const *aszPre, \
const char * const *aszSucc,int nOrder) \
{ \
@@ -39,37 +39,74 @@
pHook->szName=g_szCurrentHookName; \
if(g_bDebugHooks) \
ap_show_hook(#name,aszPre,aszSucc); \
- } \
-ret ap_run_##name args \
+ }
+
+/* RUN_ALL runs to the first one to return other than ok or decline
+ RUN_FIRST runs to the first one to return other than decline
+ VOID runs all
+*/
+
+#define IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \
+IMPLEMENT_HOOK_BASE(name) \
+void ap_run_##name args_decl \
+ { \
+ LINK_##name *pHook; \
+ int n; \
+\
+ if(!_hooks.link_##name) \
+ return; \
+\
+ pHook=(LINK_##name *)_hooks.link_##name->elts; \
+ for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \
+ pHook[n].pFunc args_use; \
+ }
+
+/* FIXME: note that this returns ok when nothing is run. I suspect it should
+ really return decline, but that breaks Apache currently - Ben
+*/
+#define IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
+IMPLEMENT_HOOK_BASE(name) \
+ret ap_run_##name args_decl \
{ \
LINK_##name *pHook; \
int n; \
- rv_decl \
+ ret rv; \
\
if(!_hooks.link_##name) \
- return rv_final; \
+ return ok; \
\
pHook=(LINK_##name *)_hooks.link_##name->elts; \
for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \
{ \
- sv pHook[n].pFunc args2; \
+ rv=pHook[n].pFunc args_use; \
\
- if(term1 && (!run_all || term2)) \
+ if(rv != ok && rv != decline) \
return rv; \
} \
- return rv_final; \
+ return ok; \
}
-/* RUN_ALL runs to the first one to return other than ok or decline
- RUN_FIRST runs to the first one to return other than ok
-*/
-#define RUN_ALL 1
-#define RUN_FIRST 0
-
-#define IMPLEMENT_HOOK(ret,name,args,args2,run_all,ok,decline) \
- IMPLEMENT_HOOK_BASE(ret,ret r_;,r_=,r_,name,args,args2,run_all,r_ !=
decline,r_ != ok,run_all ? ok : decline)
-#define IMPLEMENT_VOID_HOOK(name,args,args2) \
- IMPLEMENT_HOOK_BASE(void,,,,name,args,args2,RUN_ALL,1,0,)
+#define IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
+IMPLEMENT_HOOK_BASE(name) \
+ret ap_run_##name args_decl \
+ { \
+ LINK_##name *pHook; \
+ int n; \
+ ret rv; \
+\
+ if(!_hooks.link_##name) \
+ return decline; \
+\
+ pHook=(LINK_##name *)_hooks.link_##name->elts; \
+ for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \
+ { \
+ rv=pHook[n].pFunc args_use; \
+\
+ if(rv != decline) \
+ return rv; \
+ } \
+ return decline; \
+ }
/* Hook orderings */
#define HOOK_REALLY_FIRST (-10)
1.16 +2 -2 apache-2.0/mpm/src/main/http_config.c
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_config.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- http_config.c 1999/07/27 21:16:38 1.15
+++ http_config.c 1999/07/31 09:31:20 1.16
@@ -86,8 +86,8 @@
HOOK_LINK(pre_config)
)
-IMPLEMENT_HOOK(int,header_parser,(request_rec *r),(r),RUN_ALL,OK,DECLINED)
-IMPLEMENT_VOID_HOOK(pre_config,(pool *pconf,pool *plog,pool *ptemp),
+IMPLEMENT_HOOK_RUN_ALL(int,header_parser,(request_rec *r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_VOID(pre_config,(pool *pconf,pool *plog,pool *ptemp),
(pconf,plog,ptemp))
DEF_Explain
1.14 +2 -2 apache-2.0/mpm/src/main/http_connection.c
Index: http_connection.c
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_connection.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- http_connection.c 1999/07/27 21:16:38 1.13
+++ http_connection.c 1999/07/31 09:31:21 1.14
@@ -69,8 +69,8 @@
HOOK_LINK(process_connection)
);
-IMPLEMENT_VOID_HOOK(pre_connection,(conn_rec *c),(c))
-IMPLEMENT_HOOK(int,process_connection,(conn_rec
*c),(c),RUN_FIRST,OK,DECLINED)
+IMPLEMENT_HOOK_VOID(pre_connection,(conn_rec *c),(c))
+IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED)
/* TODO: re-implement the lingering close stuff */
#define NO_LINGCLOSE
1.14 +6 -5 apache-2.0/mpm/src/main/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_protocol.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- http_protocol.c 1999/07/25 14:24:01 1.13
+++ http_protocol.c 1999/07/31 09:31:22 1.14
@@ -2691,8 +2691,9 @@
ap_finalize_request_protocol(r);
}
-IMPLEMENT_HOOK(int,post_read_request,(request_rec
*r),(r),RUN_ALL,OK,DECLINED)
-IMPLEMENT_HOOK(int,log_transaction,(request_rec *r),(r),RUN_ALL,OK,DECLINED)
-IMPLEMENT_HOOK(const char *,http_method,(const request_rec *r),(r),RUN_FIRST,
- NULL,NULL)
-IMPLEMENT_HOOK(unsigned short,default_port,(const request_rec
*r),(r),RUN_FIRST,0,0)
+IMPLEMENT_HOOK_RUN_ALL(int,post_read_request,(request_rec
*r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_RUN_ALL(int,log_transaction,(request_rec *r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_RUN_FIRST(const char *,http_method,(const request_rec *r),(r),
+ NULL)
+IMPLEMENT_HOOK_RUN_FIRST(unsigned short,default_port,(const request_rec *r),
+ (r),0)
1.15 +4 -4 apache-2.0/mpm/src/main/http_request.c
Index: http_request.c
===================================================================
RCS file: /export/home/cvs/apache-2.0/mpm/src/main/http_request.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- http_request.c 1999/07/24 18:38:50 1.14
+++ http_request.c 1999/07/31 09:31:23 1.15
@@ -85,10 +85,10 @@
HOOK_LINK(type_checker)
)
-IMPLEMENT_HOOK(int,translate_name,(request_rec *r),(r),RUN_FIRST,OK,DECLINED)
-IMPLEMENT_HOOK(int,check_user_id,(request_rec *r),(r),RUN_FIRST,OK,DECLINED)
-IMPLEMENT_HOOK(int,fixups,(request_rec *r),(r),RUN_ALL,OK,DECLINED)
-IMPLEMENT_HOOK(int,type_checker,(request_rec *r),(r),RUN_FIRST,OK,DECLINED)
+IMPLEMENT_HOOK_RUN_FIRST(int,translate_name,(request_rec *r),(r),DECLINED)
+IMPLEMENT_HOOK_RUN_FIRST(int,check_user_id,(request_rec *r),(r),DECLINED)
+IMPLEMENT_HOOK_RUN_ALL(int,fixups,(request_rec *r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_RUN_FIRST(int,type_checker,(request_rec *r),(r),DECLINED)
/*****************************************************************
*