#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#if 0
typedef struct {
ngx_buf_t *buf;
size_t size;
ngx_pool_t *pool;
size_t alloc_size;
ngx_chain_t **last_out;
} ngx_http_autoindex_ctx_t;
#endif
ngx_http_autoindex_entry_t;
ngx_http_autoindex_loc_conf_t;
#define NGX_HTTP_AUTOINDEX_HTML …
#define NGX_HTTP_AUTOINDEX_JSON …
#define NGX_HTTP_AUTOINDEX_JSONP …
#define NGX_HTTP_AUTOINDEX_XML …
#define NGX_HTTP_AUTOINDEX_PREALLOCATE …
#define NGX_HTTP_AUTOINDEX_NAME_LEN …
static ngx_buf_t *ngx_http_autoindex_html(ngx_http_request_t *r,
ngx_array_t *entries);
static ngx_buf_t *ngx_http_autoindex_json(ngx_http_request_t *r,
ngx_array_t *entries, ngx_str_t *callback);
static ngx_int_t ngx_http_autoindex_jsonp_callback(ngx_http_request_t *r,
ngx_str_t *callback);
static ngx_buf_t *ngx_http_autoindex_xml(ngx_http_request_t *r,
ngx_array_t *entries);
static int ngx_libc_cdecl ngx_http_autoindex_cmp_entries(const void *one,
const void *two);
static ngx_int_t ngx_http_autoindex_error(ngx_http_request_t *r,
ngx_dir_t *dir, ngx_str_t *name);
static ngx_int_t ngx_http_autoindex_init(ngx_conf_t *cf);
static void *ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf);
static char *ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child);
static ngx_conf_enum_t ngx_http_autoindex_format[] = …;
static ngx_command_t ngx_http_autoindex_commands[] = …;
static ngx_http_module_t ngx_http_autoindex_module_ctx = …;
ngx_module_t ngx_http_autoindex_module = …;
static ngx_int_t
ngx_http_autoindex_handler(ngx_http_request_t *r)
{ … }
static ngx_buf_t *
ngx_http_autoindex_html(ngx_http_request_t *r, ngx_array_t *entries)
{ … }
static ngx_buf_t *
ngx_http_autoindex_json(ngx_http_request_t *r, ngx_array_t *entries,
ngx_str_t *callback)
{ … }
static ngx_int_t
ngx_http_autoindex_jsonp_callback(ngx_http_request_t *r, ngx_str_t *callback)
{ … }
static ngx_buf_t *
ngx_http_autoindex_xml(ngx_http_request_t *r, ngx_array_t *entries)
{ … }
static int ngx_libc_cdecl
ngx_http_autoindex_cmp_entries(const void *one, const void *two)
{ … }
#if 0
static ngx_buf_t *
ngx_http_autoindex_alloc(ngx_http_autoindex_ctx_t *ctx, size_t size)
{
ngx_chain_t *cl;
if (ctx->buf) {
if ((size_t) (ctx->buf->end - ctx->buf->last) >= size) {
return ctx->buf;
}
ctx->size += ctx->buf->last - ctx->buf->pos;
}
ctx->buf = ngx_create_temp_buf(ctx->pool, ctx->alloc_size);
if (ctx->buf == NULL) {
return NULL;
}
cl = ngx_alloc_chain_link(ctx->pool);
if (cl == NULL) {
return NULL;
}
cl->buf = ctx->buf;
cl->next = NULL;
*ctx->last_out = cl;
ctx->last_out = &cl->next;
return ctx->buf;
}
#endif
static ngx_int_t
ngx_http_autoindex_error(ngx_http_request_t *r, ngx_dir_t *dir, ngx_str_t *name)
{ … }
static void *
ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf)
{ … }
static char *
ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
{ … }
static ngx_int_t
ngx_http_autoindex_init(ngx_conf_t *cf)
{ … }