Removed unneeded stuff, we will do subrequests
parent
b2553401cf
commit
323cea9298
2
config
2
config
|
@ -2,5 +2,3 @@
|
||||||
ngx_addon_name=ngx_http_fancyindex_module
|
ngx_addon_name=ngx_http_fancyindex_module
|
||||||
HTTP_MODULES="$HTTP_MODULES ngx_http_fancyindex_module"
|
HTTP_MODULES="$HTTP_MODULES ngx_http_fancyindex_module"
|
||||||
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fancyindex_module.c"
|
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fancyindex_module.c"
|
||||||
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_dict.c"
|
|
||||||
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/inliner.c"
|
|
||||||
|
|
96
inliner.c
96
inliner.c
|
@ -1,96 +0,0 @@
|
||||||
/*
|
|
||||||
* inliner.c
|
|
||||||
* Copyright © 2007 Adrian Perez <adrianperez@udc.es>
|
|
||||||
*
|
|
||||||
* Distributed under terms of the MIT license.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ngx_config.h>
|
|
||||||
#include <ngx_core.h>
|
|
||||||
#include <ngx_http.h>
|
|
||||||
|
|
||||||
|
|
||||||
ngx_buf_t* nfi_inline_getbuf(ngx_http_request_t *r,
|
|
||||||
const ngx_str_t const * path, ngx_int_t mode)
|
|
||||||
{
|
|
||||||
size_t root_len;
|
|
||||||
u_char *pos;
|
|
||||||
ngx_str_t resolved;
|
|
||||||
ngx_buf_t *buf;
|
|
||||||
ngx_file_t *bfile;
|
|
||||||
ngx_file_info_t bfileinfo;
|
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
||||||
"http nfi_inline_getbuf path: \"%V\"", path);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: We do not handle absolute paths in configuration file yet.
|
|
||||||
*/
|
|
||||||
pos = ngx_http_map_uri_to_path(r, &resolved, &root_len, path->len);
|
|
||||||
ngx_memcpy(pos, path->data, path->len);
|
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
||||||
"nfi_inline_getbuf resolved: \"%V\"", &resolved);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Append final '\0' so we can use it to call ngx_file_info() below.
|
|
||||||
*
|
|
||||||
* If stat() fails, we know the file does *not* exist. We also check
|
|
||||||
* whether the file is readable. Note that if the file exists and is
|
|
||||||
* readable, the file info will be in the kernel inode cache so we
|
|
||||||
* do not incur in a lot of overhead by retrieving the information
|
|
||||||
* first.
|
|
||||||
*/
|
|
||||||
resolved.data[resolved.len] = '\0';
|
|
||||||
|
|
||||||
if (ngx_file_info(resolved.data, &bfileinfo) != 0) {
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, ngx_errno,
|
|
||||||
"nfi_inline_getbuf no file stats");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ngx_is_file(&bfileinfo) || /* we read regular files... */
|
|
||||||
!(ngx_file_access(&bfileinfo) & 0444) /* ...which can be read... */
|
|
||||||
|| ngx_is_link(&bfileinfo)) /* ...and are not symlinks. */
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
bfile = ngx_pcalloc(r->pool, sizeof(ngx_file_t));
|
|
||||||
if (bfile == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Fill in the file structure with sensible values. */
|
|
||||||
bfile->fd = NGX_INVALID_FILE;
|
|
||||||
bfile->name.len = resolved.len;
|
|
||||||
bfile->name.data = resolved.data;
|
|
||||||
ngx_memcpy(&bfile->info, &bfileinfo, sizeof(ngx_file_info_t));
|
|
||||||
bfile->valid_info = 1;
|
|
||||||
|
|
||||||
buf = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
|
|
||||||
if (buf == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ngx_pcalloc() makes zeros, which are good defaults for most values, we
|
|
||||||
* tell nginx that the file is on-disk, not in memory, and we associate
|
|
||||||
* the corresponding file information (ngx_file_t) structure.
|
|
||||||
*/
|
|
||||||
buf->file = bfile;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Data is in the file, so we set the flag. Nginx will decide whether to
|
|
||||||
* read and send the contents or issue a call to snedfile() or whatever.
|
|
||||||
*/
|
|
||||||
buf->in_file = 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We want to send all the contents of the file, so set the offset of the
|
|
||||||
* last sent byte to the length of the file minus one (remeber: use offset)
|
|
||||||
*/
|
|
||||||
buf->file_last = ngx_file_size(&bfileinfo) - 1;
|
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
||||||
"nfi_inline_getbuf returned buf %p", buf);
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
279
ngx_dict.c
279
ngx_dict.c
|
@ -1,279 +0,0 @@
|
||||||
/*
|
|
||||||
* ngx_dict.c
|
|
||||||
* Copyright © 2007 Adrian Perez <adrianperez@udc.es>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NGX_DICT_DEFAULT_SIZE
|
|
||||||
#define NGX_DICT_DEFAULT_SIZE 128
|
|
||||||
#endif /* !NGX_DICT_DEFAULT_SIZE */
|
|
||||||
|
|
||||||
#ifndef NGX_DICT_RESIZE_FACTOR
|
|
||||||
#define NGX_DICT_RESIZE_FACTOR 10
|
|
||||||
#endif /* !NGX_DICT_RESIZE_FACTOR */
|
|
||||||
|
|
||||||
#ifndef NGX_DICT_COUNT_TO_SIZE_RATIO
|
|
||||||
#define NGX_DICT_COUNT_TO_SIZE_RATIO 1.2
|
|
||||||
#endif /* !NGX_DICT_COUNT_TO_SIZE_RATIO */
|
|
||||||
|
|
||||||
#ifndef NGX_DICT_HASH
|
|
||||||
#define NGX_DICT_HASH(_k, _s) (ngx_dict_hashstr(_k) % ((_s) - 1))
|
|
||||||
#endif /* !NGX_DICT_HASH */
|
|
||||||
|
|
||||||
#ifndef NGX_DICT_HASHN
|
|
||||||
#define NGX_DICT_HASHN(_k, _s, _n) (ngx_dict_hashnstr(_k, _n) % ((_s) - 1))
|
|
||||||
#endif /* !NGX_DICT_HASHN */
|
|
||||||
|
|
||||||
#ifndef NGX_DICT_KEY_EQ
|
|
||||||
#define NGX_DICT_KEY_EQ(_a, _b) (ngx_dict_streq((_a), (_b)))
|
|
||||||
#endif /* !NGX_DICT_KEY_EQ */
|
|
||||||
|
|
||||||
#ifndef NGX_DICT_KEY_EQN
|
|
||||||
#define NGX_DICT_KEY_EQN(_a, _b, _blen) (ngx_dict_strneq((_a), (_b), (_blen)))
|
|
||||||
#endif /* !NGX_DICT_KEY_EQN */
|
|
||||||
|
|
||||||
#include "ngx_dict.h"
|
|
||||||
|
|
||||||
|
|
||||||
static ngx_slab_pool_t s_node_slab;
|
|
||||||
static ngx_slab_pool_t s_strs_slab;
|
|
||||||
|
|
||||||
|
|
||||||
static inline ngx_dict_node_t*
|
|
||||||
_ngx_dict_node_new(const ngx_str_t *key, void *val)
|
|
||||||
{
|
|
||||||
ngx_dict_node_t *node;
|
|
||||||
|
|
||||||
node = ngx_slab_alloc(&s_node_slab, sizeof(ngx_dict_node_t));
|
|
||||||
node->val = val;
|
|
||||||
node->key.len = key->len;
|
|
||||||
/* FIXME: Allocate from proper place! */
|
|
||||||
node->key.data = ngx_slab_alloc(&s_strs_slab, key->len);
|
|
||||||
/* TODO: Copy string data */
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline ngx_dict_node_t*
|
|
||||||
_ngx_dict_node_newn(const ngx_str_t *key, size_t len, void *val)
|
|
||||||
{
|
|
||||||
ngx_dict_node_t *node;
|
|
||||||
|
|
||||||
node = ngx_slab_alloc(&s_node_slab, sizeof(ngx_dict_node_t));
|
|
||||||
node->val = val;
|
|
||||||
node->key.len = len;
|
|
||||||
/* FIXME: Allocate from proper place! */
|
|
||||||
node->key.data = ngx_slab_alloc(&s_strs_slab, len);
|
|
||||||
/* TODO: Copy string data */
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
_ngx_dict_node_free(ngx_dict_node_t *node)
|
|
||||||
{
|
|
||||||
/* TODO: What to free and how?
|
|
||||||
w_free(node->key);
|
|
||||||
w_free(node);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
_ngx_dict_free_nodes(ngx_dict_t *d)
|
|
||||||
{
|
|
||||||
ngx_dict_node_t *node = d->first;
|
|
||||||
ngx_dict_node_t *next;
|
|
||||||
|
|
||||||
while (node) {
|
|
||||||
next = node->nextNode;
|
|
||||||
_ngx_dict_node_free(node);
|
|
||||||
node = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
ngx_dict_init(ngx_pool_t *pool, ngx_dict_t *d)
|
|
||||||
{
|
|
||||||
d->size = NGX_DICT_DEFAULT_SIZE;
|
|
||||||
/* TODO: Allocate this one... from where?
|
|
||||||
d->nodes = w_alloc(w_dict_node_t*, d->size);
|
|
||||||
*/
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ngx_dict_free(ngx_dict_t *d)
|
|
||||||
{
|
|
||||||
_ngx_dict_free_nodes(d);
|
|
||||||
/* FIXME: How to deallocate those?
|
|
||||||
w_free(d->nodes);
|
|
||||||
w_free(d);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ngx_dict_clear(ngx_dict_t *d)
|
|
||||||
{
|
|
||||||
_ngx_dict_free_nodes(d);
|
|
||||||
memset(d->nodes, 0x00, d->size * sizeof(ngx_dict_node_t*));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void*
|
|
||||||
ngx_dict_getn(const ngx_dict_t *d, const ngx_str_t *key, size_t len)
|
|
||||||
{
|
|
||||||
ngx_dict_node_t *node;
|
|
||||||
unsigned hval;
|
|
||||||
|
|
||||||
hval = NGX_DICT_HASHN(key, d->size, len);
|
|
||||||
node = d->nodes[hval];
|
|
||||||
|
|
||||||
if (node) {
|
|
||||||
if (NGX_DICT_KEY_EQN(&node->key, key, len)) {
|
|
||||||
return node->val;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ngx_dict_node_t *lastNode = node;
|
|
||||||
node = node->next;
|
|
||||||
while (node) {
|
|
||||||
if (NGX_DICT_KEY_EQN(&node->key, key, len)) {
|
|
||||||
lastNode->next = node->next;
|
|
||||||
node->next = d->nodes[hval];
|
|
||||||
d->nodes[hval] = node;
|
|
||||||
return node->val;
|
|
||||||
}
|
|
||||||
lastNode = node;
|
|
||||||
node = node->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
_ngx_dict_rehash(ngx_dict_t *d)
|
|
||||||
{
|
|
||||||
ngx_dict_node_t *node = d->first;
|
|
||||||
|
|
||||||
while (node) {
|
|
||||||
node->next = NULL;
|
|
||||||
node = node->nextNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->size *= NGX_DICT_RESIZE_FACTOR;
|
|
||||||
/* TODO FIXME XXX: How the hell do we resize memory with nginx's model?
|
|
||||||
d->nodes = w_resize(d->nodes, w_dict_node_t*, ++d->size);
|
|
||||||
*/
|
|
||||||
memset(d->nodes, 0x00, d->size * sizeof(ngx_dict_node_t*));
|
|
||||||
|
|
||||||
for (node = d->first; node; node = node->nextNode) {
|
|
||||||
unsigned hval = NGX_DICT_HASH(&node->key, d->size);
|
|
||||||
ngx_dict_node_t *n = d->nodes[hval];
|
|
||||||
if (!n) d->nodes[hval] = node;
|
|
||||||
else {
|
|
||||||
for (;; n = n->next) {
|
|
||||||
if (!n->next) {
|
|
||||||
n->next = node;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ngx_dict_setn(ngx_dict_t *d, const ngx_str_t *key, size_t len, void *val)
|
|
||||||
{
|
|
||||||
unsigned hval;
|
|
||||||
ngx_dict_node_t *node;
|
|
||||||
|
|
||||||
hval = NGX_DICT_HASHN(key, d->size, len);
|
|
||||||
node = d->nodes[hval];
|
|
||||||
|
|
||||||
while (node) {
|
|
||||||
if (NGX_DICT_KEY_EQN(&node->key, key, len)) {
|
|
||||||
node->val = val;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
node = node->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
node = _ngx_dict_node_newn(key, len, val);
|
|
||||||
|
|
||||||
if (d->nodes[hval]) node->next = d->nodes[hval];
|
|
||||||
d->nodes[hval] = node;
|
|
||||||
|
|
||||||
node->nextNode = d->first;
|
|
||||||
if (d->first) d->first->prevNode = node;
|
|
||||||
d->first = node;
|
|
||||||
|
|
||||||
d->count++;
|
|
||||||
if (d->count > (d->size * NGX_DICT_COUNT_TO_SIZE_RATIO))
|
|
||||||
_ngx_dict_rehash(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ngx_dict_del(ngx_dict_t *d, const ngx_str_t *key)
|
|
||||||
{
|
|
||||||
unsigned hval;
|
|
||||||
ngx_dict_node_t *node;
|
|
||||||
ngx_dict_node_t *lastNode = NULL;
|
|
||||||
|
|
||||||
hval = NGX_DICT_HASH(key, d->size);
|
|
||||||
|
|
||||||
for (node = d->nodes[hval]; node; node = node->next) {
|
|
||||||
if (NGX_DICT_KEY_EQ(&node->key, key)) {
|
|
||||||
ngx_dict_node_t *prevNode = node->prevNode;
|
|
||||||
ngx_dict_node_t *nextNode = node->nextNode;
|
|
||||||
|
|
||||||
if (prevNode) prevNode->nextNode = nextNode;
|
|
||||||
else d->first = nextNode;
|
|
||||||
if (nextNode) nextNode->prevNode = prevNode;
|
|
||||||
|
|
||||||
if (lastNode) lastNode->next = node->next;
|
|
||||||
else d->nodes[hval] = node->next;
|
|
||||||
|
|
||||||
_ngx_dict_node_free(node);
|
|
||||||
d->count--;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ngx_dict_traverse_nodes(const ngx_dict_t *d, ngx_dict_traverse_fun_t f, void *ctx)
|
|
||||||
{
|
|
||||||
ngx_dict_node_t *n;
|
|
||||||
|
|
||||||
for (n = ngx_dict_first_node(d); n != NULL; n = ngx_dict_next_node(n))
|
|
||||||
(*f)(n, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ngx_dict_traverse_keys(const ngx_dict_t *d, ngx_dict_traverse_fun_t f, void *ctx)
|
|
||||||
{
|
|
||||||
ngx_dict_node_t *n;
|
|
||||||
|
|
||||||
for (n = ngx_dict_first_node(d); n != NULL; n = ngx_dict_next_node(n))
|
|
||||||
(*f)(&n->key, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ngx_dict_traverse_values(const ngx_dict_t *d, ngx_dict_traverse_fun_t f, void *ctx)
|
|
||||||
{
|
|
||||||
ngx_dict_node_t *n;
|
|
||||||
|
|
||||||
for (n = ngx_dict_first_node(d); n != NULL; n = ngx_dict_next_node(n))
|
|
||||||
(*f)(n->val, ctx);
|
|
||||||
}
|
|
||||||
|
|
161
ngx_dict.h
161
ngx_dict.h
|
@ -1,161 +0,0 @@
|
||||||
/*
|
|
||||||
* ngx_dict.h
|
|
||||||
* Copyright © 2007 Adrian Perez <adrianperez@udc.es>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ngx_dict_h__
|
|
||||||
#define __ngx_dict_h__ 1
|
|
||||||
|
|
||||||
#include <ngx_config.h>
|
|
||||||
#include <ngx_core.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Declarations for inline stuff (implemented below)
|
|
||||||
*/
|
|
||||||
static inline int
|
|
||||||
ngx_dict_streq(const ngx_str_t const* a, const ngx_str_t const* b);
|
|
||||||
static inline int
|
|
||||||
ngx_dict_strneq(const ngx_str_t const* a, const ngx_str_t const* b,
|
|
||||||
register size_t len);
|
|
||||||
static inline unsigned
|
|
||||||
ngx_dict_strhash(const ngx_str_t *s);
|
|
||||||
static inline unsigned
|
|
||||||
ngx_dict_strnhash(const ngx_str_t *s, register size_t len);
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct ngx_dict ngx_dict_t;
|
|
||||||
typedef void** ngx_dict_iterator_t;
|
|
||||||
typedef void (*ngx_dict_traverse_fun_t)(void *data, void *context);
|
|
||||||
|
|
||||||
|
|
||||||
int ngx_dict_init(ngx_pool_t *pool, ngx_dict_t *d);
|
|
||||||
void ngx_dict_free(ngx_dict_t *d);
|
|
||||||
void ngx_dict_clear(ngx_dict_t *d);
|
|
||||||
|
|
||||||
size_t ngx_dict_count(const ngx_dict_t *d);
|
|
||||||
|
|
||||||
void* ngx_dict_getn(const ngx_dict_t *d, const ngx_str_t *key, size_t keylen);
|
|
||||||
void ngx_dict_setn(ngx_dict_t *d, const ngx_str_t *key, size_t keylen, void *data);
|
|
||||||
|
|
||||||
#define ngx_dict_get(_d, _s) \
|
|
||||||
ngx_dict_getn((_d), (_s), (_s)->len)
|
|
||||||
|
|
||||||
#define ngx_dict_set(_d, _s, _v) \
|
|
||||||
ngx_dict_setn((_d), (_s), (_s)->len, (_v))
|
|
||||||
|
|
||||||
void ngx_dict_del(ngx_dict_t *d, const ngx_str_t *key);
|
|
||||||
void ngx_dict_update(ngx_dict_t *d, const ngx_dict_t *o);
|
|
||||||
|
|
||||||
void ngx_dict_traverse_nodes(const ngx_dict_t *d,
|
|
||||||
ngx_dict_traverse_fun_t f, void *ctx);
|
|
||||||
|
|
||||||
void ngx_dict_traverse_keys(const ngx_dict_t *d,
|
|
||||||
ngx_dict_traverse_fun_t f, void *ctx);
|
|
||||||
|
|
||||||
void ngx_dict_traverse_values(const ngx_dict_t *d,
|
|
||||||
ngx_dict_traverse_fun_t f, void *ctx);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the layout of a dictionary node. Do not move "val" out of the
|
|
||||||
* first place, or the iterator trick won't work anymore.
|
|
||||||
*/
|
|
||||||
typedef struct ngx_dict_node ngx_dict_node_t;
|
|
||||||
|
|
||||||
struct ngx_dict_node
|
|
||||||
{
|
|
||||||
void *val;
|
|
||||||
ngx_str_t key;
|
|
||||||
ngx_dict_node_t *next;
|
|
||||||
ngx_dict_node_t *nextNode;
|
|
||||||
ngx_dict_node_t *prevNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct ngx_dict
|
|
||||||
{
|
|
||||||
ngx_dict_node_t **nodes;
|
|
||||||
ngx_dict_node_t *first;
|
|
||||||
unsigned count;
|
|
||||||
unsigned size;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#define ngx_dict_first_node(_d) \
|
|
||||||
((_d)->first)
|
|
||||||
|
|
||||||
#define ngx_dict_next_node(_n) \
|
|
||||||
((_n)->nextNode)
|
|
||||||
|
|
||||||
#define ngx_dict_count(_d) \
|
|
||||||
((_d)->count)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Inline functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
ngx_dict_streq(const ngx_str_t const* a, const ngx_str_t const* b)
|
|
||||||
{
|
|
||||||
register unsigned len;
|
|
||||||
u_char *sa, *sb;
|
|
||||||
|
|
||||||
if (a->len != b->len) return 0;
|
|
||||||
|
|
||||||
for (sa = a->data, sb = b->data, len = a->len; len--;)
|
|
||||||
if (*sa++ != *sb++) return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
ngx_dict_strneq(const ngx_str_t const* a, const ngx_str_t const* b, register size_t len)
|
|
||||||
{
|
|
||||||
u_char *sa, *sb;
|
|
||||||
|
|
||||||
if ((a->len != b->len) || (a->len < len)) return 0;
|
|
||||||
|
|
||||||
for (sa = a->data, sb = b->data; len--;)
|
|
||||||
if (*sa++ != *sb++) return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline unsigned
|
|
||||||
ngx_dict_hashstr(const ngx_str_t *s)
|
|
||||||
{
|
|
||||||
register unsigned ret = 0;
|
|
||||||
register unsigned ctr = 0;
|
|
||||||
register unsigned cnt = s->len;
|
|
||||||
register u_char *str = s->data;
|
|
||||||
|
|
||||||
while (cnt--) {
|
|
||||||
ret ^= *str++ << ctr;
|
|
||||||
ctr = (ctr + 1) % sizeof(void*);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline unsigned
|
|
||||||
ngx_dict_hashnstr(const ngx_str_t *s, register unsigned len)
|
|
||||||
{
|
|
||||||
register unsigned ret = 0;
|
|
||||||
register unsigned ctr = 0;
|
|
||||||
register u_char *str = s->data;
|
|
||||||
|
|
||||||
if (len > s->len)
|
|
||||||
len = s->len;
|
|
||||||
|
|
||||||
while (len--) {
|
|
||||||
ret ^= *str++ << ctr;
|
|
||||||
ctr = (ctr + 1) % sizeof(void*);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !__ngx_dict_h__ */
|
|
||||||
|
|
|
@ -191,8 +191,6 @@ ngx_http_fancyindex_handler(ngx_http_request_t *r)
|
||||||
ngx_tm_t tm;
|
ngx_tm_t tm;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_buf_t *bheader = NULL;
|
|
||||||
ngx_buf_t *bfooter = NULL;
|
|
||||||
ngx_int_t rc, size;
|
ngx_int_t rc, size;
|
||||||
ngx_str_t path;
|
ngx_str_t path;
|
||||||
ngx_str_t readme_path;
|
ngx_str_t readme_path;
|
||||||
|
@ -389,15 +387,10 @@ ngx_http_fancyindex_handler(ngx_http_request_t *r)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to get header and footer, if enabled.
|
* FIXME: When adding header and/or footer from external resources we
|
||||||
|
* are wasting some bytes here because we allocate space for *all*
|
||||||
|
* built-in template pieces.
|
||||||
*/
|
*/
|
||||||
if (alcf->header.len > 0) {
|
|
||||||
bheader = nfi_inline_getbuf(r, &alcf->header, alcf->include_mode);
|
|
||||||
}
|
|
||||||
if (alcf->footer.len > 0) {
|
|
||||||
bfooter = nfi_inline_getbuf(r, &alcf->footer, alcf->include_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
len = NFI_TEMPLATE_SIZE
|
len = NFI_TEMPLATE_SIZE
|
||||||
+ r->uri.len /* URI is included two times: as <title> in the */
|
+ r->uri.len /* URI is included two times: as <title> in the */
|
||||||
+ r->uri.len /* HTML head and as an <h1> in the HTML body */
|
+ r->uri.len /* HTML head and as an <h1> in the HTML body */
|
||||||
|
|
|
@ -93,18 +93,6 @@ typedef struct {
|
||||||
(((_where) & (_what)) == (_what))
|
(((_where) & (_what)) == (_what))
|
||||||
|
|
||||||
|
|
||||||
#include <ngx_http.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a buffer out of a file name. The buffer will be ready to add to
|
|
||||||
* a processing chain (an ngx_chain_t). The "mode" determines how the file
|
|
||||||
* will be searched for, it ca be either NGX_HTTP_FANCYINDEX_INCLUDE_STATIC
|
|
||||||
* or NGX_HTTP_FANCYINDEX_INCLUDE_CACHED.
|
|
||||||
*/
|
|
||||||
ngx_buf_t* nfi_inline_getbuf(ngx_http_request_t *req,
|
|
||||||
const ngx_str_t const * path, ngx_int_t mode);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__ngx_http_fancyindex_module_h__ */
|
#endif /* !__ngx_http_fancyindex_module_h__ */
|
||||||
/* vim:ft=c
|
/* vim:ft=c
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue