Home > Tags > コンピュータ

コンピュータ Tag Archive

Google 日本語入力 でライトノベル作家の名前をいろいろ変換してみよう

アニメやらゲームやらラノベやらのオタ系コンテンツの固有名詞の予測変換がかなり強力な Google 日本語入力。それらの感想を書いているひとには強力な IME になりそうな感じ。

残念ながら私のメイン環境は Windows 7 の 64ビット版なので、まだインストールはできないのですが、仮想環境上に置いてある XP でいろいろ試してみました。

まぁ、うちのサイト的にはラノベ関連の語がどれくらい変換できるかってことで、メディアマーカーに登録してある本から100人ばかり、変換してみました。

結果は以下。

OS
Windows XP SP2
Google 日本語入力バージョン
GoogleJapaneseInput-0.8.186.0 (インストール直後の状態)
作家 予測変換
逢空 万太 あいそら(変換できず)まんた
葵せきな あおい(変換)せきな
青橋由高 あおは
蒼山サグ あおやま(変換)さぐ(変換)
赤松中学 あかまつちゅ
日日日 あきら(変換)
浅井ラボ あさいら
アサウラ あさう
麻宮楓 あさみやか
安彦薫 あびこか
新井輝 あらいてる
荒川工 あらかわた
有沢まみず ありさわ
石踏一榮 いしぶみ
一色銀河 いっしきぎ
犬村小六 いぬむら
井上堅二 いのうえけ
入間人間 いるまひ
うえお久光 うえお
上原りょう うえはらり
おかざき登 おかざきの
岡崎裕信 おかざきひろの
小河正岳 おがわまさた
沖田雅 おきたまさ
折口良乃 おりぐち(変換)よしの(変換できず)
かい(変換できず)
海冬レイジ かいとうれい
櫂末高彰 かいまた
風見周 かざみめ
柏葉空十郎 かしわばそ
鎌池和馬 かまちか
鴨志田一 かもしだは
川上稔 かわかみみ
川口士 かわぐちつ
川原礫 かわはら(変換)れき(変換)
神崎紫電 かんざきしで
城崎火也 きざきか
木村心一 きむらしんい
久住四季 くずみし
甲田学人 こうだが
上月司 こうづきつ
小林三六九 こばやし(変換)みろく(変換できず)
三枝零一 さえぐされ
桜坂洋 さくらざかひ
細音 啓 さざね(変換できず)けい
佐々原史緒 ささはら
三田誠 さんだま
志瑞祐 しみず(変換)ゆう(変換)
十文字青 じゅうもんじあ
周防ツカサ すおうつ
菅沼雅也 すがぬま(変換)まさ(変換)や(変換)
杉井光 すぎいひ
鈴木鈴 すずきすず
瀬那和章 せなかず
田尾典丈 たお(変換)のりたけ(変換)
高崎とおる たかさきと
鷹羽知 たかば(変換)とも(変換)
高橋弥七郎 たかはしや
鷹見一幸 たかみか
竹岡葉月 たけおかは
健速 たけはや
橘公司 たちばな(変換)こうじ(変換)
時田唯 ときた(変換)ゆい(変換)
土橋真二郎 どばしし
長野聖樹 ながのま
夏海公司 なつみこ
七飯宏隆 ななえひ
七尾あきら ななおあきら(変換)
七海ユウリ ななみゆ
二階堂紘嗣 にかいどうひろ
西尾維新 にしおい
西村悠 にしむら(変換)ゆう(変換)
野村美月 のむらみ
橋本和也 はしもとかずや
支倉凍砂 はせくら
長谷敏司 はせさと
林亮介 はやしりょうす
早矢塚 かつや はやづか(変換できず)かつや
比嘉智康 ひがとも
平坂読 ひらさかよ
伏見つかさ ふしみつ
藤原祐 ふじわらゆ
松智洋 まつとも
松原真琴 まつばらま
丸山秀人 まるやまひでと(変換)
三浦勇雄 みうらい
みかづき紅月 みかづきこ
三上延 みかみえ
三雲岳斗 みくもが
箕崎准 みさきじゅ
水瀬葉月 みなせは
峰守ひろかず みねも
六塚光 むつづ
森田季節 もりたき
森野一角 もりの(変換)いっかく(変換)
八薙玉造 やなぎたま
山形石雄 やまがたいし
山口幸三郎 やまぐちこうざぶろう(変換)
ヤマグチノボル やまぐちの
弓弦イズル ゆみずる(変換)いずる(変換)
予測変換で出てきた作家名
80
変換キー押下で変換する必要があった作家名
16
そのままでは変換できなかった作家名
4

