last++ = _evenodd[i & 0x01];
/*
* Alternative implementation:
* *b->last++ = (i & 0x01) ? 'e' : 'o';
*/
- b->last = nfi_cpymem_ssz(b->last, "\">last = ngx_cpymem_ssz(b->last, "\"> | last, entry[i].name.data, entry[i].name.len,
@@ -477,7 +549,7 @@ skip_readme_top:
b->last += entry[i].name.len + entry[i].escape;
} else {
- b->last = nfi_cpymem_str(b->last, entry[i].name);
+ b->last = ngx_cpymem_str(b->last, entry[i].name);
}
if (entry[i].dir) {
@@ -506,7 +578,7 @@ skip_readme_top:
}
if (len > NGX_HTTP_FANCYINDEX_NAME_LEN) {
- b->last = nfi_cpymem_ssz(last, "..> | ");
+ b->last = ngx_cpymem_ssz(last, "..> | ");
} else {
if (entry[i].dir && NGX_HTTP_FANCYINDEX_NAME_LEN - len > 0) {
@@ -514,7 +586,7 @@ skip_readme_top:
len++;
}
- b->last = nfi_cpymem_ssz(b->last, " | ");
+ b->last = ngx_cpymem_ssz(b->last, " | ");
}
if (alcf->exact_size) {
@@ -582,15 +654,15 @@ skip_readme_top:
}
/* Output table bottom */
- b->last = nfi_cpymem_ssz(b->last, t06_list2);
+ b->last = ngx_cpymem_ssz(b->last, t06_list2);
/* Insert readme at bottom, if appropriate */
if ((readme_path.len == 0) ||
- nfi_has_flag(alcf->readme_flags, NGX_HTTP_FANCYINDEX_README_TOP) ||
- !nfi_has_flag(alcf->readme_flags, NGX_HTTP_FANCYINDEX_README_BOTTOM))
+ ngx_has_flag(alcf->readme_flags, NGX_HTTP_FANCYINDEX_README_TOP) ||
+ !ngx_has_flag(alcf->readme_flags, NGX_HTTP_FANCYINDEX_README_BOTTOM))
goto skip_readme_bottom;
- if (nfi_has_flag(alcf->readme_flags, NGX_HTTP_FANCYINDEX_README_IFRAME))
+ if (ngx_has_flag(alcf->readme_flags, NGX_HTTP_FANCYINDEX_README_IFRAME))
nfi_add_readme_iframe();
else {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
@@ -637,8 +709,8 @@ ngx_http_fancyindex_handler(ngx_http_request_t *r)
return rc;
r->headers_out.status = NGX_HTTP_OK;
- r->headers_out.content_type_len = nfi_sizeof_ssz("text/html");
- r->headers_out.content_type.len = nfi_sizeof_ssz("text/html");
+ r->headers_out.content_type_len = ngx_sizeof_ssz("text/html");
+ r->headers_out.content_type.len = ngx_sizeof_ssz("text/html");
r->headers_out.content_type.data = (u_char *) "text/html";
rc = ngx_http_send_header(r);
@@ -785,46 +857,9 @@ ngx_http_fancyindex_cmp_entries(const void *one, const void *two)
}
-#if 0
-
-static ngx_buf_t *
-ngx_http_fancyindex_alloc(ngx_http_fancyindex_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_inline ngx_str_t
-nfi_get_readme_path(ngx_http_request_t *r, const ngx_str_t *path)
+get_readme_path(ngx_http_request_t *r, const ngx_str_t *path)
{
u_char *last;
ngx_file_info_t info;
@@ -838,8 +873,8 @@ nfi_get_readme_path(ngx_http_request_t *r, const ngx_str_t *path)
fullpath.len = path->len + 2 + alcf->readme.len;
fullpath.data = ngx_palloc(r->pool, fullpath.len);
- last = nfi_cpymem_str(fullpath.data, *path); *last++ = '/';
- last = nfi_cpymem_str(last, alcf->readme); *last++ = '\0';
+ last = ngx_cpymem_str(fullpath.data, *path); *last++ = '/';
+ last = ngx_cpymem_str(last, alcf->readme); *last++ = '\0';
/* File does not exists, or cannot be accessed */
if (ngx_file_info(fullpath.data, &info) != 0)
diff --git a/ngx_http_fancyindex_module.h b/ngx_http_fancyindex_module.h
deleted file mode 100644
index 9340cf8..0000000
--- a/ngx_http_fancyindex_module.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * ngx_http_fancyindex_module.h
- * Copyright © 2007 Adrian Perez
- *
- * Distributed under terms of the BSD license.
- */
-
-#ifndef __ngx_http_fancyindex_module_h__
-#define __ngx_http_fancyindex_module_h__
-
-#include
-#include
-
-
-#define NGX_HTTP_FANCYINDEX_README_ASIS 0x01
-#define NGX_HTTP_FANCYINDEX_README_TOP 0x02
-#define NGX_HTTP_FANCYINDEX_README_BOTTOM 0x04
-#define NGX_HTTP_FANCYINDEX_README_DIV 0x08
-#define NGX_HTTP_FANCYINDEX_README_IFRAME 0x10
-#define NGX_HTTP_FANCYINDEX_README_PRE 0x20
-
-
-/*
- * NGX_HTTP_FANCYINDEX_INCLUDE_STATIC
- * Cache file contents on first request
- * NGX_HTTP_FANCYINDEX_INCLUDE_CACHED
- * Cache file contents on first request,
- * and re-read if needed afterwards
- */
-#define NGX_HTTP_FANCYINDEX_INCLUDE_STATIC 0
-#define NGX_HTTP_FANCYINDEX_INCLUDE_CACHED 1
-
-
-
-/**
- * Configuration structure for the fancyindex module. The configuration
- * commands defined in the module do fill in the members of this structure.
- */
-typedef struct {
- ngx_flag_t enable; /**< Module is enabled. */
- ngx_flag_t localtime; /**< File mtime dates are sent in local time. */
- ngx_flag_t exact_size; /**< Sizes are sent always in bytes. */
-
- ngx_str_t header; /**< File name for header, or empty if none. */
- ngx_str_t footer; /**< File name for footer, or empty if none. */
- ngx_str_t readme; /**< File name for readme, or empty if none. */
-
- ngx_uint_t readme_flags; /**< Options for readme file inclusion. */
-} ngx_http_fancyindex_loc_conf_t;
-
-
-
-
-#define nfi_sizeof_ssz(_s) (sizeof(_s) - 1)
-
-
-#define NGX_HTTP_FANCYINDEX_PREALLOCATE 50
-#define NGX_HTTP_FANCYINDEX_NAME_LEN 50
-
-
-/**
- * Copy a static zero-terminated string. Useful to output template
- * string pieces into a temporary buffer.
- */
-#define nfi_cpymem_ssz(_p, _t) \
- (ngx_cpymem((_p), (_t), sizeof(_t) - 1))
-
-/**
- * Copy a ngx_str_t.
- */
-#define nfi_cpymem_str(_p, _s) \
- (ngx_cpymem((_p), (_s).data, (_s).len))
-
-/**
- * Copy a static zero-terminated string, but only if the string is
- * non-empty. Using this may avoid jumping into ngx_cpymem().
- */
-#define nfi_maybe_cpymem_ssz(__p, __t) \
- if ((__t)[0] != '\0') nfi_cpymem_ssz((__p), (__t))
-
-#define nfi_has_flag(_where, _what) \
- (((_where) & (_what)) == (_what))
-
-
-#define nfi_log_debug_buf_chain(_r, _b) \
- do { \
- ngx_chain_t *__chain_b = (_b); \
- ngx_buf_t *__temp_b = __chain_b->buf; \
- while (!__temp_b->last_buf && __chain_b->buf != NULL) { \
- ngx_log_debug(NGX_LOG_DEBUG_HTTP, (_r)->connection->log, 0, \
- "http fancyindex: buf %p, last_in_buf = %i\n" \
- "\tmemory = %i, temporary = %i\n", \
- __temp_b, __temp_b->last_in_chain, \
- __temp_b->memory, __temp_b->temporary \
- ); \
- __chain_b = __chain_b->next; \
- __temp_b = __chain_b->buf; \
- } \
- } while (0)
-
-
-#endif /* !__ngx_http_fancyindex_module_h__ */
-/* vim:ft=c
- */
|