httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@lnd.com>
Subject RE: Filtered I/O ... again. :-)
Date Wed, 31 May 2000 16:09:22 GMT
> From: rbb@covalent.net [mailto:rbb@covalent.net]
> Sent: Wednesday, May 31, 2000 10:55 AM
> 
> Index: src/include/ap_hooks.h
> ===================================================================
> RCS file: /home/cvs/apache-2.0/src/include/ap_hooks.h,v
> retrieving revision 1.20
> diff -u -d -b -w -u -r1.20 ap_hooks.h
> --- src/include/ap_hooks.h	2000/05/27 22:53:46	1.20
> +++ src/include/ap_hooks.h	2000/05/31 15:07:18
> @@ -167,6 +167,116 @@
>      return decline; \
>      }
>  
> +/* Set of Hook definitions designed to put the list of 
> functions off a
> + * pointer pre-defined in the request_rec.
> + */
> +#define AP_DECLARE_RHOOK(ret,name,args) \
> +typedef ret HOOK_##name args; \

please API_EXPORT(void) this:

> +void ap_rhook_##name(HOOK_##name *pf,request_rec *r,const 
> char * const *aszPre,\
> +		    const char * const *aszSucc,int nOrder); \
> +ret ap_run_##name args; \
> +typedef struct _LINK_##name \
> +    { \
> +    HOOK_##name *pFunc; \
> +    const char *szName; \
> +    const char * const *aszPredecessors; \
> +    const char * const *aszSuccessors; \
> +    int nOrder; \
> +    } LINK_##name;
> +
> +#define AP_RHOOK_STRUCT(members) \
> +struct { members } _hooks;
> +
> +#define AP_RHOOK_LINK(name) \
> +    ap_array_header_t *link_##name;
> +
> +#define AP_IMPLEMENT_RHOOK_BASE(name) \

please API_EXPORT(void) this:

> +void ap_rhook_##name(HOOK_##name *pf,request_rec *r,const 
> char * const *aszPre,\
> +		    const char * const *aszSucc,int nOrder) \
> +    { \
> +    LINK_##name *pHook; \
> +    if(!r->_hooks.link_##name) \
> +	{ \
> +	
> r->_hooks.link_##name=ap_make_array(r->pool,1,sizeof(LINK_##name)); \
> +	ap_hook_sort_register(#name,&r->_hooks.link_##name); \
> +	} \
> +    pHook=ap_push_array(r->_hooks.link_##name); \
> +    pHook->pFunc=pf; \
> +    pHook->aszPredecessors=aszPre; \
> +    pHook->aszSuccessors=aszSucc; \
> +    pHook->nOrder=nOrder; \
> +    pHook->szName=ap_debug_module_name; \
> +    if(ap_debug_module_hooks) \
> +	ap_show_hook(#name,aszPre,aszSucc); \
> +    }
> +
> +/* 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 AP_IMPLEMENT_RHOOK_VOID(name,args_decl,args_use) \
> +AP_IMPLEMENT_RHOOK_BASE(name) \
> +void ap_run_##name args_decl \
> +    { \
> +    LINK_##name *pHook; \
> +    int n; \
> +\
> +    if(!r->_hooks.link_##name) \
> +	return; \
> +\
> +    pHook=(LINK_##name *)r->_hooks.link_##name->elts; \
> +    for(n=0 ; n < r->_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 
> AP_IMPLEMENT_RHOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
> +AP_IMPLEMENT_RHOOK_BASE(name) \

please API_EXPORT(ret) this:

> +ret ap_run_##name args_decl \
> +    { \
> +    LINK_##name *pHook; \
> +    int n; \
> +    ret rv; \
> +\
> +    if(!r->_hooks.link_##name) \
> +	return ok; \
> +\
> +    pHook=(LINK_##name *)r->_hooks.link_##name->elts; \
> +    for(n=0 ; n < r->_hooks.link_##name->nelts ; ++n) \
> +	{ \
> +	rv=pHook[n].pFunc args_use; \
> +\
> +	if(rv != ok && rv != decline) \
> +	    return rv; \
> +	} \
> +    return ok; \
> +    }
> +
> +#define 
> AP_IMPLEMENT_RHOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
> +AP_IMPLEMENT_RHOOK_BASE(name) \

please API_EXPORT(ret) this:

> +ret ap_run_##name args_decl \
> +    { \
> +    LINK_##name *pHook; \
> +    int n; \
> +    ret rv; \
> +\
> +    if(!r->_hooks.link_##name) \
> +	return decline; \
> +\
> +    pHook=(LINK_##name *)r->_hooks.link_##name->elts; \
> +    for(n=0 ; n < r->_hooks.link_##name->nelts ; ++n) \
> +	{ \
> +	rv=pHook[n].pFunc args_use; \
> +\
> +	if(rv != decline) \
> +	    return rv; \
> +	} \
> +    return decline; \
> +    }
> +
>       /* Hook orderings */
>  #define AP_HOOK_REALLY_FIRST	(-10)
>  #define AP_HOOK_FIRST		0

please don't do this to httpd.h...
can your changes be applied to http_protocol.h?:

> Index: src/include/httpd.h
> ===================================================================
> RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v
> retrieving revision 1.49
> diff -u -d -b -w -u -r1.49 httpd.h
> --- src/include/httpd.h	2000/05/28 17:52:19	1.49
> +++ src/include/httpd.h	2000/05/31 15:07:18
> @@ -81,6 +81,7 @@
>  #include "apr_network_io.h"
>  #include "buff.h"
>  #include "ap_mmn.h"
> +#include "ap_hooks.h"
>  
>  #ifdef HAVE_NETINET_IN_H
>  #include <netinet/in.h>
> @@ -606,6 +607,8 @@
>      const char *short_name;
>  };
>  
> +AP_DECLARE_RHOOK(void, filter, (request_rec *r, char *str, int len));
> +
>  struct request_rec {
>  
>      ap_pool_t *pool;
> @@ -622,6 +625,10 @@
>      request_rec *main;		/* If this is a 
> sub_request (see request.h) 
>  				 * pointer back to the main request.
>  				 */
> +
> +    AP_RHOOK_STRUCT (
> +        AP_RHOOK_LINK(filter)   /* per-request filter I/O hook. */
> +    );
>  
>      /* Info about the request itself... we begin with stuff that only
>       * protocol.c should ever touch...

Other than that (at first blush) it looks good!

Bill

Mime
View raw message