From f8f6e67559f3a6d23422bea381797bd03a55f462 Mon Sep 17 00:00:00 2001 From: konn Date: Tue, 20 Jun 2006 02:14:43 +0000 Subject: [PATCH] * change to acquire it even if the extension is attached by the image acquisition request. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/trunk@1085 1a406e8e-add9-4483-a2c8-d8cac5b7c224 --- ChangeLog | 2 ++ configure | 20 ++++++------ include/chxj_specified_device.h | 15 +++++++++ include/mod_chxj.h | 6 ++-- src/chxj_img_conv_format.c | 59 ++++++++++++++++++++++++++-------- src/mod_chxj.c | 70 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 147 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4d5fc37..7c919ed5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ libapache2-mod-chxj (0.6.3-1) unstable; urgency=low * bug fix which the size before it converts it into Content-Length when HEAD of the image conversion is requested is returned. + * change to acquire it even if the extension is attached by the image acquisition + request. -- Atsushi Konno Mon, 19 Jun 2006 17:29:48 +0900 diff --git a/configure b/configure index 222f17ae..71f98019 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for mod_chxj 0.6.2-stable. +# Generated by GNU Autoconf 2.59 for mod_chxj 0.6.3-stable. # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation @@ -421,8 +421,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='mod_chxj' PACKAGE_TARNAME='mod_chxj' -PACKAGE_VERSION='0.6.2-stable' -PACKAGE_STRING='mod_chxj 0.6.2-stable' +PACKAGE_VERSION='0.6.3-stable' +PACKAGE_STRING='mod_chxj 0.6.3-stable' PACKAGE_BUGREPORT='' ac_unique_file="src/mod_chxj.c" @@ -952,7 +952,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures mod_chxj 0.6.2-stable to adapt to many kinds of systems. +\`configure' configures mod_chxj 0.6.3-stable to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1019,7 +1019,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of mod_chxj 0.6.2-stable:";; + short | recursive ) echo "Configuration of mod_chxj 0.6.3-stable:";; esac cat <<\_ACEOF @@ -1163,7 +1163,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -mod_chxj configure 0.6.2-stable +mod_chxj configure 0.6.3-stable generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1177,7 +1177,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by mod_chxj $as_me 0.6.2-stable, which was +It was created by mod_chxj $as_me 0.6.3-stable, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1792,7 +1792,7 @@ fi PACKAGE=mod_chxj -VERSION=0.6.2-stable +VERSION=0.6.3-stable if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 @@ -20292,7 +20292,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by mod_chxj $as_me 0.6.2-stable, which was +This file was extended by mod_chxj $as_me 0.6.3-stable, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20355,7 +20355,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -mod_chxj config.status 0.6.2-stable +mod_chxj config.status 0.6.3-stable configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/include/chxj_specified_device.h b/include/chxj_specified_device.h index 50c97cd1..7a99a3e0 100644 --- a/include/chxj_specified_device.h +++ b/include/chxj_specified_device.h @@ -80,6 +80,7 @@ typedef struct _device_table_t { int color; char* emoji_type; + } device_table; typedef struct _device_table_list_t { @@ -90,6 +91,20 @@ typedef struct _device_table_list_t { device_table* tail; } device_table_list; +typedef struct _exchange_t { + /* convert routine */ + char* (*exchange)(request_rec* r, + struct _device_table_t* spec, + const char* src, + apr_size_t srclen, + apr_size_t *dstlen, + struct _chxjconvrule_entry* entryp); + + char* (*encoder)(request_rec *r, const char* src, apr_size_t* len); +} exchange_t; + +extern exchange_t exchange_routine[]; + device_table* chxj_specified_device(request_rec* r, const char* user_agent); #endif diff --git a/include/mod_chxj.h b/include/mod_chxj.h index 6da95d75..dfdc0bef 100644 --- a/include/mod_chxj.h +++ b/include/mod_chxj.h @@ -135,7 +135,6 @@ #endif -#include "chxj_specified_device.h" #ifdef HAVE_APR_GLOBAL_MUTEX_H @@ -173,7 +172,7 @@ typedef struct _emoji_t { jphone_emoji_t* jphone; } emoji_t; -typedef struct { +typedef struct _chxjconvrule_entry { char *pattern; ap_regex_t *regexp; int flags; @@ -182,6 +181,8 @@ typedef struct { int pc_flag; } chxjconvrule_entry; +#include "chxj_specified_device.h" + typedef struct { int image; @@ -250,6 +251,7 @@ module AP_MODULE_DECLARE_DATA chxj_module; #define ERR1(X,Y,Za) ap_log_rerror(APLOG_MARK,APLOG_ERR,0,(X),(Y),(Za)) + #endif /* * vim:ts=2 et diff --git a/src/chxj_img_conv_format.c b/src/chxj_img_conv_format.c index 4779d418..eb08f0ab 100644 --- a/src/chxj_img_conv_format.c +++ b/src/chxj_img_conv_format.c @@ -1509,6 +1509,7 @@ chxj_trans_name(request_rec *r) int ii; char* ext[] = { "jpg", + "jpeg", "png", "bmp", "gif", @@ -1518,6 +1519,8 @@ chxj_trans_name(request_rec *r) char* fname; char* idx; char* filename_sv; + int do_ext_check = TRUE; + int next_ok = FALSE; conf = ap_get_module_config(r->per_dir_config, &chxj_module); @@ -1558,25 +1561,55 @@ chxj_trans_name(request_rec *r) DBG1(r,"URI[%s]", filename_sv); + do_ext_check = TRUE; + for (ii=0; ii<7-1; ii++) { + char* pos = strrchr(filename_sv, '.'); + if (pos && pos++) { + if (strcasecmp(pos, ext[ii]) == 0) { + do_ext_check = FALSE; + fname = apr_psprintf(r->pool, "%s", filename_sv); + break; + } + } + } - for (ii=0; ii<6; ii++) { - if (strlen(ext[ii]) == 0) - fname = apr_psprintf(r->pool, "%s", filename_sv); - else - fname = apr_psprintf(r->pool, "%s.%s", filename_sv, ext[ii]); - - DBG1(r,"search [%s]", fname); - - rv = apr_stat(&st, fname, APR_FINFO_MIN, r->pool); - if (rv == APR_SUCCESS) - break; - - fname = NULL; + if (do_ext_check) { + for (ii=0; ii<7; ii++) { + if (strlen(ext[ii]) == 0) { + fname = apr_psprintf(r->pool, "%s", filename_sv); + } + else + fname = apr_psprintf(r->pool, "%s.%s", filename_sv, ext[ii]); + + DBG1(r,"search [%s]", fname); + + rv = apr_stat(&st, fname, APR_FINFO_MIN, r->pool); + if (rv == APR_SUCCESS) { + if (st.filetype != APR_DIR) + break; + } + + fname = NULL; + } } if (fname == NULL) { DBG1(r,"NotFound [%s]", r->filename); return DECLINED; } + for (ii=0; ii<7-1; ii++) { + char* pos = strrchr(fname, '.'); + if (pos && pos++) { + if (strcasecmp(pos, ext[ii]) == 0) { + next_ok = TRUE; + break; + } + } + } + + if (! next_ok) { + DBG1(r,"NotFound [%s]", r->filename); + return DECLINED; + } if (r->handler == NULL || strcasecmp(r->handler, "chxj-qrcode") != 0) { DBG1(r,"Found [%s]", fname); diff --git a/src/mod_chxj.c b/src/mod_chxj.c index 408c8a7e..cd60fe4e 100644 --- a/src/mod_chxj.c +++ b/src/mod_chxj.c @@ -61,6 +61,62 @@ #define CHXJ_VERSION_PREFIX PACKAGE_NAME "/" #define CHXJ_VERSION PACKAGE_VERSION +exchange_t exchange_routine[] = { + { + /* CHXJ_SPEC_UNKNOWN */ + .exchange = NULL, + .encoder = NULL, + }, + { + /* CHXJ_SPEC_Chtml_1_0 */ + .exchange = chxj_exchange_chtml10, + .encoder = chxj_encoding, + }, + { + /* CHXJ_SPEC_Chtml_2_0 */ + .exchange = chxj_exchange_chtml20, + .encoder = chxj_encoding, + }, + { + /* CHXJ_SPEC_Chtml_3_0 */ + .exchange = chxj_exchange_chtml30, + .encoder = chxj_encoding, + }, + { + /* CHXJ_SPEC_Chtml_4_0 */ + .exchange = chxj_exchange_chtml30, + .encoder = chxj_encoding, + }, + { + /* CHXJ_SPEC_Chtml_5_0 */ + .exchange = chxj_exchange_chtml30, + .encoder = chxj_encoding, + }, + { + /* CHXJ_SPEC_XHtml_Mobile_1_0 */ + .exchange = chxj_exchange_xhtml_mobile_1_0, + .encoder = chxj_encoding, + }, + { + /* CHXJ_SPEC_Hdml */ + .exchange = chxj_exchange_hdml, + .encoder = chxj_encoding, + }, + { + /* CHXJ_SPEC_Jhtml */ + .exchange = chxj_exchange_jhtml, + .encoder = chxj_encoding, + }, + { + /* CHXJ_SPEC_HTML */ + .exchange = NULL, + .encoder = NULL, + }, + { + NULL + } +}; + /** * It converts it from CHTML into XXML corresponding to each model. * @@ -104,6 +160,19 @@ chxj_exchange(request_rec *r, const char** src, apr_size_t* len) if (!r->header_only) { device_table* spec = chxj_specified_device(r, user_agent); + tmp = NULL; + if (exchange_routine[spec->html_spec_type].encoder) + tmp = exchange_routine[spec->html_spec_type].encoder(r, *src, (apr_size_t*)len); + + if (exchange_routine[spec->html_spec_type].exchange) { + if (tmp) + dst = exchange_routine[spec->html_spec_type].exchange(r, spec, tmp, *len, len, entryp); + else + dst = exchange_routine[spec->html_spec_type].exchange(r, spec, *src, *len, len, entryp); + } + + +#if 0 switch(spec->html_spec_type) { case CHXJ_SPEC_Chtml_1_0: /*----------------------------------------------------------------------*/ @@ -182,6 +251,7 @@ chxj_exchange(request_rec *r, const char** src, apr_size_t* len) DBG1(r,"html_spec_type[%d]", spec->html_spec_type); break; } +#endif } DBG(r, "end chxj_exchange()"); -- 2.11.0