mod_autoindex.c revision da38e62659addbc4bf0fe3ab4c8c5cf54604e5f9
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi/* ====================================================================
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * Redistribution and use in source and binary forms, with or without
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * modification, are permitted provided that the following conditions
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * are met:
3e6b8c7840a46cdccd46b7a4b1902c2bc82f6cc2gryzor * 1. Redistributions of source code must retain the above copyright
3e6b8c7840a46cdccd46b7a4b1902c2bc82f6cc2gryzor * notice, this list of conditions and the following disclaimer.
6ae232055d4d8a97267517c5e50074c2c819941and * 2. Redistributions in binary form must reproduce the above copyright
412bf2d2fd3ee0608bc0767e2281e47ea317963end * notice, this list of conditions and the following disclaimer in
6ae232055d4d8a97267517c5e50074c2c819941and * the documentation and/or other materials provided with the
412bf2d2fd3ee0608bc0767e2281e47ea317963end * distribution.
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * 3. All advertising materials mentioning features or use of this
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * software must display the following acknowledgment:
* for use in the Apache HTTP server project (http://www.apache.org/)."
* for use in the Apache HTTP server project (http://www.apache.org/)."
* project, please see <http://www.apache.org/>.
* mod_autoindex.c: Handles the on-the-fly html index generation
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_request.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
#include "fnmatch.h"
#define NO_HRULE 0
#define END_MATTER 0
#define K_NOPAD 0
#define K_NOADJUST 0
struct item {
char *type;
char *apply_to;
char *apply_path;
char *data;
typedef struct ai_desc_t {
char *pattern;
char *description;
int full_path;
int wildcards;
} ai_desc_t;
typedef struct autoindex_config_struct {
char *default_icon;
int opts;
int incremented_opts;
int decremented_opts;
int name_width;
int name_adjust;
int icon_width;
int icon_height;
char *default_order;
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, c, ch;
ap_ssize_t n;
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) {
ap_ssize_t n;
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);
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}