Apache HTTPD
Classes | Macros | Typedefs | Functions | Variables
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"

Go to the source code of this file.

Classes

struct  item
 
struct  ai_desc_t
 
struct  autoindex_config_struct
 
struct  ent
 

Macros

#define APR_WANT_STRFUNC
 
#define NO_OPTIONS   (1 << 0) /* Indexing options */
 
#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 SHOW_FORBIDDEN   (1 << 18)
 
#define ADDALTCLASS   (1 << 19)
 
#define OPTION_UNSET   (1 << 20)
 
#define K_NOADJUST   0
 
#define K_ADJUST   1
 
#define K_UNSET   2
 
#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'
 
#define D_DESCENDING   'D'
 
#define D_VALID   "AD" /* String containing _all_ valid D_ opts */
 
#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_by_request(p,d->icon_list,t)
 
#define find_alt(d, p, t)   find_item_by_request(p,d->alt_list,t)
 
#define find_default_icon(d, n)   find_item(NULL, NULL, n, d->icon_list, 1)
 
#define find_default_alt(d, n)   find_item(NULL, NULL, n, d->alt_list, 1)
 
#define MATCH_FLAGS   0
 

Typedefs

typedef struct ai_desc_t ai_desc_t
 
typedef struct autoindex_config_struct autoindex_config_rec
 

Functions

static APR_INLINE int response_is_html (request_rec *r)
 
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 charadd_alt (cmd_parms *cmd, void *d, const char *alt, const char *to)
 
static const charadd_icon (cmd_parms *cmd, void *d, const char *icon, const char *to)
 
static const charadd_desc (cmd_parms *cmd, void *d, const char *desc, const char *to)
 
static const charadd_ignore (cmd_parms *cmd, void *d, const char *ext)
 
static const charadd_opts (cmd_parms *cmd, void *d, int argc, char *const argv[])
 
static const charset_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 charfind_item (const char *content_type, const char *content_encoding, char *path, apr_array_header_t *list, int path_only)
 
static charfind_item_by_request (request_rec *r, apr_array_header_t *list, int path_only)
 
static charfind_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 charfind_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 charterminate_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

static char c_by_encoding
 
static char c_by_type
 
static char c_by_path
 
static const command_rec autoindex_cmds []
 
static int *const aplog_module_index = &( autoindex_module.module_index)
 

Macro Definition Documentation

◆ ADDALTCLASS

#define ADDALTCLASS   (1 << 19)

Definition at line 74 of file mod_autoindex.c.

◆ APR_WANT_STRFUNC

#define APR_WANT_STRFUNC

Definition at line 33 of file mod_autoindex.c.

◆ BY_ENCODING

#define BY_ENCODING   &c_by_encoding

Definition at line 152 of file mod_autoindex.c.

◆ BY_PATH

#define BY_PATH   &c_by_path

Definition at line 154 of file mod_autoindex.c.

◆ BY_TYPE

#define BY_TYPE   &c_by_type

Definition at line 153 of file mod_autoindex.c.

◆ D_ASCENDING

#define D_ASCENDING   'A'

Definition at line 90 of file mod_autoindex.c.

◆ D_DESCENDING

#define D_DESCENDING   'D'

Definition at line 91 of file mod_autoindex.c.

◆ D_VALID

#define D_VALID   "AD" /* String containing _all_ valid D_ opts */

Definition at line 92 of file mod_autoindex.c.

◆ DEFAULT_DESC_WIDTH

#define DEFAULT_DESC_WIDTH   23

Definition at line 104 of file mod_autoindex.c.

◆ DEFAULT_ICON_HEIGHT

#define DEFAULT_ICON_HEIGHT   22

Definition at line 98 of file mod_autoindex.c.

◆ DEFAULT_ICON_WIDTH

#define DEFAULT_ICON_WIDTH   20

Definition at line 97 of file mod_autoindex.c.

◆ DEFAULT_NAME_WIDTH

#define DEFAULT_NAME_WIDTH   23

Definition at line 103 of file mod_autoindex.c.

◆ DIR_CMD_PERMS

#define DIR_CMD_PERMS   OR_INDEXES

Definition at line 562 of file mod_autoindex.c.

◆ EMIT_XHTML

#define EMIT_XHTML   (1 << 17)

Definition at line 72 of file mod_autoindex.c.

◆ FANCY_INDEXING

#define FANCY_INDEXING   (1 << 13)

Definition at line 68 of file mod_autoindex.c.

◆ find_alt

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

Definition at line 811 of file mod_autoindex.c.

◆ find_default_alt

#define find_default_alt (   d,
  n 
)    find_item(NULL, NULL, n, d->alt_list, 1)

Definition at line 813 of file mod_autoindex.c.

◆ find_default_icon

#define find_default_icon (   d,
  n 
)    find_item(NULL, NULL, n, d->icon_list, 1)

Definition at line 812 of file mod_autoindex.c.

◆ find_icon

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

Definition at line 810 of file mod_autoindex.c.

◆ FOLDERS_FIRST

