dbskkd-cdb-2.00/000700 001750 001750 00000000000 11142723370 013251 5ustar00kenjik2r000000 000000 dbskkd-cdb-2.00/READMEJP000600 001750 001750 00000011507 11142723357 014376 0ustar00kenjik2r000000 000000 # -*- coding: euc-jp-unix -*- dbskkd-cdb Release Notes in Japanese for version dbskkd-cdb-2.00 by Kenji Rikitake last updated 6-FEB-2009 ● dbskkd-cdb の概要 dbskkd-cdb は, skkserv と同様の機能を提供する SKK 用の共通辞書サーバーで ある.辞書は D. J. Bernstein の cdb を使ってデータベース化し,検索を高速 化している.本サーバーは同種のツール pskkserv を基にしている. cdb http://cr.yp.to/cdb.html 本プログラムは cdb 互換ライブラリである TinyCDB へのリンクを前提としている. ビルドには TinyCDB のヘッダ cdb.h とライブラリ libcdb.a が必要である. (cdbの同種のライブラリも使用可能であるが,テストしていない.) TinyCDB http://www.corpit.ru/mjt/tinycdb.html ● dbskkd-cdb の動作環境 dbskkd-cdb は,現時点では FreeBSD 7.1-RELEASE にて基本的動作を確認している. FreeBSD の port および debian の package については動作を確認している. 他の OS でも大きな変更なしに動作すると思われる.ただし動作の確認は動作の 保証を意味しない.また動作条件の細かな変化による誤動作については一切保証 しない. dbskkd-cdb-1.01 および 1.71dev の cdb ファイルはそのまま動作する. ●インストール前の注意 1. 添付の makeskkcdb.sh を実行する.このスクリプトでは 辞書ファイルは skktocdbm.sh の標準入力に与える. ファイル名の既定値は /usr/local/share/skk/SKK-JISYO.L である. 実行するとカレントディレクトリに SKK-JISYO.L.cdb が作られる. この辞書ファイルはインストールの際 dbskkd-cdb.c 中の JISYO_FILE で指定するディレクトリに置く. JISYO_FILE の規定値は /usr/local/share/skk/SKK-JISYO.L.cdb である. 注意: 1.x ではこのマクロは "JISHO_FILE" と定義していたが, 辞書ファイルとの名前の整合性を取るためにこのようにした. 2. 実行ファイル dbskkd-cdb をコンパイルするため make する. この際 TinyCDB 中の cdb.h が必要となる. また TinyCDB 中の libcdb.a をリンクする. 3. make install で dbskkd-cdb を実行ディレクトリにコピーする. 既定値では /usr/local/libexec へコピーする. ●インストールの際の注意 このプログラム専用の非特権ユーザを設定し, そのユーザの権限で起動するようにすること. ★ root 権限で起動してはならない. example-inetd.txt に inetd.conf への追加内容例, example-daemontools.txt に daemontools を使った場合の run ファイルへの記述例を示している. ●注意・限界・改良の余地 dbskkd-cdb は一旦起動されると終了するまではcdb辞書ファイルをオープンした ままになっている. cdb ではオープンされたファイルの中身は変わらないことを 仮定しているため, dbskkd-cdb を起動した状態で cdb 辞書ファイルの内容を変 更してはならない. cdb 辞書ファイルを作り直す場合は, dbskkd-cdb を起動し ていないことを確認する必要がある. 個人的には SERVER_NOT_FOUND の時の挙動は無駄だと思うが,慣習として対応し ている.プロトコルの詳細については skk-server-protocol.txt に記している. ●配布条件 Creative Commons Attribution 3.0 Unported License http://creativecommons.org/licenses/by/3.0/ あるいは Simplified BSD License に準拠します. 詳しい条件については ファイル LICENSE の内容を 参照してください. ●バグレポート,意見交換など 本プログラムに関する意見交換は 情報共有のため Google Code 上のレポジトリ http://code.google.com/p/dbskkd-cdb/ の上でお願いします. 日本語あるいは英語でお願いします. ●謝辞 cdb の開発者 Daniel J. Bernstein および TinyCDB の開発者 Michael Tokarev の両氏に 最大限の感謝と賛辞を贈ります. また,本プログラムの開発にあたって,以下の方々, ここに列挙していない contributor の皆様, ならびに SKK の利用を通じて改良点などをご教示くださった皆様に 感謝致します. (敬称略) 佐藤 雅彦,中島 幹夫,亀山 幸義,佐藤 正章,阪本 崇,鵜飼 文敏, 前野 年紀,本田 康弘,中原 早生,菊地 高広,まつもとひでお, 鯉江 英隆,川村 尚生,木原 英人,稲員 力士,松下 誠,山縣 敦, 木下 達也,中居 良介 ●1.71dev からの修正箇所のメモ (see CHANGES for details) 木下達也さん (Debian maintainer) からのパッチを適用 以下の Twitter @konosuke 氏からの指摘により, BSD make 依存の部分を GNU make でも通るようにした http://twitter.com/konosuke/status/1094925767 gcc-4.2.1 (FreeBSD 7.1-RELEASE stock cc) の signedness の問題をとりあえ ず形式的に修正(意味的にも問題はないと思うが,要確認) chroot, setuid, setgid をやめた. TinyCDB にリンクするように変更 FreeBSD でも主な Linux distro でも tinycdb-0.76 の cdb.h は別途入手可 (FreeBSD databases/tinycdb, Debian libcdb-dev package) hostname/IP アドレスを返すクライアントからの要求 ('3') は, 変換の用途にはまったく使われていないことを確認 (情報表示用の用途のみ) よってこの要求に対する返答は固定文字列で返すようにした. これで TCPLOCALHOST/TCPLOCALIP を getenv() しなくて済む. inetd は stderr も stdout 同様に扱ってしまうため, stderr でメッセージを返す意味がない. syslog でわざわざメッセージを出すほどの理由もないので, stderr へ出力するコードはすべて VERBOSE_MSG という コンパイル時フラグを有効にした時のみ組み込まれるようにした. 名前の整合性を取るために JISHO_FILE -> JISYO_FILE としている. makeskkcdb.sh で tinycdb の cdb を使うようにした. READMEJP の encoding を euc-jp に変更. skk-server-protocol.txt を追加. README を追加. [End of memorandum] dbskkd-cdb-2.00/LICENSE000600 001750 001750 00000003204 11142723357 014264 0ustar00kenjik2r000000 000000 License statement for dbskkd-cdb Copyright (c) 1998-2009 by Kenji Rikitake. All rights reserved. This software is distributed under the terms of either Creative Commons Attribution 3.0 Unported License http://creativecommons.org/licenses/by/3.0/ or the Simplified BSD license, shown as follows: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. For more information on the dbskkd-cdb project, please refer to http://code.google.com/p/dbskkd-cdb/ [End of License statement for dbskkd-cdb] dbskkd-cdb-2.00/example-inetd.txt000600 001750 001750 00000000455 11142723357 016561 0ustar00kenjik2r000000 000000 # inetd entries for dbskkd-cdb # NOTE: set unprivileged and dedicated uid for execution # Define *both* IPv4 and IPv6 entries for dual-stack support. skkserv stream tcp nowait dbskkd /usr/local/libexec/dbskkd-cdb dbskkd-cdb skkserv stream tcp6 nowait dbskkd /usr/local/libexec/dbskkd-cdb dbskkd-cdb # dbskkd-cdb-2.00/makeskkcdb.sh000700 001750 001750 00000000135 11142723357 015713 0ustar00kenjik2r000000 000000 #!/bin/sh ./skktocdbm.sh < /usr/local/share/skk/SKK-JISYO.L | \ cdb -c -t - SKK-JISYO.L.cdb dbskkd-cdb-2.00/CHANGES000600 001750 001750 00000004575 11142723357 014266 0ustar00kenjik2r000000 000000 20090206 version: 2.00. READMEJP encoding changed to euc-jp skk-server-protocol.txt revised README added as a brief English document 20090131 skk-server-protocol.txt added READMEJP revised and simplified 20090129 Made CHANGES in reverse-chlonogical order 20090127 makeskkcdb.sh now uses tinycdb's cdb instead of djb's cdbmake 20090126 Removed ambiguity from LICENSE Attached LICENSE content in dbskkd-cdb.c 20090125 inetd does not handle stderr well, so explicit error messages before crashing are all commented out (the fast-fail principle applied) setting VERBOSE_MSG as a compile flag will reenable the messages (still useful when used with ucspi-tcp) More comments on the code inserted DUMMYHOSTNAME made shorter NOTE: dictionary name is changed to JISYO_FILE (previously JISHO -> now *JISYO*) to match the SKK-JISYO.* filenames 20090125-2 dbskkd-cdb.c performs macro replacement diesys(string) -> exit(1) 20090124 dropped supporting server request '3' with actual hostname or IP address (the current syntax will be broken anyway if IPv6 should be supported) since NO CLIENT uses this information for authentication or anything meaningful except for showing the information to the user when optionally requested, so the answer to the request is replaced by a fixed string defined in the DUMMYHOSTNAME macro 20090118 version: 1.99-expr. strictly EXPERIMENTAL, NOT a release removed cdb-0.75 dependencies now tinycdb-0.76 required removed chroot, setuid, setgid calls from the program (more like 1.01) Japanese docs changed to reflect the status 20090114 patches from Tatsuya Kinoshita (Debian package maintainer) * awk-locale.patch: Set LC_ALL to C for awk in skktocdbm.sh. * datasize.patch: Increase DATASIZE from 2048 to 4096 so that the longest line of SKK-JISYO.L can be used. also Tatsuya pointed out the uint32 problem (which has been fixed) of variable datalen 20090113 BSD make dependencies resolved as pointed out in the following tweet: http://twitter.com/konosuke/status/1094925767 cleanupcdb.sh added gcc-4.2.1 signedness warning cleared by quitting using unsigned chars 20000325 Japanese README complete version: dbskkd-cdb-1.70dev. 20000312 Changes from 1.01 to 1.70dev: * chroot()s to the SERVER_DIR * search() included into the main()'s command loop * reports pid to stderr * now uses cdb-0.75 source files instead of cdb-0.55's dbskkd-cdb-2.00/dbskkd-cdb.c000600 001750 001750 00000015156 11142723357 015424 0ustar00kenjik2r000000 000000 /* * dbskkd-cdb.c * SKK dictionary Server * with Daniel J. Bernstein's cdb database * * Copyright (c) 1998-2009 by Kenji Rikitake. All rights reserved. * See LICENSE of the distribution kit for the redistribution conditions. * The copy of the LICENSE file is attached at the end of this code. */ #include #include #include #include #include #include #include #include /* tinycdb required */ #include "cdb.h" /* * dbskkd dictionary file * default value: FreeBSD port japanese/ddskk * note: the macro was JISHO_FILE in 1.x * spelling changed from JISHO to JISYO */ #ifndef JISYO_FILE #define JISYO_FILE "/usr/local/share/skk/SKK-JISYO.L.cdb" #endif /* JISYO_FILE */ #define BUFSIZE (1024) /* max size of a request */ #define DATASIZE (4096) /* max size of a result */ #define CLIENT_END '0' #define CLIENT_REQUEST '1' #define CLIENT_VERSION '2' #define CLIENT_HOST '3' #define SERVER_FOUND '1' #define SERVER_NOT_FOUND '4' #define STDIN (fileno(stdin)) #define STDOUT (fileno(stdout)) /* these strings must be terminated with space */ #define VERSION "dbskkd-cdb-2.00 " #define DUMMYHOSTNAME "novalue: " /* * define VERBOSE_MSG * if explicit error messages are needed */ /* #undef VERBOSE_MSG */ /* * diesys() is replaced by exit(1) * when VERBOSE_MSG is not defined */ #ifdef VERBOSE_MSG /* * diesys() originally from DJB's cdb-0.55 * modified by Kenji Rikitake */ void diesys(char *why) { fprintf(stderr, "dbskkd-cdb: pid %d ", getpid()); perror(why); exit(1); } #else /* !VERBOSE_MSG */ #define diesys(dummy_string) exit(1) #endif /* VERBOSE_MSG */ /* main program */ int main(int argc, char *argv[]) { char combuf[BUFSIZE], data[DATASIZE]; char *pbuf, *key, *p; struct cdb diccdb; int dicfd, ex, length; unsigned int keylen, datalen; /* open dictionary cdb file */ if ((dicfd = open(JISYO_FILE, O_RDONLY, S_IRUSR)) < 0) { diesys("cannot open() the dictionary file " JISYO_FILE); /* NOTREACHED */ } cdb_init(&diccdb, dicfd); /* command loop */ /* set ex to non-zero for exiting */ ex = 0; while (!ex) { length = read(STDIN, &combuf[0], BUFSIZE - 1); if (length < 0) diesys("read error from stdin"); else if (length == 0) { #ifdef VERBOSE_MSG fprintf(stderr, "dbskkd-cdb: pid %d end of file detected\n", getpid()); #endif /* VERBOSE_MSG */ ex = 1; break; } /* parse request code */ switch (combuf[0]) { case CLIENT_END: #ifdef VERBOSE_MSG fprintf(stderr, "dbskkd-cdb: pid %d end of conversion requested\n", getpid()); #endif /* VERBOSE_MSG */ ex = 1; break; case CLIENT_VERSION: if (write(STDOUT, VERSION, sizeof(VERSION) - 1) < 0) diesys("write error (version string)"); break; case CLIENT_HOST: if (write(STDOUT, DUMMYHOSTNAME, sizeof(DUMMYHOSTNAME) - 1) < 0) diesys("write error (dummyhostname string)"); break; case CLIENT_REQUEST: /* get size of key */ key = &combuf[1]; for (pbuf = &combuf[1]; *pbuf != ' ' && pbuf != &combuf[length - 1]; pbuf++) {} keylen = pbuf - &combuf[1]; if (keylen <= 0) diesys("invalid keysize"); /* lookup the cdb database */ switch (cdb_find(&diccdb, key, keylen)) { case -1: /* error */ diesys("fatal error on cdb_find()"); case 1: /* found */ if ((datalen = cdb_datalen(&diccdb)) >= DATASIZE - 2) diesys("searched entry too long"); /* generate the answer string */ p = data; *p++ = SERVER_FOUND; if (cdb_read(&diccdb, p, datalen, cdb_datapos(&diccdb)) < 0) diesys("read error (seeked dictionary data)"); p += datalen; *p = '\n'; /* sending found code and the result data string with LF */ if (write(STDOUT, data, datalen + 2) < 0) diesys("write error (converted data)"); break; case 0: /* NOT found */ /* generate the answer string */ combuf[0] = SERVER_NOT_FOUND; *pbuf = '\n'; /* sending error code and the key string with LF */ /* this action is required by skkinput */ if (write(STDOUT, combuf, keylen + 2) < 0) diesys("write error (NOT_FOUND message)"); break; default: /* unknown cdb return value */ diesys("unknown return value from cdb_seek()"); } break; /* end CLIENT_REQUEST switch statement*/ /* unknown request code */ default: #ifdef VERBOSE_MSG fprintf(stderr, "dbskkd-cdb: pid %d unknown client request code = %d\n", getpid(), combuf[0]); #endif /* VERBOSE_MSG */ exit(1); } /* end request code parsing */ } /* close dictionary db file */ cdb_free(&diccdb); if (close(dicfd) != 0) diesys("cannot close() the dictionary file"); exit(0); } /* end of program */ /* * License statement for dbskkd-cdb * * Copyright (c) 1998-2009 by Kenji Rikitake. All rights reserved. * * This software is distributed under the terms of either * * Creative Commons Attribution 3.0 Unported License * http://creativecommons.org/licenses/by/3.0/ * * or * * the Simplified BSD license, shown as follows: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * For more information on the dbskkd-cdb project, please refer to * http://code.google.com/p/dbskkd-cdb/ * * [End of License statement for dbskkd-cdb] */ dbskkd-cdb-2.00/skktocdbm.sh000700 001750 001750 00000000571 11142723357 015601 0ustar00kenjik2r000000 000000 #!/bin/sh # Converting SKK Dictionary to cdbmake-acceptable form # Originally by D. J. Bernstein's 12tocdbm.sh # modified by Kenji Rikitake # bugfix of truncated strings by Hideto Kihara # bugfix of locale by Tatsuya Kinoshita LC_ALL=C awk ' /^[^;]/ { s = substr($0, index($0, " ") + 1) print "+" length($1) "," length(s) ":" $1 "->" s } END { print "" } ' dbskkd-cdb-2.00/skk-server-protocol.txt000600 001750 001750 00000003151 11142723357 017754 0ustar00kenjik2r000000 000000 SKK server-client protocol for dbskkd-cdb (unofficial) by Kenji Rikitake last update 6-FEB-2009 Note: this document is for dbskkd-cdb only this document does not describe sub-protocols for the server completion which is unsupported on dbskkd-cdb Notation: '0' is ASCII 0x30 LF is ASCII 0x0a space is ASCII 0x20 "abc" is ASCII/EUC-JP string Size limit: maximum request size: 1024 bytes maximum result size: 4096 bytes CLIENT_END: request to server: '0' + space + LF CLIENT_REQUEST: request to server: '1' + dictionary_key + space + LF answer if found: '1' + ('/' + candidate) * number_of_candidates + '/' + LF answer if not found: '4' + dictionary_key + space + LF note: dictionary_key and candidates are all variable-length strings character code of dictionary_key and candidate are in EUC-JP CLIENT_VERSION: request to server: '2' + space + LF answer: string including server version + space e.g. "dbskkd-cdb-2.00 " note: no known client parses this string on dbskkd-cdb: returns version string CLIENT_HOST: request to server: '3' + space + LF answer: string including host information + space e.g. "localhost:127.0.0.1: " note: no known client parses this string on dbskkd-cdb: returns dummy string "novalue: " Shutting down: The server disconnects the link and shuts down when received an unknown request on dbskkd-cdb: an internal error will cause shutdown (exit(1)) [end of document] dbskkd-cdb-2.00/README000600 001750 001750 00000003731 11142723357 014144 0ustar00kenjik2r000000 000000 # -*- coding: iso-latin-1-unix -*- dbskkd-cdb readme/installation note in English for version dbskkd-cdb-2.00 by Kenji Rikitake last updated 6-FEB-2009 * Summary dbskkd-cdb is a dictionary server for SKK Japanese Input Method system. For building the executable file, TinyCDB is required. TinyCDB http://www.corpit.ru/mjt/tinycdb.html See skk-server-protocol.txt for the details. This program is tested under FreeBSD 7.1-RELEASE. * Installation procedure 1. makeskkcdb.sh converts a plaintext SKK dictionary to the CDB format. The default source file name is /usr/local/share/skk/SKK-JISYO.L and the converted cdb file will be placed in the current directory as SKK-JISYO.L.cdb. This .cdb file should be placed with the filename specified in JISYO_FILE macro in dbskkd-cdb.c. 2. do 'make' to compile. This require cdb.h and libcdb.a of TinyCDB. 3. do 'make install' to copy the compile executable image to the executable image directory. The default directory is /usr/local/libexec. * User privilege on installation Assign a dedicated non-privileged user for this program and invoke with the uid. DO NOT invoke with the root or superuser privilege. An example of inetd.conf is available at example-inetd.txt. An example of daemontools run file is available at example-daemontools.txt. * Bug reports and comments The source code repository and issue tracker is available in Google Code at http://code.google.com/p/dbskkd-cdb/ Inquiries and comments are welcome in Japanese and English. * Acknowledgment Daniel J. Bernstein for his cdb, Michael Tokarev for his TinyCDB. SKK developers and contributors including: Makahito Sato, Mikio Nakajima, Yukiyoshi Kameyama, Masaaki Sato, Takashi Sakamoto, Fumitoshi Ukai, Toshinori Maeno, Yasuhiro Honda, Hayao Nakahara, Takahiro Kikuchi, Hideo Matsumoto, Hidetaka Koie, Takao Kawamura, Hideto Kihara, Rikishi Inakazu, Makoto Matsushita, Atsushi Yamagata, Tatsuya Kinoshita, Ryosuke Nakai. [end of README] dbskkd-cdb-2.00/example-daemontools.txt000600 001750 001750 00000000512 11142723357 017774 0ustar00kenjik2r000000 000000 #!/bin/sh exec 2>&1 exec setuidgid dbskkd softlimit -d100000 -s100000 \ tcpserver -x ./tcprules.cdb \ -vDRH -l localhost 127.0.0.1 skkserv \ /usr/local/libexec/dbskkd-cdb # # this is an example run file # for daemontools service directory. # note that dbskkd-cdb must be invoked # with a non-privileged dedicated user account. # dbskkd-cdb-2.00/Makefile000600 001750 001750 00000001031 11142723357 014713 0ustar00kenjik2r000000 000000 # dbskkd-cdb Makefile CC = cc -Wall -O2 -g -I/usr/local/include COMPAT = CDBLIB = /usr/local/lib/libcdb.a INSTALLDIR = /usr/local/libexec .c.o: $(CC) $(COMPAT) $(PRIVATE) -c $*.c all: dbskkd-cdb clean: /bin/rm -f dbskkd-cdb *.o dbskkd-cdb: dbskkd-cdb.o $(CC) $(COMPAT) $(PRIVATE) -o dbskkd-cdb \ dbskkd-cdb.o ${CDBLIB} dbskkd-cdb.o: dbskkd-cdb.c $(CC) $(COMPAT) $(PRIVATE) -c dbskkd-cdb.c error.o: error.c error.h install: dbskkd-cdb cp dbskkd-cdb $(INSTALLDIR); chmod 755 $(INSTALLDIR)/dbskkd-cdb # end of makefile