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 23:03:35 GMT
nd          2003/08/22 16:03:35

  Modified:    modules/filters mod_include.c
  Log:
  cleanup handle_printenv function
  
  Revision  Changes    Path
  1.250     +58 -45    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.249
  retrieving revision 1.250
  diff -u -r1.249 -r1.250
  --- mod_include.c	22 Aug 2003 22:44:37 -0000	1.249
  +++ mod_include.c	22 Aug 2003 23:03:35 -0000	1.250
  @@ -2428,59 +2428,72 @@
       return APR_SUCCESS;
   }
   
  +/*
  + * <!--#printenv -->
  + */
   static apr_status_t handle_printenv(include_ctx_t *ctx, ap_filter_t *f,
                                       apr_bucket_brigade *bb)
   {
  -    char *tag     = NULL;
  -    char *tag_val = NULL;
  -    apr_bucket *tmp_buck;
       request_rec *r = f->r;
  +    const apr_array_header_t *arr;
  +    const apr_table_entry_t *elts;
  +    int i;
   
  -    if (ctx->flags & SSI_FLAG_PRINTING) {
  -        ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, SSI_VALUE_DECODED);
  -        if (!tag && !tag_val) {
  -            const apr_array_header_t *arr = apr_table_elts(r->subprocess_env);
  -            const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts;
  -            int i;
  -            const char *key_text, *val_text;
  -            char *key_val, *next;
  -            apr_size_t   k_len, v_len, kv_length;
  -
  -            for (i = 0; i < arr->nelts; ++i) {
  -                key_text = ap_escape_html(r->pool, elts[i].key);
  -                val_text = elts[i].val;
  -                if (val_text == LAZY_VALUE) {
  -                    val_text = add_include_vars_lazy(r, elts[i].key);
  -                }
  -                val_text = ap_escape_html(r->pool, elts[i].val);
  -                k_len = strlen(key_text);
  -                v_len = strlen(val_text);
  -                kv_length = k_len + v_len + sizeof("=\n");
  -                key_val = apr_palloc(r->pool, kv_length);
  -                next = key_val;
  -                memcpy(next, key_text, k_len);
  -                next += k_len;
  -                *next++ = '=';
  -                memcpy(next, val_text, v_len);
  -                next += v_len;
  -                *next++ = '\n';
  -                *next = 0;
  -                tmp_buck = apr_bucket_pool_create(key_val, kv_length - 1,
  -                                                  r->pool,
  -                                                  r->connection->bucket_alloc);
  -                APR_BRIGADE_INSERT_TAIL(bb, tmp_buck);
  -            }
  -            return APR_SUCCESS;
  -        }
  -        else {
  -            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
  -                        "printenv directive does not take tags in %s", 
  -                        r->filename);
  -            SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
  -            return APR_SUCCESS;
  +    if (ctx->argc) {
  +        ap_log_rerror(APLOG_MARK,
  +                      (ctx->flags & SSI_FLAG_PRINTING)
  +                          ? APLOG_ERR : APLOG_WARNING,
  +                      0, r, "printenv directive does not take tags 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;
  +    }
  +
  +    arr = apr_table_elts(r->subprocess_env);
  +    elts = (apr_table_entry_t *)arr->elts;
  +
  +    for (i = 0; i < arr->nelts; ++i) {
  +        const char *key_text, *val_text;
  +        char *key_val, *next;
  +        apr_size_t k_len, v_len, kv_length;
  +
  +        /* get key */
  +        key_text = ap_escape_html(ctx->dpool, elts[i].key);
  +        k_len = strlen(key_text);
  +
  +        /* get value */
  +        val_text = elts[i].val;
  +        if (val_text == LAZY_VALUE) {
  +            val_text = add_include_vars_lazy(r, elts[i].key);
           }
  +        val_text = ap_escape_html(ctx->dpool, elts[i].val);
  +        v_len = strlen(val_text);
  +
  +        /* assemble result */
  +        kv_length = k_len + v_len + sizeof("=\n");
  +        key_val = apr_palloc(ctx->pool, kv_length);
  +        next = key_val;
  +
  +        memcpy(next, key_text, k_len);
  +        next += k_len;
  +        *next++ = '=';
  +        memcpy(next, val_text, v_len);
  +        next += v_len;
  +        *next++ = '\n';
  +        *next = 0;
  +
  +        APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(key_val, kv_length-1,
  +                                ctx->pool, f->c->bucket_alloc));
       }
   
  +    ctx->flush_now = 1;
       return APR_SUCCESS;
   }
   
  
  
  

Mime
View raw message