From 5a4d9e05f6cddc0b44915079d31724d6b60ed7f5 Mon Sep 17 00:00:00 2001
From: Lennart Poettering
Date: Mon, 23 Jan 2006 01:17:14 +0000
Subject: port to apache 2.0
git-svn-id: file:///home/lennart/svn/public/mod_mime_xattr/trunk@12 f01872de-66d6-0310-9185-fc3b30f50adc
---
Makefile.am | 8 +--
NOTICE | 1 -
bootstrap.sh | 39 ++++++----
configure.ac | 63 ++++++++++++++--
doc/Makefile.am | 2 +-
doc/README.html.in | 52 ++++++++------
doc/style.css | 19 ++---
src/Makefile.in | 43 +++++------
src/mod_mime_xattr.c | 198 ++++++++++++++++++++++++++++++---------------------
9 files changed, 257 insertions(+), 168 deletions(-)
delete mode 100644 NOTICE
diff --git a/Makefile.am b/Makefile.am
index d45b20d..609829e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
# $Id$
-# Copyright 2004 Lennart Poettering
+# Copyright 2004-2006 Lennart Poettering
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License. You
@@ -14,11 +14,11 @@
# implied. See the License for the specific language governing
# permissions and limitations under the License.
-EXTRA_DIST=bootstrap.sh README LICENSE NOTICE
+EXTRA_DIST=bootstrap.sh README LICENSE src/mod_mime_xattr.c src/Makefile.in
SUBDIRS=src doc
MAINTAINERCLEANFILES = README
-noinst_DATA = README NOTICE LICENSE
+noinst_DATA = README LICENSE
README:
rm -f README
@@ -30,7 +30,7 @@ homepage: all dist
mkdir -p $$HOME/homepage/private/projects/mod_mime_xattr
cp *.tar.gz $$HOME/homepage/private/projects/mod_mime_xattr
cp doc/README.html doc/style.css $$HOME/homepage/private/projects/mod_mime_xattr
- cp $$HOME/homepage/private/projects/mod_mime_xattr/README.html $$HOME/homepage/private/projects/mod_mime_xattr/index.html
+ ln -sf $$HOME/homepage/private/projects/mod_mime_xattr/README.html $$HOME/homepage/private/projects/mod_mime_xattr/index.html
distcleancheck:
@:
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index 8587606..0000000
--- a/NOTICE
+++ /dev/null
@@ -1 +0,0 @@
-This software has been developed by Lennart Poettering
diff --git a/bootstrap.sh b/bootstrap.sh
index f843d46..19315af 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# $Id$
-# Copyright 2004 Lennart Poettering
+# Copyright 2004-2006 Lennart Poettering
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License. You
@@ -15,29 +15,44 @@
# implied. See the License for the specific language governing
# permissions and limitations under the License.
+VERSION=1.9
+
run_versioned() {
local P
- type -p "$1-$2" &> /dev/null && P="$1-$2" || local P="$1"
+ local V
+
+ V=$(echo "$2" | sed -e 's,\.,,g')
+
+ if [ -e "`which $1$V`" ] ; then
+ P="$1$V"
+ else
+ if [ -e "`which $1-$2`" ] ; then
+ P="$1-$2"
+ else
+ P="$1"
+ fi
+ fi
shift 2
"$P" "$@"
}
+set -ex
+
if [ "x$1" = "xam" ] ; then
- set -ex
- run_versioned automake 1.7 -a -c
+ run_versioned automake "$VERSION" -a -c --foreign
./config.status
else
- set -ex
rm -rf autom4te.cache
rm -f config.cache
- run_versioned aclocal 1.7
- autoheader
- run_versioned automake 1.7 -a -c
- autoconf -Wall
-
- ./configure --sysconfdir=/etc "$@"
+ run_versioned aclocal "$VERSION"
+ run_versioned autoconf 2.59 -Wall
+ run_versioned autoheader 2.59
+ run_versioned automake "$VERSION" -a -c --foreign
- make clean
+ if test "x$NOCONFIGURE" = "x"; then
+ CFLAGS="-g -O0" ./configure --sysconfdir=/etc "$@"
+ make clean
+ fi
fi
diff --git a/configure.ac b/configure.ac
index dd204f4..df981ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
# $Id$
-# Copyright 2004 Lennart Poettering
+# Copyright 2004-2006 Lennart Poettering
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License. You
@@ -17,11 +17,11 @@
# implied. See the License for the specific language governing
# permissions and limitations under the License.
-AC_PREREQ(2.59)
-AC_INIT([mod_mime_xattr],[0.2],[mzzvzrkngge (at) 0pointer (dot) de])
+AC_PREREQ(2.57)
+AC_INIT([mod_mime_xattr],[0.3],[mzzvzrkngge (at) 0pointer (dot) net])
AC_CONFIG_SRCDIR([src/mod_mime_xattr.c])
AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([foreign -Wall])
+AM_INIT_AUTOMAKE([foreign 1.9 -Wall])
AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/mod_mime_xattr/])
@@ -31,15 +31,66 @@ AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET
+test_gcc_flag() {
+ AC_LANG_CONFTEST([int main() {}])
+ $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
+ ret=$?
+ rm -f conftest.o
+ return $ret
+}
+
+# If using GCC specify some additional parameters
+if test "x$GCC" = "xyes" ; then
+
+ DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Winline"
+
+ if test "x$HAVE_NETLINK" = "xyes" ; then
+ # Test whether rtnetlink.h can be included when compiled with -std=c99
+ # some distributions (e.g. archlinux) have broken headers that dont
+ # define __u64 with -std=c99
+ AC_MSG_CHECKING([checking whether rtnetlink.h can be included with -std=c99])
+ OLDCFLAGS="$CFLAGS"
+ CFLAGS="-std=c99"
+ AC_TRY_COMPILE([#include ], [],
+ use_stdc99=yes, use_stdc99=no)
+
+ if test x"$use_stdc99" = xyes; then
+ DESIRED_FLAGS="-std=c99 $DESIRED_FLAGS"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+
+ CFLAGS="$OLDCFLAGS"
+ else
+ DESIRED_FLAGS="-std=c99 $DESIRED_FLAGS"
+ fi
+
+ for flag in $DESIRED_FLAGS ; do
+ AC_MSG_CHECKING([whether $CC accepts $flag])
+ if test_gcc_flag $flag ; then
+ CFLAGS="$CFLAGS $flag"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ done
+fi
+
AC_ARG_WITH(apxs,
AS_HELP_STRING(--with-apxs=PATH,/path/to/apxs),
- [ AC_PATH_PROG(APXS, apxs, "notfound", "$withval:$PATH") ],
- [ AC_PATH_PROG(APXS, apxs, "notfound", "/usr/local/apache/bin:/usr/local/bin:/usr/sbin:$PATH")])
+ [ AC_PATH_PROGS(APXS, [apxs2 apxs], "notfound", "$withval:$PATH") ],
+ [ AC_PATH_PROGS(APXS, [apxs2 apxs], "notfound", "/usr/local/apache/bin:/usr/local/bin:/usr/sbin:$PATH")])
if test "x$APXS" = "xnotfound" ; then
AC_MSG_ERROR([*** Sorry, could not find apxs ***])
fi
+AC_ARG_WITH(apachectl,
+ AS_HELP_STRING(--with-apachectl=PATH,/path/to/apachectl),
+ [ AC_PATH_PROGS(APACHECTL, [apache2ctl apachectl], "notfound", "$withval:$PATH") ],
+ [ AC_PATH_PROGS(APACHECTL, [apache2ctl apachectl], "notfound", "/usr/local/apache/bin:/usr/local/bin:/usr/sbin:$PATH")])
+
# Check for libattr
AC_CHECK_LIB([attr], [getxattr],, [AC_MSG_ERROR([*** Sorry, you have to install libattr ***])])
AC_CHECK_HEADER([attr/xattr.h],, [AC_MSG_ERROR([*** Sorry, you have to install the libattr headers ***])])
diff --git a/doc/Makefile.am b/doc/Makefile.am
index f21e42c..50afd4f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,6 +1,6 @@
# $Id$
-# Copyright 2004 Lennart Poettering
+# Copyright 2004-2006 Lennart Poettering
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License. You
diff --git a/doc/README.html.in b/doc/README.html.in
index 575ffd9..4d69132 100644
--- a/doc/README.html.in
+++ b/doc/README.html.in
@@ -10,7 +10,7 @@
-Copyright 2004 Lennart Poettering <@PACKAGE_BUGREPORT@>
+Copyright 2004-2006 Lennart Poettering <@PACKAGE_BUGREPORT@>
- License
@@ -42,6 +42,10 @@ permissions and limitations under the License.
+Mon Jan 23 2004:
Version
+0.3 released; changes include: ported to Apache 2.0 - For Apache 1 use versions <= 0.2
+
Sun Mar 28 2004:
Version
0.2 released; changes include: look for both user.mime_type and user.mime-type for compliance with XDG
@@ -53,7 +57,7 @@ href="@PACKAGE_URL@mod_mime_xattr-0.1.tar.gz">Version
mod_mime_xattr is a module for the Apache HTTPD 1.3 which may be used to
+href="http://httpd.apache.org/">Apache HTTPD 2.0 which may be used to
set a range of MIME properties of files served from a document tree with
extended attributes (EAs) as supported by the underlying file
system. The current version of mod_mime_xattr has support for
@@ -83,38 +87,38 @@ MIME database specification as published by Requirements
-
A current release of Apache 1.3 with apxs, the development
+
A current release of Apache 2.0 (2.2 probably works, too) with apxs, the development
headers and libraries installed. You need to install libattr
and its development package.
@@ -157,7 +161,7 @@ and its development package.
easy to do, however. Feel free to send me patches!
mod_mime_xattr was developed and tested on Debian GNU/Linux
-"testing" from March 2004, it should work on most other Linux
+"testing" from January 2006, it should work on most other Linux
distributions since it uses GNU autoconf source code configuration.
@@ -178,12 +182,14 @@ compilation and make install (as root) for installation of
The current release is @PACKAGE_VERSION@
-Get mod_mime_xattr's development sources from the Subversion repository.
+Get mod_mime_xattr's development sources from the Subversion repository (viewcvs):
+
+svn checkout svn://svn.0pointer.net/mod_mime_xattr/trunk mod_mime_xattr
If you want to be notified whenever I release a new version of this software use the subscription feature of Freshmeat.
-Lennart Poettering <@PACKAGE_BUGREPORT@>, March 2004
+Lennart Poettering <@PACKAGE_BUGREPORT@>, January 2006
$Id$
diff --git a/doc/style.css b/doc/style.css
index 3499640..7d7eb75 100644
--- a/doc/style.css
+++ b/doc/style.css
@@ -1,8 +1,7 @@
/* $Id$ */
/***
-
- Copyright 2004 Lennart Poettering
+ Copyright 2004-2006 Lennart Poettering
Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You
@@ -15,18 +14,10 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
-
***/
-body { color: black; background-color: white; margin: 0.5cm; }
+body { color: black; background-color: white; }
a:link, a:visited { color: #900000; }
-p { margin-left: 0.5cm; margin-right: 0.5cm; }
-div.news-date { margin-left: 0.5cm; font-size: 80%; color: #4f0000; }
-p.news-text { margin-left: 1cm; }
-h1 { color: #00009F; }
-h2 { color: #00009F; }
-h3 { color: #00004F; margin-left: 0.5cm; }
-ul { margin-left: .5cm; }
-ol { margin-left: .5cm; }
-pre { margin-left: .5cm; background-color: #f0f0f0; padding: 0.4cm;}
-.grey { color: #afafaf; }
+div.news-date { font-size: 80%; font-style: italic; }
+pre { background-color: #f0f0f0; padding: 0.4cm; }
+.grey { color: #8f8f8f; font-size: 80%; }
diff --git a/src/Makefile.in b/src/Makefile.in
index 0311c0d..92d3ec5 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,6 +1,6 @@
# $Id$
-# Copyright 2004 Lennart Poettering
+# Copyright 2004-2006 Lennart Poettering
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License. You
@@ -14,51 +14,40 @@
# implied. See the License for the specific language governing
# permissions and limitations under the License.
-DISTFILES=Makefile.in mod_mime_xattr.c
APXS=@APXS@
-APACHECTL=apachectl
+APACHECTL=@APACHECTL@
+LIBS=-Wl,"@LIBS@"
+CFLAGS=-Wc,"@CFLAGS@"
-# additional user defines, includes and libraries
-#DEF=-Dmy_define=my_value
-#INC=-Imy/include/dir
-#LIB=-Lmy/lib/dir -lc -lmylib
-LIB=-lattr
+all: mod_mime_xattr.la
-# the default target
-all: mod_mime_xattr.so
+mod_mime_xattr.la: @srcdir@/mod_mime_xattr.c
+ $(APXS) -c $(CFLAGS) $(LIBS) @srcdir@/mod_mime_xattr.c
-# compile the DSO file
-mod_mime_xattr.so: mod_mime_xattr.c
- $(APXS) -c $(DEF) $(INC) $(LIB) mod_mime_xattr.c
-
-# install the DSO file into the Apache installation
-# and activate it in the Apache configuration
install: all
- $(APXS) -i -a -n 'mime_xattr' mod_mime_xattr.so
+ $(APXS) -i -a mod_mime_xattr.la
-# cleanup
clean:
- -rm -f mod_mime_xattr.o mod_mime_xattr.so
+ rm -rf *.o *.so *.loT .deps/ *.la *.lo *.slo .libs/
-# reload the module by installing and restarting Apache
reload: install restart
-# the general Apache start/restart/stop procedures
start:
$(APACHECTL) start
+
restart:
$(APACHECTL) restart
+
stop:
$(APACHECTL) stop
-distdir:
- mkdir -p $(distdir)
- cp -p $(DISTFILES) $(distdir)
-
mostlyclean: clean
distclean: clean
-
maintainer-clean: clean
rm -f Makefile
-.PHONY: all clean maintainer-clean mostlyclean distclean distdir install reload start stop restart
+Makefile: @srcdir@/Makefile.in
+ (cd .. && ./config.status )
+
+
+.PHONY: all install clean reload start restart stop mostlyclean distclean maintainer-clean
diff --git a/src/mod_mime_xattr.c b/src/mod_mime_xattr.c
index 3a18b1e..a08fb4d 100644
--- a/src/mod_mime_xattr.c
+++ b/src/mod_mime_xattr.c
@@ -1,8 +1,7 @@
/* $Id$ */
/***
-
- Copyright 2004 Lennart Poettering
+ Copyright 2004-2006 Lennart Poettering
Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You
@@ -15,21 +14,32 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
-
***/
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
#include
#include
#include
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "ap_config.h"
+#ifdef __GNUC__
+#define __unused __attribute__ ((unused))
+#else
+#define __unused
+#endif
+
#define XATTR_NAME_MIMETYPE "user.mime_type"
#define XATTR_NAME_MIMETYPE2 "user.mime-type"
@@ -39,61 +49,68 @@
#define XATTR_NAME_HANDLER "user.apache_handler"
#define XATTR_NAME_HANDLER2 "user.apache-handler"
-module MODULE_VAR_EXPORT mime_xattr_module;
+module AP_MODULE_DECLARE_DATA mime_xattr_module;
struct mime_xattr_dir_config {
int enable_mime_type;
+ int enable_mime_type_set;
int enable_handler;
+ int enable_handler_set;
};
-static void* create_mime_xattr_dir_config(pool *p, char*dummy) {
- struct mime_xattr_dir_config *c = (struct mime_xattr_dir_config*) ap_palloc(p, sizeof(struct mime_xattr_dir_config));
+static void* create_mime_xattr_dir_config(apr_pool_t *p, __unused char *dummy) {
+ struct mime_xattr_dir_config *c = apr_palloc(p, sizeof(struct mime_xattr_dir_config));
+
c->enable_mime_type = 0;
+ c->enable_mime_type_set = 0;
c->enable_handler = 0;
+ c->enable_handler_set = 0;
+
+ return c;
+}
+
+static void *merge_mime_xattr_dir_config(apr_pool_t *p, void *basev, void *overridesv) {
+ struct mime_xattr_dir_config *base = basev, *override = overridesv, *c;
+
+ c = apr_palloc(p, sizeof(struct mime_xattr_dir_config));
+
+ c->enable_mime_type = override->enable_mime_type_set ? override->enable_mime_type : base->enable_mime_type;
+ c->enable_mime_type_set = override->enable_mime_type_set || base->enable_mime_type_set;
+ c->enable_handler = override->enable_handler_set ? override->enable_handler : base->enable_handler;
+ c->enable_handler_set = override->enable_handler_set || base->enable_handler_set;
+
return c;
}
-static const char *enable_xattr_mime_type(cmd_parms *parms, void *mconfig, int flag) {
- struct mime_xattr_dir_config *c = (struct mime_xattr_dir_config*) mconfig;
+static const char *enable_xattr_mime_type(__unused cmd_parms *parms, void *mconfig, int flag) {
+ struct mime_xattr_dir_config *c = mconfig;
+
c->enable_mime_type = flag;
+ c->enable_mime_type_set = 1;
+
return NULL;
}
-static const char *enable_xattr_handler(cmd_parms *parms, void *mconfig, int flag) {
- struct mime_xattr_dir_config *c = (struct mime_xattr_dir_config*) mconfig;
+static const char *enable_xattr_handler(__unused cmd_parms *parms, void *mconfig, int flag) {
+ struct mime_xattr_dir_config *c = mconfig;
+
c->enable_handler = flag;
+ c->enable_handler_set = 1;
+
return NULL;
}
-static const command_rec mime_xattr_cmds[] = {
- {"XAttrMimeType",
- enable_xattr_mime_type,
- NULL,
- OR_FILEINFO,
- FLAG,
- "Requires 'On' or 'Off' for enabling resp. disabling usage of file system extended attribute data for MIME type detection." },
-
- {"XAttrHandler",
- enable_xattr_handler,
- NULL,
- OR_FILEINFO,
- FLAG,
- "Requires 'On' or 'Off' for enabling resp. disabling usage of file system extended attribute data for handler detection." },
-
- { NULL }
-};
-
-static char* get_xattr(pool *p, const char *fn, const char *attr) {
+static char* get_xattr(apr_pool_t *p, const char *fn, const char *attr) {
char v[256];
ssize_t l;
- if ((l = lgetxattr(fn, attr, v, sizeof(v)-1)) < 0)
- if ((l = getxattr(fn, attr, v, sizeof(v)-1)) < 0)
+ if ((l = lgetxattr(fn, attr, v, sizeof(v)-1)) <= 0)
+ if ((l = getxattr(fn, attr, v, sizeof(v)-1)) <= 0)
return NULL;
v[l] = 0;
- return ap_pstrdup(p, v);
+ return apr_pstrdup(p, v);
}
static char* validate_charset(char *f) {
@@ -101,7 +118,9 @@ static char* validate_charset(char *f) {
for (c = f; *c; c++) {
*c = tolower(*c);
- if (!(*c >= 'a' && *c <= 'z') && !(*c >= '0' && *c <= '9') && *c != '-')
+ if (!(*c >= 'a' && *c <= 'z') &&
+ !(*c >= '0' && *c <= '9') &&
+ *c != '-')
return NULL;
}
@@ -125,7 +144,9 @@ static char* validate_mime_type(char *f) {
return NULL;
}
- if (!(*c >= 'a' && *c <= 'z') && !(*c >= '0' && *c <= '9') && *c != '-')
+ if (!(*c >= 'a' && *c <= 'z') &&
+ !(*c >= '0' && *c <= '9') &&
+ *c != '-')
return NULL;
}
@@ -135,28 +156,28 @@ static char* validate_mime_type(char *f) {
static int find_ct(request_rec *r) {
int result = DECLINED;
struct mime_xattr_dir_config* c;
-
- if (r->finfo.st_mode == 0 || !r->filename || !S_ISREG(r->finfo.st_mode))
+
+ if (!(r->finfo.valid & APR_FINFO_TYPE) || !r->filename || r->finfo.filetype != APR_REG)
return DECLINED;
- c = (struct mime_xattr_dir_config*) ap_get_module_config(r->per_dir_config, &mime_xattr_module);
+ c = ap_get_module_config(r->per_dir_config, &mime_xattr_module);
if (c->enable_mime_type) {
char *mime_type, *charset, *encoding;
if ((charset = get_xattr(r->pool, r->filename, XATTR_NAME_CHARSET)))
if (!(charset = validate_charset(charset)))
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "mod_mime_xattr: bad charset specification on file <%s>", r->filename);
+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server, "Bad charset specification on file '%s'", r->filename);
if (!(mime_type = get_xattr(r->pool, r->filename, XATTR_NAME_MIMETYPE)))
mime_type = get_xattr(r->pool, r->filename, XATTR_NAME_MIMETYPE2);
if (mime_type) {
if (!(mime_type = validate_mime_type(mime_type)))
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "mod_mime_xattr: bad mime type specification on file <%s>", r->filename);
+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server, "Bad MIME type specification on file '%s'", r->filename);
else {
if (charset)
- mime_type = ap_psprintf(r->pool, "%s; charset=%s", mime_type, charset);
+ mime_type = apr_psprintf(r->pool, "%s; charset=%s", mime_type, charset);
r->content_type = mime_type;
result = OK;
@@ -164,7 +185,7 @@ static int find_ct(request_rec *r) {
}
if (charset && !mime_type && r->content_type) {
- char *a, *ct = ap_pstrdup(r->pool, r->content_type);
+ char *a, *ct = apr_pstrdup(r->pool, r->content_type);
static const char spec[] = "; charset=";
if ((a = strstr(ct, spec))) {
@@ -174,9 +195,9 @@ static int find_ct(request_rec *r) {
*a = 0;
- r->content_type = ap_psprintf(r->pool, "%s; charset=%s%s", ct, charset, e);
+ r->content_type = apr_psprintf(r->pool, "%s; charset=%s%s", ct, charset, e);
} else
- r->content_type = ap_psprintf(r->pool, "%s; charset=%s", ct, charset);
+ r->content_type = apr_psprintf(r->pool, "%s; charset=%s", ct, charset);
}
if (!(encoding = get_xattr(r->pool, r->filename, XATTR_NAME_ENCODING)))
@@ -184,9 +205,11 @@ static int find_ct(request_rec *r) {
if (encoding) {
if (!(encoding = validate_encoding(encoding)))
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "mod_mime_xattr: bad encoding specification on file <%s>", r->filename);
- else
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "Bad encoding specification on file '%s'", r->filename);
+ else {
r->content_encoding = encoding;
+ result = OK;
+ }
}
}
@@ -198,7 +221,7 @@ static int find_ct(request_rec *r) {
if (handler) {
if (!(handler = validate_handler(handler)))
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "mod_mime_xattr: bad apache handler specification on file <%s>", r->filename);
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "Bad apache handler specification on file <%s>", r->filename);
else {
r->handler = handler;
result = OK;
@@ -209,31 +232,46 @@ static int find_ct(request_rec *r) {
return result;
}
-/* Dispatch list for API hooks */
-module MODULE_VAR_EXPORT mime_xattr_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* module initializer */
+static void register_hooks(__unused apr_pool_t *p){
+ static const char * const pre[] = {
+ "mod_rewrite.c",
+ NULL
+ };
+
+ static const char * const post[] = {
+ "mod_mime.c",
+ "mod_mime_magic.c",
+ NULL
+ };
+
+ ap_hook_type_checker(find_ct, pre, post, APR_HOOK_MIDDLE);
+}
+
+static const command_rec commands[] = {
+
+ AP_INIT_FLAG(
+ "XAttrMimeType",
+ enable_xattr_mime_type,
+ NULL,
+ OR_FILEINFO,
+ "Takes 'On' or 'Off' for enabling resp. disabling usage of file system extended attribute data for MIME type detection."),
+
+ AP_INIT_FLAG(
+ "XAttrHandler",
+ enable_xattr_handler,
+ NULL,
+ OR_FILEINFO,
+ "Takes 'On' or 'Off' for enabling resp. disabling usage of file system extended attribute data for handler detection."),
+
+ { NULL }
+};
+
+module AP_MODULE_DECLARE_DATA mime_xattr_module = {
+ STANDARD20_MODULE_STUFF,
create_mime_xattr_dir_config, /* create per-dir config structures */
- NULL, /* merge per-dir config structures */
- NULL, /* create per-server config structures */
- NULL, /* merge per-server config structures */
- mime_xattr_cmds, /* table of config file commands */
- NULL, /* [#8] MIME-typed-dispatched handlers */
- NULL, /* [#1] URI to filename translation */
- NULL, /* [#4] validate user id from request */
- NULL, /* [#5] check if the user is ok _here_ */
- NULL, /* [#3] check access by host address */
- find_ct, /* [#6] determine MIME type */
- NULL, /* [#7] pre-run fixups */
- NULL, /* [#9] log a transaction */
- NULL, /* [#2] header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* [#0] post read-request */
-#ifdef EAPI
- ,NULL, /* EAPI: add_module */
- NULL, /* EAPI: remove_module */
- NULL, /* EAPI: rewrite_command */
- NULL /* EAPI: new_connection */
-#endif
+ merge_mime_xattr_dir_config, /* merge per-dir config structures */
+ NULL, /* create per-server config structures */
+ NULL, /* merge per-server config structures */
+ commands, /* table of config file commands */
+ register_hooks /* register hooks */
};
--
cgit