coar 98/09/28 15:32:13
Modified: . STATUS htdocs/manual/mod mod_autoindex.html src CHANGES src/modules/standard mod_autoindex.c Log: There appear to be no dissenters (other than for brand-new and incompatible syntaxes) after three days, and I want to get this in for 1.3.3. It can always be modified or reverted later. Add +/- prefixes to IndexOptions keywords, allow merging of multiple occurrences, and document the changes. Revision Changes Path 1.495 +0 -4 apache-1.3/STATUS Index: STATUS =================================================================== RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.494 retrieving revision 1.495 diff -u -r1.494 -r1.495 --- STATUS 1998/09/25 19:33:38 1.494 +++ STATUS 1998/09/28 22:32:09 1.495 @@ -25,10 +25,6 @@ Available Patches: - * Ken's "[PATCH] Add '+' and '-' to IndexOptions keywords" - Message-ID: <[EMAIL PROTECTED]> - Status: Ken +1 - * Earle Ake: Apache 1.3.1 port to Pyramid DC/OSx <[EMAIL PROTECTED]> 1.25 +78 -4 apache-1.3/htdocs/manual/mod/mod_autoindex.html Index: mod_autoindex.html =================================================================== RCS file: /export/home/cvs/apache-1.3/htdocs/manual/mod/mod_autoindex.html,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- mod_autoindex.html 1998/09/24 15:27:52 1.24 +++ mod_autoindex.html 1998/09/28 22:32:10 1.25 @@ -470,8 +470,17 @@ <A HREF="directive-dict.html#Syntax" REL="Help" -><STRONG>Syntax:</STRONG></A> IndexOptions <EM>option option ...</EM><BR> +><STRONG>Syntax:</STRONG></A> IndexOptions <EM>option option ...</EM> + (Apache 1.3.2 and earlier) +<BR> <A + HREF="directive-dict.html#Syntax" + REL="Help" +><STRONG>Syntax:</STRONG></A> IndexOptions <EM>[+|-]option [+|-]option + ...</EM> + (Apache 1.3.3 and later) +<BR> +<A HREF="directive-dict.html#Context" REL="Help" ><STRONG>Context:</STRONG></A> server config, virtual host, directory, @@ -487,7 +496,15 @@ <A HREF="directive-dict.html#Module" REL="Help" -><STRONG>Module:</STRONG></A> mod_autoindex<P> +><STRONG>Module:</STRONG></A> mod_autoindex +<BR> +<A + HREF="directive-dict.html#Compatibility" + REL="Help" +><STRONG>Compatibility:</STRONG></A> '+/-' syntax and merging of multiple + <SAMP>IndexOptions</SAMP> directives is only available with + Apache 1.3.3 and later +<P> The IndexOptions directive specifies the behavior of the directory indexing. <EM>Option</EM> can be one of @@ -577,7 +594,15 @@ <!--%plaintext <?INDEX {\tt SuppressSize} index option> --> This will suppress the file size in fancy indexing listings. </DL> -This default is that no options are enabled. If multiple IndexOptions +<P> +There are some noticeable differences in the behaviour of this +directive in recent (post-1.3.0) versions of Apache. +</P> +<DL> +<DT>Apache 1.3.2 and earlier:</DT> +<DD> +<P> +The default is that no options are enabled. If multiple IndexOptions could apply to a directory, then the most specific one is taken complete; the options are not merged. For example: <BLOCKQUOTE><CODE> @@ -589,7 +614,56 @@ </Directory> </CODE></BLOCKQUOTE> then only <CODE>ScanHTMLTitles</CODE> will be set for the /web/docs/spec -directory.<P><HR> +directory. +</P> +</DD> +<DT>Apache 1.3.3 and later:</DT> +<DD> +<P> +Apache 1.3.3 introduced some significant changes in the handling of +<SAMP>IndexOptions</SAMP> directives. In particular, +</P> +<UL> + <LI>Multiple <SAMP>IndexOptions</SAMP> directives for a single + directory are now merged together. The result of the example above + will now be the equivalent of + <CODE>IndexOptions FancyIndexing ScanHTMLTitles</CODE>. + </LI> + <LI>The addition of the incremental syntax (<EM>i.e.</EM>, prefixing + keywords with '+' or '-'). + </LI> +</UL> +<P> +Whenever a '+' or '-' prefixed keyword is encountered, it is applied +to the current <SAMP>IndexOptions</SAMP> settings (which may have been +inherited from an upper-level directory). However, whenever an unprefixed +keyword is processed, it clears all incremental settings. Consider +the following example: +</P> +<BLOCKQUOTE><CODE>IndexOptions +ScanHTMLTitles -IconsAreLinks FancyIndexing +<BR> +IndexOptions +SuppressSize +<BR> +</CODE></BLOCKQUOTE> +<P> +The net effect is equivalent to +<CODE>IndexOptions FancyIndexing +SuppressSize</CODE>, because +the unprefixed <CODE>FancyIndexing</CODE> discarded the incremental +keywords before it, but allowed them to start accumulating again +afterward. +</P> +<P> +To unconditionally set the <CODE>IndexOptions</CODE> for a +particular directory, clearing the inherited settings, use +</P> +<BLOCKQUOTE><CODE> +IndexOptions None +<BR> +IndexOptions <EM>new-setting</EM> ... +</CODE></BLOCKQUOTE> +</DD> +</DL> +<HR> <H2><A NAME="readmename">ReadmeName</A></H2> <!--%plaintext <?INDEX {\tt ReadmeName} directive> --> 1.1083 +3 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1082 retrieving revision 1.1083 diff -u -r1.1082 -r1.1083 --- CHANGES 1998/09/28 20:04:33 1.1082 +++ CHANGES 1998/09/28 22:32:10 1.1083 @@ -1,5 +1,8 @@ Changes with Apache 1.3.3 + *) Add +/- incremental prefixes to IndexOptions keywords, and + enable merging of multiple IndexOptions directives. [Ken Coar] + *) PORT: Allow GuessOS to recognize Unixware 7.0.1 [Steve Cameron <[EMAIL PROTECTED]>] 1.94 +102 -12 apache-1.3/src/modules/standard/mod_autoindex.c Index: mod_autoindex.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_autoindex.c,v retrieving revision 1.93 retrieving revision 1.94 diff -u -r1.93 -r1.94 --- mod_autoindex.c 1998/09/24 15:53:40 1.93 +++ mod_autoindex.c 1998/09/28 22:32:12 1.94 @@ -131,6 +131,8 @@ char *default_icon; int opts; + int incremented_opts; + int decremented_opts; int name_width; int name_adjust; int icon_width; @@ -294,6 +296,10 @@ cfg = (autoindex_config_rec *) d; curopts = cfg->opts; + if (curopts & NO_OPTIONS) { + return "FancyIndexing directive conflicts with existing " + "IndexOptions None"; + } newopts = (arg ? (curopts | FANCY_INDEXING) : (curopts & ~FANCY_INDEXING)); cfg->opts = newopts; return NULL; @@ -302,51 +308,97 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr) { char *w; - int opts = 0; + int opts; + int opts_add; + int opts_remove; + char action; autoindex_config_rec *d_cfg = (autoindex_config_rec *) d; + opts = d_cfg->opts; + opts_add = d_cfg->incremented_opts; + opts_remove = d_cfg->decremented_opts; while (optstr[0]) { + int option = 0; + w = ap_getword_conf(cmd->pool, &optstr); + if ((*w == '+') || (*w == '-')) { + action = *(w++); + } + else { + action = '\0'; + } if (!strcasecmp(w, "FancyIndexing")) { - opts |= FANCY_INDEXING; + option = FANCY_INDEXING; } else if (!strcasecmp(w, "IconsAreLinks")) { - opts |= ICONS_ARE_LINKS; + option = ICONS_ARE_LINKS; } else if (!strcasecmp(w, "ScanHTMLTitles")) { - opts |= SCAN_HTML_TITLES; + option = SCAN_HTML_TITLES; } else if (!strcasecmp(w, "SuppressLastModified")) { - opts |= SUPPRESS_LAST_MOD; + option = SUPPRESS_LAST_MOD; } else if (!strcasecmp(w, "SuppressSize")) { - opts |= SUPPRESS_SIZE; + option = SUPPRESS_SIZE; } else if (!strcasecmp(w, "SuppressDescription")) { - opts |= SUPPRESS_DESC; + option = SUPPRESS_DESC; } else if (!strcasecmp(w, "SuppressHTMLPreamble")) { - opts |= SUPPRESS_PREAMBLE; + option = SUPPRESS_PREAMBLE; } else if (!strcasecmp(w, "SuppressColumnSorting")) { - opts |= SUPPRESS_COLSORT; + option = SUPPRESS_COLSORT; } else if (!strcasecmp(w, "None")) { + if (action != '\0') { + return "Cannot combine '+' or '-' with 'None' keyword"; + } opts = NO_OPTIONS; + opts_add = 0; + opts_remove = 0; } else if (!strcasecmp(w, "IconWidth")) { - d_cfg->icon_width = DEFAULT_ICON_WIDTH; + if (action != '-') { + d_cfg->icon_width = DEFAULT_ICON_WIDTH; + } + else { + d_cfg->icon_width = 0; + } } else if (!strncasecmp(w, "IconWidth=", 10)) { + if (action != '\0') { + return "Cannot combine '+' or '-' with IconWidth=n"; + } d_cfg->icon_width = atoi(&w[10]); } else if (!strcasecmp(w, "IconHeight")) { - d_cfg->icon_height = DEFAULT_ICON_HEIGHT; + if (action != '-') { + d_cfg->icon_height = DEFAULT_ICON_HEIGHT; + } + else { + d_cfg->icon_height = 0; + } } else if (!strncasecmp(w, "IconHeight=", 11)) { + if (action != '\0') { + return "Cannot combine '+' or '-' with IconHeight=n"; + } d_cfg->icon_height = atoi(&w[11]); } + else if (!strcasecmp(w, "NameWidth")) { + if (action != '-') { + return "NameWidth with no value may only appear as " + "'-NameWidth'"; + } + d_cfg->name_width = DEFAULT_NAME_WIDTH; + d_cfg->name_adjust = 0; + } else if (!strncasecmp(w, "NameWidth=", 10)) { + if (action != '\0') { + return "Cannot combine '+' or '-' with NameWidth=n"; + } if (w[10] == '*') { d_cfg->name_adjust = 1; } @@ -362,10 +414,25 @@ else { return "Invalid directory indexing option"; } + if (action == '\0') { + opts |= option; + opts_add = 0; + opts_remove = 0; + } + else if (action == '+') { + opts_add |= option; + opts_remove &= ~option; + } + else { + opts_remove |= option; + opts_add &= ~option; + } } if ((opts & NO_OPTIONS) && (opts & ~NO_OPTIONS)) { return "Cannot combine other IndexOptions keywords with 'None'"; } + d_cfg->incremented_opts = opts_add; + d_cfg->decremented_opts = opts_remove; d_cfg->opts = opts; return NULL; } @@ -418,6 +485,8 @@ new->hdr_list = ap_make_array(p, 4, sizeof(struct item)); new->rdme_list = ap_make_array(p, 4, sizeof(struct item)); new->opts = 0; + new->incremented_opts = 0; + new->decremented_opts = 0; return (void *) new; } @@ -441,10 +510,31 @@ new->icon_list = ap_append_arrays(p, add->icon_list, base->icon_list); new->rdme_list = ap_append_arrays(p, add->rdme_list, base->rdme_list); if (add->opts & NO_OPTIONS) { + /* + * If the current directory says 'no options' then we also + * clear any incremental mods from being inheritable. + */ new->opts = NO_OPTIONS; + new->incremented_opts = 0; + new->decremented_opts = 0; } else { - new->opts = base->opts | add->opts; + new->incremented_opts = (base->incremented_opts + | add->incremented_opts) + & ~add->decremented_opts; + new->decremented_opts = (base->decremented_opts + | add->decremented_opts); + /* + * We've got some local settings, so make sure we don't inadvertently + * inherit an IndexOptions None from above. + */ + new->opts = ((base->opts | add->opts) & ~NO_OPTIONS); + /* + * We're guaranteed that there'll be no overlap between + * the add-options and the remove-options. + */ + new->opts |= new->incremented_opts; + new->opts &= ~new->decremented_opts; } new->name_width = add->name_width; new->name_adjust = add->name_adjust;