httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: httpd-apreq-2/src apreq_env.h apreq_params.c apreq_params.h apreq_parsers.c
Date Sat, 12 Apr 2003 04:52:15 GMT
joes        2003/04/11 21:52:15

  Modified:    .        Makefile.am configure.in
               src      apreq_env.h apreq_params.c apreq_params.h
                        apreq_parsers.c
  Added:       env      Makefile.am mod_apreq.c
  Log:
  Add template for mod_apreq.
  
  Revision  Changes    Path
  1.2       +1 -1      httpd-apreq-2/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/Makefile.am,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile.am	17 Jan 2003 06:41:15 -0000	1.1
  +++ Makefile.am	12 Apr 2003 04:52:14 -0000	1.2
  @@ -1,3 +1,3 @@
   AUTOMAKE_OPTIONS = foreign
  -SUBDIRS = src
  +SUBDIRS = src env
   EXTRA_DIST = libapreq.pod
  
  
  
  1.3       +1 -1      httpd-apreq-2/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/configure.in,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- configure.in	6 Apr 2003 05:57:17 -0000	1.2
  +++ configure.in	12 Apr 2003 04:52:14 -0000	1.3
  @@ -31,4 +31,4 @@
   dnl Checks for library functions.
   
   AC_APREQ
  -AC_OUTPUT(Makefile src/Makefile)
  +AC_OUTPUT(Makefile src/Makefile env/Makefile)
  
  
  
  1.1                  httpd-apreq-2/env/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  lib_LTLIBRARIES = lib_mod_apreq.la
  lib_mod_apreq_la_SOURCES = mod_apreq.c
  lib_mod_apreq_la_LDFLAGS = -version-info 2:0
  INCLUDES = @APREQ_INCLUDES@ -I../src
  
  
  
  1.1                  httpd-apreq-2/env/mod_apreq.c
  
  Index: mod_apreq.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "httpd.h"
  #include "http_config.h"
  #include "http_log.h"
  #include "util_filter.h"
  #include "apr_tables.h"
  #include "apr_buckets.h"
  #include "http_request.h"
  
  #include "apreq.h"
  #include "apreq_env.h"
  #include "apreq_params.h"
  #include "apreq_cookie.h"
  
  #define dR  request_rec *r = (request_rec *)ctx
  
  /* the "warehouse" */
  
  struct env_note {
      apreq_request_t *req;
      apreq_jar_t *jar;
      apr_bucket_brigade *bb;
  };
  
  static const char env_name[] = "APACHE2";
  static const char filter_name[] = "APREQ";
  
  static apr_pool_t *env_pool(void *ctx)
  {
      dR;
      return r->pool;
  }
  
  static const char *env_in(void *ctx, const char *name)
  {
      dR;
      return apr_table_get(r->headers_in, name);
  }
  
  static apr_status_t env_out(void *ctx, const char *name, char *value)
  {
      dR;
      apr_table_add(r->headers_in, name, value);
      return APR_SUCCESS;
  }
  
  static const char *env_args(void *ctx)
  {
      dR;
      return r->args;
  }
  
  static APR_INLINE struct env_note *apreq_note(request_rec *r)
  {
      struct env_note *n = (struct env_note *)
          apr_table_get(r->notes, filter_name);
  
      if (n == NULL) {
          n = apr_palloc(r->pool, sizeof *n);
          n->req = NULL;
          n->jar = NULL;
          n->bb = NULL;
          apr_table_add(r->notes, filter_name, (char *)n);
      }
      return n;
  }
  
  static void *env_jar(void *ctx, void *jar)
  {
      dR;
      struct env_note *n = apreq_note(r);
  
      if (jar != NULL) {
          apreq_jar_t *oldjar = n->jar;
          n->jar = (apreq_jar_t *)jar;
          return oldjar;
      }        
      return n->jar;
  }
  
  static void *env_request(void *ctx, void *req)
  {
      dR;
      struct env_note *n = apreq_note(r);
  
      if (req != NULL) {
          apreq_request_t *oldreq = n->req;
          n->req = (apreq_request_t *)req;
          return oldreq;
      }
      return n->req;
  }
  
  static apreq_cfg_t *env_cfg(void *ctx)
  {
      /* XXX: not implemented */
      return NULL;
  }
  
  static apr_status_t env_get_brigade(void *ctx, apr_bucket_brigade **bb)
  {
      dR;
      struct env_note *n = apreq_note(r);
  
      if (n->bb == NULL)
          n->bb = apr_brigade_create(r->pool, 
                                     apr_bucket_alloc_create(r->pool));
  
      /* XXX: do something here to populate n->bb */
  
      *bb = n->bb;
      return APR_SUCCESS;
  }
  
  static apr_status_t apreq_filter(ap_filter_t *f,
                                   apr_bucket_brigade *bb,
                                   ap_input_mode_t mode,
                                   apr_read_type_e block,
                                   apr_off_t readbytes)
  {
      /* XXX ... */
  
  	return APR_SUCCESS;
  }
  
  
  
  static void register_hooks (apr_pool_t *p)
  {
      ap_register_input_filter(filter_name, apreq_filter, NULL, 
                               AP_FTYPE_CONTENT_SET);
  }
  
  
  module AP_MODULE_DECLARE_DATA apreq_module =
  {
  	// Only one callback function is provided.  Real
  	// modules will need to declare callback functions for
  	// server/directory configuration, configuration merging
  	// and other tasks.
  	STANDARD20_MODULE_STUFF,
  	NULL,
  	NULL,
  	NULL,
  	NULL,
  	NULL,
  	register_hooks,			/* callback for registering hooks */
  };
  
  const struct apreq_env APREQ_ENV = (struct apreq_env)
  {
      env_name,
      env_pool,
      env_in,
      env_out,
      env_args,
      env_jar,
      env_request,
      env_cfg,
      env_get_brigade,
      ap_log_rerror
   };
  
  
  
  
  1.8       +2 -2      httpd-apreq-2/src/apreq_env.h
  
  Index: apreq_env.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_env.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- apreq_env.h	12 Apr 2003 01:45:30 -0000	1.7
  +++ apreq_env.h	12 Apr 2003 04:52:15 -0000	1.8
  @@ -70,8 +70,8 @@
       const char          *(*args)(void *ctx);
   
       /* (get/set) cached core objects */
  -    void                *(*jar)(void *ctx, void *j);
  -    void                *(*request)(void *ctx, void *r);
  +    void                *(*jar)(void *ctx, void *jar);
  +    void                *(*request)(void *ctx, void *req);
   
       /* environment configuration */
       apreq_cfg_t         *(*config)(void *ctx);
  
  
  
  1.8       +11 -0     httpd-apreq-2/src/apreq_params.c
  
  Index: apreq_params.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_params.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- apreq_params.c	12 Apr 2003 01:45:30 -0000	1.7
  +++ apreq_params.c	12 Apr 2003 04:52:15 -0000	1.8
  @@ -155,6 +155,17 @@
   }
   
   
  +APREQ_DECLARE(const apreq_table_t *) (apreq_args)(const apreq_request_t *req)
  +{
  +    return apreq_args(req);
  +}
  +
  +
  +APREQ_DECLARE(const apreq_table_t *) (apreq_body)(const apreq_request_t *req)
  +{
  +    return apreq_body(req);
  +}
  +
   APREQ_DECLARE(apr_array_header_t *) apreq_params(apr_pool_t *pool,
                                                    const apreq_request_t *req, 
                                                    const char *name)
  
  
  
  1.7       +2 -1      httpd-apreq-2/src/apreq_params.h
  
  Index: apreq_params.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_params.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- apreq_params.h	12 Apr 2003 01:45:30 -0000	1.6
  +++ apreq_params.h	12 Apr 2003 04:52:15 -0000	1.7
  @@ -126,7 +126,7 @@
   
   APREQ_DECLARE(const char *) apreq_arg(const apreq_request_t *req, 
                                         const char *name);
  -#define apreq_arg(r,k) apreq_table_get((req)->arg, k)
  +#define apreq_arg(req,k) apreq_table_get((req)->args, k)
   
   
   APREQ_DECLARE(const apreq_table_t *) apreq_args(const apreq_request_t *req);
  @@ -178,6 +178,7 @@
                                                     const char *word,
                                                     const apr_size_t nlen, 
                                                     const apr_size_t vlen);
  +
   APREQ_DECLARE(char *) apreq_encode_param(apr_pool_t *pool, 
                                            const apreq_param_t *param);
   
  
  
  
  1.6       +3 -1      httpd-apreq-2/src/apreq_parsers.c
  
  Index: apreq_parsers.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_parsers.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- apreq_parsers.c	12 Apr 2003 01:45:30 -0000	1.5
  +++ apreq_parsers.c	12 Apr 2003 04:52:15 -0000	1.6
  @@ -900,6 +900,7 @@
   
       case MFD_UPLOAD:
           {
  +            apr_bucket *eos;
               apr_status_t s = split_on_bdry(pool, ctx->bb, bb, ctx->bdry);
               apreq_param_t *param;
               const apreq_value_t *v;
  @@ -922,7 +923,8 @@
                   apreq_table_last(req->body, &v, &dummy);
                   param = apreq_value_to_param(v);
   
  -                /* XXX: push an eos bucket onto ctx->bb */
  +                eos = apr_bucket_eos_create(ctx->bb->bucket_alloc);
  +                APR_BRIGADE_INSERT_TAIL(ctx->bb, eos);
   
                   if (parser->hook) {
                       do s = parser->hook(pool, param->bb, ctx->bb, parser);
  
  
  

Mime
View raw message