#define FOLDERS_FIRST   (1 << 10)

Definition at line 65 of file mod_autoindex.c.

◆ ICONS_ARE_LINKS

#define ICONS_ARE_LINKS   (1 << 1)

Definition at line 56 of file mod_autoindex.c.

◆ IGNORE_CASE

#define IGNORE_CASE   (1 << 16)

Definition at line 71 of file mod_autoindex.c.

◆ IGNORE_CLIENT

#define IGNORE_CLIENT   (1 << 15)

Definition at line 70 of file mod_autoindex.c.

◆ K_ADJUST

#define K_ADJUST   1

Definition at line 78 of file mod_autoindex.c.

◆ K_DESC

#define K_DESC   'D' /* Description */

Definition at line 87 of file mod_autoindex.c.

◆ K_LAST_MOD

#define K_LAST_MOD   'M' /* Last modification date */

Definition at line 85 of file mod_autoindex.c.

◆ K_NAME

#define K_NAME   'N' /* Sort by file name (default) */

Definition at line 84 of file mod_autoindex.c.

◆ K_NOADJUST

#define K_NOADJUST   0

Definition at line 77 of file mod_autoindex.c.

◆ K_SIZE

#define K_SIZE   'S' /* Size (absolute, not as displayed) */

Definition at line 86 of file mod_autoindex.c.

◆ K_UNSET

#define K_UNSET   2

Definition at line 79 of file mod_autoindex.c.

◆ K_VALID

#define K_VALID   "NMSD" /* String containing _all_ valid K_ opts */

Definition at line 88 of file mod_autoindex.c.

◆ MATCH_FLAGS

#define MATCH_FLAGS   0

Definition at line 826 of file mod_autoindex.c.

◆ NO_OPTIONS

#define NO_OPTIONS   (1 << 0) /* Indexing options */

Definition at line 55 of file mod_autoindex.c.

◆ OPTION_UNSET

#define OPTION_UNSET   (1 << 20)

Definition at line 75 of file mod_autoindex.c.

◆ SCAN_HTML_TITLES

#define SCAN_HTML_TITLES   (1 << 2)

Definition at line 57 of file mod_autoindex.c.

◆ SHOW_FORBIDDEN

#define SHOW_FORBIDDEN   (1 << 18)

Definition at line 73 of file mod_autoindex.c.

◆ SUPPRESS_COLSORT

#define SUPPRESS_COLSORT   (1 << 8)

Definition at line 63 of file mod_autoindex.c.

◆ SUPPRESS_DESC

#define SUPPRESS_DESC   (1 << 6)

Definition at line 61 of file mod_autoindex.c.

◆ SUPPRESS_ICON

#define SUPPRESS_ICON   (1 << 3)

Definition at line 58 of file mod_autoindex.c.

◆ SUPPRESS_LAST_MOD

#define SUPPRESS_LAST_MOD   (1 << 4)

Definition at line 59 of file mod_autoindex.c.

◆ SUPPRESS_PREAMBLE

#define SUPPRESS_PREAMBLE   (1 << 7)

Definition at line 62 of file mod_autoindex.c.

◆ SUPPRESS_RULES

#define SUPPRESS_RULES   (1 << 9)

Definition at line 64 of file mod_autoindex.c.

◆ SUPPRESS_SIZE

#define SUPPRESS_SIZE   (1 << 5)

Definition at line 60 of file mod_autoindex.c.

◆ TABLE_INDEXING

#define TABLE_INDEXING   (1 << 14)

Definition at line 69 of file mod_autoindex.c.

◆ TRACK_MODIFIED

#define TRACK_MODIFIED   (1 << 12)

Definition at line 67 of file mod_autoindex.c.

◆ VERSION_SORT

#define VERSION_SORT   (1 << 11)

Definition at line 66 of file mod_autoindex.c.

◆ WILDCARDS_REQUIRED

#define WILDCARDS_REQUIRED   0

Definition at line 292 of file mod_autoindex.c.

Typedef Documentation

◆ ai_desc_t

◆ autoindex_config_rec

Function Documentation

◆ add_alt()

static const char * add_alt ( cmd_parms cmd,
void *  d,
const char alt,
const char to 
)
static

Definition at line 222 of file mod_autoindex.c.

◆ add_desc()

static const char * add_desc ( cmd_parms cmd,
void *  d,
const char desc,
const char to 
)
static

Definition at line 295 of file mod_autoindex.c.

◆ add_icon()

static const char * add_icon ( cmd_parms cmd,
void *  d,
const char icon,
const char to 
)
static

Definition at line 241 of file mod_autoindex.c.

◆ add_ignore()

static const char * add_ignore ( cmd_parms cmd,
void *  d,
const char ext 
)
static

Definition at line 319 of file mod_autoindex.c.

◆ add_opts()

static const char * add_opts ( cmd_parms cmd,
void *  d,
int  argc,
char *const  argv[] 
)
static

Definition at line 325 of file mod_autoindex.c.

◆ create_autoindex_config()

