httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/filters mod_include.c
Date Fri, 22 Aug 2003 05:15:58 GMT
nd          2003/08/21 22:15:58

  Modified:    modules/filters mod_include.c
  Log:
  cleanup handle_config function
  
  Revision  Changes    Path
  1.243     +72 -51    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.242
  retrieving revision 1.243
  diff -u -r1.242 -r1.243
  --- mod_include.c	22 Aug 2003 04:54:59 -0000	1.242
  +++ mod_include.c	22 Aug 2003 05:15:58 -0000	1.243
  @@ -1873,72 +1873,93 @@
       return APR_SUCCESS;
   }
   
  -/* error and tf must point to a string with room for at 
  - * least MAX_STRING_LEN characters 
  +/*
  + * <!--#config [timefmt="..."] [sizefmt="..."] [errmsg="..."] -->
    */
   static apr_status_t handle_config(include_ctx_t *ctx, ap_filter_t *f,
                                     apr_bucket_brigade *bb)
   {
  -    char *tag     = NULL;
  -    char *tag_val = NULL;
  -    char *parsed_string;
       request_rec *r = f->r;
       apr_table_t *env = r->subprocess_env;
   
  -    if (ctx->flags & SSI_FLAG_PRINTING) {
  -        while (1) {
  -            ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, SSI_VALUE_RAW);
  -            if (! tag || !tag_val) {
  -                return APR_SUCCESS;
  +    if (!ctx->argc) {
  +        ap_log_rerror(APLOG_MARK,
  +                      (ctx->flags & SSI_FLAG_PRINTING)
  +                          ? APLOG_ERR : APLOG_WARNING,
  +                      0, r, "missing argument for config element in %s",
  +                      r->filename);
  +    }
  +
  +    if (!(ctx->flags & SSI_FLAG_PRINTING)) {
  +        return APR_SUCCESS;
  +    }
  +
  +    if (!ctx->argc) {
  +        SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
  +        return APR_SUCCESS;
  +    }
  +
  +    while (1) {
  +        char *tag     = NULL;
  +        char *tag_val = NULL;
  +        char *parsed_string;
  +
  +        ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, SSI_VALUE_RAW);
  +        if (!tag || !tag_val) {
  +            break;
  +        }
  +
  +        if (!strcmp(tag, "errmsg")) {
  +            if (!ctx->intern->error_str_override) {
  +                ctx->intern->error_str_override = apr_palloc(ctx->pool,
  +                                                             MAX_STRING_LEN);
  +                ctx->error_str = ctx->intern->error_str_override;
               }
   
  -            if (!strcmp(tag, "errmsg")) {
  -                if (ctx->intern->error_str_override == NULL) {
  -                    ctx->intern->error_str_override = apr_palloc(ctx->pool,
  -                                                                MAX_STRING_LEN);
  -                    ctx->error_str = ctx->intern->error_str_override;
  -                }
  -                ap_ssi_parse_string(r, ctx, tag_val,
  -                                    ctx->intern->error_str_override,
  -                                    MAX_STRING_LEN, SSI_EXPAND_DROP_NAME);
  +            ap_ssi_parse_string(r, ctx, tag_val,ctx->intern->error_str_override,
  +                                MAX_STRING_LEN, SSI_EXPAND_DROP_NAME);
  +        }
  +        else if (!strcmp(tag, "timefmt")) {
  +            apr_time_t date = r->request_time;
  +            if (!ctx->intern->time_str_override) {
  +                ctx->intern->time_str_override = apr_palloc(ctx->pool,
  +                                                            MAX_STRING_LEN);
  +                ctx->time_str = ctx->intern->time_str_override;
               }
  -            else if (!strcmp(tag, "timefmt")) {
  -                apr_time_t date = r->request_time;
  -                if (ctx->intern->time_str_override == NULL) {
  -                    ctx->intern->time_str_override = apr_palloc(ctx->pool,
  -                                                                MAX_STRING_LEN);
  -                    ctx->time_str = ctx->intern->time_str_override;
  -                }
  -                ap_ssi_parse_string(r, ctx, tag_val,
  -                                    ctx->intern->time_str_override,
  -                                    MAX_STRING_LEN, SSI_EXPAND_DROP_NAME);
  -
  -                apr_table_setn(env, "DATE_LOCAL", ap_ht_time(r->pool, date, 
  -                               ctx->time_str, 0));
  -                apr_table_setn(env, "DATE_GMT", ap_ht_time(r->pool, date, 
  -                               ctx->time_str, 1));
  -                apr_table_setn(env, "LAST_MODIFIED",
  -                               ap_ht_time(r->pool, r->finfo.mtime, 
  -                               ctx->time_str, 0));
  +            ap_ssi_parse_string(r, ctx, tag_val, ctx->intern->time_str_override,
  +                                MAX_STRING_LEN, SSI_EXPAND_DROP_NAME);
  +
  +            apr_table_setn(env, "DATE_LOCAL", ap_ht_time(r->pool, date, 
  +                           ctx->time_str, 0));
  +            apr_table_setn(env, "DATE_GMT", ap_ht_time(r->pool, date, 
  +                           ctx->time_str, 1));
  +            apr_table_setn(env, "LAST_MODIFIED",
  +                           ap_ht_time(r->pool, r->finfo.mtime, 
  +                           ctx->time_str, 0));
  +        }
  +        else if (!strcmp(tag, "sizefmt")) {
  +            parsed_string = ap_ssi_parse_string(r, ctx, tag_val, NULL, 
  +                                                MAX_STRING_LEN,
  +                                                SSI_EXPAND_DROP_NAME);
  +            if (!strcmp(parsed_string, "bytes")) {
  +                ctx->flags |= SSI_FLAG_SIZE_IN_BYTES;
               }
  -            else if (!strcmp(tag, "sizefmt")) {
  -                parsed_string = ap_ssi_parse_string(r, ctx, tag_val, NULL, 
  -                                                    MAX_STRING_LEN,
  -                                                    SSI_EXPAND_DROP_NAME);
  -                decodehtml(parsed_string);
  -                if (!strcmp(parsed_string, "bytes")) {
  -                    ctx->flags |= SSI_FLAG_SIZE_IN_BYTES;
  -                }
  -                else if (!strcmp(parsed_string, "abbrev")) {
  -                    ctx->flags &= SSI_FLAG_SIZE_ABBREV;
  -                }
  +            else if (!strcmp(parsed_string, "abbrev")) {
  +                ctx->flags &= SSI_FLAG_SIZE_ABBREV;
               }
               else {
  -                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
  -                              "unknown parameter \"%s\" to tag config in %s",
  -                              tag, r->filename);
  +                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "unknown value "
  +                              "\"%s\" to parameter \"sizefmt\" of tag config "
  +                              "in %s", parsed_string, r->filename);
                   SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
  +                break;
               }
  +        }
  +        else {
  +            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "unknown parameter "
  +                          "\"%s\" to tag config in %s", tag, r->filename);
  +            SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
  +            break;
           }
       }
   
  
  
  

Mime
View raw message