33#define APR_WANT_STRFUNC
48module AP_MODULE_DECLARE_DATA autoindex_module;
55#define NO_OPTIONS (1 << 0)
56#define ICONS_ARE_LINKS (1 << 1)
57#define SCAN_HTML_TITLES (1 << 2)
58#define SUPPRESS_ICON (1 << 3)
59#define SUPPRESS_LAST_MOD (1 << 4)
60#define SUPPRESS_SIZE (1 << 5)
61#define SUPPRESS_DESC (1 << 6)
62#define SUPPRESS_PREAMBLE (1 << 7)
63#define SUPPRESS_COLSORT (1 << 8)
64#define SUPPRESS_RULES (1 << 9)
65#define FOLDERS_FIRST (1 << 10)
66#define VERSION_SORT (1 << 11)
67#define TRACK_MODIFIED (1 << 12)
68#define FANCY_INDEXING (1 << 13)
69#define TABLE_INDEXING (1 << 14)
70#define IGNORE_CLIENT (1 << 15)
71#define IGNORE_CASE (1 << 16)
72#define EMIT_XHTML (1 << 17)
73#define SHOW_FORBIDDEN (1 << 18)
74#define ADDALTCLASS (1 << 19)
75#define OPTION_UNSET (1 << 20)
90#define D_ASCENDING 'A'
91#define D_DESCENDING 'D'
97#define DEFAULT_ICON_WIDTH 20
98#define DEFAULT_ICON_HEIGHT 22
103#define DEFAULT_NAME_WIDTH 23
104#define DEFAULT_DESC_WIDTH 23
152#define BY_ENCODING &c_by_encoding
153#define BY_TYPE &c_by_type
154#define BY_PATH &c_by_path
178 "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
179 " <head>\n <title>Index of ",
title,
184 " <title>Index of ",
title,
188 if (
d->style_sheet !=
NULL) {
189 ap_rvputs(
r,
" <link rel=\"stylesheet\" href=\"",
d->style_sheet,
190 "\" type=\"text/css\"",
xhtml ?
" />\n" :
">\n",
NULL);
192 if (
d->head_insert !=
NULL) {
227 to =
"^^DIRECTORY^^";
246 if (icon[0] ==
'(') {
251 return "missing closing paren";
259 to =
"^^DIRECTORY^^";
289#ifdef CASE_BLIND_FILESYSTEM
290#define WILDCARDS_REQUIRED 1
292#define WILDCARDS_REQUIRED 0
336 opts_add =
d_cfg->incremented_opts;
337 opts_remove =
d_cfg->decremented_opts;
343 if ((*w ==
'+') || (*w ==
'-')) {
370 else if (!
strcasecmp(w,
"SuppressColumnSorting")) {
373 else if (!
strcasecmp(w,
"SuppressDescription")) {
376 else if (!
strcasecmp(w,
"SuppressHTMLPreamble")) {
382 else if (!
strcasecmp(w,
"SuppressLastModified")) {
407 if (action !=
'\0') {
408 return "Cannot combine '+' or '-' with 'None' keyword";
419 d_cfg->icon_width = 0;
424 return "Cannot combine '-' with IconWidth=n";
433 d_cfg->icon_height = 0;
438 return "Cannot combine '-' with IconHeight=n";
444 return "NameWidth with no value may only appear as "
452 return "Cannot combine '-' with NameWidth=n";
461 return "NameWidth value must be greater than 5";
467 else if (!
strcasecmp(w,
"DescriptionWidth")) {
469 return "DescriptionWidth with no value may only appear as "
470 "'-DescriptionWidth'";
475 else if (!
strncasecmp(w,
"DescriptionWidth=", 17)) {
477 return "Cannot combine '-' with DescriptionWidth=n";
486 return "DescriptionWidth value must be greater than 12";
498 else if (!
strcasecmp(w,
"UseOldDateFormat")) {
499 d_cfg->datetime_format =
"%d-%b-%Y %H:%M";
502 return "Invalid directory indexing option";
504 if (action ==
'\0') {
509 else if (action ==
'+') {
519 return "Cannot combine other IndexOptions keywords with 'None'";
521 d_cfg->incremented_opts = opts_add;
522 d_cfg->decremented_opts = opts_remove;
528 const char *direction,
const char *
key)
535 else if (!
strcasecmp(direction,
"Descending")) {
539 return "First keyword must be 'Ascending' or 'Descending'";
555 return "Second keyword must be 'Name', 'Date', 'Size', or "
562#define DIR_CMD_PERMS OR_INDEXES
567 "an icon URL followed by one or more filenames"),
569 "an icon URL followed by one or more MIME types"),
571 "an icon URL followed by one or more content encodings"),
573 "alternate descriptive text followed by one or more "
576 "alternate descriptive text followed by one or more MIME "
579 "alternate descriptive text followed by one or more "
580 "content encodings"),
582 "one or more index options [+|-][]"),
584 "{Ascending,Descending} {Name,Size,Description,Date}"),
586 "one or more file extensions"),
590 "Reset the inherited list of IndexIgnore filenames"),
592 "Descriptive text followed by one or more filenames"),
600 "The FancyIndexing directive is no longer supported. "
601 "Use IndexOptions FancyIndexing."),
620 new->icon_height = 0;
630 new->incremented_opts = 0;
631 new->decremented_opts = 0;
632 new->default_keyid =
'\0';
633 new->default_direction =
'\0';
646 :
base->default_icon;
672 new->incremented_opts = 0;
673 new->decremented_opts = 0;
683 new->incremented_opts = (
base->incremented_opts
686 new->decremented_opts = (
base->decremented_opts
699 new->opts = add->
opts;
705 new->opts |=
new->incremented_opts;
706 new->opts &=
~new->decremented_opts;
714 new->name_width =
base->name_width;
715 new->name_adjust =
base->name_adjust;
726 new->desc_width =
base->desc_width;
727 new->desc_adjust =
base->desc_adjust;
735 :
base->default_keyid;
737 :
base->default_direction;
772 if (!*(
p->apply_to)) {
781 if (!content_encoding) {
810#define find_icon(d,p,t) find_item_by_request(p,d->icon_list,t)
811#define find_alt(d,p,t) find_item_by_request(p,d->alt_list,t)
812#define find_default_icon(d,n) find_item(NULL, NULL, n, d->icon_list, 1)
813#define find_default_alt(d,n) find_item(NULL, NULL, n, d->alt_list, 1)
823#ifdef CASE_BLIND_FILESYSTEM
824#define MATCH_FLAGS APR_FNM_CASE_BLIND
846 for (
i = 0;
i <
dcfg->desc_list->nelts; ++
i) {
858 if (
tuple->wildcards) {
865 return tuple->description;
896#ifndef CASE_BLIND_FILESYSTEM
968 for (
i =
c;
i <
n;
i++) {
979 else if (
ch ==
'>') {
982 else if (
ch ==
'&') {
1029 && (
rr->filename !=
NULL)
1036 if (
rr->content_type !=
NULL) {
1058 for (
f=
rr->output_filters;
1110 if (
d->style_sheet !=
NULL) {
1147 && (
rr->filename !=
NULL)
1154 if (
rr->content_type !=
NULL) {
1157 for (
f=
rr->output_filters;
1271 ||
p->name[0] ==
'\0') {
1294 p->alt =
"PARENTDIR";
1374 p->lm =
rr->finfo.mtime;
1382 rr->filename[strlen(
rr->filename) - 1] =
'\0';
1396 p->size =
rr->finfo.size;
1442 if (
desc[x] ==
'<') {
1443 while (
desc[x] !=
'>') {
1451 else if (
desc[x] ==
'&') {
1454 for ( ;
desc[x] !=
';'; ++x) {
1455 if (
desc[x] ==
'\0') {
1506 char direction,
const char *
colargs)
1515 char *datetime_format;
1523 name_width =
d->name_width;
1524 desc_width =
d->desc_width;
1525 datetime_format =
d->datetime_format ?
d->datetime_format :
"%Y-%m-%d %H:%M";
1530 for (x = 0; x <
n; x++) {
1532 if (
t > name_width) {
1539 for (x = 0; x <
n; x++) {
1542 if (
t > desc_width) {
1556 if (
d->style_sheet !=
NULL) {
1558 ap_rputs(
" <table id=\"indexlist\">\n <tr class=\"indexhead\">",
r);
1563 ap_rvputs(
r,
"<th", (
d->style_sheet !=
NULL) ?
" class=\"indexcolicon\">" :
" valign=\"top\">",
NULL);
1566 "\" alt=\"[ICO]\"",
NULL);
1567 if (
d->icon_width) {
1570 if (
d->icon_height) {
1589 ap_rvputs(
r,
"</th><th", (
d->style_sheet !=
NULL) ?
" class=\"indexcollastmod\">" :
">",
NULL);
1595 ap_rvputs(
r,
"</th><th", (
d->style_sheet !=
NULL) ?
" class=\"indexcolsize\">" :
">",
NULL);
1601 ap_rvputs(
r,
"</th><th", (
d->style_sheet !=
NULL) ?
" class=\"indexcoldesc\">" :
">",
NULL);
1608 " <tr%s><th colspan=\"%d\">"
1609 "<hr%s></th></tr>\n",
1610 (
d->style_sheet !=
NULL) ?
" class=\"indexbreakrow\"" :
"",
1621 "\" alt=\"Icon \"",
NULL);
1622 if (
d->icon_width) {
1625 if (
d->icon_height) {
1674 for (x = 0; x <
n; x++) {
1683 if (!x &&
t[0] ==
'/') {
1684 t2 =
"Parent Directory";
1692 if (
d->style_sheet !=
NULL) {
1700 ap_rvputs(
r,
" <tr class=\"", ( x & 0x1) ?
"odd" :
"even",
"\">",
NULL);
1707 ap_rvputs(
r,
"<td", (
d->style_sheet !=
NULL) ?
" class=\"indexcolicon\">" :
" valign=\"top\">",
NULL);
1711 if ((
ar[x]->
icon) ||
d->default_icon) {
1716 "\" alt=\"[", (
ar[x]->
alt ?
ar[x]->
alt :
" "),
1718 if (
d->icon_width) {
1721 if (
d->icon_height) {
1741 ap_rvputs(
r,
"<td", (
d->style_sheet !=
NULL) ?
" class=\"indexcolname\">" :
">",
"<a href=\"",
anchor,
"\">",
1746 if (
nwidth > name_width) {
1755 ap_rvputs(
r,
"<td", (
d->style_sheet !=
NULL) ?
" class=\"indexcolname\">" :
">",
"<a href=\"",
anchor,
"\">",
1760 if (
ar[x]->
lm != -1) {
1767 ap_rvputs(
r,
"</td><td", (
d->style_sheet !=
NULL) ?
" class=\"indexcollastmod\">" :
" align=\"right\">", time_str,
" ",
NULL);
1770 ap_rvputs(
r,
"</td><td", (
d->style_sheet !=
NULL) ?
" class=\"indexcollastmod\"> " :
"> ",
NULL);
1775 ap_rvputs(
r,
"</td><td", (
d->style_sheet !=
NULL) ?
" class=\"indexcolsize\">" :
" align=\"right\">",
1781 ap_rvputs(
r,
"</td><td", (
d->style_sheet !=
NULL) ?
" class=\"indexcoldesc\">" :
">",
ar[x]->desc,
NULL);
1784 ap_rvputs(
r,
"</td><td", (
d->style_sheet !=
NULL) ?
" class=\"indexcoldesc\">" :
">",
1791 ap_rvputs(
r,
"</td><td", (
d->style_sheet !=
NULL) ?
" class=\"indexcoldesc\">" :
">",
" ",
NULL);
1801 if ((
ar[x]->
icon) ||
d->default_icon) {
1806 "\" alt=\"[", (
ar[x]->
alt ?
ar[x]->
alt :
" "),
1808 if (
d->icon_width) {
1811 if (
d->icon_height) {
1831 if (
nwidth > name_width) {
1848 if (
ar[x]->
lm != -1) {
1882 "</a></li>\n",
NULL);
1920 if ((*e1)->name[0] ==
'/') {
1923 if ((*e2)->name[0] ==
'/') {
1930 if ((*e1)->isdir != (*e2)->isdir) {
1931 return (*e1)->isdir ? -1 : 1;
1937 if ((*e1)->ascending) {
1948 if (c1->
lm > c2->
lm) {
1951 else if (c1->
lm < c2->
lm) {
2023 struct ent *head, *
p;
2032 char *ctype =
"text/html";
2037 "Can't open directory for index: %s",
r->
filename);
2048#if APR_HAS_UNICODE_FS
2051 charset =
"ISO-8859-1";
2159 while (*
eos && *
eos !=
'&' && *
eos !=
';') {
2268 (
int (*)(
const void *,
const void *))
dsortf);
2327 "Cannot serve directory %s: No matching DirectoryIndex (%s) found, and "
2328 "server-generated directory index forbidden by "
2329 "Options directive",
2331 index_names ? index_names :
"none");
Symbol export macros and hook functions.
APR general purpose library routines.
apr_size_t const unsigned char unsigned int unsigned int d
apr_array_append(apr_pool_t *p, const apr_array_header_t *first, const apr_array_header_t *second)
APR Standard Headers Support.
#define AP_INIT_TAKE1(directive, func, mconfig, where, help)
#define ap_get_module_config(v, m)
#define AP_INIT_ITERATE2(directive, func, mconfig, where, help)
#define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help)
#define AP_DECLARE_MODULE(foo)
#define AP_INIT_FLAG(directive, func, mconfig, where, help)
const char * ap_set_deprecated(cmd_parms *cmd, void *struct_ptr, const char *arg)
#define AP_INIT_ITERATE(directive, func, mconfig, where, help)
#define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help)
void ap_hook_handler(ap_HOOK_handler_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
const char * ap_set_string_slot(cmd_parms *cmd, void *struct_ptr, const char *arg)
request_rec int int apr_table_t const char * path
const char * ap_set_flag_slot(cmd_parms *cmd, void *struct_ptr, int arg)
#define AP_INIT_TAKE2(directive, func, mconfig, where, help)
#define DOCTYPE_XHTML_1_0T
ap_filter_rec_t * ap_subreq_core_filter_handle
int ap_allow_options(request_rec *r)
const unsigned char * buf
void ap_set_etag(request_rec *r)
int ap_rvputs(request_rec *r,...)
int ap_rprintf(request_rec *r, const char *fmt,...) __attribute__((format(printf
static APR_INLINE int ap_rputs(const char *str, request_rec *r)
int ap_rputc(int c, request_rec *r)
void ap_set_last_modified(request_rec *r)
void ap_set_content_type(request_rec *r, const char *ct)
int ap_discard_request_body(request_rec *r)
request_rec * ap_sub_req_lookup_dirent(const apr_finfo_t *finfo, const request_rec *r, int subtype, ap_filter_t *next_filter)
request_rec * ap_sub_req_lookup_uri(const char *new_uri, const request_rec *r, ap_filter_t *next_filter)
int ap_run_sub_req(request_rec *r)
void ap_destroy_sub_req(request_rec *r)
#define AP_SUBREQ_NO_ARGS
void ap_update_mtime(request_rec *r, apr_time_t dependency_mtime)
#define APR_STATUS_IS_EINTR(s)
#define APR_STATUS_IS_INCOMPLETE(s)
#define ap_is_HTTP_REDIRECT(x)
#define HTTP_UNAUTHORIZED
#define ap_is_HTTP_SUCCESS(x)
#define STANDARD20_MODULE_STUFF
#define AP_NORMALIZE_ALLOW_RELATIVE
int ap_strcmp_match(const char *str, const char *expected)
int ap_strcasecmp_match(const char *str, const char *expected)
char * ap_make_full_path(apr_pool_t *a, const char *dir, const char *f)
int ap_cstr_casecmp(const char *s1, const char *s2)
const char * ap_psignature(const char *prefix, request_rec *r)
#define ap_escape_uri(ppool, path)
int ap_normalize_path(char *path, unsigned int flags)
#define ap_strrchr_c(s, c)
#define ap_strstr_c(s, c)
#define ap_strchr_c(s, c)
char * ap_make_dirstr_parent(apr_pool_t *p, const char *s)
int ap_cstr_casecmpn(const char *s1, const char *s2, apr_size_t n)
int ap_is_matchexp(const char *str)
#define ap_escape_html(p, s)
void ap_str_tolower(char *s)
int ap_unescape_url(char *url)
int ap_ind(const char *str, char c)
char * ap_field_noparam(apr_pool_t *p, const char *intype)
#define AP_NORMALIZE_NOT_ABOVE_ROOT
char * ap_os_escape_path(apr_pool_t *p, const char *path, int partial)
char * ap_getword_nc(apr_pool_t *p, char **line, char stop)
const apr_array_header_t * list
apr_int32_t apr_dir_t * thedir
apr_array_header_t ** result
#define APR_FNM_CASE_BLIND
int strcasecmp(const char *a, const char *b)
int strncasecmp(const char *a, const char *b, size_t n)
apr_vformatter_buff_t * c
apr_vformatter_buff_t const char va_list ap
#define apr_pool_create(newpool, parent)
#define apr_pcalloc(p, size)
apr_size_t const char * filename
const apr_array_header_t * arr
#define AP_IS_DEFAULT_HANDLER_NAME(x)
#define INCLUDES_MAGIC_TYPE
static void output_directories(struct ent **ar, int n, autoindex_config_rec *d, request_rec *r, apr_int32_t autoindex_opts, char keyid, char direction, const char *colargs)
static int ignore_entry(autoindex_config_rec *d, char *path)
static void * merge_autoindex_configs(apr_pool_t *p, void *basev, void *addv)
struct autoindex_config_struct autoindex_config_rec
static struct ent * make_autoindex_entry(const apr_finfo_t *dirent, int autoindex_opts, autoindex_config_rec *d, request_rec *r, char keyid, char direction, const char *pattern)
static char c_by_encoding
#define DEFAULT_NAME_WIDTH
#define DEFAULT_DESC_WIDTH
static const command_rec autoindex_cmds[]
#define find_alt(d, p, t)
static const char * add_desc(cmd_parms *cmd, void *d, const char *desc, const char *to)
static void emit_head(request_rec *r, char *header_fname, int suppress_amble, int emit_xhtml, char *title)
static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble)
static int handle_autoindex(request_rec *r)
static const char * add_icon(cmd_parms *cmd, void *d, const char *icon, const char *to)
static char * find_desc(autoindex_config_rec *dcfg, const char *filename_full)
static void * create_autoindex_config(apr_pool_t *p, char *dummy)
#define DEFAULT_ICON_WIDTH
static int dsortf(struct ent **e1, struct ent **e2)
static char * terminate_description(autoindex_config_rec *d, char *desc, apr_int32_t autoindex_opts, int desc_width)
static void register_hooks(apr_pool_t *p)
static APR_INLINE int response_is_html(request_rec *r)
#define DEFAULT_ICON_HEIGHT
static char * find_item(const char *content_type, const char *content_encoding, char *path, apr_array_header_t *list, int path_only)
static const char * add_alt(cmd_parms *cmd, void *d, const char *alt, const char *to)
static const char * add_ignore(cmd_parms *cmd, void *d, const char *ext)
static struct ent * make_parent_entry(apr_int32_t autoindex_opts, autoindex_config_rec *d, request_rec *r, char keyid, char direction)
#define WILDCARDS_REQUIRED
#define SUPPRESS_PREAMBLE
#define find_default_alt(d, n)
#define SUPPRESS_LAST_MOD
static void push_item(apr_array_header_t *arr, char *type, const char *to, const char *path, const char *data)
static const char * set_default_order(cmd_parms *cmd, void *m, const char *direction, const char *key)
static void emit_link(request_rec *r, const char *anchor, char column, char curkey, char curdirection, const char *colargs, int nosort)
static char * find_item_by_request(request_rec *r, apr_array_header_t *list, int path_only)
#define find_icon(d, p, t)
static char * find_title(request_rec *r)
static void do_emit_plain(request_rec *r, apr_file_t *f)
static void emit_preamble(request_rec *r, int xhtml, const char *title)
#define find_default_icon(d, n)
static const char * add_opts(cmd_parms *cmd, void *d, int argc, char *const argv[])
static int index_directory(request_rec *r, autoindex_config_rec *autoindex_conf)
mod_core private header file
The representation of a filter chain.
apr_array_header_t * alt_list
apr_array_header_t * ign_list
apr_array_header_t * desc_list
apr_array_header_t * icon_list
apr_int32_t decremented_opts
apr_int32_t incremented_opts
A structure that represents the current request.
const char * content_type
struct ap_filter_t * output_filters
struct ap_conf_vector_t * per_dir_config
const char * content_encoding
abts_suite * testpath(abts_suite *suite)
apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, apr_dir_t *thedir)
apr_status_t apr_dir_close(apr_dir_t *thedir)
apr_status_t apr_dir_open(apr_dir_t **new, const char *dirname, apr_pool_t *pool)
apr_status_t apr_strftime(char *s, apr_size_t *retsize, apr_size_t max, const char *format, apr_time_exp_t *xt)