You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by aa...@apache.org on 2001/12/27 19:07:23 UTC
cvs commit: httpd-2.0/modules/generators mod_autoindex.c
aaron 01/12/27 10:07:22
Modified: modules/generators mod_autoindex.c
Log:
Just style changes. Really just 's/\t/ /' since the tabstop alignment
was pretty good. Added a couple braces and spaces here and there.
Revision Changes Path
1.89 +777 -776 httpd-2.0/modules/generators/mod_autoindex.c
Index: mod_autoindex.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_autoindex.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- mod_autoindex.c 2001/10/25 20:36:10 1.88
+++ mod_autoindex.c 2001/12/27 18:07:22 1.89
@@ -104,8 +104,8 @@
#define SUPPRESS_PREAMBLE 0x0080
#define SUPPRESS_COLSORT 0x0100
#define SUPPRESS_RULES 0x0200
-#define FOLDERS_FIRST 0x0400
-#define VERSION_SORT 0x0800
+#define FOLDERS_FIRST 0x0400
+#define VERSION_SORT 0x0800
#define TRACK_MODIFIED 0x1000
#define FANCY_INDEXING 0x2000
#define TABLE_INDEXING 0x4000
@@ -118,10 +118,10 @@
/*
* Define keys for sorting.
*/
-#define K_NAME 'N' /* Sort by file name (default) */
-#define K_LAST_MOD 'M' /* Last modification date */
-#define K_SIZE 'S' /* Size (absolute, not as displayed) */
-#define K_DESC 'D' /* Description */
+#define K_NAME 'N' /* Sort by file name (default) */
+#define K_LAST_MOD 'M' /* Last modification date */
+#define K_SIZE 'S' /* Size (absolute, not as displayed) */
+#define K_DESC 'D' /* Description */
#define K_VALID "NMSD" /* String containing _all_ valid K_ opts */
#define D_ASCENDING 'A'
@@ -192,20 +192,20 @@
static void emit_preamble(request_rec *r, char *title)
{
ap_rvputs(r, DOCTYPE_HTML_3_2,
- "<html>\n <head>\n <title>Index of ", title,
- "</title>\n </head>\n <body>\n", NULL);
+ "<html>\n <head>\n <title>Index of ", title,
+ "</title>\n </head>\n <body>\n", NULL);
}
static void push_item(apr_array_header_t *arr, char *type, const char *to,
- const char *path, const char *data)
+ const char *path, const char *data)
{
struct item *p = (struct item *) apr_array_push(arr);
if (!to) {
- to = "";
+ to = "";
}
if (!path) {
- path = "";
+ path = "";
}
p->type = type;
@@ -213,64 +213,64 @@
p->apply_path = apr_pstrcat(arr->pool, path, "*", NULL);
if ((type == BY_PATH) && (!ap_is_matchexp(to))) {
- p->apply_to = apr_pstrcat(arr->pool, "*", to, NULL);
+ p->apply_to = apr_pstrcat(arr->pool, "*", to, NULL);
}
else if (to) {
- p->apply_to = apr_pstrdup(arr->pool, to);
+ p->apply_to = apr_pstrdup(arr->pool, to);
}
else {
- p->apply_to = NULL;
+ p->apply_to = NULL;
}
}
static const char *add_alt(cmd_parms *cmd, void *d, const char *alt,
- const char *to)
+ const char *to)
{
if (cmd->info == BY_PATH) {
if (!strcmp(to, "**DIRECTORY**")) {
- to = "^^DIRECTORY^^";
- }
+ to = "^^DIRECTORY^^";
+ }
}
if (cmd->info == BY_ENCODING) {
char *tmp = apr_pstrdup(cmd->pool, to);
- ap_str_tolower(tmp);
- to = tmp;
+ ap_str_tolower(tmp);
+ to = tmp;
}
push_item(((autoindex_config_rec *) d)->alt_list, cmd->info, to,
- cmd->path, alt);
+ cmd->path, alt);
return NULL;
}
static const char *add_icon(cmd_parms *cmd, void *d, const char *icon,
- const char *to)
+ const char *to)
{
char *iconbak = apr_pstrdup(cmd->pool, icon);
if (icon[0] == '(') {
- char *alt;
- char *cl = strchr(iconbak, ')');
+ char *alt;
+ char *cl = strchr(iconbak, ')');
- if (cl == NULL) {
- return "missing closing paren";
- }
- alt = ap_getword_nc(cmd->pool, &iconbak, ',');
- *cl = '\0'; /* Lose closing paren */
- add_alt(cmd, d, &alt[1], to);
+ if (cl == NULL) {
+ return "missing closing paren";
+ }
+ alt = ap_getword_nc(cmd->pool, &iconbak, ',');
+ *cl = '\0'; /* Lose closing paren */
+ add_alt(cmd, d, &alt[1], to);
}
if (cmd->info == BY_PATH) {
if (!strcmp(to, "**DIRECTORY**")) {
- to = "^^DIRECTORY^^";
- }
+ to = "^^DIRECTORY^^";
+ }
}
if (cmd->info == BY_ENCODING) {
char *tmp = apr_pstrdup(cmd->pool, to);
- ap_str_tolower(tmp);
- to = tmp;
+ ap_str_tolower(tmp);
+ to = tmp;
}
push_item(((autoindex_config_rec *) d)->icon_list, cmd->info, to,
- cmd->path, iconbak);
+ cmd->path, iconbak);
return NULL;
}
@@ -297,7 +297,7 @@
#endif
static const char *add_desc(cmd_parms *cmd, void *d, const char *desc,
- const char *to)
+ const char *to)
{
autoindex_config_rec *dcfg = (autoindex_config_rec *) d;
ai_desc_t *desc_entry;
@@ -306,15 +306,15 @@
desc_entry = (ai_desc_t *) apr_array_push(dcfg->desc_list);
desc_entry->full_path = (ap_strchr_c(to, '/') == NULL) ? 0 : 1;
desc_entry->wildcards = (WILDCARDS_REQUIRED
- || desc_entry->full_path
- || apr_is_fnmatch(to));
+ || desc_entry->full_path
+ || apr_is_fnmatch(to));
if (desc_entry->wildcards) {
- prefix = desc_entry->full_path ? "*/" : "*";
- desc_entry->pattern = apr_pstrcat(dcfg->desc_list->pool,
- prefix, to, "*", NULL);
+ prefix = desc_entry->full_path ? "*/" : "*";
+ desc_entry->pattern = apr_pstrcat(dcfg->desc_list->pool,
+ prefix, to, "*", NULL);
}
else {
- desc_entry->pattern = apr_pstrdup(dcfg->desc_list->pool, to);
+ desc_entry->pattern = apr_pstrdup(dcfg->desc_list->pool, to);
}
desc_entry->description = apr_pstrdup(dcfg->desc_list->pool, desc);
return NULL;
@@ -329,14 +329,14 @@
static const char *add_header(cmd_parms *cmd, void *d, const char *name)
{
push_item(((autoindex_config_rec *) d)->hdr_list, 0, NULL, cmd->path,
- name);
+ name);
return NULL;
}
static const char *add_readme(cmd_parms *cmd, void *d, const char *name)
{
push_item(((autoindex_config_rec *) d)->rdme_list, 0, NULL, cmd->path,
- name);
+ name);
return NULL;
}
@@ -353,121 +353,121 @@
opts_add = d_cfg->incremented_opts;
opts_remove = d_cfg->decremented_opts;
while (optstr[0]) {
- int option = 0;
+ int option = 0;
- w = ap_getword_conf(cmd->pool, &optstr);
- if ((*w == '+') || (*w == '-')) {
- action = *(w++);
- }
- else {
- action = '\0';
- }
- if (!strcasecmp(w, "FancyIndexing")) {
- option = FANCY_INDEXING;
- }
+ w = ap_getword_conf(cmd->pool, &optstr);
+ if ((*w == '+') || (*w == '-')) {
+ action = *(w++);
+ }
+ else {
+ action = '\0';
+ }
+ if (!strcasecmp(w, "FancyIndexing")) {
+ option = FANCY_INDEXING;
+ }
else if (!strcasecmp(w, "FoldersFirst")) {
option = FOLDERS_FIRST;
}
- else if (!strcasecmp(w, "HTMLTable")) {
- option = TABLE_INDEXING;
- }
- else if (!strcasecmp(w, "IconsAreLinks")) {
- option = ICONS_ARE_LINKS;
- }
+ else if (!strcasecmp(w, "HTMLTable")) {
+ option = TABLE_INDEXING;
+ }
+ else if (!strcasecmp(w, "IconsAreLinks")) {
+ option = ICONS_ARE_LINKS;
+ }
else if (!strcasecmp(w, "IgnoreClient")) {
option = IGNORE_CLIENT;
- }
- else if (!strcasecmp(w, "ScanHTMLTitles")) {
- option = SCAN_HTML_TITLES;
- }
+ }
+ else if (!strcasecmp(w, "ScanHTMLTitles")) {
+ option = SCAN_HTML_TITLES;
+ }
else if (!strcasecmp(w, "SuppressColumnSorting")) {
option = SUPPRESS_COLSORT;
- }
- else if (!strcasecmp(w, "SuppressDescription")) {
- option = SUPPRESS_DESC;
- }
- else if (!strcasecmp(w, "SuppressHTMLPreamble")) {
- option = SUPPRESS_PREAMBLE;
- }
- else if (!strcasecmp(w, "SuppressIcon")) {
- option = SUPPRESS_ICON;
- }
- else if (!strcasecmp(w, "SuppressLastModified")) {
- option = SUPPRESS_LAST_MOD;
- }
- else if (!strcasecmp(w, "SuppressSize")) {
- option = SUPPRESS_SIZE;
- }
+ }
+ else if (!strcasecmp(w, "SuppressDescription")) {
+ option = SUPPRESS_DESC;
+ }
+ else if (!strcasecmp(w, "SuppressHTMLPreamble")) {
+ option = SUPPRESS_PREAMBLE;
+ }
+ else if (!strcasecmp(w, "SuppressIcon")) {
+ option = SUPPRESS_ICON;
+ }
+ else if (!strcasecmp(w, "SuppressLastModified")) {
+ option = SUPPRESS_LAST_MOD;
+ }
+ else if (!strcasecmp(w, "SuppressSize")) {
+ option = SUPPRESS_SIZE;
+ }
else if (!strcasecmp(w, "SuppressRules")) {
option = SUPPRESS_RULES;
- }
+ }
else if (!strcasecmp(w, "TrackModified")) {
option = TRACK_MODIFIED;
}
else if (!strcasecmp(w, "VersionSort")) {
option = VERSION_SORT;
- }
- 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")) {
- if (action != '-') {
- d_cfg->icon_width = DEFAULT_ICON_WIDTH;
- }
- else {
- d_cfg->icon_width = 0;
- }
- }
- else if (!strncasecmp(w, "IconWidth=", 10)) {
- if (action == '-') {
- return "Cannot combine '-' with IconWidth=n";
- }
- d_cfg->icon_width = atoi(&w[10]);
- }
- else if (!strcasecmp(w, "IconHeight")) {
- if (action != '-') {
- d_cfg->icon_height = DEFAULT_ICON_HEIGHT;
- }
- else {
- d_cfg->icon_height = 0;
- }
- }
- else if (!strncasecmp(w, "IconHeight=", 11)) {
- if (action == '-') {
- return "Cannot combine '-' 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 = K_NOADJUST;
- }
- else if (!strncasecmp(w, "NameWidth=", 10)) {
- if (action == '-') {
- return "Cannot combine '-' with NameWidth=n";
- }
- if (w[10] == '*') {
- d_cfg->name_adjust = K_ADJUST;
- }
- else {
- int width = atoi(&w[10]);
-
- if (width && (width < 5)) {
- return "NameWidth value must be greater than 5";
- }
- d_cfg->name_width = width;
- d_cfg->name_adjust = K_NOADJUST;
- }
- }
+ }
+ 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")) {
+ if (action != '-') {
+ d_cfg->icon_width = DEFAULT_ICON_WIDTH;
+ }
+ else {
+ d_cfg->icon_width = 0;
+ }
+ }
+ else if (!strncasecmp(w, "IconWidth=", 10)) {
+ if (action == '-') {
+ return "Cannot combine '-' with IconWidth=n";
+ }
+ d_cfg->icon_width = atoi(&w[10]);
+ }
+ else if (!strcasecmp(w, "IconHeight")) {
+ if (action != '-') {
+ d_cfg->icon_height = DEFAULT_ICON_HEIGHT;
+ }
+ else {
+ d_cfg->icon_height = 0;
+ }
+ }
+ else if (!strncasecmp(w, "IconHeight=", 11)) {
+ if (action == '-') {
+ return "Cannot combine '-' 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 = K_NOADJUST;
+ }
+ else if (!strncasecmp(w, "NameWidth=", 10)) {
+ if (action == '-') {
+ return "Cannot combine '-' with NameWidth=n";
+ }
+ if (w[10] == '*') {
+ d_cfg->name_adjust = K_ADJUST;
+ }
+ else {
+ int width = atoi(&w[10]);
+
+ if (width && (width < 5)) {
+ return "NameWidth value must be greater than 5";
+ }
+ d_cfg->name_width = width;
+ d_cfg->name_adjust = K_NOADJUST;
+ }
+ }
else if (!strcasecmp(w, "DescriptionWidth")) {
if (action != '-') {
return "DescriptionWidth with no value may only appear as "
@@ -493,25 +493,25 @@
d_cfg->desc_adjust = K_NOADJUST;
}
}
- 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;
- }
+ 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'";
+ return "Cannot combine other IndexOptions keywords with 'None'";
}
d_cfg->incremented_opts = opts_add;
d_cfg->decremented_opts = opts_remove;
@@ -519,36 +519,36 @@
return NULL;
}
-static const char *set_default_order(cmd_parms *cmd, void *m, const char *direction,
- const char *key)
+static const char *set_default_order(cmd_parms *cmd, void *m,
+ const char *direction, const char *key)
{
autoindex_config_rec *d_cfg = (autoindex_config_rec *) m;
if (!strcasecmp(direction, "Ascending")) {
- d_cfg->default_direction = D_ASCENDING;
+ d_cfg->default_direction = D_ASCENDING;
}
else if (!strcasecmp(direction, "Descending")) {
- d_cfg->default_direction = D_DESCENDING;
+ d_cfg->default_direction = D_DESCENDING;
}
else {
- return "First keyword must be 'Ascending' or 'Descending'";
+ return "First keyword must be 'Ascending' or 'Descending'";
}
if (!strcasecmp(key, "Name")) {
- d_cfg->default_keyid = K_NAME;
+ d_cfg->default_keyid = K_NAME;
}
else if (!strcasecmp(key, "Date")) {
- d_cfg->default_keyid = K_LAST_MOD;
+ d_cfg->default_keyid = K_LAST_MOD;
}
else if (!strcasecmp(key, "Size")) {
- d_cfg->default_keyid = K_SIZE;
+ d_cfg->default_keyid = K_SIZE;
}
else if (!strcasecmp(key, "Description")) {
- d_cfg->default_keyid = K_DESC;
+ d_cfg->default_keyid = K_DESC;
}
else {
- return "Second keyword must be 'Name', 'Date', 'Size', or "
- "'Description'";
+ return "Second keyword must be 'Name', 'Date', 'Size', or "
+ "'Description'";
}
return NULL;
@@ -635,46 +635,46 @@
new->icon_list = apr_array_append(p, add->icon_list, base->icon_list);
new->rdme_list = apr_array_append(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 further down.
- */
- new->opts = NO_OPTIONS;
- new->incremented_opts = 0;
- new->decremented_opts = 0;
+ /*
+ * If the current directory says 'no options' then we also
+ * clear any incremental mods from being inheritable further down.
+ */
+ new->opts = NO_OPTIONS;
+ new->incremented_opts = 0;
+ new->decremented_opts = 0;
}
else {
- /*
- * If there were any nonincremental options selected for
- * this directory, they dominate and we don't inherit *anything.*
- * Contrariwise, we *do* inherit if the only settings here are
- * incremental ones.
- */
- if (add->opts == 0) {
- new->incremented_opts = (base->incremented_opts
- | add->incremented_opts)
- & ~add->decremented_opts;
- new->decremented_opts = (base->decremented_opts
- | add->decremented_opts);
- /*
- * We may have incremental settings, so make sure we don't
- * inadvertently inherit an IndexOptions None from above.
- */
- new->opts = (base->opts & ~NO_OPTIONS);
- }
- else {
- /*
- * There are local nonincremental settings, which clear
- * all inheritance from above. They *are* the new base settings.
- */
- new->opts = add->opts;;
- }
- /*
- * 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;
+ /*
+ * If there were any nonincremental options selected for
+ * this directory, they dominate and we don't inherit *anything.*
+ * Contrariwise, we *do* inherit if the only settings here are
+ * incremental ones.
+ */
+ if (add->opts == 0) {
+ new->incremented_opts = (base->incremented_opts
+ | add->incremented_opts)
+ & ~add->decremented_opts;
+ new->decremented_opts = (base->decremented_opts
+ | add->decremented_opts);
+ /*
+ * We may have incremental settings, so make sure we don't
+ * inadvertently inherit an IndexOptions None from above.
+ */
+ new->opts = (base->opts & ~NO_OPTIONS);
+ }
+ else {
+ /*
+ * There are local nonincremental settings, which clear
+ * all inheritance from above. They *are* the new base settings.
+ */
+ new->opts = add->opts;;
+ }
+ /*
+ * 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;
}
/*
* Inherit the NameWidth settings if there aren't any specific to
@@ -682,12 +682,12 @@
* config-rec creation routine.
*/
if (add->name_adjust == K_UNSET) {
- new->name_width = base->name_width;
- new->name_adjust = base->name_adjust;
+ new->name_width = base->name_width;
+ new->name_adjust = base->name_adjust;
}
else {
- new->name_width = add->name_width;
- new->name_adjust = add->name_adjust;
+ new->name_width = add->name_width;
+ new->name_adjust = add->name_adjust;
}
/*
@@ -739,38 +739,38 @@
int i;
for (i = 0; i < list->nelts; ++i) {
- struct item *p = &items[i];
+ struct item *p = &items[i];
- /* Special cased for ^^DIRECTORY^^ and ^^BLANKICON^^ */
- if ((path[0] == '^') || (!ap_strcmp_match(path, p->apply_path))) {
- if (!*(p->apply_to)) {
- return p->data;
- }
- else if (p->type == BY_PATH || path[0] == '^') {
- if (!ap_strcmp_match(path, p->apply_to)) {
- return p->data;
- }
- }
- else if (!path_only) {
- if (!content_encoding) {
- if (p->type == BY_TYPE) {
- if (content_type
- && !ap_strcasecmp_match(content_type,
- p->apply_to)) {
- return p->data;
- }
- }
- }
- else {
- if (p->type == BY_ENCODING) {
- if (!ap_strcasecmp_match(content_encoding,
- p->apply_to)) {
- return p->data;
- }
- }
- }
- }
- }
+ /* Special cased for ^^DIRECTORY^^ and ^^BLANKICON^^ */
+ if ((path[0] == '^') || (!ap_strcmp_match(path, p->apply_path))) {
+ if (!*(p->apply_to)) {
+ return p->data;
+ }
+ else if (p->type == BY_PATH || path[0] == '^') {
+ if (!ap_strcmp_match(path, p->apply_to)) {
+ return p->data;
+ }
+ }
+ else if (!path_only) {
+ if (!content_encoding) {
+ if (p->type == BY_TYPE) {
+ if (content_type
+ && !ap_strcasecmp_match(content_type,
+ p->apply_to)) {
+ return p->data;
+ }
+ }
+ }
+ else {
+ if (p->type == BY_ENCODING) {
+ if (!ap_strcasecmp_match(content_encoding,
+ p->apply_to)) {
+ return p->data;
+ }
+ }
+ }
+ }
+ }
}
return NULL;
}
@@ -821,32 +821,32 @@
* for the simple matches.
*/
if ((filename_only = ap_strrchr_c(filename_full, '/')) == NULL) {
- filename_only = filename_full;
+ filename_only = filename_full;
}
else {
- filename_only++;
+ filename_only++;
}
for (i = 0; i < dcfg->desc_list->nelts; ++i) {
- ai_desc_t *tuple = &list[i];
- int found;
+ ai_desc_t *tuple = &list[i];
+ int found;
- /*
- * Only use the full-path filename if the pattern contains '/'s.
- */
- filename = (tuple->full_path) ? filename_full : filename_only;
- /*
- * Make the comparison using the cheapest method; only do
- * wildcard checking if we must.
- */
- if (tuple->wildcards) {
- found = (apr_fnmatch(tuple->pattern, filename, MATCH_FLAGS) == 0);
- }
- else {
- found = (ap_strstr_c(filename, tuple->pattern) != NULL);
- }
- if (found) {
- return tuple->description;
- }
+ /*
+ * Only use the full-path filename if the pattern contains '/'s.
+ */
+ filename = (tuple->full_path) ? filename_full : filename_only;
+ /*
+ * Make the comparison using the cheapest method; only do
+ * wildcard checking if we must.
+ */
+ if (tuple->wildcards) {
+ found = (apr_fnmatch(tuple->pattern, filename, MATCH_FLAGS) == 0);
+ }
+ else {
+ found = (ap_strstr_c(filename, tuple->pattern) != NULL);
+ }
+ if (found) {
+ return tuple->description;
+ }
}
return NULL;
}
@@ -859,38 +859,38 @@
int i;
if ((tt = strrchr(path, '/')) == NULL) {
- tt = path;
+ tt = path;
}
else {
- tt++;
+ tt++;
}
for (i = 0; i < list->nelts; ++i) {
- struct item *p = &items[i];
- char *ap;
+ struct item *p = &items[i];
+ char *ap;
- if ((ap = strrchr(p->apply_to, '/')) == NULL) {
- ap = p->apply_to;
- }
- else {
- ap++;
- }
+ if ((ap = strrchr(p->apply_to, '/')) == NULL) {
+ ap = p->apply_to;
+ }
+ else {
+ ap++;
+ }
#ifndef CASE_BLIND_FILESYSTEM
- if (!ap_strcmp_match(path, p->apply_path)
- && !ap_strcmp_match(tt, ap)) {
- return 1;
- }
+ if (!ap_strcmp_match(path, p->apply_path)
+ && !ap_strcmp_match(tt, ap)) {
+ return 1;
+ }
#else /* !CASE_BLIND_FILESYSTEM */
- /*
- * On some platforms, the match must be case-blind. This is really
- * a factor of the filesystem involved, but we can't detect that
- * reliably - so we have to granularise at the OS level.
- */
- if (!ap_strcasecmp_match(path, p->apply_path)
- && !ap_strcasecmp_match(tt, ap)) {
- return 1;
- }
+ /*
+ * On some platforms, the match must be case-blind. This is really
+ * a factor of the filesystem involved, but we can't detect that
+ * reliably - so we have to granularise at the OS level.
+ */
+ if (!ap_strcasecmp_match(path, p->apply_path)
+ && !ap_strcasecmp_match(tt, ap)) {
+ return 1;
+ }
#endif /* !CASE_BLIND_FILESYSTEM */
}
return 0;
@@ -903,25 +903,25 @@
/*
* Elements of the emitted document:
- * Preamble
- * Emitted unless SUPPRESS_PREAMBLE is set AND ap_run_sub_req
- * succeeds for the (content_type == text/html) header file.
- * Header file
- * Emitted if found (and able).
- * H1 tag line
- * Emitted if a header file is NOT emitted.
- * Directory stuff
- * Always emitted.
- * HR
- * Emitted if FANCY_INDEXING is set.
- * Readme file
- * Emitted if found (and able).
- * ServerSig
- * Emitted if ServerSignature is not Off AND a readme file
- * is NOT emitted.
- * Postamble
- * Emitted unless SUPPRESS_PREAMBLE is set AND ap_run_sub_req
- * succeeds for the (content_type == text/html) readme file.
+ * Preamble
+ * Emitted unless SUPPRESS_PREAMBLE is set AND ap_run_sub_req
+ * succeeds for the (content_type == text/html) header file.
+ * Header file
+ * Emitted if found (and able).
+ * H1 tag line
+ * Emitted if a header file is NOT emitted.
+ * Directory stuff
+ * Always emitted.
+ * HR
+ * Emitted if FANCY_INDEXING is set.
+ * Readme file
+ * Emitted if found (and able).
+ * ServerSig
+ * Emitted if ServerSignature is not Off AND a readme file
+ * is NOT emitted.
+ * Postamble
+ * Emitted unless SUPPRESS_PREAMBLE is set AND ap_run_sub_req
+ * succeeds for the (content_type == text/html) readme file.
*/
@@ -937,37 +937,36 @@
ap_rputs("<pre>\n", r);
while (!apr_file_eof(f)) {
- do {
+ do {
n = sizeof(char) * AP_IOBUFSIZE;
- stat = apr_file_read(f, buf, &n);
- }
- while (APR_STATUS_IS_EINTR(stat));
- if (n == 0 || stat != APR_SUCCESS) {
+ stat = apr_file_read(f, buf, &n);
+ } while (APR_STATUS_IS_EINTR(stat));
+ if (n == 0 || stat != APR_SUCCESS) {
/* ###: better error here? */
- break;
- }
- buf[n] = '\0';
- c = 0;
- while (c < n) {
- for (i = c; i < n; i++) {
- if (buf[i] == '<' || buf[i] == '>' || buf[i] == '&') {
- break;
- }
- }
- ch = buf[i];
- buf[i] = '\0';
- ap_rputs(&buf[c], r);
- if (ch == '<') {
- ap_rputs("<", r);
- }
- else if (ch == '>') {
- ap_rputs(">", r);
- }
- else if (ch == '&') {
- ap_rputs("&", r);
- }
- c = i + 1;
- }
+ break;
+ }
+ buf[n] = '\0';
+ c = 0;
+ while (c < n) {
+ for (i = c; i < n; i++) {
+ if (buf[i] == '<' || buf[i] == '>' || buf[i] == '&') {
+ break;
+ }
+ }
+ ch = buf[i];
+ buf[i] = '\0';
+ ap_rputs(&buf[c], r);
+ if (ch == '<') {
+ ap_rputs("<", r);
+ }
+ else if (ch == '>') {
+ ap_rputs(">", r);
+ }
+ else if (ch == '&') {
+ ap_rputs("&", r);
+ }
+ c = i + 1;
+ }
}
ap_rputs("</pre>\n", r);
}
@@ -982,7 +981,7 @@
* oh well.
*/
static void emit_head(request_rec *r, char *header_fname, int suppress_amble,
- char *title)
+ char *title)
{
apr_table_t *hdrs = r->headers_in;
apr_file_t *f = NULL;
@@ -1006,53 +1005,53 @@
}
if ((header_fname != NULL)
- && (rr = ap_sub_req_lookup_uri(header_fname , r, NULL))
- && (rr->status == HTTP_OK)
- && (rr->filename != NULL)
- && (rr->finfo.filetype == APR_REG)) {
- /*
- * Check for the two specific cases we allow: text/html and
- * text/anything-else. The former is allowed to be processed for
- * SSIs.
- */
- if (rr->content_type != NULL) {
- if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
- "text/html")) {
- /* Hope everything will work... */
- emit_amble = 0;
- emit_H1 = 0;
-
- if (! suppress_amble) {
- emit_preamble(r, title);
- }
- /*
- * If there's a problem running the subrequest, display the
- * preamble if we didn't do it before -- the header file
- * didn't get displayed.
- */
- if (ap_run_sub_req(rr) != OK) {
- /* It didn't work */
- emit_amble = suppress_amble;
- emit_H1 = 1;
- }
- }
- else if (!strncasecmp("text/", rr->content_type, 5)) {
- /*
- * If we can open the file, prefix it with the preamble
- * regardless; since we'll be sending a <pre> block around
- * the file's contents, any HTML header it had won't end up
- * where it belongs.
- */
- if (apr_file_open(&f, rr->filename, APR_READ,
- APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
- emit_preamble(r, title);
- emit_amble = 0;
- do_emit_plain(r, f);
- apr_file_close(f);
- emit_H1 = 0;
- }
- }
- }
+ && (rr = ap_sub_req_lookup_uri(header_fname , r, NULL))
+ && (rr->status == HTTP_OK)
+ && (rr->filename != NULL)
+ && (rr->finfo.filetype == APR_REG)) {
+ /*
+ * Check for the two specific cases we allow: text/html and
+ * text/anything-else. The former is allowed to be processed for
+ * SSIs.
+ */
+ if (rr->content_type != NULL) {
+ if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
+ "text/html")) {
+ /* Hope everything will work... */
+ emit_amble = 0;
+ emit_H1 = 0;
+
+ if (! suppress_amble) {
+ emit_preamble(r, title);
+ }
+ /*
+ * If there's a problem running the subrequest, display the
+ * preamble if we didn't do it before -- the header file
+ * didn't get displayed.
+ */
+ if (ap_run_sub_req(rr) != OK) {
+ /* It didn't work */
+ emit_amble = suppress_amble;
+ emit_H1 = 1;
+ }
+ }
+ else if (!strncasecmp("text/", rr->content_type, 5)) {
+ /*
+ * If we can open the file, prefix it with the preamble
+ * regardless; since we'll be sending a <pre> block around
+ * the file's contents, any HTML header it had won't end up
+ * where it belongs.
+ */
+ if (apr_file_open(&f, rr->filename, APR_READ,
+ APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
+ emit_preamble(r, title);
+ emit_amble = 0;
+ do_emit_plain(r, f);
+ apr_file_close(f);
+ emit_H1 = 0;
+ }
+ }
+ }
}
if (r_accept) {
@@ -1067,13 +1066,13 @@
}
if (emit_amble) {
- emit_preamble(r, title);
+ emit_preamble(r, title);
}
if (emit_H1) {
- ap_rvputs(r, "<h1>Index of ", title, "</h1>\n", NULL);
+ ap_rvputs(r, "<h1>Index of ", title, "</h1>\n", NULL);
}
if (rr != NULL) {
- ap_destroy_sub_req(rr);
+ ap_destroy_sub_req(rr);
}
}
@@ -1100,46 +1099,46 @@
* pretend there's nothing there.
*/
if ((readme_fname != NULL)
- && (rr = ap_sub_req_lookup_uri(readme_fname, r, NULL))
- && (rr->status == HTTP_OK)
- && (rr->filename != NULL)
- && rr->finfo.filetype == APR_REG) {
- /*
- * Check for the two specific cases we allow: text/html and
- * text/anything-else. The former is allowed to be processed for
- * SSIs.
- */
- if (rr->content_type != NULL) {
- if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
- "text/html")) {
- if (ap_run_sub_req(rr) == OK) {
- /* worked... */
- suppress_sig = 1;
- suppress_post = suppress_amble;
- }
- }
- else if (!strncasecmp("text/", rr->content_type, 5)) {
- /*
- * If we can open the file, suppress the signature.
- */
- if (apr_file_open(&f, rr->filename, APR_READ,
- APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
- do_emit_plain(r, f);
- apr_file_close(f);
- suppress_sig = 1;
- }
- }
- }
+ && (rr = ap_sub_req_lookup_uri(readme_fname, r, NULL))
+ && (rr->status == HTTP_OK)
+ && (rr->filename != NULL)
+ && rr->finfo.filetype == APR_REG) {
+ /*
+ * Check for the two specific cases we allow: text/html and
+ * text/anything-else. The former is allowed to be processed for
+ * SSIs.
+ */
+ if (rr->content_type != NULL) {
+ if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
+ "text/html")) {
+ if (ap_run_sub_req(rr) == OK) {
+ /* worked... */
+ suppress_sig = 1;
+ suppress_post = suppress_amble;
+ }
+ }
+ else if (!strncasecmp("text/", rr->content_type, 5)) {
+ /*
+ * If we can open the file, suppress the signature.
+ */
+ if (apr_file_open(&f, rr->filename, APR_READ,
+ APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
+ do_emit_plain(r, f);
+ apr_file_close(f);
+ suppress_sig = 1;
+ }
+ }
+ }
}
if (!suppress_sig) {
- ap_rputs(ap_psignature("", r), r);
+ ap_rputs(ap_psignature("", r), r);
}
if (!suppress_post) {
- ap_rputs("</body></html>\n", r);
+ ap_rputs("</body></html>\n", r);
}
if (rr != NULL) {
- ap_destroy_sub_req(rr);
+ ap_destroy_sub_req(rr);
}
}
@@ -1152,56 +1151,56 @@
apr_size_t n;
if (r->status != HTTP_OK) {
- return NULL;
+ return NULL;
}
if ((r->content_type != NULL)
- && (!strcasecmp(ap_field_noparam(r->pool, r->content_type),
- "text/html")
- || !strcmp(r->content_type, INCLUDES_MAGIC_TYPE))
- && !r->content_encoding) {
+ && (!strcasecmp(ap_field_noparam(r->pool, r->content_type),
+ "text/html")
+ || !strcmp(r->content_type, INCLUDES_MAGIC_TYPE))
+ && !r->content_encoding) {
if (apr_file_open(&thefile, r->filename, APR_READ,
- APR_OS_DEFAULT, r->pool) != APR_SUCCESS) {
- return NULL;
- }
+ APR_OS_DEFAULT, r->pool) != APR_SUCCESS) {
+ return NULL;
+ }
n = sizeof(char) * (MAX_STRING_LEN - 1);
- apr_file_read(thefile, titlebuf, &n);
- if (n <= 0) {
- apr_file_close(thefile);
- return NULL;
- }
- titlebuf[n] = '\0';
- for (x = 0, p = 0; titlebuf[x]; x++) {
- if (apr_tolower(titlebuf[x]) == find[p]) {
- if (!find[++p]) {
- if ((p = ap_ind(&titlebuf[++x], '<')) != -1) {
- titlebuf[x + p] = '\0';
- }
- /* Scan for line breaks for Tanmoy's secretary */
- for (y = x; titlebuf[y]; y++) {
- if ((titlebuf[y] == CR) || (titlebuf[y] == LF)) {
- if (y == x) {
- x++;
- }
- else {
- titlebuf[y] = ' ';
- }
- }
- }
- apr_file_close(thefile);
- return apr_pstrdup(r->pool, &titlebuf[x]);
- }
- }
- else {
- p = 0;
- }
- }
- apr_file_close(thefile);
+ apr_file_read(thefile, titlebuf, &n);
+ if (n <= 0) {
+ apr_file_close(thefile);
+ return NULL;
+ }
+ titlebuf[n] = '\0';
+ for (x = 0, p = 0; titlebuf[x]; x++) {
+ if (apr_tolower(titlebuf[x]) == find[p]) {
+ if (!find[++p]) {
+ if ((p = ap_ind(&titlebuf[++x], '<')) != -1) {
+ titlebuf[x + p] = '\0';
+ }
+ /* Scan for line breaks for Tanmoy's secretary */
+ for (y = x; titlebuf[y]; y++) {
+ if ((titlebuf[y] == CR) || (titlebuf[y] == LF)) {
+ if (y == x) {
+ x++;
+ }
+ else {
+ titlebuf[y] = ' ';
+ }
+ }
+ }
+ apr_file_close(thefile);
+ return apr_pstrdup(r->pool, &titlebuf[x]);
+ }
+ }
+ else {
+ p = 0;
+ }
+ }
+ apr_file_close(thefile);
}
return NULL;
}
static struct ent *make_parent_entry(apr_int32_t autoindex_opts,
- autoindex_config_rec *d,
+ autoindex_config_rec *d,
request_rec *r, char keyid,
char direction)
{
@@ -1238,11 +1237,11 @@
p->version_sort = autoindex_opts & VERSION_SORT;
if (autoindex_opts & FANCY_INDEXING) {
if (!(p->icon = find_default_icon(d, testpath))) {
- p->icon = find_default_icon(d, "^^DIRECTORY^^");
+ p->icon = find_default_icon(d, "^^DIRECTORY^^");
}
if (!(p->alt = find_default_alt(d, testpath))) {
if (!(p->alt = find_default_alt(d, "^^DIRECTORY^^"))) {
- p->alt = "DIR";
+ p->alt = "DIR";
}
}
p->desc = find_desc(d, testpath);
@@ -1252,9 +1251,9 @@
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,
+ autoindex_config_rec *d,
+ request_rec *r, char keyid,
+ char direction,
const char *pattern)
{
request_rec *rr;
@@ -1263,7 +1262,7 @@
/* Dot is ignored, Parent is handled by make_parent_entry() */
if ((dirent->name[0] == '.') && (!dirent->name[1]
|| ((dirent->name[1] == '.') && !dirent->name[2])))
- return (NULL);
+ return (NULL);
#ifndef CASE_BLIND_FILESYSTEM
if (pattern && (apr_fnmatch(pattern, dirent->name,
@@ -1271,11 +1270,11 @@
!= APR_SUCCESS))
return (NULL);
#else /* !CASE_BLIND_FILESYSTEM */
- /*
- * On some platforms, the match must be case-blind. This is really
- * a factor of the filesystem involved, but we can't detect that
- * reliably - so we have to granularise at the OS level.
- */
+ /*
+ * On some platforms, the match must be case-blind. This is really
+ * a factor of the filesystem involved, but we can't detect that
+ * reliably - so we have to granularise at the OS level.
+ */
if (pattern && (apr_fnmatch(pattern, dirent->name,
FNM_NOESCAPE | FNM_PERIOD | FNM_CASE_BLIND)
!= APR_SUCCESS))
@@ -1316,31 +1315,31 @@
p->version_sort = !!(autoindex_opts & VERSION_SORT);
if (autoindex_opts & (FANCY_INDEXING | TABLE_INDEXING)) {
- p->lm = rr->finfo.mtime;
- if (rr->finfo.filetype == APR_DIR) {
+ p->lm = rr->finfo.mtime;
+ if (rr->finfo.filetype == APR_DIR) {
if (autoindex_opts & FOLDERS_FIRST) {
p->isdir = 1;
+ }
+ if (!(p->icon = find_icon(d, rr, 1))) {
+ p->icon = find_default_icon(d, "^^DIRECTORY^^");
+ }
+ if (!(p->alt = find_alt(d, rr, 1))) {
+ if (!(p->alt = find_default_alt(d, "^^DIRECTORY^^"))) {
+ p->alt = "DIR";
+ }
}
- if (!(p->icon = find_icon(d, rr, 1))) {
- p->icon = find_default_icon(d, "^^DIRECTORY^^");
- }
- if (!(p->alt = find_alt(d, rr, 1))) {
- if (!(p->alt = find_default_alt(d, "^^DIRECTORY^^"))) {
- p->alt = "DIR";
- }
- }
- }
- else {
- p->icon = find_icon(d, rr, 0);
- p->alt = find_alt(d, rr, 0);
- p->size = rr->finfo.size;
- }
-
- p->desc = find_desc(d, rr->filename);
-
- if ((!p->desc) && (autoindex_opts & SCAN_HTML_TITLES)) {
- p->desc = apr_pstrdup(r->pool, find_title(rr));
- }
+ }
+ else {
+ p->icon = find_icon(d, rr, 0);
+ p->alt = find_alt(d, rr, 0);
+ p->size = rr->finfo.size;
+ }
+
+ p->desc = find_desc(d, rr->filename);
+
+ if ((!p->desc) && (autoindex_opts & SCAN_HTML_TITLES)) {
+ p->desc = apr_pstrdup(r->pool, find_title(rr));
+ }
}
ap_destroy_sub_req(rr);
/*
@@ -1349,14 +1348,14 @@
*/
if (keyid == K_LAST_MOD) {
if (p->lm < 0) {
- p->lm = 0;
- }
+ p->lm = 0;
+ }
}
return (p);
}
static char *terminate_description(autoindex_config_rec *d, char *desc,
- apr_int32_t autoindex_opts, int desc_width)
+ apr_int32_t autoindex_opts, int desc_width)
{
int maxsize = desc_width;
register int x;
@@ -1369,42 +1368,42 @@
*/
if (d->desc_adjust == K_UNSET) {
if (autoindex_opts & SUPPRESS_ICON) {
- maxsize += 6;
+ maxsize += 6;
}
if (autoindex_opts & SUPPRESS_LAST_MOD) {
- maxsize += 19;
+ maxsize += 19;
}
if (autoindex_opts & SUPPRESS_SIZE) {
- maxsize += 7;
+ maxsize += 7;
}
}
for (x = 0; desc[x] && ((maxsize > 0) || (desc[x] == '<')); x++) {
- if (desc[x] == '<') {
- while (desc[x] != '>') {
- if (!desc[x]) {
- maxsize = 0;
- break;
- }
- ++x;
- }
- }
- else if (desc[x] == '&') {
- /* entities like ä count as one character */
- --maxsize;
- for ( ; desc[x] != ';'; ++x) {
- if (desc[x] == '\0') {
+ if (desc[x] == '<') {
+ while (desc[x] != '>') {
+ if (!desc[x]) {
+ maxsize = 0;
+ break;
+ }
+ ++x;
+ }
+ }
+ else if (desc[x] == '&') {
+ /* entities like ä count as one character */
+ --maxsize;
+ for ( ; desc[x] != ';'; ++x) {
+ if (desc[x] == '\0') {
maxsize = 0;
break;
- }
- }
+ }
+ }
}
- else {
- --maxsize;
- }
+ else {
+ --maxsize;
+ }
}
if (!maxsize && desc[x] != '\0') {
- desc[x - 1] = '>'; /* Grump. */
- desc[x] = '\0'; /* Double Grump! */
+ desc[x - 1] = '>'; /* Grump. */
+ desc[x] = '\0'; /* Double Grump! */
}
return desc;
}
@@ -1422,17 +1421,17 @@
int reverse;
if (!nosort) {
- reverse = ((curkey == column) && (curdirection == D_ASCENDING));
- qvalue[0] = '?';
- qvalue[1] = 'C';
- qvalue[2] = '=';
- qvalue[3] = column;
- qvalue[4] = '&';
- qvalue[5] = 'O';
- qvalue[6] = '=';
- qvalue[7] = reverse ? D_DESCENDING : D_ASCENDING;
- qvalue[8] = '\0';
- ap_rvputs(r, "<a href=\"", qvalue, colargs ? colargs : "",
+ reverse = ((curkey == column) && (curdirection == D_ASCENDING));
+ qvalue[0] = '?';
+ qvalue[1] = 'C';
+ qvalue[2] = '=';
+ qvalue[3] = column;
+ qvalue[4] = '&';
+ qvalue[5] = 'O';
+ qvalue[6] = '=';
+ qvalue[7] = reverse ? D_DESCENDING : D_ASCENDING;
+ qvalue[8] = '\0';
+ ap_rvputs(r, "<a href=\"", qvalue, colargs ? colargs : "",
"\">", anchor, "</a>", NULL);
}
else {
@@ -1441,8 +1440,8 @@
}
static void output_directories(struct ent **ar, int n,
- autoindex_config_rec *d, request_rec *r,
- apr_int32_t autoindex_opts, char keyid,
+ autoindex_config_rec *d, request_rec *r,
+ apr_int32_t autoindex_opts, char keyid,
char direction, const char *colargs)
{
int x;
@@ -1459,7 +1458,7 @@
apr_pool_create(&scratch, r->pool);
if (name[0] == '\0') {
- name = "/";
+ name = "/";
}
name_width = d->name_width;
@@ -1468,12 +1467,12 @@
if ((autoindex_opts & (FANCY_INDEXING | TABLE_INDEXING))
== FANCY_INDEXING) {
if (d->name_adjust == K_ADJUST) {
- for (x = 0; x < n; x++) {
- int t = strlen(ar[x]->name);
- if (t > name_width) {
- name_width = t;
- }
- }
+ for (x = 0; x < n; x++) {
+ int t = strlen(ar[x]->name);
+ if (t > name_width) {
+ name_width = t;
+ }
+ }
}
if (d->desc_adjust == K_ADJUST) {
@@ -1494,19 +1493,19 @@
if (autoindex_opts & TABLE_INDEXING) {
int cols = 1;
- ap_rputs("<table><tr>", r);
- if (!(autoindex_opts & SUPPRESS_ICON)) {
+ ap_rputs("<table><tr>", r);
+ if (!(autoindex_opts & SUPPRESS_ICON)) {
ap_rputs("<th title=\"Icon\">", r);
- if ((tp = find_default_icon(d, "^^BLANKICON^^"))) {
- ap_rvputs(r, "<img src=\"", ap_escape_html(scratch, tp),
- "\" alt=\"[ICO]\"", NULL);
- if (d->icon_width) {
- ap_rprintf(r, " width=\"%d\"", d->icon_width);
+ if ((tp = find_default_icon(d, "^^BLANKICON^^"))) {
+ ap_rvputs(r, "<img src=\"", ap_escape_html(scratch, tp),
+ "\" alt=\"[ICO]\"", NULL);
+ if (d->icon_width) {
+ ap_rprintf(r, " width=\"%d\"", d->icon_width);
}
if (d->icon_height) {
- ap_rprintf(r, " height=\"%d\"", d->icon_height);
+ ap_rprintf(r, " height=\"%d\"", d->icon_height);
}
- ap_rputs(" /></th>", r);
+ ap_rputs(" /></th>", r);
}
else {
ap_rputs(" </th>", r);
@@ -1517,263 +1516,265 @@
ap_rputs("<th>", r);
emit_link(r, "Name", K_NAME, keyid, direction,
colargs, static_columns);
- if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
+ if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
ap_rputs("</th><th>", r);
- emit_link(r, "Last modified", K_LAST_MOD, keyid, direction,
+ emit_link(r, "Last modified", K_LAST_MOD, keyid, direction,
colargs, static_columns);
- ++cols;
- }
- if (!(autoindex_opts & SUPPRESS_SIZE)) {
+ ++cols;
+ }
+ if (!(autoindex_opts & SUPPRESS_SIZE)) {
ap_rputs("</th><th>", r);
- emit_link(r, "Size", K_SIZE, keyid, direction,
+ emit_link(r, "Size", K_SIZE, keyid, direction,
colargs, static_columns);
- ++cols;
- }
- if (!(autoindex_opts & SUPPRESS_DESC)) {
+ ++cols;
+ }
+ if (!(autoindex_opts & SUPPRESS_DESC)) {
ap_rputs("</th><th>", r);
- emit_link(r, "Description", K_DESC, keyid, direction,
+ emit_link(r, "Description", K_DESC, keyid, direction,
colargs, static_columns);
- ++cols;
- }
+ ++cols;
+ }
if (!(autoindex_opts & SUPPRESS_RULES)) {
breakrow = apr_psprintf(r->pool,
"<tr><th colspan=\"%d\">"
"<hr /></th></tr>\n", cols);
}
- ap_rvputs(r, "</th></tr>", breakrow, NULL);
+ ap_rvputs(r, "</th></tr>", breakrow, NULL);
}
else if (autoindex_opts & FANCY_INDEXING) {
- ap_rputs("<pre>", r);
- if (!(autoindex_opts & SUPPRESS_ICON)) {
- if ((tp = find_default_icon(d, "^^BLANKICON^^"))) {
- ap_rvputs(r, "<img src=\"", ap_escape_html(scratch, tp),
- "\" alt=\"Icon \"", NULL);
- if (d->icon_width) {
- ap_rprintf(r, " width=\"%d\"", d->icon_width);
+ ap_rputs("<pre>", r);
+ if (!(autoindex_opts & SUPPRESS_ICON)) {
+ if ((tp = find_default_icon(d, "^^BLANKICON^^"))) {
+ ap_rvputs(r, "<img src=\"", ap_escape_html(scratch, tp),
+ "\" alt=\"Icon \"", NULL);
+ if (d->icon_width) {
+ ap_rprintf(r, " width=\"%d\"", d->icon_width);
}
if (d->icon_height) {
- ap_rprintf(r, " height=\"%d\"", d->icon_height);
+ ap_rprintf(r, " height=\"%d\"", d->icon_height);
}
- ap_rputs(" /> ", r);
- }
+ ap_rputs(" /> ", r);
+ }
else {
- ap_rputs(" ", r);
+ ap_rputs(" ", r);
}
}
emit_link(r, "Name", K_NAME, keyid, direction,
colargs, static_columns);
- ap_rputs(pad_scratch + 4, r);
- /*
- * Emit the guaranteed-at-least-one-space-between-columns byte.
- */
- ap_rputs(" ", r);
- if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
+ ap_rputs(pad_scratch + 4, r);
+ /*
+ * Emit the guaranteed-at-least-one-space-between-columns byte.
+ */
+ ap_rputs(" ", r);
+ if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
emit_link(r, "Last modified", K_LAST_MOD, keyid, direction,
colargs, static_columns);
- ap_rputs(" ", r);
- }
- if (!(autoindex_opts & SUPPRESS_SIZE)) {
+ ap_rputs(" ", r);
+ }
+ if (!(autoindex_opts & SUPPRESS_SIZE)) {
emit_link(r, "Size", K_SIZE, keyid, direction,
colargs, static_columns);
- ap_rputs(" ", r);
- }
- if (!(autoindex_opts & SUPPRESS_DESC)) {
+ ap_rputs(" ", r);
+ }
+ if (!(autoindex_opts & SUPPRESS_DESC)) {
emit_link(r, "Description", K_DESC, keyid, direction,
colargs, static_columns);
- }
- if (!(autoindex_opts & SUPPRESS_RULES)) {
+ }
+ if (!(autoindex_opts & SUPPRESS_RULES)) {
ap_rputs("<hr />", r);
}
}
else {
- ap_rputs("<ul>", r);
+ ap_rputs("<ul>", r);
}
for (x = 0; x < n; x++) {
- char *anchor, *t, *t2;
- int nwidth;
+ char *anchor, *t, *t2;
+ int nwidth;
- apr_pool_clear(scratch);
+ apr_pool_clear(scratch);
t = ar[x]->name;
- anchor = ap_escape_html(scratch, ap_os_escape_path(scratch, t, 0));
+ anchor = ap_escape_html(scratch, ap_os_escape_path(scratch, t, 0));
if (!x && t[0] == '/') {
- t2 = "Parent Directory";
+ t2 = "Parent Directory";
}
else {
- t2 = t;
+ t2 = t;
}
if (autoindex_opts & TABLE_INDEXING) {
- if (!(autoindex_opts & SUPPRESS_ICON)) {
- ap_rputs("<tr><td valign=\"top\">", r);
+ if (!(autoindex_opts & SUPPRESS_ICON)) {
+ ap_rputs("<tr><td valign=\"top\">", r);
if (autoindex_opts & ICONS_ARE_LINKS) {
- ap_rvputs(r, "<a href=\"", anchor, "\">", NULL);
- }
+ ap_rvputs(r, "<a href=\"", anchor, "\">", NULL);
+ }
if ((ar[x]->icon) || d->default_icon) {
- ap_rvputs(r, "<img src=\"",
- ap_escape_html(scratch,
- ar[x]->icon ? ar[x]->icon
- : d->default_icon),
- "\" alt=\"[", (ar[x]->alt ? ar[x]->alt : " "),
- "]\"", NULL);
- if (d->icon_width) {
- ap_rprintf(r, " width=\"%d\"", d->icon_width);
+ ap_rvputs(r, "<img src=\"",
+ ap_escape_html(scratch,
+ ar[x]->icon ? ar[x]->icon
+ : d->default_icon),
+ "\" alt=\"[", (ar[x]->alt ? ar[x]->alt : " "),
+ "]\"", NULL);
+ if (d->icon_width) {
+ ap_rprintf(r, " width=\"%d\"", d->icon_width);
}
if (d->icon_height) {
ap_rprintf(r, " height=\"%d\"", d->icon_height);
}
- ap_rputs(" />", r);
- }
+ ap_rputs(" />", r);
+ }
else {
ap_rputs(" ", r);
}
- if (autoindex_opts & ICONS_ARE_LINKS) {
- ap_rputs("</a></td>", r);
+ if (autoindex_opts & ICONS_ARE_LINKS) {
+ ap_rputs("</a></td>", r);
}
- else {
+ else {
ap_rputs("</td>", r);
}
}
if (d->name_adjust == K_ADJUST) {
- ap_rvputs(r, "<td><a href=\"", anchor, "\">",
+ ap_rvputs(r, "<td><a href=\"", anchor, "\">",
ap_escape_html(scratch, t2), "</a>", NULL);
}
else {
- nwidth = strlen(t2);
- if (nwidth > name_width) {
- memcpy(name_scratch, t2, name_width - 3);
- name_scratch[name_width - 3] = '.';
- name_scratch[name_width - 2] = '.';
- name_scratch[name_width - 1] = '>';
- name_scratch[name_width] = 0;
- t2 = name_scratch;
- nwidth = name_width;
- }
- ap_rvputs(r, "<td><a href=\"", anchor, "\">",
- ap_escape_html(scratch, t2), "</a>", pad_scratch + nwidth,
- NULL);
- }
- if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
- if (ar[x]->lm != -1) {
- char time_str[MAX_STRING_LEN];
- apr_exploded_time_t ts;
+ nwidth = strlen(t2);
+ if (nwidth > name_width) {
+ memcpy(name_scratch, t2, name_width - 3);
+ name_scratch[name_width - 3] = '.';
+ name_scratch[name_width - 2] = '.';
+ name_scratch[name_width - 1] = '>';
+ name_scratch[name_width] = 0;
+ t2 = name_scratch;
+ nwidth = name_width;
+ }
+ ap_rvputs(r, "<td><a href=\"", anchor, "\">",
+ ap_escape_html(scratch, t2),
+ "</a>", pad_scratch + nwidth, NULL);
+ }
+ if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
+ if (ar[x]->lm != -1) {
+ char time_str[MAX_STRING_LEN];
+ apr_exploded_time_t ts;
apr_explode_localtime(&ts, ar[x]->lm);
- apr_strftime(time_str, &rv, MAX_STRING_LEN,
+ apr_strftime(time_str, &rv, MAX_STRING_LEN,
"</td><td align=\"right\">%d-%b-%Y %H:%M ", &ts);
- ap_rputs(time_str, r);
- }
- else {
- ap_rputs("</td><td> ", r);
- }
- }
- if (!(autoindex_opts & SUPPRESS_SIZE)) {
+ ap_rputs(time_str, r);
+ }
+ else {
+ ap_rputs("</td><td> ", r);
+ }
+ }
+ if (!(autoindex_opts & SUPPRESS_SIZE)) {
char buf[5];
- ap_rvputs(r, "</td><td align=\"right\">", apr_strfsize(ar[x]->size, buf), NULL);
- }
- if (!(autoindex_opts & SUPPRESS_DESC)) {
- if (ar[x]->desc) {
+ ap_rvputs(r, "</td><td align=\"right\">",
+ apr_strfsize(ar[x]->size, buf), NULL);
+ }
+ if (!(autoindex_opts & SUPPRESS_DESC)) {
+ if (ar[x]->desc) {
if (d->desc_adjust == K_ADJUST) {
- ap_rvputs(r, "</td><td>", ar[x]->desc, NULL);
+ ap_rvputs(r, "</td><td>", ar[x]->desc, NULL);
}
else {
- ap_rvputs(r, "</td><td>",
+ ap_rvputs(r, "</td><td>",
terminate_description(d, ar[x]->desc,
- autoindex_opts,
+ autoindex_opts,
desc_width), NULL);
}
- }
- }
- else
+ }
+ }
+ else {
ap_rputs("</td><td> ", r);
+ }
ap_rputs("</td></tr>\n", r);
}
- else if (autoindex_opts & FANCY_INDEXING) {
- if (!(autoindex_opts & SUPPRESS_ICON)) {
- if (autoindex_opts & ICONS_ARE_LINKS) {
- ap_rvputs(r, "<a href=\"", anchor, "\">", NULL);
- }
- if ((ar[x]->icon) || d->default_icon) {
- ap_rvputs(r, "<img src=\"",
- ap_escape_html(scratch,
- ar[x]->icon ? ar[x]->icon
- : d->default_icon),
- "\" alt=\"[", (ar[x]->alt ? ar[x]->alt : " "),
- "]\"", NULL);
- if (d->icon_width) {
- ap_rprintf(r, " width=\"%d\"", d->icon_width);
+ else if (autoindex_opts & FANCY_INDEXING) {
+ if (!(autoindex_opts & SUPPRESS_ICON)) {
+ if (autoindex_opts & ICONS_ARE_LINKS) {
+ ap_rvputs(r, "<a href=\"", anchor, "\">", NULL);
+ }
+ if ((ar[x]->icon) || d->default_icon) {
+ ap_rvputs(r, "<img src=\"",
+ ap_escape_html(scratch,
+ ar[x]->icon ? ar[x]->icon
+ : d->default_icon),
+ "\" alt=\"[", (ar[x]->alt ? ar[x]->alt : " "),
+ "]\"", NULL);
+ if (d->icon_width) {
+ ap_rprintf(r, " width=\"%d\"", d->icon_width);
}
if (d->icon_height) {
ap_rprintf(r, " height=\"%d\"", d->icon_height);
}
- ap_rputs(" />", r);
- }
+ ap_rputs(" />", r);
+ }
else {
- ap_rputs(" ", r);
+ ap_rputs(" ", r);
}
- if (autoindex_opts & ICONS_ARE_LINKS) {
- ap_rputs("</a> ", r);
+ if (autoindex_opts & ICONS_ARE_LINKS) {
+ ap_rputs("</a> ", r);
}
- else {
- ap_rputc(' ', r);
+ else {
+ ap_rputc(' ', r);
}
+ }
+ nwidth = strlen(t2);
+ if (nwidth > name_width) {
+ memcpy(name_scratch, t2, name_width - 3);
+ name_scratch[name_width - 3] = '.';
+ name_scratch[name_width - 2] = '.';
+ name_scratch[name_width - 1] = '>';
+ name_scratch[name_width] = 0;
+ t2 = name_scratch;
+ nwidth = name_width;
}
- nwidth = strlen(t2);
- if (nwidth > name_width) {
- memcpy(name_scratch, t2, name_width - 3);
- name_scratch[name_width - 3] = '.';
- name_scratch[name_width - 2] = '.';
- name_scratch[name_width - 1] = '>';
- name_scratch[name_width] = 0;
- t2 = name_scratch;
- nwidth = name_width;
- }
- ap_rvputs(r, "<a href=\"", anchor, "\">",
- ap_escape_html(scratch, t2), "</a>", pad_scratch + nwidth,
- NULL);
- /*
- * The blank before the storm.. er, before the next field.
- */
- ap_rputs(" ", r);
- if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
- if (ar[x]->lm != -1) {
- char time_str[MAX_STRING_LEN];
- apr_exploded_time_t ts;
+ ap_rvputs(r, "<a href=\"", anchor, "\">",
+ ap_escape_html(scratch, t2),
+ "</a>", pad_scratch + nwidth, NULL);
+ /*
+ * The blank before the storm.. er, before the next field.
+ */
+ ap_rputs(" ", r);
+ if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
+ if (ar[x]->lm != -1) {
+ char time_str[MAX_STRING_LEN];
+ apr_exploded_time_t ts;
apr_explode_localtime(&ts, ar[x]->lm);
- apr_strftime(time_str, &rv, MAX_STRING_LEN,
+ apr_strftime(time_str, &rv, MAX_STRING_LEN,
"%d-%b-%Y %H:%M ", &ts);
- ap_rputs(time_str, r);
- }
- else {
- /*Length="22-Feb-1998 23:42 " (see 4 lines above) */
- ap_rputs(" ", r);
- }
- }
- if (!(autoindex_opts & SUPPRESS_SIZE)) {
+ ap_rputs(time_str, r);
+ }
+ else {
+ /*Length="22-Feb-1998 23:42 " (see 4 lines above) */
+ ap_rputs(" ", r);
+ }
+ }
+ if (!(autoindex_opts & SUPPRESS_SIZE)) {
char buf[5];
- ap_rputs(apr_strfsize(ar[x]->size, buf), r);
- ap_rputs(" ", r);
- }
- if (!(autoindex_opts & SUPPRESS_DESC)) {
- if (ar[x]->desc) {
- ap_rputs(terminate_description(d, ar[x]->desc,
- autoindex_opts,
+ ap_rputs(apr_strfsize(ar[x]->size, buf), r);
+ ap_rputs(" ", r);
+ }
+ if (!(autoindex_opts & SUPPRESS_DESC)) {
+ if (ar[x]->desc) {
+ ap_rputs(terminate_description(d, ar[x]->desc,
+ autoindex_opts,
desc_width), r);
- }
- }
- ap_rputc('\n', r);
- }
- else {
- ap_rvputs(r, "<li><a href=\"", anchor, "\"> ", t2,
- "</a></li>\n", NULL);
- }
+ }
+ }
+ ap_rputc('\n', r);
+ }
+ else {
+ ap_rvputs(r, "<li><a href=\"", anchor, "\"> ", t2,
+ "</a></li>\n", NULL);
+ }
}
if (autoindex_opts & TABLE_INDEXING) {
- ap_rvputs(r, breakrow, "</table>\n", NULL);
+ ap_rvputs(r, breakrow, "</table>\n", NULL);
}
else if (autoindex_opts & FANCY_INDEXING) {
- if (!(autoindex_opts & SUPPRESS_RULES)) {
+ if (!(autoindex_opts & SUPPRESS_RULES)) {
ap_rputs("<hr /></pre>\n", r);
}
else {
@@ -1781,7 +1782,7 @@
}
}
else {
- ap_rputs("</ul>\n", r);
+ ap_rputs("</ul>\n", r);
}
}
@@ -1828,7 +1829,7 @@
switch (c1->key) {
case K_LAST_MOD:
- if (c1->lm > c2->lm) {
+ if (c1->lm > c2->lm) {
return 1;
}
else if (c1->lm < c2->lm) {
@@ -1844,12 +1845,12 @@
}
break;
case K_DESC:
- if (c1->version_sort) {
- result = apr_strnatcmp(c1->desc ? c1->desc : "",
+ if (c1->version_sort) {
+ result = apr_strnatcmp(c1->desc ? c1->desc : "",
c2->desc ? c2->desc : "");
}
- else {
- result = strcmp(c1->desc ? c1->desc : "",
+ else {
+ result = strcmp(c1->desc ? c1->desc : "",
c2->desc ? c2->desc : "");
}
if (result) {
@@ -1858,16 +1859,16 @@
break;
}
if (c1->version_sort) {
- return apr_strnatcmp(c1->name, c2->name);
+ return apr_strnatcmp(c1->name, c2->name);
}
else {
- return strcmp(c1->name, c2->name);
+ return strcmp(c1->name, c2->name);
}
}
static int index_directory(request_rec *r,
- autoindex_config_rec *autoindex_conf)
+ autoindex_config_rec *autoindex_conf)
{
char *title_name = ap_escape_html(r->pool, r->uri);
char *title_endp;
@@ -1886,9 +1887,9 @@
char *colargs;
if ((status = apr_dir_open(&thedir, name, r->pool)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
- "Can't open directory for index: %s", r->filename);
- return HTTP_FORBIDDEN;
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
+ "Can't open directory for index: %s", r->filename);
+ return HTTP_FORBIDDEN;
}
#if APR_HAS_UNICODE_FS
@@ -1902,8 +1903,8 @@
ap_set_etag(r);
}
if (r->header_only) {
- apr_dir_close(thedir);
- return 0;
+ apr_dir_close(thedir);
+ return 0;
}
/*
@@ -1936,14 +1937,14 @@
if (qstring[0] == 'C' && qstring[1] == '='
&& qstring[2] && strchr(K_VALID, qstring[2])
&& (qstring[3] == '&' || !qstring[3])) {
- keyid = qstring[2];
+ keyid = qstring[2];
qstring += qstring[3] ? 4 : 3;
}
else if (qstring[0] == 'O' && qstring[1] == '='
&& ((qstring[2] == D_ASCENDING)
|| (qstring[2] == D_DESCENDING))
&& (qstring[3] == '&' || !qstring[3])) {
- direction = qstring[2];
+ direction = qstring[2];
qstring += qstring[3] ? 4 : 3;
}
else if (qstring[0] == 'F' && qstring[1] == '='
@@ -2005,11 +2006,11 @@
title_endp = title_name + strlen(title_name) - 1;
while (title_endp > title_name && *title_endp == '/') {
- *title_endp-- = '\0';
+ *title_endp-- = '\0';
}
emit_head(r, find_header(autoindex_conf, r),
- autoindex_opts & SUPPRESS_PREAMBLE, title_name);
+ autoindex_opts & SUPPRESS_PREAMBLE, title_name);
/*
* Since we don't know how many dir. entries there are, put them into a
@@ -2018,38 +2019,38 @@
head = NULL;
p = make_parent_entry(autoindex_opts, autoindex_conf, r, keyid, direction);
if (p != NULL) {
- p->next = head;
- head = p;
- num_ent++;
+ p->next = head;
+ head = p;
+ num_ent++;
}
while (apr_dir_read(&dirent, APR_FINFO_DIRENT, thedir) == APR_SUCCESS) {
- p = make_autoindex_entry(&dirent, autoindex_opts, autoindex_conf, r,
+ p = make_autoindex_entry(&dirent, autoindex_opts, autoindex_conf, r,
keyid, direction, pstring);
- if (p != NULL) {
- p->next = head;
- head = p;
- num_ent++;
- }
+ if (p != NULL) {
+ p->next = head;
+ head = p;
+ num_ent++;
+ }
}
if (num_ent > 0) {
- ar = (struct ent **) apr_palloc(r->pool,
- num_ent * sizeof(struct ent *));
- p = head;
- x = 0;
- while (p) {
- ar[x++] = p;
- p = p->next;
- }
+ ar = (struct ent **) apr_palloc(r->pool,
+ num_ent * sizeof(struct ent *));
+ p = head;
+ x = 0;
+ while (p) {
+ ar[x++] = p;
+ p = p->next;
+ }
- qsort((void *) ar, num_ent, sizeof(struct ent *),
- (int (*)(const void *, const void *)) dsortf);
+ qsort((void *) ar, num_ent, sizeof(struct ent *),
+ (int (*)(const void *, const void *)) dsortf);
}
output_directories(ar, num_ent, autoindex_conf, r, autoindex_opts,
keyid, direction, colargs);
apr_dir_close(thedir);
emit_tail(r, find_readme(autoindex_conf, r),
- autoindex_opts & SUPPRESS_PREAMBLE);
+ autoindex_opts & SUPPRESS_PREAMBLE);
return 0;
}
@@ -2062,36 +2063,36 @@
int allow_opts;
if(strcmp(r->handler,DIR_MAGIC_TYPE)) {
- return DECLINED;
+ return DECLINED;
}
allow_opts = ap_allow_options(r);
d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config,
- &autoindex_module);
+ &autoindex_module);
r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET) {
- return DECLINED;
+ return DECLINED;
}
/* OK, nothing easy. Trot out the heavy artillery... */
if (allow_opts & OPT_INDEXES) {
- /* KLUDGE --- make the sub_req lookups happen in the right directory.
- * Fixing this in the sub_req_lookup functions themselves is difficult,
- * and would probably break virtual includes...
- */
-
- if (r->filename[strlen(r->filename) - 1] != '/') {
- r->filename = apr_pstrcat(r->pool, r->filename, "/", NULL);
- }
- return index_directory(r, d);
+ /* KLUDGE --- make the sub_req lookups happen in the right directory.
+ * Fixing this in the sub_req_lookup functions themselves is difficult,
+ * and would probably break virtual includes...
+ */
+
+ if (r->filename[strlen(r->filename) - 1] != '/') {
+ r->filename = apr_pstrcat(r->pool, r->filename, "/", NULL);
+ }
+ return index_directory(r, d);
}
else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Directory index forbidden by rule: %s", r->filename);
- return HTTP_FORBIDDEN;
+ ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
+ "Directory index forbidden by rule: %s", r->filename);
+ return HTTP_FORBIDDEN;
}
}
@@ -2103,10 +2104,10 @@
module AP_MODULE_DECLARE_DATA autoindex_module =
{
STANDARD20_MODULE_STUFF,
- create_autoindex_config, /* dir config creater */
- merge_autoindex_configs, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- autoindex_cmds, /* command apr_table_t */
- register_hooks /* register hooks */
+ create_autoindex_config, /* dir config creater */
+ merge_autoindex_configs, /* dir merger --- default is to override */
+ NULL, /* server config */
+ NULL, /* merge server config */
+ autoindex_cmds, /* command apr_table_t */
+ register_hooks /* register hooks */
};