httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/experimental mod_charset_lite.c
Date Tue, 19 Sep 2000 17:46:29 GMT
trawick     00/09/19 10:46:28

  Modified:    src/modules/experimental mod_charset_lite.c
  Log:
  Change the registered filter name to XLATEOUT (from XLATE).
  
  Set up the context in the filter in case the filter was inserted via
  AddOutputFilter.
  
  Provide a temporary hack to avoid having the module and core both
  insert the output translation filter.  For now, code
  "CharsetOptions NoImplicitAdd" in a container with "AddOutputFilter."
  
  Make a few cosmetic changes (e.g., rename the mis-named
  xlate_register_filter routine).
  
  Revision  Changes    Path
  1.17      +58 -16    apache-2.0/src/modules/experimental/mod_charset_lite.c
  
  Index: mod_charset_lite.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/experimental/mod_charset_lite.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- mod_charset_lite.c	2000/09/14 15:31:58	1.16
  +++ mod_charset_lite.c	2000/09/19 17:46:28	1.17
  @@ -76,6 +76,7 @@
   #include "util_charset.h"
   #include "ap_buckets.h"
   #include "util_filter.h"
  +#include "apr_strings.h"
   
   #ifndef APACHE_XLATE
   #error mod_charset_lite cannot work without APACHE_XLATE enabled
  @@ -101,13 +102,14 @@
       EES_BAD_INPUT   /* input data invalid */
   } ees_t;
   
  -#define XLATE_FILTER_NAME "XLATE" /* registered name of the translation filter */
  +#define XLATEOUT_FILTER_NAME "XLATEOUT" /* registered name of the translation filter */
   
   typedef struct charset_dir_t {
       enum {NO_DEBUG = 1, DEBUG} debug; /* whether or not verbose logging is enabled; 0
                                           means uninitialized */
       const char *charset_source; /* source encoding */
       const char *charset_default; /* how to ship on wire */
  +    enum {IA_INIT, IA_IMPADD, IA_NOIMPADD} implicit_add; /* tmp hack! module does ap_add_filter()?
*/
   } charset_dir_t;
   
   /* charset_filter_ctx_t is created for each filter instance; because the same
  @@ -153,6 +155,8 @@
           over->charset_default ? over->charset_default : base->charset_default;
       a->charset_source = 
           over->charset_source ? over->charset_source : base->charset_source;
  +    a->implicit_add =
  +        over->implicit_add != IA_INIT ? over->implicit_add : base->implicit_add;
       return a;
   }
   
  @@ -178,7 +182,7 @@
       return NULL;
   }
   
  -/* CharsetDefault charset
  +/* CharsetDebug on/off
    */
   static const char *add_charset_debug(cmd_parms *cmd, void *in_dc, int arg)
   {
  @@ -194,6 +198,29 @@
       return NULL;
   }
   
  +/* CharsetOptions optionflag...
  + */
  +static const char *add_charset_options(cmd_parms *cmd, void *in_dc, 
  +                                       const char *flag)
  +{
  +    charset_dir_t *dc = in_dc;
  +
  +    if (!strcasecmp(flag, "ImplicitAdd")) {
  +        dc->implicit_add = IA_IMPADD;
  +    }
  +    else if (!strcasecmp(flag, "NoImplicitAdd")) {
  +        dc->implicit_add = IA_NOIMPADD;
  +    }
  +    else {
  +        return apr_pstrcat(cmd->temp_pool, 
  +                           "Invalid CharsetOptions option: ",
  +                           flag,
  +                           NULL);
  +    }
  +
  +    return NULL;
  +}
  +
   /* find_code_page() is a fixup hook that decides if translation should be
    * enabled; if so, it sets up request data for use by the filter registration
    * hook so that it knows what to do
  @@ -327,10 +354,10 @@
       return DECLINED;
   }
   
  -/* xlate_register_filter() is a filter hook which decides whether or not
  +/* xlate_insert_filter() is a filter hook which decides whether or not
    * to insert a translation filter for the current request.
    */
  -static void xlate_register_filter(request_rec *r)
  +static void xlate_insert_filter(request_rec *r)
   {
       /* Hey... don't be so quick to use reqinfo->dc here; reqinfo may be NULL */
       charset_req_t *reqinfo = ap_get_module_config(r->request_config, 
  @@ -341,20 +368,24 @@
   
       if (debug) {
           ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  -                     "xlate_register_filter() - "
  +                     "xlate_insert_filter() - "
                        "dc: %X charset_source: %s charset_default: %s",
                        (unsigned)dc,
                        dc && dc->charset_source ? dc->charset_source : "(none)",
                        dc && dc->charset_default ? dc->charset_default : "(none)");
       }
   
  -    if (reqinfo && reqinfo->output_ctx) {
  -        ap_add_filter(XLATE_FILTER_NAME, reqinfo->output_ctx, r);
  +    if (reqinfo && 
  +        dc->implicit_add == IA_IMPADD &&
  +        reqinfo->output_ctx) {
  +        ap_add_filter(XLATEOUT_FILTER_NAME, reqinfo->output_ctx, r);
       }
       
  -#ifdef NOT_YET
  -    if (reqinfo && reqinfo->input_ctx) {
  -        /* ap_add_filter(xxx, yyy, r); */
  +#ifdef NOT_YET /* no input filters yet; we still rely on BUFF */
  +    if (reqinfo && 
  +        dc->implicit_add == IA_IMPADD &&
  +        reqinfo->input_ctx) {
  +        /* ap_add_filter(XLATEIN_FILTER_NAME, reqinfo->input_ctx, r); */
       }
   #endif
   }
  @@ -514,6 +545,16 @@
       int done;
       apr_status_t rv = APR_SUCCESS;
   
  +    if (!ctx) { /* this is AddOutputFilter path */
  +        ap_assert(dc->implicit_add == IA_NOIMPADD); 
  +        if (!strcmp(f->frec->name, XLATEOUT_FILTER_NAME)) {
  +            ctx = f->ctx = reqinfo->output_ctx;
  +        }
  +        else {
  +            ap_assert(1 != 1);
  +        }
  +    }
  +
       if (debug) {
           ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, f->r->server,
                        "xlate_filter() - "
  @@ -650,18 +691,19 @@
                    NULL,
                    OR_FILEINFO,
                    "mod_charset_lite debug flag"),
  +    AP_INIT_ITERATE("CharsetOptions",
  +                    add_charset_options,
  +                    NULL,
  +                    OR_FILEINFO,
  +                    "valid options: ImplicitAdd, NoImplicitAdd"),
       {NULL}
   };
   
   static void charset_register_hooks(void)
   {
       ap_hook_fixups(find_code_page, NULL, NULL, AP_HOOK_MIDDLE);
  -    /* The first function just registers this module's register_filter 
  -     * hook.  The other associates a global name with the filter defined
  -     * by this module.
  -     */
  -    ap_hook_insert_filter(xlate_register_filter, NULL, NULL, AP_HOOK_MIDDLE);
  -    ap_register_filter(XLATE_FILTER_NAME, xlate_filter, AP_FTYPE_CONTENT);
  +    ap_hook_insert_filter(xlate_insert_filter, NULL, NULL, AP_HOOK_MIDDLE);
  +    ap_register_filter(XLATEOUT_FILTER_NAME, xlate_filter, AP_FTYPE_CONTENT);
   }
   
   module charset_lite_module =
  
  
  

Mime
View raw message