MCPcopy Create free account
hub / github.com/apache/httpd / index_directory

Function index_directory

modules/generators/mod_autoindex.c:2012–2278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2010
2011
2012static int index_directory(request_rec *r,
2013 autoindex_config_rec *autoindex_conf)
2014{
2015 char *title_name = ap_escape_html(r->pool, r->uri);
2016 char *title_endp;
2017 char *name = r->filename;
2018 char *pstring = NULL;
2019 apr_finfo_t dirent;
2020 apr_dir_t *thedir;
2021 apr_status_t status;
2022 int num_ent = 0, x;
2023 struct ent *head, *p;
2024 struct ent **ar = NULL;
2025 const char *qstring;
2026 apr_int32_t autoindex_opts = autoindex_conf->opts;
2027 char keyid;
2028 char direction;
2029 char *colargs;
2030 char *fullpath;
2031 apr_size_t dirpathlen;
2032 char *ctype = "text/html";
2033 char *charset;
2034
2035 if ((status = apr_dir_open(&thedir, name, r->pool)) != APR_SUCCESS) {
2036 ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(01275)
2037 "Can't open directory for index: %s", r->filename);
2038 return HTTP_FORBIDDEN;
2039 }
2040
2041 if (autoindex_conf->ctype) {
2042 ctype = autoindex_conf->ctype;
2043 }
2044 if (autoindex_conf->charset) {
2045 charset = autoindex_conf->charset;
2046 }
2047 else {
2048#if APR_HAS_UNICODE_FS
2049 charset = "UTF-8";
2050#else
2051 charset = "ISO-8859-1";
2052#endif
2053 }
2054 if (*charset) {
2055 ap_set_content_type_ex(r, apr_pstrcat(r->pool, ctype, ";charset=",
2056 charset, NULL), 1);
2057 }
2058 else {
2059 ap_set_content_type_ex(r, ctype, 1);
2060 }
2061
2062 if (autoindex_opts & TRACK_MODIFIED) {
2063 ap_update_mtime(r, r->finfo.mtime);
2064 ap_set_last_modified(r);
2065 ap_set_etag(r);
2066 }
2067 if (r->header_only) {
2068 apr_dir_close(thedir);
2069 return 0;

Callers 1

handle_autoindexFunction · 0.85

Calls 10

ap_set_content_type_exFunction · 0.85
ap_update_mtimeFunction · 0.85
ap_set_last_modifiedFunction · 0.85
ap_set_etagFunction · 0.85
ap_unescape_urlFunction · 0.85
emit_headFunction · 0.85
make_parent_entryFunction · 0.85
make_autoindex_entryFunction · 0.85
output_directoriesFunction · 0.85
emit_tailFunction · 0.85

Tested by

no test coverage detected