static void * create_autoindex_config ( apr_pool_t p,
char dummy 
)
static

Definition at line 614 of file mod_autoindex.c.

◆ do_emit_plain()

static void do_emit_plain ( request_rec r,
apr_file_t f 
)
static

Definition at line 948 of file mod_autoindex.c.

◆ dsortf()

static int dsortf ( struct ent **  e1,
struct ent **  e2 
)
static

Definition at line 1910 of file mod_autoindex.c.

◆ emit_head()

static void emit_head ( request_rec r,
char header_fname,
int  suppress_amble,
int  emit_xhtml,
char title 
)
static

< Module has handled this stage.

< Open the file for reading

<

Deprecated:
See also
APR_FOPEN_READ

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

Definition at line 1000 of file mod_autoindex.c.

◆ emit_link()

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 1477 of file mod_autoindex.c.

◆ emit_preamble()

static void emit_preamble ( request_rec r,
int  xhtml,
const char title 
)
static

Definition at line 169 of file mod_autoindex.c.

◆ emit_tail()

static void emit_tail ( request_rec r,
char readme_fname,
int  suppress_amble 
)
static

< Module has handled this stage.

< Open the file for reading

<

Deprecated:
See also
APR_FOPEN_READ

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

Definition at line 1132 of file mod_autoindex.c.

◆ find_desc()

static char * find_desc ( autoindex_config_rec dcfg,
const char filename_full 
)
static

Definition at line 829 of file mod_autoindex.c.

◆ find_item()

static char * find_item ( const char content_type,
const char content_encoding,
char path,
apr_array_header_t list,
int  path_only 
)
static

Definition at line 761 of file mod_autoindex.c.

◆ find_item_by_request()

static char * find_item_by_request ( request_rec r,
apr_array_header_t list,
int  path_only 
)
static

Definition at line 804 of file mod_autoindex.c.

◆ find_title()

static char * find_title ( request_rec r)
static

< Open the file for reading

<

Deprecated:
See also
APR_FOPEN_READ

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

Definition at line 1194 of file mod_autoindex.c.

◆ handle_autoindex()

static int handle_autoindex ( request_rec r)
static

< Module declines to handle

< Module declines to handle

RFC 2616: HTTP

RFC 2616: HTTP

< Module declines to handle

< Module has handled this stage.

Definition at line 2282 of file mod_autoindex.c.

◆ ignore_entry()

static int ignore_entry ( autoindex_config_rec d,
char path 
)
static

Definition at line 871 of file mod_autoindex.c.

◆ index_directory()

static int index_directory ( request_rec r,
autoindex_config_rec autoindex_conf 
)
static

< Module has handled this stage.

< type, mtime, ctime, atime, size

< ->name in proper case

< ->name in proper case

< ->name in proper case

Definition at line 2012 of file mod_autoindex.c.

◆ make_autoindex_entry()

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

< Disable backslash escaping.

< Period must be matched by period.

< Module has handled this stage.

Definition at line 1302 of file mod_autoindex.c.

◆ make_parent_entry()

static struct ent * make_parent_entry ( apr_int32_t  autoindex_opts,
autoindex_config_rec d,
request_rec r,
char  keyid,
char  direction 
)
static

Definition at line 1249 of file mod_autoindex.c.

◆ merge_autoindex_configs()

static void * merge_autoindex_configs ( apr_pool_t p,
void *  basev,
void *  addv 
)
static

Definition at line 638 of file mod_autoindex.c.

◆ output_directories()

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

Definition at line 1503 of file mod_autoindex.c.

◆ push_item()

static void push_item ( apr_array_header_t arr,
char type,
const char to,
const char path,
const char data 
)
static

Definition at line 198 of file mod_autoindex.c.

◆ register_hooks()

static void register_hooks ( apr_pool_t p)
static

Definition at line 2336 of file mod_autoindex.c.

◆ response_is_html()

static APR_INLINE int response_is_html ( request_rec r)
static

Definition at line 156 of file mod_autoindex.c.

◆ set_default_order()

static const char * set_default_order ( cmd_parms cmd,
void *  m,
const char direction,
const char key 
)
static

Definition at line 527 of file mod_autoindex.c.

◆ terminate_description()

static char * terminate_description ( autoindex_config_rec d,
char desc,
apr_int32_t  autoindex_opts,
int  desc_width 
)
static

Definition at line 1418 of file mod_autoindex.c.

Variable Documentation

◆ aplog_module_index

int* const aplog_module_index = &( autoindex_module.module_index)
static

Definition at line 2341 of file mod_autoindex.c.

◆ autoindex_cmds

const command_rec autoindex_cmds[]
static

Definition at line 564 of file mod_autoindex.c.

◆ c_by_encoding

char c_by_encoding
static

Definition at line 150 of file mod_autoindex.c.

◆ c_by_path

char c_by_path
static

Definition at line 150 of file mod_autoindex.c.

◆ c_by_type

char c_by_type
static

Definition at line 150 of file mod_autoindex.c.