httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Terbush <ra...@hyperreal.org>
Subject cvs commit: apachen/src/modules/standard mod_cern_meta.c
Date Sat, 23 Aug 1997 02:19:04 GMT
randy       97/08/22 19:19:04

  Modified:    src/modules/standard mod_cern_meta.c
  Log:
  This version of mod_cern_meta.c controls Meta File behaviour on a
  per-directory basis.  Previous versions of the module defined behaviour
  on a per-server basis.  The upshot is that you'll need to revisit your
  configuration files in order to make use of the new module.
  Submitted by:	David J. MacKenzie <djm@va.pubnix.com>
  Reviewed by:	Dean Gaudet, Brian Behlendorf, Randy Terbush
  
  Revision  Changes    Path
  1.18      +78 -34    apachen/src/modules/standard/mod_cern_meta.c
  
  Index: mod_cern_meta.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_cern_meta.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- mod_cern_meta.c	1997/08/18 13:12:10	1.17
  +++ mod_cern_meta.c	1997/08/23 02:19:01	1.18
  @@ -52,11 +52,18 @@
   
   /*
    * mod_cern_meta.c
  - * version 0.0.5
  + * version 0.1.0
    * status beta
    * 
    * Andrew Wilson <Andrew.Wilson@cm.cf.ac.uk> 25.Jan.96
    *
  + * *** IMPORTANT ***
  + * This version of mod_cern_meta.c controls Meta File behaviour on a
  + * per-directory basis.  Previous versions of the module defined behaviour
  + * on a per-server basis.  The upshot is that you'll need to revisit your 
  + * configuration files in order to make use of the new module.
  + * ***
  + *
    * Emulate the CERN HTTPD Meta file semantics.  Meta files are HTTP
    * headers that can be output in addition to the normal range of
    * headers for each file accessed.  They appear rather like the Apache
  @@ -67,8 +74,16 @@
    * who can exploit this module.  It should be noted that there are probably
    * more sensitive ways of managing the Expires: header specifically.
    *
  - * The module obeys the following directives, which can only appear 
  - * in the server's .conf files and not in any .htaccess file.
  + * The module obeys the following directives, which can appear 
  + * in the server's .conf files and in .htaccess files.
  + *
  + *  MetaFiles <on|off> 
  + *
  + *    turns on|off meta file processing for any directory.  
  + *    Default value is off
  + *
  + *        # turn on MetaFiles in this directory
  + *        MetaFiles on
    *
    *  MetaDir <directory name>
    *      
  @@ -122,7 +137,10 @@
    *           need to report missing ones as spurious errors. 
    * 31.Jan.96 log_error reports about a malformed .meta file, rather
    *           than a script error.
  - *
  + * 20.Jun.96 MetaFiles <on|off> default off, added, so that module
  + *           can be configured per-directory.  Prior to this the module
  + *           was running for each request anywhere on the server, naughty..
  + * 29.Jun.96 All directives made per-directory.
    */
   
   #include "httpd.h"
  @@ -133,51 +151,70 @@
   #include "http_log.h"
   #include "http_request.h"
   
  +#define DIR_CMD_PERMS OR_INDEXES
  +
   #define DEFAULT_METADIR		".web"
   #define DEFAULT_METASUFFIX	".meta"
  +#define DEFAULT_METAFILES	0
   
   module MODULE_VAR_EXPORT cern_meta_module;
   
   typedef struct {
  -	char *metadir;
  -	char *metasuffix;
  -} cern_meta_config;
  +    char *metadir;
  +    char *metasuffix;
  +    char *metafiles;
  +} cern_meta_dir_config;
   
  -void *create_cern_meta_config (pool *p, server_rec *dummy)
  +void *create_cern_meta_dir_config (pool *p, char *dummy)
   {
  -    cern_meta_config *new =
  -      (cern_meta_config *) palloc (p, sizeof(cern_meta_config)); 
  - 
  -    new->metadir = DEFAULT_METADIR;
  -    new->metasuffix = DEFAULT_METASUFFIX;
  +    cern_meta_dir_config *new =
  +	(cern_meta_dir_config *)palloc(p, sizeof(cern_meta_dir_config));
  +
  +    new->metadir = NULL;
  +    new->metasuffix = NULL;
  +    new->metafiles = DEFAULT_METAFILES;
  +
  +    return new;
  +}
  +
  +void *merge_cern_meta_dir_configs (pool *p, void *basev, void *addv) 
  +{
  +    cern_meta_dir_config *base = (cern_meta_dir_config *)basev;
  +    cern_meta_dir_config *add = (cern_meta_dir_config *)addv; 
  +    cern_meta_dir_config *new =
  +	(cern_meta_dir_config *)palloc(p, sizeof(cern_meta_dir_config));
       
  +    new->metadir = add->metadir ? add->metadir : base->metadir;
  +    new->metasuffix = add->metasuffix ? add->metasuffix : base->metasuffix;
  +    new->metafiles = add->metafiles;
  +
       return new;
   }   
   
  -const char *set_metadir (cmd_parms *parms, void *dummy, char *arg)
  +const char *set_metadir (cmd_parms *parms, cern_meta_dir_config *dconf, char *arg)
   {       
  -    cern_meta_config *cmc ;
  -
  -    cmc = get_module_config (parms->server->module_config,
  -                           &cern_meta_module); 
  -    cmc->metadir = arg;
  +    dconf->metadir = arg;
       return NULL;
   }
   
  -const char *set_metasuffix (cmd_parms *parms, void *dummy, char *arg)
  +const char *set_metasuffix (cmd_parms *parms, cern_meta_dir_config *dconf, char *arg)
   {       
  -    cern_meta_config *cmc ;
  -
  -    cmc = get_module_config (parms->server->module_config,
  -                           &cern_meta_module); 
  -    cmc->metasuffix = arg;
  +    dconf->metasuffix = arg;
  +    return NULL;
  +}
  +  
  +const char *set_metafiles (cmd_parms *parms, cern_meta_dir_config *dconf, char *arg) 
  +{
  +    dconf->metafiles = arg;
       return NULL;
   }
   
  +
   command_rec cern_meta_cmds[] = {
  -{ "MetaDir", set_metadir, NULL, RSRC_CONF, TAKE1,
  +{ "MetaFiles", set_metafiles, NULL, DIR_CMD_PERMS, FLAG, NULL},
  +{ "MetaDir", set_metadir, NULL, DIR_CMD_PERMS, TAKE1,
       "the name of the directory containing meta files"},
  -{ "MetaSuffix", set_metasuffix, NULL, RSRC_CONF, TAKE1,
  +{ "MetaSuffix", set_metasuffix, NULL, DIR_CMD_PERMS, TAKE1,
       "the filename suffix for meta files"},
   { NULL }
   };  
  @@ -240,12 +277,15 @@
       char *real_file;
       char *scrap_book;
       FILE *f;   
  -    cern_meta_config *cmc ;
  +    cern_meta_dir_config *dconf ;
       int rv;
       request_rec *rr;
   
  -    cmc = get_module_config (r->server->module_config,
  -                           &cern_meta_module); 
  +    dconf = get_module_config (r->per_dir_config, &cern_meta_module); 
  +
  +    if (!dconf->metafiles) {
  +        return DECLINED;
  +    };
   
       /* if ./.web/$1.meta exists then output 'asis' */
   
  @@ -275,7 +315,11 @@
   	return DECLINED;
       };
   
  -    metafilename = pstrcat(r->pool, "/", scrap_book, "/", cmc->metadir, "/", real_file,
cmc->metasuffix, NULL);
  +    metafilename = pstrcat(r->pool, "/", scrap_book, "/", 
  +        dconf->metadir ? dconf->metadir : DEFAULT_METADIR, 
  +        "/", real_file, 
  +        dconf->metasuffix ? dconf->metasuffix : DEFAULT_METASUFFIX, 
  +        NULL);
   
       /* XXX: it sucks to require this subrequest to complete, because this
        * means people must leave their meta files accessible to the world.
  @@ -308,9 +352,9 @@
   module MODULE_VAR_EXPORT cern_meta_module = {
      STANDARD_MODULE_STUFF,
      NULL,			/* initializer */
  -   NULL,			/* dir config creater */
  -   NULL,			/* dir merger --- default is to override */
  -   create_cern_meta_config,	/* server config */
  +   create_cern_meta_dir_config,	/* dir config creater */
  +   merge_cern_meta_dir_configs,	/* dir merger --- default is to override */
  +   NULL,			/* server config */
      NULL,			/* merge server configs */
      cern_meta_cmds,		/* command table */
      NULL,			/* handlers */
  
  
  

Mime
View raw message