You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2001/02/26 07:26:24 UTC

cvs commit: httpd-2.0/modules/filters mod_include.c

rbb         01/02/25 22:26:24

  Modified:    .        CHANGES
               modules/filters mod_include.c
  Log:
  Add config directives to override the DEFAULT_ERROR_MSG and
  DEFAULT_TIME_FORMAT.
  PR:	6193
  Submitted by:	Dan Rench <dr...@xnet.com>
  Reviewed by:	Ryan Bloom
  
  Revision  Changes    Path
  1.115     +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -d -b -w -u -r1.114 -r1.115
  --- CHANGES	2001/02/26 04:56:08	1.114
  +++ CHANGES	2001/02/26 06:26:23	1.115
  @@ -1,5 +1,9 @@
   Changes with Apache 2.0.14-dev
   
  +  *) Add config directives to override DEFAULT_ERROR_MSG and
  +     DEFAULT_TIME_FORMAT.  This was sent in as PR 6193.
  +     [Dan Rench <dr...@xnet.com>]
  +
     *) Get mod_info building and loading on Win32.  [William Rowe]
   
     *) Begin to move protocol independant functions out of mod_http.  The goal
  
  
  
  1.101     +43 -13    httpd-2.0/modules/filters/mod_include.c
  
  Index: mod_include.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/filters/mod_include.c,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -d -b -w -u -r1.100 -r1.101
  --- mod_include.c	2001/02/25 23:08:51	1.100
  +++ mod_include.c	2001/02/26 06:26:24	1.101
  @@ -2314,7 +2314,6 @@
       return 0;
   }
   
  -
   /* -------------------------- The main function --------------------------- */
   
   static void send_parsed_content(apr_bucket_brigade **bb, request_rec *r, 
  @@ -2616,6 +2615,12 @@
       xbithack_off, xbithack_on, xbithack_full
   };
   
  +typedef struct {
  +    char *default_error_msg;
  +    char *default_time_fmt;
  +    enum xbithack *xbithack;
  +} include_dir_config;
  +
   #ifdef XBITHACK
   #define DEFAULT_XBITHACK xbithack_full
   #else
  @@ -2624,23 +2629,29 @@
   
   static void *create_includes_dir_config(apr_pool_t *p, char *dummy)
   {
  -    enum xbithack *result = (enum xbithack *) apr_palloc(p, sizeof(enum xbithack));
  -    *result = DEFAULT_XBITHACK;
  +    include_dir_config *result =
  +        (include_dir_config *)apr_palloc(p, sizeof(include_dir_config));
  +    enum xbithack *xbh = (enum xbithack *) apr_palloc(p, sizeof(enum xbithack));
  +    *xbh = DEFAULT_XBITHACK;
  +    result->default_error_msg = DEFAULT_ERROR_MSG;
  +    result->default_time_fmt = DEFAULT_TIME_FORMAT;
  +    result->xbithack = xbh;
       return result;
  +    return result;
   }
   
   static const char *set_xbithack(cmd_parms *cmd, void *xbp, const char *arg)
   {
  -    enum xbithack *state = (enum xbithack *) xbp;
  +    include_dir_config *conf = (include_dir_config *)xbp;
   
       if (!strcasecmp(arg, "off")) {
  -        *state = xbithack_off;
  +        *conf->xbithack = xbithack_off;
       }
       else if (!strcasecmp(arg, "on")) {
  -        *state = xbithack_on;
  +        *conf->xbithack = xbithack_on;
       }
       else if (!strcasecmp(arg, "full")) {
  -        *state = xbithack_full;
  +        *conf->xbithack = xbithack_full;
       }
       else {
           return "XBitHack must be set to Off, On, or Full";
  @@ -2653,9 +2664,10 @@
   {
       request_rec *r = f->r;
       include_ctx_t *ctx = f->ctx;
  -    enum xbithack *state =
  -    (enum xbithack *) ap_get_module_config(r->per_dir_config, &include_module);
       request_rec *parent;
  +    include_dir_config *conf = 
  +                   (include_dir_config *)ap_get_module_config(r->per_dir_config,
  +                                                              &include_module);
   
       if (!(ap_allow_options(r) & OPT_INCLUDES)) {
           return ap_pass_brigade(f->next, b);
  @@ -2675,8 +2687,8 @@
               }
               ctx->ssi_tag_brigade = apr_brigade_create(f->c->pool);
   
  -            apr_cpystrn(ctx->error_str, DEFAULT_ERROR_MSG,   sizeof(ctx->error_str));
  -            apr_cpystrn(ctx->time_str,  DEFAULT_TIME_FORMAT, sizeof(ctx->time_str));
  +            apr_cpystrn(ctx->error_str, conf->default_error_msg, sizeof(ctx->error_str));
  +            apr_cpystrn(ctx->time_str, conf->default_time_fmt, sizeof(ctx->time_str));
               ctx->error_length = strlen(ctx->error_str);
           }
           else {
  @@ -2686,7 +2698,7 @@
       }
   
       /* Assure the platform supports Group protections */
  -    if ((*state == xbithack_full)
  +    if ((*conf->xbithack == xbithack_full)
           && (r->finfo.valid & APR_FINFO_GPROT)
           && (r->finfo.protection & APR_GEXECUTE)) {
           ap_update_mtime(r, r->finfo.mtime);
  @@ -2711,7 +2723,7 @@
   	 * environment */
           ap_add_common_vars(r);
           ap_add_cgi_vars(r);
  -        add_include_vars(r, DEFAULT_TIME_FORMAT);
  +        add_include_vars(r, conf->default_time_fmt);
       }
       /* XXX: this is bogus, at some point we're going to do a subrequest,
        * and when we do it we're going to be subjecting code that doesn't
  @@ -2758,6 +2770,20 @@
       }
   }
   
  +static const char *set_default_error_msg(cmd_parms *cmd, void *mconfig, const char *msg)
  +{
  +    include_dir_config *conf = (include_dir_config *)mconfig;
  +    conf->default_error_msg = apr_pstrdup(cmd->pool, msg);
  +    return NULL;
  +}
  +
  +static const char *set_default_time_fmt(cmd_parms *cmd, void *mconfig, const char *fmt)
  +{
  +    include_dir_config *conf = (include_dir_config *)mconfig;
  +    conf->default_time_fmt = apr_pstrdup(cmd->pool, fmt);
  +    return NULL;
  +}
  +
   /*
    * Module definition and configuration data structs...
    */
  @@ -2765,6 +2791,10 @@
   {
       AP_INIT_TAKE1("XBitHack", set_xbithack, NULL, OR_OPTIONS, 
                     "Off, On, or Full"),
  +    AP_INIT_TAKE1("SSIErrorMsg", set_default_error_msg, NULL, OR_ALL, 
  +                  "a string"),
  +    AP_INIT_TAKE1("SSITimeFormat", set_default_time_fmt, NULL, OR_ALL,
  +                  "a strftime(3) formatted string"),
       {NULL}
   };