apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: apr-util/src/hooks ap_hooks.c
Date Sat, 06 Jan 2001 20:10:56 GMT
rbb         01/01/06 12:10:56

  Modified:    src/hooks ap_hooks.c
  Added:       include  ap_generic_hook.h
  Removed:     include  ap_generic_hook.h
  Log:
  Move ap_generic_hook from the Apache include directory to the apr-util
  include directory.  The hooks themselves are implemented by apr-util,
  instead of Apache.  This removes a few warnings when compiled in
  maintainer-mode that have been bothering me.
  
  Revision  Changes    Path
  1.1                  apr-util/include/ap_generic_hook.h
  
  Index: ap_generic_hook.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef APACHE_AP_GENERIC_HOOK_H
  #define APACHE_AP_GENERIC_HOOK_H
  
  #include "apr_tables.h"
  
  /**
   * @package Apache hooks functions
   */
  
  #define APU_DECLARE_GENERIC_HOOK(link,ret,name,args) \
  typedef ret HOOK_##name args;
  
  APU_DECLARE(void) ap_hook_generic(const char *szName,void (*pfn)(void),
  				 const char * const *aszPre,
  				 const char * const *aszSucc,int nOrder);
  
  /**
   * Hook to a generic hook.
   *
   * @param name The name of the hook
   * @param pfn A pointer to a function that will be called
   * @param aszPre a NULL-terminated array of strings that name modules whose hooks should
precede this one
   * @param aszSucc a NULL-terminated array of strings that name modules whose hooks should
succeed this one
   * @param nOrder an integer determining order before honouring aszPre and aszSucc (for example
HOOK_MIDDLE)
   */
  
  #define AP_HOOK_GENERIC(name,pfn,aszPre,aszSucc,nOrder) \
      ((void (*)(const char *,HOOK_##name *,const char * const *, \
  	       const char * const *,int))&ap_hook_generic)(#name,pfn,aszPre, \
  							   aszSucc, nOrder)
  
  apr_array_header_t *ap_generic_hook_get(const char *szName);
  
  /**
   * Implement a generic hook that runs until one of the functions
   * returns something other than OK or DECLINE.
   *
   * @param ret The type of the return value of the hook
   * @param name The name of the hook
   * @param args_decl The declaration of the arguments for the hook
   * @param args_used The names for the arguments for the hook
   * @deffunc int AP_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(link, name, args_decl, args_use)
   */
  #define AP_IMPLEMENT_GENERIC_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
  APU_DECLARE(ret) ap_run_##name args_decl \
      { \
      LINK_##name *pHook; \
      int n; \
      ret rv; \
      apr_array_header_t *pHookArray=ap_generic_hook_get(#name); \
  \
      if(!pHookArray) \
  	return ok; \
  \
      pHook=(LINK_##name *)pHookArray->elts; \
      for(n=0 ; n < pHookArray->nelts ; ++n) \
  	{ \
  	rv=pHook[n].pFunc args_use; \
  \
  	if(rv != ok && rv != decline) \
  	    return rv; \
  	} \
      return ok; \
      }
  
  #endif /* def APACHE_AP_GENERIC_HOOK_H */
  
  
  
  1.27      +2 -1      apr-util/src/hooks/ap_hooks.c
  
  Index: ap_hooks.c
  ===================================================================
  RCS file: /home/cvs/apr-util/src/hooks/ap_hooks.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ap_hooks.c	2001/01/02 17:41:49	1.26
  +++ ap_hooks.c	2001/01/06 20:10:56	1.27
  @@ -61,6 +61,7 @@
   #include "apr.h"
   #include "ap_hooks.h"
   #include "apr_hash.h"
  +#include "ap_generic_hook.h"
   
   #if APR_HAVE_STRINGS_H
   #include <strings.h>
  @@ -284,7 +285,7 @@
   
   /* Generic hook support */
   
  -AP_DECLARE_EXTERNAL_HOOK(APU,void,_generic,(void))
  +APU_DECLARE_EXTERNAL_HOOK(APU,void,_generic,(void))
   
   APU_DECLARE(apr_array_header_t *) ap_generic_hook_get(const char *szName)
   {
  
  
  

Mime
View raw message