httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject cvs commit: httpd-2.0/modules/filters mod_include.c mod_include.h
Date Sun, 30 Dec 2001 06:51:21 GMT
ianh        01/12/29 22:51:21

  Modified:    .        CHANGES
               docs/manual/mod mod_include.html
               modules/filters mod_include.c mod_include.h
  Log:
  allow mod_include to handle different start/end tags instead of the default
  <!-- --> ones.
  
  Revision  Changes    Path
  1.494     +2 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.493
  retrieving revision 1.494
  diff -u -r1.493 -r1.494
  --- CHANGES	30 Dec 2001 04:40:40 -0000	1.493
  +++ CHANGES	30 Dec 2001 06:51:20 -0000	1.494
  @@ -1,5 +1,7 @@
   Changes with Apache 2.0.30-dev
   
  +  *) Allow mod-include to look for alternate start & end tags [Ian Holsman]
  +
     *) Introduced the ForceLanguagePriority directive, to prevent
        returning MULTIPLE_CHOICES or NONE_ACCEPTABLE in some cases,
        when using Multiviews.  [William Rowe]
  
  
  
  1.42      +42 -0     httpd-2.0/docs/manual/mod/mod_include.html
  
  Index: mod_include.html
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/docs/manual/mod/mod_include.html,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- mod_include.html	30 Dec 2001 06:41:14 -0000	1.41
  +++ mod_include.html	30 Dec 2001 06:51:21 -0000	1.42
  @@ -41,6 +41,8 @@
         <li><a href="#xbithack">XBitHack</a></li>
         <li><a href="#ssierrormsg">SSIErrorMsg</a></li>
         <li><a href="#ssitimeformat">SSITimeFormat</a></li>
  +      <li><a href="#ssistarttag">SSIStartTag</a></li>
  +      <li><a href="#ssiendtag">SSIEndTag</a></li>
       </ul>
   
       <p>See also: <a href="core.html#options">Options</a>, <a
  @@ -585,7 +587,47 @@
       <p>This directive changes the format in which date strings are displayed 
       in note variables</p>
       <hr />
  +    <h2><a id="ssistarttag" name="ssistarttag">SSIStartTag</a>
  +    directive</h2>
  +    <!--%plaintext &lt;?INDEX {\tt SSIStartTag} directive&gt; -->
  +    <a href="directive-dict.html#Syntax"
  +        rel="Help"><strong>Syntax:</strong></a> SSIStartTag
  +    tag<br />
  +     <a href="directive-dict.html#Default"
  +    rel="Help"><strong>Default:</strong></a> <code>SSIStartTag
  +    &quot;&lt;--!&quot;</code><br />
  +     <a href="directive-dict.html#Context"
  +    rel="Help"><strong>Context:</strong></a> server config, virtual
  +    host<br />
  +     <a href="directive-dict.html#Status"
  +    rel="Help"><strong>Status:</strong></a> Base<br />
  +     <a href="directive-dict.html#Module"
  +    rel="Help"><strong>Module:</strong></a> mod_include 
  +
  +    <p>This directive changes the string that mod_include looks for 
  +    to mark a include command to process</p>
  +    <p>you may want to use this option if have 2 servers parsing the output of a
