Main Page | Modules | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

mod_autoindex.c File Reference

#include "apr_strings.h"
#include "apr_fnmatch.h"
#include "apr_lib.h"
#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"

Include dependency graph for mod_autoindex.c:

Go to the source code of this file.

Defines

#define APR_WANT_STRFUNC
#define NO_OPTIONS   (1 << 0)
#define ICONS_ARE_LINKS   (1 << 1)
#define SCAN_HTML_TITLES   (1 << 2)
#define SUPPRESS_ICON   (1 << 3)
#define SUPPRESS_LAST_MOD   (1 << 4)
#define SUPPRESS_SIZE   (1 << 5)
#define SUPPRESS_DESC   (1 << 6)
#define SUPPRESS_PREAMBLE   (1 << 7)
#define SUPPRESS_COLSORT   (1 << 8)
#define SUPPRESS_RULES   (1 << 9)
#define FOLDERS_FIRST   (1 << 10)
#define VERSION_SORT   (1 << 11)
#define TRACK_MODIFIED   (1 << 12)
#define FANCY_INDEXING   (1 << 13)
#define TABLE_INDEXING   (1 << 14)
#define IGNORE_CLIENT   (1 << 15)
#define IGNORE_CASE   (1 << 16)
#define EMIT_XHTML   (1 << 17)
#define K_NOADJUST   0
#define K_ADJUST   1
#define K_UNSET   2
#define K_NAME   'N'
#define K_LAST_MOD   'M'
#define K_SIZE   'S'
#define K_DESC   'D'
#define K_VALID   "NMSD"
#define D_ASCENDING   'A'
#define D_DESCENDING   'D'
#define D_VALID   "AD"
#define DEFAULT_ICON_WIDTH   20
#define DEFAULT_ICON_HEIGHT   22
#define DEFAULT_NAME_WIDTH   23
#define DEFAULT_DESC_WIDTH   23
#define BY_ENCODING   &c_by_encoding
#define BY_TYPE   &c_by_type
#define BY_PATH   &c_by_path
#define WILDCARDS_REQUIRED   0
#define DIR_CMD_PERMS   OR_INDEXES
#define find_icon(d, p, t)   find_item(p,d->icon_list,t)
#define find_alt(d, p, t)   find_item(p,d->alt_list,t)
#define find_header(d, p)   find_item(p,d->hdr_list,0)
#define find_readme(d, p)   find_item(p,d->rdme_list,0)
#define find_default_icon(d, n)   find_default_item(n, d->icon_list)
#define find_default_alt(d, n)   find_default_item(n, d->alt_list)
#define MATCH_FLAGS   0

Typedefs

typedef ai_desc_t ai_desc_t
typedef autoindex_config_struct autoindex_config_rec

Functions

static void emit_preamble (request_rec *r, int xhtml, const char *title)
static void push_item (apr_array_header_t *arr, char *type, const char *to, const char *path, const char *data)
static const char * add_alt (cmd_parms *cmd, void *d, const char *alt, const char *to)
static const char * add_icon (cmd_parms *cmd, void *d, const char *icon, const char *to)
static const char * add_desc (cmd_parms *cmd, void *d, const char *desc, const char *to)
static const char * add_ignore (cmd_parms *cmd, void *d, const char *ext)
static const char * add_header (cmd_parms *cmd, void *d, const char *name)
static const char * add_readme (cmd_parms *cmd, void *d, const char *name)
static const char * add_opts (cmd_parms *cmd, void *d, const char *optstr)
static const char * set_default_order (cmd_parms *cmd, void *m, const char *direction, const char *key)
static void * create_autoindex_config (apr_pool_t *p, char *dummy)
static void * merge_autoindex_configs (apr_pool_t *p, void *basev, void *addv)
static char * find_item (request_rec *r, apr_array_header_t *list, int path_only)
static char * find_default_item (char *bogus_name, apr_array_header_t *list)
static char * find_desc (autoindex_config_rec *dcfg, const char *filename_full)
static int ignore_entry (autoindex_config_rec *d, char *path)
static void do_emit_plain (request_rec *r, apr_file_t *f)
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 char * find_title (request_rec *r)
static struct entmake_parent_entry (apr_int32_t autoindex_opts, autoindex_config_rec *d, request_rec *r, char keyid, char direction)
static struct entmake_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 * terminate_description (autoindex_config_rec *d, char *desc, apr_int32_t autoindex_opts, int desc_width)
static void emit_link (request_rec *r, const char *anchor, char column, char curkey, char curdirection, const char *colargs, int nosort)
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 dsortf (struct ent **e1, struct ent **e2)
static int index_directory (request_rec *r, autoindex_config_rec *autoindex_conf)
static int handle_autoindex (request_rec *r)
static void register_hooks (apr_pool_t *p)

