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 22:44:37 GMT
nd          2003/08/22 15:44:37

  Modified:    modules/filters mod_include.c
  Log:
  cleanup handle_set function
  
  Revision  Changes    Path
  1.249     +55 -35    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.248
  retrieving revision 1.249
  diff -u -r1.248 -r1.249
  --- mod_include.c	22 Aug 2003 22:03:17 -0000	1.248
  +++ mod_include.c	22 Aug 2003 22:44:37 -0000	1.249
  @@ -2350,17 +2350,34 @@
       return APR_SUCCESS;
   }
   
  +/*
  + * <!--#set var="..." value="..." ... -->
  + */
   static apr_status_t handle_set(include_ctx_t *ctx, ap_filter_t *f,
                                  apr_bucket_brigade *bb)
   {
  -    char *tag     = NULL;
  -    char *tag_val = NULL;
  -    char *var     = NULL;
  -    char *parsed_string;
  +    char *var = NULL;
       request_rec *r = f->r;
       request_rec *sub = r->main;
       apr_pool_t *p = r->pool;
   
  +    if (ctx->argc < 2) {
  +        ap_log_rerror(APLOG_MARK,
  +                      (ctx->flags & SSI_FLAG_PRINTING)
  +                          ? APLOG_ERR : APLOG_WARNING,
  +                      0, r, "missing argument for set element in %s",
  +                      r->filename);
  +    }
  +
  +    if (!(ctx->flags & SSI_FLAG_PRINTING)) {
  +        return APR_SUCCESS;
  +    }
  +
  +    if (ctx->argc < 2) {
  +        SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
  +        return APR_SUCCESS;
  +    }
  +
       /* we need to use the 'main' request pool to set notes as that is 
        * a notes lifetime
        */
  @@ -2369,39 +2386,42 @@
           sub = sub->main;
       }
   
  -    if (ctx->flags & SSI_FLAG_PRINTING) {
  -        while (1) {
  -            ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, SSI_VALUE_DECODED);
  -            if (!tag && !tag_val) {
  -                return APR_SUCCESS;
  -            }
  -            else if (!tag_val) {
  -                return APR_SUCCESS;
  -            }
  -            else if (!strcmp(tag, "var")) {
  -                var = ap_ssi_parse_string(r, ctx, tag_val, NULL,
  -                                          MAX_STRING_LEN, SSI_EXPAND_DROP_NAME);
  -            }
  -            else if (!strcmp(tag, "value")) {
  -                if (var == (char *) NULL) {
  -                    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
  -                           "variable must precede value in set directive in %s",
  -                           r->filename);
  -                    SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
  -                    return APR_SUCCESS;
  -                }
  -                parsed_string = ap_ssi_parse_string(r, ctx, tag_val, NULL, 
  -                                                    MAX_STRING_LEN,
  -                                                    SSI_EXPAND_DROP_NAME);
  -                apr_table_setn(r->subprocess_env, apr_pstrdup(p, var),
  -                               apr_pstrdup(p, parsed_string));
  -            }
  -            else {
  -                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
  -                            "Invalid tag for set directive in %s", r->filename);
  +    while (1) {
  +        char *tag = NULL;
  +        char *tag_val = NULL;
  +
  +        ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, SSI_VALUE_DECODED);
  +
  +        if (!tag || !tag_val) {
  +            break;
  +        }
  +
  +        if (!strcmp(tag, "var")) {
  +            var = ap_ssi_parse_string(r, ctx, tag_val, NULL, MAX_STRING_LEN,
  +                                      SSI_EXPAND_DROP_NAME);
  +        }
  +        else if (!strcmp(tag, "value")) {
  +            char *parsed_string;
  +
  +            if (!var) {
  +                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "variable must "
  +                              "precede value in set directive in %s",
  +                              r->filename);
                   SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
  -                return APR_SUCCESS;
  +                break;
               }
  +
  +            parsed_string = ap_ssi_parse_string(r, ctx, tag_val, NULL,
  +                                                MAX_STRING_LEN,
  +                                                SSI_EXPAND_DROP_NAME);
  +            apr_table_setn(r->subprocess_env, apr_pstrdup(p, var),
  +                           apr_pstrdup(p, parsed_string));
  +        }
  +        else {
  +            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Invalid tag for set "
  +                          "directive in %s", r->filename);
  +            SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
  +            break;
           }
       }
   
  
  
  

Mime
View raw message