mod_autoindex.c revision aa159513a8774ee6edd9f3cfabf511c52004fb05
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd/* ====================================================================
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * The Apache Software License, Version 1.1
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
6ae232055d4d8a97267517c5e50074c2c819941and * reserved.
6ae232055d4d8a97267517c5e50074c2c819941and * Redistribution and use in source and binary forms, with or without
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * modification, are permitted provided that the following conditions
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * are met:
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd * 1. Redistributions of source code must retain the above copyright
* Apache Software Foundation (http://www.apache.org/)."
* mod_autoindex.c: Handles the on-the-fly html index generation
#include "apr_strings.h"
#include "apr_fnmatch.h"
#include "apr_strings.h"
#include "apr_lib.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "ap_config.h"
#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 "mod_core.h"
#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 name_width;
int name_adjust;
int desc_width;
int desc_adjust;
int icon_width;
int icon_height;
char default_keyid;
char default_direction;
if (!to) {
if (!path) {
else if (to) {
const char *to)
return NULL;
const char *to)
char *alt;
return NULL;
#ifdef CASE_BLIND_FILESYSTEM
#define WILDCARDS_REQUIRED 0
const char *to)
return NULL;
return NULL;
name);
return NULL;
name);
return NULL;
char action;
while (optstr[0]) {
int option = 0;
action = *(w++);
opts_add = 0;
opts_remove = 0;
opts_add = 0;
opts_remove = 0;
return NULL;
return NULL;
{NULL}
return (void *) new;
return new;
struct ent {
char *name;
char *icon;
char *alt;
char *desc;
char key;
int isdir;
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 ch;
apr_size_t i, c, n;
while (!apr_file_eof(f)) {
n = sizeof(char) * AP_IOBUFSIZE;
char *title)
const char *r_accept;
const char *r_accept_enc;
* text/anything-else. The former is allowed to be processed for
ap_filter_t *f;
emit_amble = 0;
emit_H1 = 0;
if (! suppress_amble) {
emit_amble = 0;
do_emit_plain(r, f);
apr_file_close(f);
emit_H1 = 0;
if (r_accept) {
if (r_accept_enc) {
if (emit_amble) {
if (emit_H1) {
int suppress_post = 0;
int suppress_sig = 0;
* text/anything-else. The former is allowed to be processed for
ap_filter_t *f;
do_emit_plain(r, f);
apr_file_close(f);
if (!suppress_sig) {
if (!suppress_post) {
apr_size_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)
char *testpath;
return (NULL);
if (!*p->name) {
return (NULL);
return (NULL);
int autoindex_opts,
char direction,
const char *pattern)
struct ent *p;
return (NULL);
#ifndef CASE_BLIND_FILESYSTEM
!= APR_SUCCESS))
return (NULL);
!= APR_SUCCESS))
return (NULL);
return (NULL);
return (NULL);
return (NULL);
p->isdir = 0;
if (p->lm < 0) {
p->lm = 0;
if (!desc[x]) {
maxsize = 0;
--maxsize;
maxsize = 0;
--maxsize;
return desc;
int reverse;
if (!nosort) {
char *tp;
int name_width;
int desc_width;
char *name_scratch;
char *pad_scratch;
== FANCY_INDEXING) {
if (t > name_width) {
name_width = t;
if (t > desc_width) {
desc_width = t;
if (d->icon_width) {
if (d->icon_height) {
++cols;
++cols;
++cols;
++cols;
if (d->icon_width) {
if (d->icon_height) {
int nwidth;
t2 = t;
: d->default_icon),
if (d->icon_width) {
if (d->icon_height) {
: d->default_icon),
if (d->icon_width) {
if (d->icon_height) {
desc_width), r);
int result = 0;
case K_LAST_MOD:
case K_SIZE:
case K_DESC:
if (result) {
return result;
char *title_endp;
int num_ent = 0, x;
const char *qstring;
char keyid;
char direction;
char *colargs;
char *fullpath;
return HTTP_FORBIDDEN;
ap_set_etag(r);
if (r->header_only) {
& ~TABLE_INDEXING;
if (eos) {
if (*pstring) {
if (p != NULL) {
head = p;
num_ent++;
const char *savename;
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);
int allow_opts;
return DECLINED;
return DECLINED;
int errstatus;
return errstatus;
return index_directory(r, d);
return HTTP_FORBIDDEN;