file
  +    each processing different comnmands (possibly at different times)</p>
  +    <hr />
  +    <h2><a id="ssiendtag" name="ssiendtag">SSIEndTag</a>
  +    directive</h2>
  +    <!--%plaintext &lt;?INDEX {\tt SSIEndTag} directive&gt; -->
  +    <a href="directive-dict.html#Syntax"
  +        rel="Help"><strong>Syntax:</strong></a> SSIEndTag
  +    tag<br />
  +     <a href="directive-dict.html#Default"
  +    rel="Help"><strong>Default:</strong></a> <code>SSIEndTag
  +    &quot;--&gt;&quot;</code><br />
  +     <a href="directive-dict.html#Context"
  +    rel="Help"><strong>Context:</strong></a> server config, virtual
  +    host<br />
  +     <a href="directive-dict.html#Status"
  +    rel="Help"><strong>Status:</strong></a> Base<br />
  +     <a href="directive-dict.html#Module"
  +    rel="Help"><strong>Module:</strong></a> mod_include 
   
  +    <p>This directive changes the string that mod_include looks for 
  +    to mark the end of a include command</p>
   
       <p><!--#include virtual="footer.html" -->
       </p>
  
  
  
  1.177     +70 -26    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.176
  retrieving revision 1.177
  diff -u -r1.176 -r1.177
  --- mod_include.c	30 Dec 2001 01:24:14 -0000	1.176
  +++ mod_include.c	30 Dec 2001 06:51:21 -0000	1.177
  @@ -106,12 +106,24 @@
       xbithack_off, xbithack_on, xbithack_full
   };
   
  +struct bndm_t {
  +    unsigned int T[256];
  +    unsigned int x;
  +} ;
  +
   typedef struct {
       char *default_error_msg;
       char *default_time_fmt;
       enum xbithack *xbithack;
   } include_dir_config;
   
  +typedef struct {
  +    char *default_start_tag;
  +    char *default_end_tag;
  +    int  start_tag_len;
  +    bndm_t start_seq_pat;
  +} include_server_config;
  +
   #ifdef XBITHACK
   #define DEFAULT_XBITHACK xbithack_full
   #else
  @@ -216,16 +228,6 @@
    * Initial code submitted by Sascha Schumann.
    */
      
  -typedef struct {
  -    unsigned int T[256];
  -    unsigned int x;
  -} bndm_t;
  -
  -/* This is the pattern matcher that holds the STARTING_SEQUENCE bndm_t
  - * structure.
  - */
  -static bndm_t start_seq_pat;
  -
   /* Precompile the bndm_t data structure. */
   static void bndm_compile(bndm_t *t, const char *n, apr_size_t nl)
   {
  @@ -328,8 +330,8 @@
       apr_size_t len;
       const char *c;
       const char *buf;
  -    const char *str = STARTING_SEQUENCE;
  -    apr_size_t slen = sizeof(STARTING_SEQUENCE) - 1;
  +    const char *str = ctx->start_seq ;
  +    apr_size_t slen = ctx->start_seq_len;
       apr_size_t pos;
   
       *do_cleanup = 0;
  @@ -411,7 +413,7 @@
   
           if (len)
           {
  -            pos = bndm(str, slen, c, len, &start_seq_pat);
  +            pos = bndm(str, slen, c, len, ctx->start_seq_pat);
               if (pos != len)
               {
                   ctx->head_start_bucket = dptr;
  @@ -475,7 +477,7 @@
       apr_size_t len;
       const char *c;
       const char *buf;
  -    const char *str = ENDING_SEQUENCE;
  +    const char *str = ctx->end_seq;
   
       do {
           apr_status_t rv = 0;
  @@ -2713,7 +2715,7 @@
               if ((do_cleanup) && (!APR_BRIGADE_EMPTY(ctx->ssi_tag_brigade)))
{
                   apr_bucket *tmp_bkt;
   
  -                tmp_bkt = apr_bucket_immortal_create(STARTING_SEQUENCE,
  +                tmp_bkt = apr_bucket_immortal_create(ctx->start_seq,
                                                        cleanup_bytes);
                   APR_BRIGADE_INSERT_HEAD(*bb, tmp_bkt);
                   apr_brigade_cleanup(ctx->ssi_tag_brigade);
  @@ -3018,6 +3020,19 @@
       return result;
   }
   
  +static void *create_includes_server_config(apr_pool_t*p, server_rec *server)
  +{
  +    include_server_config *result =
  +        (include_server_config *)apr_palloc(p, sizeof(include_server_config));
  +    result->default_end_tag = ENDING_SEQUENCE;
  +    result->default_start_tag =STARTING_SEQUENCE;
  +    result->start_tag_len = sizeof(STARTING_SEQUENCE)-1;
  +    /* compile the pattern used by find_start_sequence */
  +    bndm_compile(&result->start_seq_pat, result->default_start_tag, 
  +                 result->start_tag_len); 
  +
  +    return result; 
  +}
   static const char *set_xbithack(cmd_parms *cmd, void *xbp, const char *arg)
   {
       include_dir_config *conf = (include_dir_config *)xbp;
  @@ -3047,6 +3062,9 @@
                      (include_dir_config *)ap_get_module_config(r->per_dir_config,
                                                                 &include_module);
   
  +    include_server_config *sconf= ap_get_module_config(r->server->module_config,
  +                                                              &include_module);
  +
       if (!(ap_allow_options(r) & OPT_INCLUDES)) {
           return ap_pass_brigade(f->next, b);
       }
  @@ -3065,6 +3083,10 @@
               ctx->error_str = conf->default_error_msg;
               ctx->time_str = conf->default_time_fmt;
               ctx->pool = f->c->pool;
  +            ctx->start_seq_pat = &sconf->start_seq_pat;
  +            ctx->start_seq  = sconf->default_start_tag;
  +            ctx->start_seq_len = sconf->start_tag_len;
  +            ctx->end_seq = sconf->default_end_tag;
           }
           else {
               return ap_pass_brigade(f->next, b);
  @@ -3139,11 +3161,7 @@
                                   apr_pool_t *ptemp, server_rec *s)
   {
       include_hash = apr_hash_make(p);
  -
  -    /* compile the pattern used by find_start_sequence */
  -    bndm_compile(&start_seq_pat, STARTING_SEQUENCE, 
  -                 sizeof(STARTING_SEQUENCE)-1); 
  -
  +    
       ssi_pfn_register = APR_RETRIEVE_OPTIONAL_FN(ap_register_include_handler);
   
       if(ssi_pfn_register) {
  @@ -3169,6 +3187,27 @@
       return NULL;
   }
   
  +static const char *set_default_start_tag(cmd_parms *cmd, void *mconfig, const char *msg)
  +{
  +    include_server_config *conf;
  +    conf= ap_get_module_config(cmd->server->module_config , &include_module);
  +    conf->default_start_tag = apr_pstrdup(cmd->pool, msg);
  +    conf->start_tag_len = strlen(conf->default_start_tag );
  +    bndm_compile(&conf->start_seq_pat, conf->default_start_tag, 
  +                 conf->start_tag_len); 
  +
  +    return NULL;
  +}
  +
  +static const char *set_default_end_tag(cmd_parms *cmd, void *mconfig, const char *msg)
  +{
  +    include_server_config *conf;
  +    conf= ap_get_module_config(cmd->server->module_config , &include_module);
  +    conf->default_end_tag = apr_pstrdup(cmd->pool, msg);
  +
  +    return NULL;
  +}
  +
   static const char *set_default_time_fmt(cmd_parms *cmd, void *mconfig, const char *fmt)
   {
       include_dir_config *conf = (include_dir_config *)mconfig;
  @@ -3187,6 +3226,11 @@
                     "a string"),
       AP_INIT_TAKE1("SSITimeFormat", set_default_time_fmt, NULL, OR_ALL,
                     "a strftime(3) formatted string"),
  +    AP_INIT_TAKE1("SSIStartTag", set_default_start_tag, NULL, RSRC_CONF,
  +                  "SSI Start String Tag"),
  +    AP_INIT_TAKE1("SSIEndTag", set_default_end_tag, NULL, RSRC_CONF,
  +                  "SSI End String Tag"),
  +
       {NULL}
   };
   
  @@ -3246,10 +3290,10 @@
   module AP_MODULE_DECLARE_DATA include_module =
   {
       STANDARD20_MODULE_STUFF,
  -    create_includes_dir_config, /* dir config creater */
  -    NULL,                       /* dir merger --- default is to override */
  -    NULL,                       /* server config */
  -    NULL,                       /* merge server config */
  -    includes_cmds,              /* command apr_table_t */
  -    register_hooks              /* register hooks */
  +    create_includes_dir_config,   /* dir config creater */
  +    NULL,                         /* dir merger --- default is to override */
  +    create_includes_server_config,/* server config */
  +    NULL,                         /* merge server config */
  +    includes_cmds,                /* command apr_table_t */
  +    register_hooks                /* register hooks */
   };
  
  
  
  1.26      +9 -0      httpd-2.0/modules/filters/mod_include.h
  
  Index: mod_include.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/filters/mod_include.h,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- mod_include.h	15 Nov 2001 05:05:20 -0000	1.25
  +++ mod_include.h	30 Dec 2001 06:51:21 -0000	1.26
  @@ -131,6 +131,10 @@
    *                  the buckets containing parts of the ssi tag and headers.
    */
   typedef enum {PRE_HEAD, PARSE_HEAD, PARSE_DIRECTIVE, PARSE_TAG, PARSE_TAIL, PARSED} states;
  +
  +/** forward referenced as it needs to be held on the context */
  +typedef struct bndm_t bndm_t;
  +
   typedef struct include_filter_ctx {
       states       state;
       long         flags;    /* See the FLAG_XXXXX definitions. */
  @@ -161,6 +165,11 @@
       apr_pool_t   *pool;
   
       apr_bucket_brigade *ssi_tag_brigade;
  +    bndm_t       *start_seq_pat;
  +    char         *start_seq;
  +    int          start_seq_len;
  +    char         *end_seq;
  +
   } include_ctx_t;
   
   /* These flags are used to set flag bits. */
  
  
  

Mime
View raw message