You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by fa...@locus.apache.org on 2000/05/11 22:25:49 UTC

cvs commit: apache-2.0/src/modules/example Makefile.in config.m4 .cvsignore README mod_example.c

fanf        00/05/11 13:25:48

  Modified:    src      CHANGES
               src/modules/example .cvsignore README mod_example.c
  Added:       src/modules/example Makefile.in config.m4
  Log:
  Add mod_example to the build system.
  I also fixed a few bogosities in mod_example itself, mostly improved
  ordering of the code; I also fixed the long-standing numbering mistake
  for the order of the request processing stages, and added the hook
  registering function to the module record.
  
  Revision  Changes    Path
  1.109     +3 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- CHANGES	2000/05/11 20:21:47	1.108
  +++ CHANGES	2000/05/11 20:25:38	1.109
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0a4
   
  +  *) Add mod_example to the build system.
  +     [Tony Finch]
  +
     *) APR: Add ap_xlate_conv_byte() to convert one char between single-
        byte character sets. [Jeff Trawick]
   
  
  
  
  1.2       +7 -0      apache-2.0/src/modules/example/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/example/.cvsignore,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- .cvsignore	1999/08/24 06:55:07	1.1
  +++ .cvsignore	2000/05/11 20:25:44	1.2
  @@ -1,3 +1,10 @@
  +.deps
  +.libs
  +*.la
  +modules.mk
   Makefile
   *.lo
  +*.slo
   *.so
  +*.dll
  +*.def
  
  
  
  1.2       +6 -18     apache-2.0/src/modules/example/README
  
  Index: README
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/example/README,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- README	1999/08/24 06:55:08	1.1
  +++ README	2000/05/11 20:25:45	1.2
  @@ -1,5 +1,5 @@
  -README for Apache 1.2 Example Module
  -[April, 1997]
  +README for Apache 2.0 Example Module
  +[April, 1997, updated May 2000]
   
   The files in the src/modules/example directory under the Apache
   distribution directory tree are provided as an example to those that
  @@ -15,30 +15,18 @@
   browse to that location, you will see a display of some of the tracing
   the example module did as the various callbacks were made.
   
  -To include the example module in your server, follow the steps below:
  +To include the example module in your server run `./configure
  +--enable-example` in the src directory before running `make`.
   
  -    1. Uncomment the "Module example_module" line near the bottom of
  -       the src/Configuration file.  If there isn't one, add it; it
  -       should look like this:
  -
  -       Module example_module        modules/example/mod_example.o
  -
  -    2. Run the src/Configure script ("cd src; ./Configure").  This will
  -       build the Makefile for the server itself, and update the
  -       src/modules/Makefile for any additional modules you have
  -       requested from beneath that subdirectory.
  -
  -    3. Make the server (run "make" in the src directory).
  -
   To add another module of your own:
   
       A. mkdir src/modules/mymodule
       B. cp src/modules/example/* src/modules/mymodule
       C. Modify the files in the new directory
  -    D. Follow steps [1] through [3] above, with appropriate changes.
  +    D. Build the server as above, with appropriate changes.
   
   To activate the example module, include a block similar to the
  -following in your srm.conf file:
  +following in your httpd.conf file:
   
       <Location /example-info>
   	SetHandler example-handler
  
  
  
  1.12      +85 -71    apache-2.0/src/modules/example/mod_example.c
  
  Index: mod_example.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/example/mod_example.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- mod_example.c	2000/04/28 18:27:50	1.11
  +++ mod_example.c	2000/05/11 20:25:46	1.12
  @@ -1055,6 +1055,76 @@
   
   /*--------------------------------------------------------------------------*/
   /*                                                                          */
  +/* Which functions are responsible for which hooks in the server.           */
  +/*                                                                          */
  +/*--------------------------------------------------------------------------*/
  +/* 
  + * Each function our module provides to handle a particular hook is
  + * specified here.  The functions are registered using 
  + * ap_hook_foo(name, predecessors, successors, position)
  + * where foo is the name of the hook.
  + *
  + * The args are as follows:
  + * name         -> the name of the function to call.
  + * predecessors -> a list of modules whose calls to this hook must come 
  + *                 before this module.
  + * successors   -> a list of modules whose calls to this hook must come 
  + *                 after this module.
  + * position     -> The relative position of this module.  One of AP_HOOK_FIRST,
  + *                 AP_HOOK_MIDDLE, or AP_HOOK_LAST.  Most modules will use
  + *                 AP_HOOK_MIDDLE.  If multiple modules use the same relative
  + *                 position, Apache will determine which to call first.
  + *                 If your module relies on another module to run first,
  + *                 or another module running after yours, use the 
  + *                 predecessors and/or successors.
  + *
  + * The number in brackets indicates the order in which the routine is called
  + * during request processing.  Note that not all routines are necessarily
  + * called (such as if a resource doesn't have access restrictions).
  + * The actual delivery of content to the browser [9] is not handled by
  + * a hook; see the handler declarations below.
  + */
  +static void example_register_hooks(void)
  +{
  +    /* module initializer */
  +    ap_hook_post_config(example_init,
  +			NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [1] post read_request handling */
  +    ap_hook_post_read_request(example_post_read_request,
  +			      NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [2] filename-to-URI translation */
  +    ap_hook_translate_name(example_translate_handler,
  +			   NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [3] header parser */
  +    ap_hook_header_parser(example_header_parser,
  +			  NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [4] check access by host address */
  +    ap_hook_access_checker(example_access_checker,
  +			   NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [5] check/validate user_id */
  +    ap_hook_check_user_id(example_check_user_id,
  +			  NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [6] check user_id is valid *here* */
  +    ap_hook_auth_checker(example_auth_checker,
  +			 NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [7] MIME type checker/setter */
  +    ap_hook_type_checker(example_type_checker,
  +			 NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [8] fixups */
  +    ap_hook_fixups(example_fixer_upper,
  +		   NULL, NULL, AP_HOOK_MIDDLE);
  +    /* [9] is for the handlers; see below */
  +
  +    /* [10] logger */
  +    ap_hook_log_transaction(example_logger,
  +			    NULL, NULL, AP_HOOK_MIDDLE);
  +    /* process initializer */
  +    ap_hook_child_init(example_child_init,
  +		       NULL, NULL, AP_HOOK_MIDDLE);
  +}
  +
  +/*--------------------------------------------------------------------------*/
  +/*                                                                          */
   /* All of the routines have been declared now.  Here's the list of          */
   /* directives specific to our module, and information about where they      */
   /* may appear and how the command parser should pass them to us for         */
  @@ -1068,13 +1138,12 @@
   static const command_rec example_cmds[] =
   {
       {
  -        "Example",              /* directive name */
  -        cmd_example,            /* config action routine */
  -        NULL,                   /* argument to include in call */
  -        OR_OPTIONS,             /* where available */
  -        NO_ARGS,                /* arguments */
  -        "Example directive - no arguments"
  -                                /* directive description */
  +        "Example",                          /* directive name */
  +        cmd_example,                        /* config action routine */
  +        NULL,                               /* argument to include in call */
  +        OR_OPTIONS,                         /* where available */
  +        NO_ARGS,                            /* arguments */
  +        "Example directive - no arguments"  /* directive description */
       },
       {NULL}
   };
  @@ -1104,77 +1173,22 @@
   
   /*--------------------------------------------------------------------------*/
   /*                                                                          */
  -/* Which functions are responsible for which hooks in the server.           */
  -/*                                                                          */
  -/*--------------------------------------------------------------------------*/
  -/* 
  - * Each function our module provides to handle a particular hook is
  - * specified here.  The functions are registered using 
  - * ap_hook_foo(name, predecessors, successors, position)
  - * where foo is the name of the hook.
  - *
  - * The args are as follows:
  - * name         -> the name of the function to call.
  - * predecessors -> a list of modules whose calls to this hook must come 
  - *                 before this module.
  - * successors   -> a list of modules whose calls to this hook must come 
  - *                 after this module.
  - * position     -> The relative position of this module.  One of AP_HOOK_FIRST,
  - *                 AP_HOOK_MIDDLE, or AP_HOOK_LAST.  Most modules will use
  - *                 AP_HOOK_MIDDLE.  If multiple modules use the same relative
  - *                 position, Apache will determine which to call first.
  - *                 If your module relies on another module to run first,
  - *                 or another module running after yours, use the 
  - *                 predecessors and/or successors.
  - */
  -static void register_hooks(void)
  -{
  -    /* module initializer */
  -    ap_hook_post_config(example_init, NULL, NULL, AP_HOOK_MIDDLE);
  -    /* [2] filename-to-URI translation */
  -    ap_hook_translate_name(example_translate_handler, NULL, NULL, AP_HOOK_MIDDLE);
  -    /* [5] check/validate user_id */
  -    ap_hook_check_user_id(example_check_user_id, NULL, NULL, AP_HOOK_MIDDLE);     
  -     /* [6] check user_id is valid *here* */
  -    ap_hook_auth_checker(example_auth_checker, NULL, NULL, AP_HOOK_MIDDLE); 
  -    /* [4] check access by host address */
  -    ap_hook_access_checker(example_access_checker, NULL, NULL, AP_HOOK_MIDDLE);   
  -    /* [7] MIME type checker/setter */
  -    ap_hook_type_checker(example_type_checker, NULL, NULL, AP_HOOK_MIDDLE);    
  -    /* [8] fixups */
  -    ap_hook_fixups(example_fixer_upper, NULL, NULL, AP_HOOK_MIDDLE);   
  -    /* [10] logger */
  -    ap_hook_log_transaction(example_logger, NULL, NULL, AP_HOOK_MIDDLE);         
  -    /* [3] header parser */
  -    ap_hook_header_parser(example_header_parser, NULL, NULL, AP_HOOK_MIDDLE);     
  -    /* process initializer */
  -    ap_hook_child_init(example_child_init, NULL, NULL, AP_HOOK_MIDDLE);       
  -    /* [1] post read_request handling */
  -    ap_hook_post_read_request(example_post_read_request, NULL, NULL, 
  -                              AP_HOOK_MIDDLE);
  -}
  -
  -/*--------------------------------------------------------------------------*/
  +/* Finally, the list of callback routines and data structures that provide  */
  +/* the static hooks into our module from the other parts of the server.     */
   /*                                                                          */
  -/* Finally, the list of callback routines and data structures that          */
  -/* provide the hooks into our module from the other parts of the server.    */
  -/*                                                                          */
   /*--------------------------------------------------------------------------*/
   /* 
    * Module definition for configuration.  If a particular callback is not
    * needed, replace its routine name below with the word NULL.
  - *
  - * The number in brackets indicates the order in which the routine is called
  - * during request processing.  Note that not all routines are necessarily
  - * called (such as if a resource doesn't have access restrictions).
    */
   module example_module =
   {
       STANDARD20_MODULE_STUFF,
  -    example_create_dir_config,  /* per-directory config creator */
  -    example_merge_dir_config,   /* dir config merger */
  -    example_create_server_config,       /* server config creator */
  -    example_merge_server_config,        /* server config merger */
  -    example_cmds,               /* command ap_table_t */
  -    example_handlers,           /* [7] list of handlers */
  +    example_create_dir_config,    /* per-directory config creator */
  +    example_merge_dir_config,     /* dir config merger */
  +    example_create_server_config, /* server config creator */
  +    example_merge_server_config,  /* server config merger */
  +    example_cmds,                 /* command table */
  +    example_handlers,             /* list of content delivery handlers */
  +    example_register_hooks,       /* set up other request processing hooks */
   };
  
  
  
  1.1                  apache-2.0/src/modules/example/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  
  include $(top_srcdir)/build/special.mk
  
  
  
  
  1.1                  apache-2.0/src/modules/example/config.m4
  
  Index: config.m4
  ===================================================================
  dnl autoconf stuff to include mod_example in the build
  
  APACHE_MODPATH_INIT(example)
  
  APACHE_MODULE(example, example module, , , no)
  
  APACHE_MODPATH_FINISH
  
  if test "$sharedobjs" = "yes"; then
      LIBS="$LIBS -ldl"
      LTFLAGS="$LTFLAGS -export-dynamic"
  fi
      
  APACHE_SUBST(STANDARD_LIBS)