mod_autoindex.c revision 0c9a934def126ac34fd6bfc8d25c5cb763ef126d
e1e8390280254f7f0580d701e583f670643d4f3fnilgun/* ====================================================================
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Redistribution and use in source and binary forms, with or without
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * modification, are permitted provided that the following conditions
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 1. Redistributions of source code must retain the above copyright
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * notice, this list of conditions and the following disclaimer.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 2. Redistributions in binary form must reproduce the above copyright
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * notice, this list of conditions and the following disclaimer in
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * the documentation and/or other materials provided with the
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * distribution.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 3. All advertising materials mentioning features or use of this
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * software must display the following acknowledgment:
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * "This product includes software developed by the Apache Group
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * for use in the Apache HTTP server project (http://www.apache.org/)."
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 4. The names "Apache Server" and "Apache Group" must not be used to
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * endorse or promote products derived from this software without
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * prior written permission. For written permission, please contact
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * apache@apache.org.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 5. Products derived from this software may not be called "Apache"
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * nor may "Apache" appear in their names without prior written
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * permission of the Apache Group.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * 6. Redistributions of any form whatsoever must retain the following
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * acknowledgment:
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * "This product includes software developed by the Apache Group
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * for use in the Apache HTTP server project (http://www.apache.org/)."
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * OF THE POSSIBILITY OF SUCH DAMAGE.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * ====================================================================
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * This software consists of voluntary contributions made by many
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * individuals on behalf of the Apache Group and was originally based
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * on public domain software written at the National Center for
2704de98885368683621b01c8f8f4e4b01557611takashi * Supercomputing Applications, University of Illinois, Urbana-Champaign.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * For more information on the Apache Group and the Apache HTTP server
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * project, please see <http://www.apache.org/>.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * mod_autoindex.c: Handles the on-the-fly html index generation
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Rob McCool
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Adapted to Apache by rst.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun/****************************************************************
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Handling configuration directives...
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Define keys for sorting.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun#define K_SIZE 'S' /* Size (absolute, not as displayed) */
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * These are the dimensions of the default icons supplied with Apache.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * Other default dimensions.
e1e8390280254f7f0580d701e583f670643d4f3fnilguntypedef struct ai_desc_t {
char *data)
if (!to) {
if (!path) {
else if (to) {
return NULL;
char *alt;
return NULL;
#ifdef CASE_BLIND_FILESYSTEM
#define WILDCARDS_REQUIRED 0
return NULL;
return NULL;
name);
return NULL;
name);
return NULL;
int curopts;
int newopts;
return NULL;
int opts;
int opts_add;
int opts_remove;
char action;
while (optstr[0]) {
int option = 0;
action = *(w++);
opts_add = 0;
opts_remove = 0;
opts_add = 0;
opts_remove = 0;
return NULL;
char *key)
return NULL;
{NULL}
return (void *) new;
return new;
struct ent {
char *name;
char *icon;
char *alt;
char *desc;
int ascending;
char key;
if (!*(p->apply_to)) {
return p->data;
return p->data;
else if (!path_only) {
if (!content_encoding) {
if (content_type
p->apply_to)) {
return p->data;
p->apply_to)) {
return p->data;
return NULL;
request_rec r;
* Look through the list of pattern/description pairs and return the first one
#ifdef CASE_BLIND_FILESYSTEM
#define MATCH_FLAGS 0
const char *filename_only;
const char *filename;
int found;
if (found) {
return NULL;
char *tt;
tt++;
char *ap;
ap++;
#ifndef CASE_BLIND_FILESYSTEM
int i, n, c, ch;
while (!ap_eof(f)) {
n = sizeof(char) * IOBUFSIZE;
char *title)
ap_file_t *f;
* text/anything-else. The former is allowed to be processed for
emit_amble = 0;
emit_H1 = 0;
if (! suppress_amble) {
emit_amble = 0;
do_emit_plain(r, f);
ap_close(f);
emit_H1 = 0;
if (emit_amble) {
if (emit_H1) {
ap_file_t *f;
int suppress_post = 0;
int suppress_sig = 0;
* text/anything-else. The former is allowed to be processed for
do_emit_plain(r, f);
ap_close(f);
if (!suppress_sig) {
if (!suppress_post) {
return NULL;
&& !r->content_encoding) {
return NULL;
return NULL;
for (x = 0, p = 0; titlebuf[x]; x++) {
if (!find[++p]) {
for (y = x; titlebuf[y]; y++) {
return NULL;
char direction)
struct ent *p;
return (NULL);
return (NULL);
if (p->lm < 0) {
p->lm = 0;
int autoindex_opts)
if (!desc[x]) {
maxsize = 0;
--maxsize;
maxsize = 0;
--maxsize;
return desc;
int reverse;
if (!nosort) {
char *tp;
int name_width;
char *name_scratch;
char *pad_scratch;
if (t > name_width) {
name_width = t;
d->icon_height,
d->icon_width
int nwidth;
ap_getparents(t);
t2 = t;
: d->default_icon),
NULL);
autoindex_opts), r);
int result = 0;
case K_LAST_MOD:
case K_SIZE:
case K_DESC:
if (result) {
return result;
char *title_endp;
ap_dir_t *d;
int num_ent = 0, x;
const char *qstring;
char keyid;
char direction;
return HTTP_FORBIDDEN;
if (r->header_only) {
ap_closedir(d);
while (ap_readdir(d)) {
char *d_name;
if (p != NULL) {
head = p;
num_ent++;
if (num_ent > 0) {
p = head;
ar[x++] = p;
p = p->next;
(int (*)(const void *, const void *)) dsortf);
ap_closedir(d);
return DECLINED;
return index_directory(r, d);
return HTTP_FORBIDDEN;
{NULL}