ってことで、かなり良い感じに変換してくれるみたい。今後もバージョンが上がっていくとさらに辞書が充実していきそうな感じですね。

気になる点としては間違ったよみでも変換してくれたりするので気づかないまま、名前を誤って覚えてしまう可能性があったりすること? 機械的に処理して辞書を作るという点で、ATOK とは正反対のアプローチでなかなかの変換精度を提供してくれている本 IME 、使いどころによっては十分選択肢に含まれるのではないでしょうか?

bookreader.js カスタマイズのメモ

bookreader.js バナー

SS の公開に使っている、bookreader.js ですが、やっぱり便利。ブラウザで超長文を縦スクロールで読むのは、辛いなあと思っていたひとには福音となりそうなライブラリです。というか、Web 小説を公開しているひとの多くが該当するのかも。まぁ、見せる方のこだわりの一つと思ってもらえれば……。

ただ、使用できるタグが限定されていたり、カスタマイズに関する情報はさすがに少なかったので、自力でいろいろいじってみて分かったことについてメモってみようかと思います。

bookreader.js 0.4.5 のカスタマイズ

0.4.1でも施した、p タグや div タグへの class 指定を 0.4.5 でもできるようにしてみました。パッチは以下。

--- bookreader.src.js.org	2008-07-08 00:11:32.000000000 +0900
+++ bookreader.src.js	2008-07-09 11:44:12.000000000 +0900
@@ -71,15 +71,17 @@
 				case 'P':
 					s = elm.innerHTML;
 					t = BookReader.Utils.dividelines(s, maxletter);
+					w = elm.readAttribute('class');
+					if (!w) { w = ''; }
 					t.each(function(line){
 						if (BookReader.currentline >= maxline || line == '<hr />'){ BookReader.insertPage(); }
 						if (line != '<hr />'){
 							if (elm.align == 'right'){
-								BookReader.pages[BookReader.pages.length-1] += '<p class="'+fontsize+' right">' + line + '</p>';
+								BookReader.pages[BookReader.pages.length-1] += '<p class="'+fontsize+' '+w+' right">' + line + '</p>';
 							} else if (elm.align == 'center'){
-								BookReader.pages[BookReader.pages.length-1] += '<p class="'+fontsize+' center">' + line + '</p>';
+								BookReader.pages[BookReader.pages.length-1] += '<p class="'+fontsize+' '+w+' center">' + line + '</p>';
 							} else {
-								BookReader.pages[BookReader.pages.length-1] += '<p class="'+fontsize+'">' + line + '</p>';
+								BookReader.pages[BookReader.pages.length-1] += '<p class="'+fontsize+' '+w+'">' + line + '</p>';
 							}
 							BookReader.currentline++;
 						}

0.4.5 では、行揃えなどが標準で組み込まれているので class 指定を使う必要があるケースはかなり少ないと思いますが、例えば、インラインで img タグを使用し文中に画像を入れたいときなどは、行の高さが決め打ちされているので、一部分しか表示されないなどの現象が起こりえます*1

例えば、バナーなどをインラインで表示したい場合などは、専用の class を CSS に追記して、画像を表示する行に対して class を指定してやるなどの方法で対応するのが良いかと思います。

動作サンプルで具体的な記述方法や CSS の指定を確認して下さい。

勝手にバナー作ってみました

bookreader.js バナー

アイコンの画像は、Detailed information for icon – document2 を使用させていただいています。アイコンのライセンスが GPL なので、こちらのバナーも GPL ってことで。

Illustrator で加工した EPS 形式のファイルと、バナー用の PNG ファイルをアーカイブしておいておきますので、自由に使って下さい。あ、公式とは全く関係ないので、その点はご注意を。

以下の内容は bookreader.js 0.4.1 に対して行った改造です。それ以降のバージョンではほぼ同等の機能が取り込まれていますので、改造は不要となっています。

Continue reading

  1. 画像自体に width や height を指定しないと、その行に収まるように高さを無理矢理縮めて表示するようです。 []

WordPress 2.2.3 のコメント通知メールの文字コードを変更する

WordPress 2.2.3 のコメント通知メールは、本体で使用している文字コードと同じもので送られてきます。ウチの場合は UTF-8 なので、通常のメーラ*1 での内容確認は問題ないのですが、携帯電話に転送すると UTF-8 が利用できず、化け化けになってしまうのを何とかしたいと思っていました。

ということで、検索。 WordPress 2.2.3のコメント通知メールをISO-2022-JPに | 老眼palm というエントリを発見し、そのパッチを適用してみたところ、件名および本文の文字化けは解消。
件名の方は、時折一部が化ける現象が発生していたのですが、メールの件名の文字化け防止パッチの実証プラグイン « iDeasilo を導入することで、それも解消。数件テストしてみた感じでは、件名の化けも起きていないようです。

で、気づいたのが差出人 From: フィールドは化けたままだということ。なので、さらにちょちょいと1行書き換えてテストしたら化けなかったのでこれでいいか、と。

パッチ

./wp-includes/pluggable.php に対するパッチは、以下。老眼palm のものとほぼ同じですが、$phpmailer->FromName についても、mb_encode_mimeheader を通してみました。

$ diff -u pluggable.php.bak pluggable.php
--- pluggable.php.bak   2007-09-08 14:06:51.000000000 +0900
+++ pluggable.php       2007-09-20 00:19:33.000000000 +0900
@@ -160,6 +160,8 @@
 function wp_mail($to, $subject, $message, $headers = '') {
        global $phpmailer;

+       mb_internal_encoding("UTF-8");
+
        if ( !is_object( $phpmailer ) ) {
                require_once(ABSPATH . WPINC . '/class-phpmailer.php');
                require_once(ABSPATH . WPINC . '/class-smtp.php');
@@ -185,8 +187,12 @@

        $phpmailer->FromName = "WordPress";
        $phpmailer->AddAddress("$to", "");
-       $phpmailer->Subject = $subject;
-       $phpmailer->Body    = $message;
+//     $phpmailer->Subject = $subject;
+//     $phpmailer->Body    = $message;
+       $phpmailer->CharSet = "ISO-2022-JP";
+       $phpmailer->Encoding = "7bit";
+       $phpmailer->Subject = mb_encode_mimeheader($subject, "ISO-2022-JP", "B", "\n");
+       $phpmailer->Body    = mb_convert_encoding($message, "ISO-2022-JP", "UTF-8");
        $phpmailer->IsHTML(false);
        $phpmailer->IsMail(); // set mailer to use php mail()

@@ -197,14 +203,16 @@
                $header = explode( ":", $line );
                switch ( trim( $header[0] ) ) {
                        case "From":
+
                                $from = trim( str_replace( '"', '', $header[1] ) );
                                if ( strpos( $from, '<' ) ) {
-                                       $phpmailer->FromName = str_replace( '"', '', substr( $header[1], 0, strpos( $header[1], '<' ) - 1 ) );
+                                       $phpmailer->FromName = mb_encode_mimeheader(str_replace( '"', '', substr( $header[1], 0, strpos( $header[1], '<' ) - 1 ) ), "ISO-2022-JP", "B", "\n");
                                        $from = trim( substr( $from, strpos( $from, '<' ) + 1 ) );
                                        $from = str_replace( '>', '', $from );
                                } else {
                                        $phpmailer->FromName = $from;
                                }
+
                                $phpmailer->From = trim( $from );
                                break;
                        default:
  1. Gmail とか Becky!2 とか。今は Google Apss にメールはお任せしてるので、Gmail 一本です。 []

mod_dosdetector を Apache 2.0 系で利用したい

はてなの中の人が作った mod_dosdetector を Vine 3.2 上の Apache 2.0.55 で利用しようと思ったら、

$ make
/usr/bin/apxs -c    mod_dosdetector.c
/usr/bin/libtool --silent --mode=compile gcc -prefer-pic  -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -g -O2 -pthread -I/usr/include/apache2  -I/usr/include/apache2   -I/usr/include/apache2 -I/usr/include  -c -o mod_dosdetector.lo mod_dosdetector.c && touch mod_dosdetector.slo
In file included from /usr/include/apache2/httpd.h:44,
                 from mod_dosdetector.c:32:
/usr/include/apache2/pcreposix.h:26:1: warning: "REG_ICASE" redefined
In file included from mod_dosdetector.c:31:
/usr/include/regex.h:277:1: warning: this is the location of the previous definition
In file included from /usr/include/apache2/httpd.h:44,
                 from mod_dosdetector.c:32:
/usr/include/apache2/pcreposix.h:27:1: warning: "REG_NEWLINE" redefined
In file included from mod_dosdetector.c:31:
/usr/include/regex.h:282:1: warning: this is the location of the previous definition
In file included from /usr/include/apache2/httpd.h:44,
                 from mod_dosdetector.c:32:
/usr/include/apache2/pcreposix.h:28:1: warning: "REG_NOTBOL" redefined
In file included from mod_dosdetector.c:31:
/usr/include/regex.h:296:1: warning: this is the location of the previous definition
In file included from /usr/include/apache2/httpd.h:44,
                 from mod_dosdetector.c:32:
/usr/include/apache2/pcreposix.h:29:1: warning: "REG_NOTEOL" redefined
In file included from mod_dosdetector.c:31:
/usr/include/regex.h:299:1: warning: this is the location of the previous definition
In file included from /usr/include/apache2/httpd.h:44,
                 from mod_dosdetector.c:32:
/usr/include/apache2/pcreposix.h:34:1: warning: "REG_EXTENDED" redefined
In file included from mod_dosdetector.c:31:
/usr/include/regex.h:273:1: warning: this is the location of the previous definition
In file included from /usr/include/apache2/httpd.h:44,
                 from mod_dosdetector.c:32:
/usr/include/apache2/pcreposix.h:35:1: warning: "REG_NOSUB" redefined
In file included from mod_dosdetector.c:31:
/usr/include/regex.h:286:1: warning: this is the location of the previous definition
In file included from /usr/include/apache2/httpd.h:44,
                 from mod_dosdetector.c:32:
/usr/include/apache2/pcreposix.h:41: error: redefinition of `REG_BADBR'
/usr/include/regex.h:323: error: `REG_BADBR' previously defined here
/usr/include/apache2/pcreposix.h:42: error: redefinition of `REG_BADPAT'
/usr/include/regex.h:315: error: `REG_BADPAT' previously defined here
/usr/include/apache2/pcreposix.h:43: error: redefinition of `REG_BADRPT'
/usr/include/regex.h:326: error: `REG_BADRPT' previously defined here
/usr/include/apache2/pcreposix.h:44: error: redefinition of `REG_EBRACE'
/usr/include/regex.h:322: error: `REG_EBRACE' previously defined here
/usr/include/apache2/pcreposix.h:45: error: redefinition of `REG_EBRACK'
/usr/include/regex.h:320: error: `REG_EBRACK' previously defined here
/usr/include/apache2/pcreposix.h:46: error: redefinition of `REG_ECOLLATE'
/usr/include/regex.h:316: error: `REG_ECOLLATE' previously defined here
/usr/include/apache2/pcreposix.h:47: error: redefinition of `REG_ECTYPE'
/usr/include/regex.h:317: error: `REG_ECTYPE' previously defined here
/usr/include/apache2/pcreposix.h:48: error: redefinition of `REG_EESCAPE'
/usr/include/regex.h:318: error: `REG_EESCAPE' previously defined here
/usr/include/apache2/pcreposix.h:50: error: redefinition of `REG_EPAREN'
/usr/include/regex.h:321: error: `REG_EPAREN' previously defined here
/usr/include/apache2/pcreposix.h:51: error: redefinition of `REG_ERANGE'
/usr/include/regex.h:324: error: `REG_ERANGE' previously defined here
/usr/include/apache2/pcreposix.h:52: error: redefinition of `REG_ESIZE'
/usr/include/regex.h:330: error: `REG_ESIZE' previously defined here
/usr/include/apache2/pcreposix.h:53: error: redefinition of `REG_ESPACE'
/usr/include/regex.h:325: error: `REG_ESPACE' previously defined here
/usr/include/apache2/pcreposix.h:54: error: redefinition of `REG_ESUBREG'
/usr/include/regex.h:319: error: `REG_ESUBREG' previously defined here
/usr/include/apache2/pcreposix.h:57: error: redefinition of `REG_NOMATCH'
/usr/include/regex.h:311: error: `REG_NOMATCH' previously defined here
/usr/include/apache2/pcreposix.h:66: error: conflicting types for `regex_t'
/usr/include/regex.h:412: error: previous declaration of `regex_t'
/usr/include/apache2/pcreposix.h:70: warning: redefinition of `regoff_t'
/usr/include/regex.h:415: warning: `regoff_t' previously declared here
/usr/include/apache2/pcreposix.h:75: error: conflicting types for `regmatch_t'
/usr/include/regex.h:443: error: previous declaration of `regmatch_t'
/usr/include/apache2/pcreposix.h:79: error: conflicting types for `regcomp'
/usr/include/regex.h:558: error: previous declaration of `regcomp'
/usr/include/apache2/pcreposix.h:80: error: conflicting types for `regexec'
/usr/include/regex.h:562: error: previous declaration of `regexec'
/usr/include/apache2/pcreposix.h:81: error: conflicting types for `regerror'
/usr/include/regex.h:567: error: previous declaration of `regerror'
/usr/include/apache2/pcreposix.h:82: error: conflicting types for `regfree'
/usr/include/regex.h:570: error: previous declaration of `regfree'
mod_dosdetector.c: In function `dosdetector_handler':
mod_dosdetector.c:264: error: `ap_regmatch_t' undeclared (first use in this function)
mod_dosdetector.c:264: error: (Each undeclared identifier is reported only once
mod_dosdetector.c:264: error: for each function it appears in.)
mod_dosdetector.c:264: error: syntax error before "regmatch"
mod_dosdetector.c:265: error: `ap_regex_t' undeclared (first use in this function)
mod_dosdetector.c:265: error: `contenttype_regexp' undeclared (first use in this function)
mod_dosdetector.c:265: error: syntax error before ')' token
mod_dosdetector.c:267: error: `regmatch' undeclared (first use in this function)
apxs:Error: Command failed with rc=65536
.
make: *** [mod_dosdetector.so] エラー 1

とステキな量のエラーが出てしまったので諦めていたのですが、今日検索したら、mizzy.org : mod_dosdetector を Apache 2.0 系で動かすパッチ というぐれぇとなパッチが提供されていたので、早速テスト。

$ patch < mod_dosdetector.patch
(Stripping trailing CRs from patch.)
patching file mod_dosdetector.c
Hunk #1 FAILED at 28.
Hunk #2 FAILED at 40.
Hunk #3 succeeded at 351 with fuzz 2 (offset 249 lines).
Hunk #4 FAILED at 593.
patch unexpectedly ends in middle of line
Hunk #5 FAILED at 722.
4 out of 5 hunks FAILED -- saving rejects to file mod_dosdetector.c.rej

orz

仕方ないので手パッチを行い、インストール。

$ make
/usr/bin/apxs -c    mod_dosdetector.c
/usr/bin/libtool --silent --mode=compile gcc -prefer-pic  -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -g -O2 -pthread -I/usr/include/apache2  -I/usr/include/apache2   -I/usr/include/apache2 -I/usr/include  -c -o mod_dosdetector.lo mod_dosdetector.c && touch mod_dosdetector.slo
/usr/bin/libtool --silent --mode=link gcc -o mod_dosdetector.la  -rpath /usr/lib/apache2/modules -module -avoid-version    mod_dosdetector.lo

$ su
Password:
# make install
/usr/bin/apxs -c    mod_dosdetector.c
/usr/bin/libtool --silent --mode=compile gcc -prefer-pic  -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -g -O2 -pthread -I/usr/include/apache2  -I/usr/include/apache2   -I/usr/include/apache2 -I/usr/include  -c -o mod_dosdetector.lo mod_dosdetector.c && touch mod_dosdetector.slo
/usr/bin/libtool --silent --mode=link gcc -o mod_dosdetector.la  -rpath /usr/lib/apache2/modules -module -avoid-version    mod_dosdetector.lo
/usr/bin/apxs -c -i -a -n 'dosdetector' mod_dosdetector.c
/usr/bin/libtool --silent --mode=compile gcc -prefer-pic  -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -g -O2 -pthread -I/usr/include/apache2  -I/usr/include/apache2   -I/usr/include/apache2 -I/usr/include  -c -o mod_dosdetector.lo mod_dosdetector.c && touch mod_dosdetector.slo
/usr/bin/libtool --silent --mode=link gcc -o mod_dosdetector.la  -rpath /usr/lib/apache2/modules -module -avoid-version    mod_dosdetector.lo
/etc/apache2/build/instdso.sh SH_LIBTOOL='/usr/bin/libtool' mod_dosdetector.la /usr/lib/apache2/modules
/usr/bin/libtool --mode=install cp mod_dosdetector.la /usr/lib/apache2/modules/
cp .libs/mod_dosdetector.so /usr/lib/apache2/modules/mod_dosdetector.so
cp .libs/mod_dosdetector.lai /usr/lib/apache2/modules/mod_dosdetector.la
cp .libs/mod_dosdetector.a /usr/lib/apache2/modules/mod_dosdetector.a
ranlib /usr/lib/apache2/modules/mod_dosdetector.a
chmod 644 /usr/lib/apache2/modules/mod_dosdetector.a
PATH="$PATH:/sbin" ldconfig -n /usr/lib/apache2/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/lib/apache2/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/lib/apache2/modules/mod_dosdetector.so
[activating module `dosdetector' in /etc/apache2/conf/apache2.conf]

とりあえずインストール完了まではこぎ着けました。あとは設定を詰めてテストしよう。

パッチ内容

手パッチしたのを diff した結果。Makefile も書き換え必要だったので一緒に。

 $ diff -u Makefile.org Makefile
--- Makefile.org        2007-09-19 10:53:39.000000000 +0900
+++ Makefile    2007-09-19 10:53:45.000000000 +0900
@@ -4,7 +4,7 @@
 ##

 #   the used tools
-APXS=/usr/sbin/apxs
+APXS=/usr/bin/apxs
 APACHECTL=apachectl

 #   additional user defines, includes and libraries
 $ diff -u mod_dosdetector.c.org  mod_dosdetector.c
--- mod_dosdetector.c.org       2007-09-19 10:53:15.000000000 +0900
+++ mod_dosdetector.c   2007-09-19 10:53:31.000000000 +0900
@@ -28,7 +28,6 @@
 #include <arpa/inet.h>
 //#include <netinet/in.h>
 #include <time.h>
-#include <regex.h>
 #include "httpd.h"
 #include "http_config.h"
 #include "http_request.h"
@@ -41,6 +40,7 @@
 #include "apr_strings.h"
 #include "apr_shm.h"
 #include "apr_thread_mutex.h"
+#include "apr_version.h"

 //#define _DEBUG

@@ -102,6 +102,90 @@
 static apr_global_mutex_t *lock = NULL;
 static apr_shm_t *shm = NULL;

+/* apr version 0.x not support apr_shm_remove, I have to copy it from apr version 1.x */
+#if (APR_MAJOR_VERSION < 1)
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+#ifdef HAVE_SYS_IPC_H
+#include <sys/ipc.h>
+#endif
+#ifdef HAVE_SYS_MUTEX_H
+#include <sys/mutex.h>
+#endif
+#ifdef HAVE_SYS_SHM_H
+#include <sys/shm.h>
+#endif
+#if !defined(SHM_R)
+#define SHM_R 0400
+#endif
+#if !defined(SHM_W)
+#define SHM_W 0200
+#endif
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+
+static apr_status_t apr_shm_remove(const char *filename, apr_pool_t * pool)
+{
+#if APR_USE_SHMEM_SHMGET
+    apr_status_t status;
+    apr_file_t *file;
+    key_t shmkey;
+    int shmid;
+#endif
+
+#if APR_USE_SHMEM_MMAP_TMP
+    return apr_file_remove(filename, pool);
+#endif
+#if APR_USE_SHMEM_MMAP_SHM
+    if (shm_unlink(filename) == -1) {
+        return errno;
+    }
+    return APR_SUCCESS;
+#endif
+#if APR_USE_SHMEM_SHMGET
+    /* Presume that the file already exists; just open for writing */
+    status = apr_file_open(&file, filename, APR_WRITE,
+                           APR_OS_DEFAULT, pool);
+    if (status) {
+        return status;
+    }
+
+    /* ftok() (on solaris at least) requires that the file actually
+     * exist before calling ftok(). */
+    shmkey = ftok(filename, 1);
+    if (shmkey == (key_t) - 1) {
+        goto shm_remove_failed;
+    }
+
+    apr_file_close(file);
+
+    if*1 < 0) {
+        goto shm_remove_failed;
+    }
+
+    /* Indicate that the segment is to be destroyed as soon
+     * as all processes have detached. This also disallows any
+     * new attachments to the segment. */
+    if (shmctl(shmid, IPC_RMID, NULL) == -1) {
+        goto shm_remove_failed;
+    }
+    return apr_file_remove(filename, pool);
+
+  shm_remove_failed:
+    status = errno;
+    /* ensure the file has been removed anyway. */
+    apr_file_remove(filename, pool);
+    return status;
+#endif
+
+    /* No support for anonymous shm */
+    return APR_ENOTIMPL;
+}
+#endif                            /* APR_MAJOR_VERSION<1 */
+
+

 static apr_status_t cleanup_shm(void *not_used)
 {
@@ -261,8 +345,9 @@

        address = r->connection->remote_ip;

-    ap_regmatch_t regmatch[AP_MAX_REG_MATCH];
-    ap_regex_t **contenttype_regexp = (ap_regex_t **) cfg->contenttype_regexp->elts;
+       regmatch_t regmatch[AP_MAX_REG_MATCH];
+       regex_t **contenttype_regexp = (regex_t **) cfg->contenttype_regexp->elts;
+
        for (i = 0; i < cfg->contenttype_regexp->nelts; i++) {
                if(!ap_regexec(contenttype_regexp[i], content_type, AP_MAX_REG_MATCH, regmatch, 0)){
                        //ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, 0, "ignoring content-type: %s", content_type);
@@ -390,14 +475,12 @@
                                         const char *arg)
 {
     dosdetector_dir_config *cfg = (dosdetector_dir_config *) mconfig;
-    char **ignore_contenttype = (char **) cfg->ignore_contenttype->elts;
-
-    *(char **) apr_array_push(cfg->ignore_contenttype) = apr_pstrdup(parms->pool, arg);
-
-       int i;
        regex_t *regexp;
-       for (i = 0; i < cfg->ignore_contenttype->nelts; i++) {
-        regexp = (regex_t *)ap_pregcomp(parms->pool, (char *)ignore_contenttype[i], REG_EXTENDED|REG_ICASE);
+       char *type;
+
+       while (*arg) {
+               type = ap_getword_conf(parms->pool, &arg);
+               regexp = ap_pregcomp(parms->pool, type, REG_EXTENDED|REG_ICASE);
                *(regex_t **)apr_array_push(cfg->contenttype_regexp) = regexp;
     }

あれ? でも内容一緒だな。パッチの当て方ミスってたのかなorz

設定の仕方がわからない

どうにも設定のコツがわからないので、作者手ずからの説明が書かれているという Software Design 2007年 09月号 を注文。Apache モジュールの使い方特集らしいので、役に立ちそう。

Software Design (ソフトウエア デザイン) 2007年 09月号 [雑誌]
Software Design (ソフトウエア デザイン) 2007年 09月号 [雑誌]
技術評論社 2007-08-18
売り上げランキング :

Amazonで詳しく見るby G-Tools

Software Design (ソフトウエア デザイン) 2007年 06月号 [雑誌] WEB+DB PRESS Vol.40 WEB+DB PRESS Vol.39 Software Design (ソフトウエア デザイン) 2007年 10月号 [雑誌] WEB+DB PRESS Vol.38

  1. shmid = shmget(shmkey, 0, SHM_R | SHM_W []

PHP5 へアップグレード

MediaWiki を試してみたかったので、Vine 3.2 の PHP を4から5へアップグレードしました。

デフォルトだと WordPress の投稿が化けてしまうのと一部のプラグインが動かなくなるので、php.ini を

short_open_tag = On
mbstring.internal_encoding = UTF-8
memory_limit = 64M

のように書き換えました。

また、LiveCommentPreview

PHP Notice:  Undefined variable: livePreviewDivAdded in wp-content/plugins/live-comment-preview.php on line 24

みたいなエラーを吐いたので、該当の

$livePreviewDivAdded == false;

をコメントアウト。とりあえず動いてるっぽいです。

Home > Tags > コンピュータ

応援中
サイト内検索
フィード
メタ情報
広告
ブログパーツ
あわせて読みたい フィードメーター - MOMENTS

Return to page top