Variables

module AP_MODULE_DECLARE_DATA autoindex_module
static char c_by_encoding
static char c_by_type
static char c_by_path
static const command_rec autoindex_cmds []


Define Documentation

#define APR_WANT_STRFUNC
 

Definition at line 33 of file mod_autoindex.c.

#define BY_ENCODING   &c_by_encoding
 

Definition at line 143 of file mod_autoindex.c.

Referenced by add_alt(), add_icon(), and find_item().

#define BY_PATH   &c_by_path
 

Definition at line 145 of file mod_autoindex.c.

Referenced by add_alt(), add_icon(), find_item(), and push_item().

#define BY_TYPE   &c_by_type
 

Definition at line 144 of file mod_autoindex.c.

Referenced by find_item().

#define D_ASCENDING   'A'
 

Definition at line 87 of file mod_autoindex.c.

Referenced by emit_link(), index_directory(), make_autoindex_entry(), make_parent_entry(), and set_default_order().

#define D_DESCENDING   'D'
 

Definition at line 88 of file mod_autoindex.c.

Referenced by emit_link(), index_directory(), and set_default_order().

#define D_VALID   "AD"
 

Definition at line 89 of file mod_autoindex.c.

#define DEFAULT_DESC_WIDTH   23
 

Definition at line 101 of file mod_autoindex.c.

Referenced by add_opts(), and create_autoindex_config().

#define DEFAULT_ICON_HEIGHT   22
 

Definition at line 95 of file mod_autoindex.c.

Referenced by add_opts().

#define DEFAULT_ICON_WIDTH   20
 

Definition at line 94 of file mod_autoindex.c.

Referenced by add_opts().

#define DEFAULT_NAME_WIDTH   23
 

Definition at line 100 of file mod_autoindex.c.

Referenced by add_opts(), and create_autoindex_config().

#define DIR_CMD_PERMS   OR_INDEXES
 

Definition at line 523 of file mod_autoindex.c.

#define EMIT_XHTML   (1 << 17)
 

Definition at line 72 of file mod_autoindex.c.

Referenced by add_opts(), index_directory(), and output_directories().

#define FANCY_INDEXING   (1 << 13)
 

Definition at line 68 of file mod_autoindex.c.

Referenced by add_opts(), index_directory(), make_autoindex_entry(), make_parent_entry(), and output_directories().

#define find_alt d,
p,
t   )     find_item(p,d->alt_list,t)
 

Definition at line 749 of file mod_autoindex.c.

Referenced by make_autoindex_entry().

#define find_default_alt d,
n   )     find_default_item(n, d->alt_list)
 

Definition at line 766 of file mod_autoindex.c.

Referenced by make_autoindex_entry(), and make_parent_entry().

#define find_default_icon d,
n   )     find_default_item(n, d->icon_list)
 

Definition at line 765 of file mod_autoindex.c.

Referenced by make_autoindex_entry(), make_parent_entry(), and output_directories().

#define find_header d,
p   )     find_item(p,d->hdr_list,0)
 

Definition at line 750 of file mod_autoindex.c.

Referenced by index_directory().

#define find_icon d,
p,
t   )     find_item(p,d->icon_list,t)
 

Definition at line 748 of file mod_autoindex.c.

Referenced by make_autoindex_entry().

#define find_readme d,
p   )     find_item(p,d->rdme_list,0)
 

Definition at line 751 of file mod_autoindex.c.

Referenced by index_directory().

#define FOLDERS_FIRST   (1 << 10)
 

Definition at line 65 of file mod_autoindex.c.

Referenced by add_opts(), and make_autoindex_entry().

#define ICONS_ARE_LINKS   (1 << 1)
 

Definition at line 56 of file mod_autoindex.c.

Referenced by add_opts(), and output_directories().

#define IGNORE_CASE   (1 << 16)
 

Definition at line 71 of file mod_autoindex.c.

Referenced by add_opts(), and make_autoindex_entry().

#define IGNORE_CLIENT   (1 << 15)
 

Definition at line 70 of file mod_autoindex.c.

Referenced by add_opts(), and index_directory().

#define K_ADJUST   1
 

Definition at line 75 of file mod_autoindex.c.

Referenced by add_opts(), and output_directories().

#define K_DESC   'D'
 

Definition at line 84 of file mod_autoindex.c.

Referenced by dsortf(), output_directories(), and set_default_order().

#define K_LAST_MOD   'M'
 

Definition at line 82 of file mod_autoindex.c.

Referenced by dsortf(), make_autoindex_entry(), output_directories(), and set_default_order().

#define K_NAME   'N'
 

Definition at line 81 of file mod_autoindex.c.

Referenced by index_directory(), output_directories(), and set_default_order().

#define K_NOADJUST   0
 

Definition at line 74 of file mod_autoindex.c.

Referenced by add_opts().

#define K_SIZE   'S'
 

Definition at line 83 of file mod_autoindex.c.

Referenced by dsortf(), output_directories(), and set_default_order().

#define K_UNSET   2
 

Definition at line 76 of file mod_autoindex.c.

Referenced by create_autoindex_config(), merge_autoindex_configs(), and terminate_description().

#define K_VALID   "NMSD"
 

Definition at line 85 of file mod_autoindex.c.

Referenced by index_directory().

#define MATCH_FLAGS   0
 

Definition at line 779 of file mod_autoindex.c.

Referenced by find_desc().

#define NO_OPTIONS   (1 << 0)
 

Definition at line 55 of file mod_autoindex.c.

Referenced by add_opts(), and merge_autoindex_configs().

#define SCAN_HTML_TITLES   (1 << 2)
 

Definition at line 57 of file mod_autoindex.c.

Referenced by add_opts(), and make_autoindex_entry().

#define SUPPRESS_COLSORT   (1 << 8)
 

Definition at line 63 of file mod_autoindex.c.

Referenced by add_opts(), index_directory(), and output_directories().

#define SUPPRESS_DESC   (1 << 6)
 

Definition at line 61 of file mod_autoindex.c.

Referenced by add_opts(), and output_directories().

#define SUPPRESS_ICON   (1 << 3)
 

Definition at line 58 of file mod_autoindex.c.

Referenced by add_opts(), output_directories(), and terminate_description().

#define SUPPRESS_LAST_MOD   (1 << 4)
 

Definition at line 59 of file mod_autoindex.c.

Referenced by add_opts(), output_directories(), and terminate_description().

#define SUPPRESS_PREAMBLE   (1 << 7)
 

Definition at line 62 of file mod_autoindex.c.

Referenced by add_opts(), and index_directory().

#define SUPPRESS_RULES   (1 << 9)
 

Definition at line 64 of file mod_autoindex.c.

Referenced by add_opts(), and output_directories().

#define SUPPRESS_SIZE   (1 << 5)
 

Definition at line 60 of file mod_autoindex.c.

Referenced by add_opts(), output_directories(), and terminate_description().

#define TABLE_INDEXING   (1 << 14)
 

Definition at line 69 of file mod_autoindex.c.

Referenced by add_opts(), index_directory(), make_autoindex_entry(), and output_directories().

#define TRACK_MODIFIED   (1 << 12)
 

Definition at line 67 of file mod_autoindex.c.

Referenced by add_opts(), and index_directory().

#define VERSION_SORT   (1 << 11)
 

Definition at line 66 of file mod_autoindex.c.

Referenced by add_opts(), index_directory(), make_autoindex_entry(), and make_parent_entry().

#define WILDCARDS_REQUIRED   0
 

Definition at line 256 of file mod_autoindex.c.

Referenced by add_desc().


Typedef Documentation

typedef struct ai_desc_t ai_desc_t
 

typedef struct autoindex_config_struct autoindex_config_rec
 


Function Documentation

static const char* add_alt cmd_parms cmd,
void *  d,
const char *  alt,
const char *  to
[static]
 

Definition at line 186 of file mod_autoindex.c.

References BY_ENCODING, BY_PATH, cmd_parms_struct::info, NULL, cmd_parms_struct::path, cmd_parms_struct::pool, and push_item().

Referenced by add_icon().

Here is the call graph for this function:

static const char* add_desc cmd_parms cmd,
void *  d,
const char *  desc,
const char *  to
[static]
 

Definition at line 259 of file mod_autoindex.c.

References ap_strchr_c, autoindex_config_struct::desc_list, ai_desc_t::description, ai_desc_t::full_path, NULL, ai_desc_t::pattern, apr_array_header_t::pool, ai_desc_t::wildcards, and WILDCARDS_REQUIRED.

static const char* add_header cmd_parms cmd,
void *  d,
const char *  name
[static]
 

Definition at line 289 of file mod_autoindex.c.

References NULL, cmd_parms_struct::path, and push_item().

Here is the call graph for this function:

static const char* add_icon cmd_parms cmd,
void *  d,
const char *  icon,
const char *  to
[static]
 

Definition at line 205 of file mod_autoindex.c.

References add_alt(), BY_ENCODING, BY_PATH, cmd_parms_struct::info, NULL, cmd_parms_struct::path, cmd_parms_struct::pool, and push_item().

Here is the call graph for this function:

static const char* add_ignore cmd_parms cmd,
void *  d,
const char *  ext
[static]
 

Definition at line 283 of file mod_autoindex.c.

References NULL, cmd_parms_struct::path, and push_item().

Here is the call graph for this function:

static const char* add_opts cmd_parms cmd,
void *  d,
const char *  optstr
[static]
 

Definition at line 303 of file mod_autoindex.c.

References autoindex_config_struct::decremented_opts, DEFAULT_DESC_WIDTH, DEFAULT_ICON_HEIGHT, DEFAULT_ICON_WIDTH, DEFAULT_NAME_WIDTH, autoindex_config_struct::desc_adjust, autoindex_config_struct::desc_width, EMIT_XHTML, FANCY_INDEXING, FOLDERS_FIRST, autoindex_config_struct::icon_height, autoindex_config_struct::icon_width, ICONS_ARE_LINKS, IGNORE_CASE, IGNORE_CLIENT, autoindex_config_struct::incremented_opts, K_ADJUST, K_NOADJUST, autoindex_config_struct::name_adjust, autoindex_config_struct::name_width, NO_OPTIONS, NULL, autoindex_config_struct::opts, opts, cmd_parms_struct::pool, SCAN_HTML_TITLES, strcasecmp(), strncasecmp(), SUPPRESS_COLSORT, SUPPRESS_DESC, SUPPRESS_ICON, SUPPRESS_LAST_MOD, SUPPRESS_PREAMBLE, SUPPRESS_RULES, SUPPRESS_SIZE, TABLE_INDEXING, TRACK_MODIFIED, and VERSION_SORT.

Here is the call graph for this function:

static const char* add_readme cmd_parms cmd,
void *  d,
const char *  name
[static]
 

Definition at line 296 of file mod_autoindex.c.

References NULL, cmd_parms_struct::path, and push_item().

Here is the call graph for this function:

static void* create_autoindex_config apr_pool_t p,
char *  dummy
[static]
 

Definition at line 563 of file mod_autoindex.c.

References apr_pcalloc, DEFAULT_DESC_WIDTH, DEFAULT_NAME_WIDTH, and K_UNSET.

static void do_emit_plain request_rec r,
apr_file_t f
[static]
 

Definition at line 901 of file mod_autoindex.c.

References AP_IOBUFSIZE, APR_STATUS_IS_EINTR, APR_SUCCESS, buf, c, and n.

Referenced by emit_head(), and emit_tail().

static int dsortf struct ent **  e1,
struct ent **  e2
[static]
 

Definition at line 1824 of file mod_autoindex.c.

References ent::desc, ent::ignore_case, K_DESC, K_LAST_MOD, K_SIZE, ent::key, ent::lm, ent::name, result, ent::size, strcasecmp(), and ent::version_sort.

Referenced by index_directory().

Here is the call graph for this function:

static void emit_head request_rec r,
char *  header_fname,
int  suppress_amble,
int  emit_xhtml,
char *  title
[static]
 

Definition at line 953 of file mod_autoindex.c.

References ap_subreq_core_filter_handle, APR_OS_DEFAULT, APR_READ, APR_REG, APR_SUCCESS, request_rec::args, request_rec::content_type, do_emit_plain(), emit_preamble(), f, request_rec::filename, apr_finfo_t::filetype, request_rec::finfo, ap_filter_t::frec, hdrs, request_rec::headers_in, HTTP_OK, ap_filter_t::next, NULL, OK, request_rec::output_filters, request_rec::pool, request_rec::status, strcasecmp(), and strncasecmp().

Referenced by index_directory().

Here is the call graph for this function:

static void emit_link request_rec r,
const char *  anchor,
char  column,
char  curkey,
char  curdirection,
const char *  colargs,
int  nosort
[static]
 

Definition at line 1416 of file mod_autoindex.c.

References D_ASCENDING, D_DESCENDING, and NULL.

Referenced by output_directories().

static void emit_preamble request_rec r,
int  xhtml,
const char *  title
[static]
 

Definition at line 152 of file mod_autoindex.c.

References DOCTYPE_HTML_3_2, DOCTYPE_XHTML_1_0T, and NULL.

Referenced by emit_head().

static void emit_tail request_rec r,
char *  readme_fname,
int  suppress_amble
[static]
 

Definition at line 1077 of file mod_autoindex.c.

References ap_subreq_core_filter_handle, APR_OS_DEFAULT, APR_READ, APR_REG, APR_SUCCESS, request_rec::content_type, do_emit_plain(), f, request_rec::filename, apr_finfo_t::filetype, request_rec::finfo, ap_filter_t::frec, HTTP_OK, ap_filter_t::next, NULL, OK, request_rec::output_filters, request_rec::pool, request_rec::status, strcasecmp(), and strncasecmp().

Referenced by index_directory().

Here is the call graph for this function:

static char* find_default_item char *  bogus_name,
apr_array_header_t list
[static]
 

Definition at line 753 of file mod_autoindex.c.

References request_rec::content_encoding, request_rec::content_type, request_rec::filename, find_item(), NULL, and r.

Here is the call graph for this function:

static char* find_desc autoindex_config_rec dcfg,
const char *  filename_full
[static]
 

Definition at line 782 of file mod_autoindex.c.

References ap_strrchr_c, ap_strstr_c, autoindex_config_struct::desc_list, ai_desc_t::description, apr_array_header_t::elts, filename, ai_desc_t::full_path, list, MATCH_FLAGS, NULL, ai_desc_t::pattern, and ai_desc_t::wildcards.

Referenced by make_autoindex_entry(), and make_parent_entry().

static char* find_item request_rec r,
apr_array_header_t list,
int  path_only
[static]
 

Definition at line 702 of file mod_autoindex.c.

References item::apply_path, item::apply_to, BY_ENCODING, BY_PATH, BY_TYPE, item::data, apr_array_header_t::elts, nelts, NULL, p, path, and item::type.

Referenced by find_default_item().

static char* find_title request_rec r  )  [static]
 

Definition at line 1140 of file mod_autoindex.c.

References APR_OS_DEFAULT, APR_READ, APR_SUCCESS, apr_tolower, request_rec::content_encoding, request_rec::content_type, CR, request_rec::filename, HTTP_OK, INCLUDES_MAGIC_TYPE, LF, MAX_STRING_LEN, n, NULL, p, request_rec::pool, request_rec::status, strcasecmp(), thefile, x, and y.

Referenced by make_autoindex_entry().

Here is the call graph for this function:

static int handle_autoindex request_rec r  )  [static]
 

Definition at line 2164 of file mod_autoindex.c.

References request_rec::allowed, ap_get_module_config, AP_METHOD_BIT, APLOG_ERR, APLOG_MARK, autoindex_module, DECLINED, DIR_MAGIC_TYPE, request_rec::filename, request_rec::handler, HTTP_FORBIDDEN, index_directory(), M_GET, request_rec::method_number, NULL, OK, OPT_INDEXES, request_rec::per_dir_config, and request_rec::pool.

Referenced by register_hooks().

Here is the call graph for this function:

static int ignore_entry autoindex_config_rec d,
char *  path
[static]