* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef __CHXJ_CONV_KANA_H__
-#define __CHXJ_CONV_kANA_H__
+#ifndef __CHXJ_CONV_Z2H_H__
+#define __CHXJ_CONV_Z2H_H__
#include "mod_chxj.h"
+typedef struct {
+ apr_size_t byte;
+ char *hankaku;
+} z2h_table_t;
+
extern char *chxj_conv_z2h_kana(request_rec *r, const char *src, apr_size_t *len, chxjconvrule_entry *entryp);
+extern char *chxj_conv_z2h_alpha(request_rec *r, const char *src, apr_size_t *len, chxjconvrule_entry *entryp);
+extern char *chxj_conv_z2h_num(request_rec *r, const char *src, apr_size_t *len, chxjconvrule_entry *entryp);
#endif
#define CONVRULE_COOKIE_ON_BIT (0x00000004)
#define CONVRULE_Z2H_ON_BIT (0x00000008)
#define CONVRULE_Z2H_OFF_BIT (0x00000010)
+#define CONVRULE_Z2H_ALPHA_ON_BIT (0x00000020)
+#define CONVRULE_Z2H_ALPHA_OFF_BIT (0x00000040)
+#define CONVRULE_Z2H_NUM_ON_BIT (0x00000080)
+#define CONVRULE_Z2H_NUM_OFF_BIT (0x00000100)
#define CONVRULE_ENGINE_ON_CMD "EngineOn"
#define CONVRULE_ENGINE_OFF_CMD "EngineOff"
#define CONVRULE_COOKIE_OFF_CMD "CookieOff"
#define CONVRULE_Z2H_ON_CMD "Z2hOn"
#define CONVRULE_Z2H_OFF_CMD "Z2hOff"
+#define CONVRULE_Z2H_ALPHA_ON_CMD "Z2hAlphaOn"
+#define CONVRULE_Z2H_ALPHA_OFF_CMD "Z2hAlphaOff"
+#define CONVRULE_Z2H_NUM_ON_CMD "Z2hNumOn"
+#define CONVRULE_Z2H_NUM_OFF_CMD "Z2hNumOff"
+#define CONVRULE_Z2H_ALL_ON_CMD "Z2hAllOn"
+#define CONVRULE_Z2H_ALL_OFF_CMD "Z2hAllOff"
#define CONVRULE_FLAG_NOTMATCH (0x00000001)
chxj_apache.c \
chxj_add_device_env.c \
chxj_serf.c \
- chxj_conv_kana.c
+ chxj_conv_z2h_kana.c \
+ chxj_conv_z2h_alpha.c \
+ chxj_conv_z2h_num.c
libmod_chxj_la_CFLAGS = -O2 -prefer-pic @QDEFS@ @DDEFS@ -I. -I../include -I@with_apache_header@ -I./serf
libmod_chxj_la-chxj_buffered_write.lo \
libmod_chxj_la-chxj_apache.lo \
libmod_chxj_la-chxj_add_device_env.lo \
- libmod_chxj_la-chxj_serf.lo libmod_chxj_la-chxj_conv_kana.lo
+ libmod_chxj_la-chxj_serf.lo \
+ libmod_chxj_la-chxj_conv_z2h_kana.lo \
+ libmod_chxj_la-chxj_conv_z2h_alpha.lo \
+ libmod_chxj_la-chxj_conv_z2h_num.lo
libmod_chxj_la_OBJECTS = $(am_libmod_chxj_la_OBJECTS)
libmod_chxj_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libmod_chxj_la_CFLAGS) \
chxj_apache.c \
chxj_add_device_env.c \
chxj_serf.c \
- chxj_conv_kana.c
+ chxj_conv_z2h_kana.c \
+ chxj_conv_z2h_alpha.c \
+ chxj_conv_z2h_num.c
libmod_chxj_la_CFLAGS = -O2 -prefer-pic @QDEFS@ @DDEFS@ -I. -I../include -I@with_apache_header@ -I./serf
AM_CFLAGS = @CFLAGS@ -O2 -prefer-pic @QDEFS@ @DDEFS@ -I. -I../include -I@with_apache_header@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_chtml30.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_chtml40.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_chtml50.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_conv_kana.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_alpha.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_kana.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_num.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_cookie.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_dbm.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmod_chxj_la-chxj_dump.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -c -o libmod_chxj_la-chxj_serf.lo `test -f 'chxj_serf.c' || echo '$(srcdir)/'`chxj_serf.c
-libmod_chxj_la-chxj_conv_kana.lo: chxj_conv_kana.c
-@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -MT libmod_chxj_la-chxj_conv_kana.lo -MD -MP -MF $(DEPDIR)/libmod_chxj_la-chxj_conv_kana.Tpo -c -o libmod_chxj_la-chxj_conv_kana.lo `test -f 'chxj_conv_kana.c' || echo '$(srcdir)/'`chxj_conv_kana.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libmod_chxj_la-chxj_conv_kana.Tpo $(DEPDIR)/libmod_chxj_la-chxj_conv_kana.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='chxj_conv_kana.c' object='libmod_chxj_la-chxj_conv_kana.lo' libtool=yes @AMDEPBACKSLASH@
+libmod_chxj_la-chxj_conv_z2h_kana.lo: chxj_conv_z2h_kana.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -MT libmod_chxj_la-chxj_conv_z2h_kana.lo -MD -MP -MF $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_kana.Tpo -c -o libmod_chxj_la-chxj_conv_z2h_kana.lo `test -f 'chxj_conv_z2h_kana.c' || echo '$(srcdir)/'`chxj_conv_z2h_kana.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_kana.Tpo $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_kana.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='chxj_conv_z2h_kana.c' object='libmod_chxj_la-chxj_conv_z2h_kana.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -c -o libmod_chxj_la-chxj_conv_kana.lo `test -f 'chxj_conv_kana.c' || echo '$(srcdir)/'`chxj_conv_kana.c
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -c -o libmod_chxj_la-chxj_conv_z2h_kana.lo `test -f 'chxj_conv_z2h_kana.c' || echo '$(srcdir)/'`chxj_conv_z2h_kana.c
+
+libmod_chxj_la-chxj_conv_z2h_alpha.lo: chxj_conv_z2h_alpha.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -MT libmod_chxj_la-chxj_conv_z2h_alpha.lo -MD -MP -MF $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_alpha.Tpo -c -o libmod_chxj_la-chxj_conv_z2h_alpha.lo `test -f 'chxj_conv_z2h_alpha.c' || echo '$(srcdir)/'`chxj_conv_z2h_alpha.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_alpha.Tpo $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_alpha.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='chxj_conv_z2h_alpha.c' object='libmod_chxj_la-chxj_conv_z2h_alpha.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -c -o libmod_chxj_la-chxj_conv_z2h_alpha.lo `test -f 'chxj_conv_z2h_alpha.c' || echo '$(srcdir)/'`chxj_conv_z2h_alpha.c
+
+libmod_chxj_la-chxj_conv_z2h_num.lo: chxj_conv_z2h_num.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -MT libmod_chxj_la-chxj_conv_z2h_num.lo -MD -MP -MF $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_num.Tpo -c -o libmod_chxj_la-chxj_conv_z2h_num.lo `test -f 'chxj_conv_z2h_num.c' || echo '$(srcdir)/'`chxj_conv_z2h_num.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_num.Tpo $(DEPDIR)/libmod_chxj_la-chxj_conv_z2h_num.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='chxj_conv_z2h_num.c' object='libmod_chxj_la-chxj_conv_z2h_num.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmod_chxj_la_CFLAGS) $(CFLAGS) -c -o libmod_chxj_la-chxj_conv_z2h_num.lo `test -f 'chxj_conv_z2h_num.c' || echo '$(srcdir)/'`chxj_conv_z2h_num.c
mostlyclean-libtool:
-rm -f *.lo
--- /dev/null
+/*
+ * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005 QSDN,Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 "mod_chxj.h"
+#include "chxj_conv_z2h.h"
+#include "chxj_url_encode.h"
+#include "qs_parse_string.h"
+#include <errno.h>
+
+static z2h_table_t alpha_table_uc[] = {
+ { 1, "A",},
+ { 1, "B",},
+ { 1, "C",},
+ { 1, "D",},
+ { 1, "E",},
+ { 1, "F",},
+ { 1, "G",},
+ { 1, "H",},
+ { 1, "I",},
+ { 1, "J",},
+ { 1, "K",},
+ { 1, "L",},
+ { 1, "M",},
+ { 1, "N",},
+ { 1, "O",},
+ { 1, "P",},
+ { 1, "Q",},
+ { 1, "R",},
+ { 1, "S",},
+ { 1, "T",},
+ { 1, "U",},
+ { 1, "V",},
+ { 1, "W",},
+ { 1, "X",},
+ { 1, "Y",},
+ { 1, "Z",},
+};
+static z2h_table_t alpha_table_lc[] = {
+ { 1, "a",},
+ { 1, "b",},
+ { 1, "c",},
+ { 1, "d",},
+ { 1, "e",},
+ { 1, "f",},
+ { 1, "g",},
+ { 1, "h",},
+ { 1, "i",},
+ { 1, "j",},
+ { 1, "k",},
+ { 1, "l",},
+ { 1, "m",},
+ { 1, "n",},
+ { 1, "o",},
+ { 1, "p",},
+ { 1, "q",},
+ { 1, "r",},
+ { 1, "s",},
+ { 1, "t",},
+ { 1, "u",},
+ { 1, "v",},
+ { 1, "w",},
+ { 1, "x",},
+ { 1, "y",},
+ { 1, "z",},
+};
+
+/**
+ * 0x8260 -> 0x8279
+ * 0x8281 -> 0x829a
+ */
+char *
+chxj_conv_z2h_alpha(request_rec *r, const char *src, apr_size_t *len, chxjconvrule_entry *entryp)
+{
+ apr_size_t ii;
+ apr_size_t ilen;
+ apr_pool_t *pool;
+ char *obuf;
+ apr_size_t olen;
+
+ DBG(r,"REQ[%X] start chxj_conv_z2h_alpha()", (unsigned int)(apr_size_t)r);
+
+ if (entryp->action & CONVRULE_Z2H_ALPHA_OFF_BIT) {
+ DBG(r,"REQ[%X] Detect Z2hAlphaOff", (unsigned int)(apr_size_t)r);
+ DBG(r,"REQ[%X] end chxj_conv_z2h_alpha()", (unsigned int)(apr_size_t)r);
+ return (char *)src;
+ }
+ if (! (entryp->action & CONVRULE_Z2H_ALPHA_ON_BIT)) {
+ DBG(r,"REQ[%X] Detect Z2hAlphaOff", (unsigned int)(apr_size_t)r);
+ DBG(r,"REQ[%X] end chxj_conv_z2h_alpha()", (unsigned int)(apr_size_t)r);
+ return (char *)src;
+ }
+
+ apr_pool_create(&pool, r->pool);
+
+ olen = 0;
+ ilen = *len;
+
+ obuf = apr_palloc(pool, ilen + 1);
+ if (! obuf) {
+ ERR(r,"%s:%d REQ[%X] memory allocation error", __FILE__,__LINE__,(unsigned int)(apr_size_t)r);
+ return (char*)src;
+ }
+
+ memset(obuf, 0, ilen + 1);
+ for (ii=0; ii<ilen; ii++) {
+ /* sjis only */
+ if (is_sjis_kana(src[ii])) {
+ obuf[olen++] = src[ii];
+ }
+ else if (is_sjis_kanji(src[ii])) {
+ unsigned char firstbyte = src[ii + 0];
+ unsigned char secondbyte = src[ii + 1];
+ /* Upper case */
+ if ( firstbyte == 0x82
+ && (secondbyte >= 0x60 && secondbyte <= 0x79)) {
+ unsigned char p = secondbyte - 0x60;
+ if (alpha_table_uc[p].byte != 0) {
+ /* Detect Zenkaku Alphabet */
+ strcpy(&obuf[olen], alpha_table_uc[p].hankaku);
+ olen += alpha_table_uc[p].byte;
+ }
+ else {
+ obuf[olen++] = src[ii + 0];
+ obuf[olen++] = src[ii + 1];
+ }
+ }
+ else /* Lower case */
+ if ( firstbyte == 0x82
+ && (secondbyte >= 0x81 && secondbyte <= 0x9a)) {
+ unsigned char p = secondbyte - 0x81;
+ if (alpha_table_lc[p].byte != 0) {
+ /* Detect Zenkaku Alphabet */
+ strcpy(&obuf[olen], alpha_table_lc[p].hankaku);
+ olen += alpha_table_lc[p].byte;
+ }
+ else {
+ obuf[olen++] = src[ii + 0];
+ obuf[olen++] = src[ii + 1];
+ }
+ }
+ else {
+ obuf[olen++] = src[ii + 0];
+ obuf[olen++] = src[ii + 1];
+ }
+ ii++;
+ }
+ else {
+ obuf[olen++] = src[ii];
+ }
+ }
+ *len = olen;
+
+ DBG(r,"REQ[%X] end chxj_conv_z2h_alpha()", (unsigned int)(apr_size_t)r);
+ return obuf;
+}
+/*
+ * vim: ts=2 et
+ */
* limitations under the License.
*/
#include "mod_chxj.h"
-#include "chxj_conv_kana.h"
+#include "chxj_conv_z2h.h"
#include "chxj_url_encode.h"
#include "qs_parse_string.h"
#include <errno.h>
-typedef struct {
- apr_size_t byte;
- char *hankaku;
-} kana_table_t;
-
-static kana_table_t kana_table1[] = {
+static z2h_table_t kana_table1[] = {
{ /* 00 */ 1, "\xa7\x00",},
{ /* 01 */ 1, "\xb1\x00",},
{ /* 02 */ 1, "\xa8\x00",},
{ /* 85 */ 2, "\x83\x95",},
{ /* 86 */ 2, "\x83\x96",},
};
-static kana_table_t kana_table2[] = {
+static z2h_table_t kana_table2[] = {
{ /* 0x8141 、*/ 1, "\xa4",},
{ /* 0x8142 。*/ 1, "\xa1",},
{ /* 0x8143 ,*/ 1, ",",},
{ /* 0x814a ゛*/ 1, "\xde",},
{ /* 0x814b ゜*/ 1, "\xdf",},
};
-static kana_table_t kana_table3[] = {
+static z2h_table_t kana_table3[] = {
{ /* 0x8175 「*/ 1, "\xa2",},
{ /* 0x8176 」*/ 1, "\xa3",},
};
-static kana_table_t kana_table4[] = {
+static z2h_table_t kana_table4[] = {
{ /* 0x815b ゛*/ 1, "\xb0",},
};
--- /dev/null
+/*
+ * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005 QSDN,Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 "mod_chxj.h"
+#include "chxj_conv_z2h.h"
+#include "chxj_url_encode.h"
+#include "qs_parse_string.h"
+#include <errno.h>
+
+/**
+ */
+char *
+chxj_conv_z2h_num(request_rec *r, const char *src, apr_size_t *len, chxjconvrule_entry *entryp)
+{
+ apr_size_t ii;
+ apr_size_t ilen;
+ apr_pool_t *pool;
+ char *obuf;
+ apr_size_t olen;
+
+ DBG(r,"REQ[%X] start chxj_conv_z2h_num()", (unsigned int)(apr_size_t)r);
+
+ if (entryp->action & CONVRULE_Z2H_NUM_OFF_BIT) {
+ DBG(r,"REQ[%X] Detect Z2hNumOff", (unsigned int)(apr_size_t)r);
+ DBG(r,"REQ[%X] end chxj_conv_z2h_num()", (unsigned int)(apr_size_t)r);
+ return (char *)src;
+ }
+ if (! (entryp->action & CONVRULE_Z2H_NUM_ON_BIT)) {
+ DBG(r,"REQ[%X] Detect Z2hNumOff", (unsigned int)(apr_size_t)r);
+ DBG(r,"REQ[%X] end chxj_conv_z2h_num()", (unsigned int)(apr_size_t)r);
+ return (char *)src;
+ }
+
+ apr_pool_create(&pool, r->pool);
+
+ olen = 0;
+ ilen = *len;
+
+ obuf = apr_palloc(pool, ilen + 1);
+ if (! obuf) {
+ ERR(r,"%s:%d REQ[%X] memory allocation error", __FILE__,__LINE__,(unsigned int)(apr_size_t)r);
+ return (char*)src;
+ }
+
+ memset(obuf, 0, ilen + 1);
+ for (ii=0; ii<ilen; ii++) {
+ /* sjis only */
+ if (is_sjis_kana(src[ii])) {
+ obuf[olen++] = src[ii];
+ }
+ else if (is_sjis_kanji(src[ii])) {
+ unsigned char firstbyte = src[ii + 0];
+ unsigned char secondbyte = src[ii + 1];
+ /* Upper case */
+ if ( firstbyte == 0x82
+ && (secondbyte >= 0x4F && secondbyte <= 0x58)) {
+ unsigned char p = secondbyte - 0x4F;
+ /* Detect Zenkaku Number */
+ obuf[olen] = '0' + p;
+ olen++;
+ }
+ else {
+ obuf[olen++] = src[ii + 0];
+ obuf[olen++] = src[ii + 1];
+ }
+ ii++;
+ }
+ else {
+ obuf[olen++] = src[ii];
+ }
+ }
+ *len = olen;
+
+ DBG(r,"REQ[%X] end chxj_conv_z2h_num()", (unsigned int)(apr_size_t)r);
+ return obuf;
+}
+/*
+ * vim: ts=2 et
+ */
#endif
#include "chxj_serf.h"
#include "chxj_add_device_env.h"
-#include "chxj_conv_kana.h"
+#include "chxj_conv_z2h.h"
#define CHXJ_VERSION_PREFIX PACKAGE_NAME "/"
}
if (dst && *len) {
dst = chxj_conv_z2h_kana(r, dst, len, entryp);
+ dst = chxj_conv_z2h_alpha(r, dst, len, entryp);
+ dst = chxj_conv_z2h_num(r, dst, len, entryp);
}
}
ap_set_content_length(r, *len);
if (strcasecmp(CONVRULE_Z2H_OFF_CMD, action) == 0) {
newrule->action |= CONVRULE_Z2H_OFF_BIT;
}
+ else
+ if (strcasecmp(CONVRULE_Z2H_ALPHA_ON_CMD, action) == 0) {
+ newrule->action |= CONVRULE_Z2H_ALPHA_ON_BIT;
+ }
+ else
+ if (strcasecmp(CONVRULE_Z2H_ALPHA_OFF_CMD, action) == 0) {
+ newrule->action |= CONVRULE_Z2H_ALPHA_OFF_BIT;
+ }
+ else
+ if (strcasecmp(CONVRULE_Z2H_NUM_ON_CMD, action) == 0) {
+ newrule->action |= CONVRULE_Z2H_NUM_ON_BIT;
+ }
+ else
+ if (strcasecmp(CONVRULE_Z2H_NUM_OFF_CMD, action) == 0) {
+ newrule->action |= CONVRULE_Z2H_NUM_OFF_BIT;
+ }
+ else
+ if (strcasecmp(CONVRULE_Z2H_ALL_ON_CMD, action) == 0) {
+ newrule->action |= CONVRULE_Z2H_ON_BIT | CONVRULE_Z2H_ALPHA_ON_BIT | CONVRULE_Z2H_NUM_ON_BIT;
+ }
+ else
+ if (strcasecmp(CONVRULE_Z2H_NUM_OFF_CMD, action) == 0) {
+ newrule->action |= CONVRULE_Z2H_OFF_BIT | CONVRULE_Z2H_ALPHA_OFF_BIT | CONVRULE_Z2H_NUM_OFF_BIT;
+ }
break;
default:
--- /dev/null
+.SUFFIXES:
+.SUFFIXES: .c.o
+
+TARGET= test_chxj_conv_z2h_alpha
+
+TOP_DIR=../..
+
+INC_DIR=-I$(TOP_DIR)/include \
+ -I/usr/include/apache2 \
+ -I/usr/include/apr-1.0 \
+ -I$(TOP_DIR)/src
+
+all:test
+
+
+
+test: $(TARGET)
+ ./$(TARGET)
+
+$(TARGET): $(TARGET).c
+ gcc -g -o $@ -Wall -lcunit $< $(INC_DIR) -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -lapr-1 -laprutil-1
+
+
+clean:
+ rm -f ./$(TARGET)
--- /dev/null
+#include <CUnit/CUnit.h>
+#include <CUnit/Console.h>
+#include <CUnit/Basic.h>
+#include <stdio.h>
+#define CHXJ_TEST
+#define IMG_NOT_CONVERT_FILENAME
+
+#include "apr_uri.h"
+#include "chxj_apache.h"
+#include "apr.h"
+#include "qs_malloc.c"
+#include "qs_log.c"
+#include "qs_parse_tag.c"
+#include "qs_parse_string.c"
+#include "qs_parse_attr.c"
+#include "qs_ignore_sp.c"
+#include "qs_parse_file.c"
+#include "chxj_buffered_write.c"
+#include "chxj_conv_z2h_alpha.c"
+#include "chxj_node_convert.c"
+#include "chxj_tag_util.c"
+#include "chxj_encoding.c"
+#include "chxj_img_conv.c"
+#include "chxj_url_encode.c"
+#include "chxj_apache.c"
+#include "chxj_str_util.c"
+#include <iconv.h>
+
+
+
+void test_conv_alpha_001();
+void test_conv_alpha_002();
+/* pend */
+
+int
+main()
+{
+ CU_pSuite conv_alpha_suite;
+ CU_initialize_registry();
+ conv_alpha_suite = CU_add_suite("test chxj_convert_conv_alpha()", NULL, NULL);
+ CU_add_test(conv_alpha_suite, "test void src1", test_conv_alpha_001);
+ CU_add_test(conv_alpha_suite, "test void src2", test_conv_alpha_002);
+ /* aend */
+
+ CU_basic_run_tests();
+ CU_cleanup_registry();
+
+ return(0);
+}
+
+void test_log_rerror(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...)
+{
+ va_list ap;
+ fprintf(stderr, "ERROR LOG %s:%d ", file,line);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt,ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+void test_log_error(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...)
+{
+ va_list ap;
+ fprintf(stderr, "ERROR LOG %s:%d ", file,line);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt,ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+
+char *chxj_qr_code_blob_handler(request_rec* r, const char* indata, size_t* len)
+{
+ return NULL;
+}
+
+char *test_os_escape_path(apr_pool_t *p, const char *path, int partial)
+{
+ return (char *)path;
+}
+
+void test_set_content_type(request_rec *r, const char *ct)
+{
+ fprintf(stderr, "%s:%d set_content_type(%s)\n", __FILE__,__LINE__,ct);
+}
+
+const char *test_run_http_scheme(request_rec *r)
+{
+ static char *s = "http";
+ return s;
+}
+
+tag_handler chtml10_handler[] = {};
+tag_handler chtml20_handler[] = {};
+tag_handler chtml30_handler[] = {};
+tag_handler chtml40_handler[] = {};
+tag_handler chtml50_handler[] = {};
+tag_handler hdml_handler[] = {};
+tag_handler jhtml_handler[] = {};
+tag_handler jxhtml_handler[] = {};
+tag_handler xhtml_handler[] = {};
+void * test_get_module_config(const ap_conf_vector_t *cv, const module *m)
+{
+ static mod_chxj_config cfg;
+ memset(&cfg, 0, sizeof(mod_chxj_config));
+ cfg.new_line_type = NLTYPE_NONE;
+ return &cfg;
+}
+
+chxjconvrule_entry *
+chxj_apply_convrule(request_rec* r, apr_array_header_t* convrules)
+{
+ static chxjconvrule_entry entries;
+ memset(&entries, 0, sizeof(chxjconvrule_entry));
+ entries.encoding = apr_pstrdup(r->pool, "UTF8");
+ entries.action |= CONVRULE_Z2H_ON_BIT;
+ return &entries;
+}
+
+
+char *test_ap_escape_html(apr_pool_t *pool, const char *s)
+{
+ return (char *)s;
+}
+
+#define APR_INIT \
+ request_rec r; \
+ apr_pool_t *p; \
+ do { \
+ apr_initialize(); \
+ apr_pool_create(&p, NULL); \
+ r.pool = p; \
+ r.hostname = apr_pstrdup(p, "localhost"); \
+ } \
+ while (0)
+
+#define APR_TERM \
+ do { \
+ apr_terminate(); \
+ } while (0)
+
+#define COOKIE_INIT(X) \
+ do { \
+ X.cookie_id = "test_cookie_id"; \
+ } while (0) \
+
+#define SPEC_INIT(X) \
+ do { \
+ X.html_spec_type = CHXJ_SPEC_Chtml_1_0; \
+ } while (0)
+
+
+
+void test_conv_alpha_001()
+{
+#define TEST_STRING "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+ "abcdefghijklmnopqrstuvwxyz"
+#define RESULT_STRING "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+ "abcdefghijklmnopqrstuvwxyz"
+ char *ret;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ memset(&entry, 0, sizeof(chxjconvrule_entry));
+ entry.encoding = apr_pstrdup(r.pool, "UTF8");
+ entry.action |= CONVRULE_Z2H_ALPHA_ON_BIT;
+
+ destlen = sizeof(TEST_STRING)-1;
+ char *s = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_conv_z2h_alpha(&r, s, &destlen,&entry);
+ destlen = strlen(ret);
+ ret = chxj_rencoding(&r, ret, &destlen);
+
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+}
+void test_conv_alpha_002()
+{
+#define TEST_STRING "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+ "abcdefghijklmnopqrstuvwxyz"
+#define RESULT_STRING "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+ "abcdefghijklmnopqrstuvwxyz"
+ char *ret;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ memset(&entry, 0, sizeof(chxjconvrule_entry));
+ entry.encoding = apr_pstrdup(r.pool, "UTF8");
+ entry.action |= CONVRULE_Z2H_ALPHA_ON_BIT;
+ entry.action |= CONVRULE_Z2H_ALPHA_OFF_BIT;
+
+ destlen = sizeof(TEST_STRING)-1;
+ char *s = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_conv_z2h_alpha(&r, s, &destlen,&entry);
+ destlen = strlen(ret);
+ ret = chxj_rencoding(&r, ret, &destlen);
+
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+}
+/*
+ * vim:ts=2 et
+ */
--- /dev/null
+.SUFFIXES:
+.SUFFIXES: .c.o
+
+TARGET= test_chxj_conv_z2h_kana
+
+TOP_DIR=../..
+
+INC_DIR=-I$(TOP_DIR)/include \
+ -I/usr/include/apache2 \
+ -I/usr/include/apr-1.0 \
+ -I$(TOP_DIR)/src
+
+all:test
+
+
+
+test: $(TARGET)
+ ./$(TARGET)
+
+$(TARGET): $(TARGET).c
+ gcc -g -o $@ -Wall -lcunit $< $(INC_DIR) -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -lapr-1 -laprutil-1
+
+
+clean:
+ rm -f ./$(TARGET)
#include "qs_ignore_sp.c"
#include "qs_parse_file.c"
#include "chxj_buffered_write.c"
-#include "chxj_conv_kana.c"
+#include "chxj_conv_z2h_kana.c"
#include "chxj_node_convert.c"
#include "chxj_tag_util.c"
#include "chxj_encoding.c"
.SUFFIXES:
.SUFFIXES: .c.o
-TARGET= test_chxj_conv_kana
+TARGET= test_chxj_conv_z2h_num
TOP_DIR=../..
--- /dev/null
+#include <CUnit/CUnit.h>
+#include <CUnit/Console.h>
+#include <CUnit/Basic.h>
+#include <stdio.h>
+#define CHXJ_TEST
+#define IMG_NOT_CONVERT_FILENAME
+
+#include "apr_uri.h"
+#include "chxj_apache.h"
+#include "apr.h"
+#include "qs_malloc.c"
+#include "qs_log.c"
+#include "qs_parse_tag.c"
+#include "qs_parse_string.c"
+#include "qs_parse_attr.c"
+#include "qs_ignore_sp.c"
+#include "qs_parse_file.c"
+#include "chxj_buffered_write.c"
+#include "chxj_conv_z2h_num.c"
+#include "chxj_node_convert.c"
+#include "chxj_tag_util.c"
+#include "chxj_encoding.c"
+#include "chxj_img_conv.c"
+#include "chxj_url_encode.c"
+#include "chxj_apache.c"
+#include "chxj_str_util.c"
+#include <iconv.h>
+
+
+
+void test_conv_num_001();
+void test_conv_num_002();
+/* pend */
+
+int
+main()
+{
+ CU_pSuite conv_num_suite;
+ CU_initialize_registry();
+ conv_num_suite = CU_add_suite("test chxj_convert_conv_num()", NULL, NULL);
+ CU_add_test(conv_num_suite, "test void src1", test_conv_num_001);
+ CU_add_test(conv_num_suite, "test void src2", test_conv_num_002);
+ /* aend */
+
+ CU_basic_run_tests();
+ CU_cleanup_registry();
+
+ return(0);
+}
+
+void test_log_rerror(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...)
+{
+ va_list ap;
+ fprintf(stderr, "ERROR LOG %s:%d ", file,line);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt,ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+void test_log_error(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...)
+{
+ va_list ap;
+ fprintf(stderr, "ERROR LOG %s:%d ", file,line);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt,ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+
+char *chxj_qr_code_blob_handler(request_rec* r, const char* indata, size_t* len)
+{
+ return NULL;
+}
+
+char *test_os_escape_path(apr_pool_t *p, const char *path, int partial)
+{
+ return (char *)path;
+}
+
+void test_set_content_type(request_rec *r, const char *ct)
+{
+ fprintf(stderr, "%s:%d set_content_type(%s)\n", __FILE__,__LINE__,ct);
+}
+
+const char *test_run_http_scheme(request_rec *r)
+{
+ static char *s = "http";
+ return s;
+}
+
+tag_handler chtml10_handler[] = {};
+tag_handler chtml20_handler[] = {};
+tag_handler chtml30_handler[] = {};
+tag_handler chtml40_handler[] = {};
+tag_handler chtml50_handler[] = {};
+tag_handler hdml_handler[] = {};
+tag_handler jhtml_handler[] = {};
+tag_handler jxhtml_handler[] = {};
+tag_handler xhtml_handler[] = {};
+void * test_get_module_config(const ap_conf_vector_t *cv, const module *m)
+{
+ static mod_chxj_config cfg;
+ memset(&cfg, 0, sizeof(mod_chxj_config));
+ cfg.new_line_type = NLTYPE_NONE;
+ return &cfg;
+}
+
+chxjconvrule_entry *
+chxj_apply_convrule(request_rec* r, apr_array_header_t* convrules)
+{
+ static chxjconvrule_entry entries;
+ memset(&entries, 0, sizeof(chxjconvrule_entry));
+ entries.encoding = apr_pstrdup(r->pool, "UTF8");
+ entries.action |= CONVRULE_Z2H_ON_BIT;
+ return &entries;
+}
+
+
+char *test_ap_escape_html(apr_pool_t *pool, const char *s)
+{
+ return (char *)s;
+}
+
+#define APR_INIT \
+ request_rec r; \
+ apr_pool_t *p; \
+ do { \
+ apr_initialize(); \
+ apr_pool_create(&p, NULL); \
+ r.pool = p; \
+ r.hostname = apr_pstrdup(p, "localhost"); \
+ } \
+ while (0)
+
+#define APR_TERM \
+ do { \
+ apr_terminate(); \
+ } while (0)
+
+#define COOKIE_INIT(X) \
+ do { \
+ X.cookie_id = "test_cookie_id"; \
+ } while (0) \
+
+#define SPEC_INIT(X) \
+ do { \
+ X.html_spec_type = CHXJ_SPEC_Chtml_1_0; \
+ } while (0)
+
+
+
+void test_conv_num_001()
+{
+#define TEST_STRING "0123456789"
+#define RESULT_STRING "0123456789"
+ char *ret;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ memset(&entry, 0, sizeof(chxjconvrule_entry));
+ entry.encoding = apr_pstrdup(r.pool, "UTF8");
+ entry.action |= CONVRULE_Z2H_NUM_ON_BIT;
+
+ destlen = sizeof(TEST_STRING)-1;
+ char *s = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_conv_z2h_num(&r, s, &destlen,&entry);
+ destlen = strlen(ret);
+ ret = chxj_rencoding(&r, ret, &destlen);
+
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+}
+void test_conv_num_002()
+{
+#define TEST_STRING "0123456789"
+#define RESULT_STRING "0123456789"
+ char *ret;
+ device_table spec;
+ chxjconvrule_entry entry;
+ cookie_t cookie;
+ apr_size_t destlen;
+ APR_INIT;
+
+
+ COOKIE_INIT(cookie);
+
+ SPEC_INIT(spec);
+ memset(&entry, 0, sizeof(chxjconvrule_entry));
+ entry.encoding = apr_pstrdup(r.pool, "UTF8");
+ entry.action |= CONVRULE_Z2H_NUM_ON_BIT;
+ entry.action |= CONVRULE_Z2H_NUM_OFF_BIT;
+
+ destlen = sizeof(TEST_STRING)-1;
+ char *s = chxj_encoding(&r, TEST_STRING, &destlen);
+ ret = chxj_conv_z2h_num(&r, s, &destlen,&entry);
+ destlen = strlen(ret);
+ ret = chxj_rencoding(&r, ret, &destlen);
+
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+}
+/*
+ * vim:ts=2 et
+ */