pax_global_header00006660000000000000000000000064130117721270014513gustar00rootroot0000000000000052 comment=cdcaf493de5ffb8eb52eb614b418dc17f52be534 dbskkd-cdb-3.00/000077500000000000000000000000001301177212700134255ustar00rootroot00000000000000dbskkd-cdb-3.00/.travis.yml000066400000000000000000000003361301177212700155400ustar00rootroot00000000000000language: c notifications: email: false before_install: sudo apt-get install libcdb-dev script: make CC=${CC} COMPAT="-Wall -O2 -g -I/usr/include" CDBLIB="/usr/lib/libcdb.a" install: true compiler: - clang - gcc dbskkd-cdb-3.00/CHANGES.md000066400000000000000000000057531301177212700150310ustar00rootroot00000000000000# List of changes ## 20161113 * Version 3.00 * Completely revise the source code - See git log for the details * Revise and rewrite `CHANGES` as `CHANGES.md` * Revise `skk-server-protocol.txt` to `skk-server-protocol.md` * Add `examples.md` * Remove `example-inetd.txt` and `example-daemontools.txt` ## 20161003 * Change license to MIT (see `LICENSE`) ## 20131226 * Change only documents, no code change * Revise `READMEJP` to `READMEJP.md` with UTF-8 * Remove `README` (see `README.md` instead) ## 20090206 * Version: 2.00 * Change `READMEJP` encoding to `euc-jp` * Revise `skk-server-protocol.txt` * Add `README` as a brief English document ## 20090131 * Add `skk-server-protocol.txt` * Simplify and revise `READMEJP` ## 20090129 * Made CHANGES in reverse-chlonogical order ## 20090127 * makeskkcdb.sh now uses tinycdb's cdb instead of djb's cdbmake ## 20090126 * Remove ambiguity from LICENSE * Attach LICENSE content in dbskkd-cdb.c ## 20090125 * Comment out explicit error messages before crasing - inetd does not handle stderr well - Apply the fast-fail principle - Setting `VERBOSE_MSG` as a compile flag reenables the messages - The debug messages are still useful when used with ucspi-tcp * Insert more comments on the code * Make DUMMYHOSTNAME shorter * *Note: change dictionary name to* `JISYO_FILE` - (previously JISHO -> now *JISYO* (check ***Y***) to match the `SKK-JISYO.*` filenames * Replace macros on dbskkd-cdb.c: `diesys(string)` -> `exit(1)` ## 20090124 * Drop functionality of supporting server request `3` with actual hostname or IP address - Current syntax will be broken anyway if IPv6 should be supported - *No client* uses this information for authentication or anything meaningful except for showing the information to the user when optionally requested * Replace the functionality with answering to the request with a fixed string defined in the `DUMMYHOSTNAME` macro ## 20090118 * Version: 1.99-expr (strictly *experimental*, *not* a release) * Remove `cdb-0.75` dependencies * Now require `tinycdb-0.76` * Remove chroot, setuid, setgid calls from the program (results are more like verion 1.01) * Change Japanese docs to reflect the status ## 20090114 * Apply 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 largest line of `SKK-JISYO.L` can be accepted * Fix `uint32` issue of variable `datalen`, pointed out by Tatsuya ## 20090113 * Resolve BSD make dependencies of `$>` (see http://twitter.com/konosuke/status/1094925767) * Add `cleanupcdb.sh` * Clear gcc-4.2.1 signedness warning by quitting using unsigned chars ## 20000325 * Complete writing Japanese README * Version: dbskkd-cdb-1.70dev ## 20000312 * List of changes from 1.01 to 1.70dev: * Add `chroot()`s to the `SERVER_DIR` * Include `search()` into the command loop in `main()` * Report pid to stderr * Use `cdb-0.75` source files instead of those of `cdb-0.55` dbskkd-cdb-3.00/CONTRIBUTING.md000066400000000000000000000011151301177212700156540ustar00rootroot00000000000000If you have found any problems and bugs, submit an issue on the GitHub repository at . When you propose a pull request, send the diff with the [next](https://github.com/jj1bdx/dbskkd-cdb/tree/next) branch. The PR will be reviewed and the authors will decide whether it will be merged into the master branch. If you do not want to use GitHub but have something to contribute to our project, feel free to send the request in email to Kenji Rikitake. Kenji will accept the git-am acceptable patches as substitutes for the pull requests as well. dbskkd-cdb-3.00/LICENSE000066400000000000000000000021301301177212700144260ustar00rootroot00000000000000The MIT License (MIT) Copyright © 2016 Kenji Rikitake Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. dbskkd-cdb-3.00/Makefile000066400000000000000000000010311301177212700150600ustar00rootroot00000000000000# 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 dbskkd-cdb-3.00/README.md000066400000000000000000000047761301177212700147220ustar00rootroot00000000000000# dbskkd-cdb readme/installation note in English for version dbskkd-cdb-3.00 by Kenji Rikitake last updated 13-NOV-2016 ## Travis CI build status for the master branch [![Build Status](https://travis-ci.org/jj1bdx/dbskkd-cdb.svg?branch=master)](https://travis-ci.org/jj1bdx/dbskkd-cdb) ## Summary dbskkd-cdb is a dictionary server for SKK Japanese Input Method system. For building the executable file, [TinyCDB](http://www.corpit.ru/mjt/tinycdb.html) is required. See `skk-server-protocol.md` for the details of the server-client protocol. ## License See `LICENSE`. The MIT License. ## Test environment * FreeBSD/amd64 11.0-STABLE * Periodically tested on [Travis CI](https://travis-ci.org/jj1bdx/dbskkd-cdb) with both clang and gcc ## 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. For the Make prodecure on Linux, consult `.travis.yml`. 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. See `examples.md` for the configuration examples. ## Note on collecting user information dbskkd-cdb does *not* collect any usage statistics or information. ## Bug reports and comments The source code repository and issue tracker is available in Github at . Inquiries and comments are welcome by the forms of GitHub Pull Requests and issues in Japanese and English. If you do not want to use GitHub, contact Kenji Rikitake by email for your proposals. ## 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, Hajimu Umemoto. dbskkd-cdb-3.00/READMEJP.md000066400000000000000000000111541301177212700151400ustar00rootroot00000000000000# dbskkd-cdb Release Notes in Japanese for version dbskkd-cdb-3.00 by Kenji Rikitake last updated 13-NOV-2016 ## dbskkd-cdb の概要 dbskkd-cdb は, skkserv と同様の機能を提供する SKK 用の共通辞書サーバーである.辞書は D. J. Bernstein の cdb を使ってデータベース化し,検索を高速化している.本サーバーは同種のツール pskkserv を基にしている. cdb 本プログラムは cdb 互換ライブラリである TinyCDB へのリンクを前提としている.ビルドには TinyCDB のヘッダ cdb.h とライブラリ libcdb.a が必要である.(cdbの同種のライブラリも使用可能であるが,テストしていない.) TinyCDB ## dbskkd-cdb の動作環境 dbskkd-cdb は,現時点では FreeBSD 11.0-STABLE (svn r308241) にて基本的動作を確認している. FreeBSD の port および debian の package については動作を確認している. 他の OS でも大きな変更なしに動作すると思われる.ただし動作の確認は動作の保証を意味しない.また動作条件の細かな変化による誤動作については一切保証しない. ## インストール前の注意 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 権限で起動してはならない. ★ 設定例は examples.md に記している. ## 注意・限界・改良の余地 dbskkd-cdb は一旦起動されると終了するまではcdb辞書ファイルをオープンしたままになっている. cdb ではオープンされたファイルの中身は変わらないことを仮定しているため, dbskkd-cdb を起動した状態で cdb 辞書ファイルの内容を変更してはならない. cdb 辞書ファイルを作り直す場合は, dbskkd-cdb を起動していないことを確認する必要がある. 個人的には SERVER\_NOT\_FOUND の時の挙動は無駄だと思うが,慣習として対応している.プロトコルの詳細については skk-server-protocol.md に記している. dbskkd-cdb では,接続してきたクライアントの利用履歴を取ることはない. ## 配布条件 The MIT License に準拠します.詳しい条件については ファイル LICENSE の内容を参照してください. ## バグレポート,意見交換など 本プログラムに関する意見交換は情報共有のためGitHub 上のレポジトリ のissueとして報告していただくようお願いします.日本語あるいは英語でお願いします. ## 謝辞 cdb の開発者 Daniel J. Bernstein および TinyCDB の開発者 Michael Tokarev の両氏に最大限の感謝と賛辞を贈ります. また,本プログラムの開発にあたって,以下の方々,ここに列挙していない contributor の皆様,ならびに SKK の利用を通じて改良点などをご教示くださった皆様に感謝致します. (敬称略) 佐藤 雅彦,中島 幹夫,亀山 幸義,佐藤 正章,阪本 崇,鵜飼 文敏,前野 年紀,本田 康弘,中原 早生,菊地 高広,まつもとひでお,鯉江 英隆,川村 尚生,木原 英人,稲員 力士,松下 誠,山縣 敦,木下 達也,中居 良介,梅本 肇 ## 修正箇所について 過去の修正履歴については CHANGES.md および Git のコミットログを参照してください。 [End of memorandum] dbskkd-cdb-3.00/dbskkd-cdb.c000066400000000000000000000117231301177212700155650ustar00rootroot00000000000000/* * dbskkd-cdb.c * SKK dictionary Server * with Daniel J. Bernstein's cdb database */ /* * MIT License (MIT) * Copyright © 2016 Kenji Rikitake * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include #include #include #include #include #include #include #include #include /* tinycdb required */ #include "cdb.h" /* dbskkd dictionary file name */ /* default value is for FreeBSD port japanese/ddskk */ #ifndef JISYO_FILE #define JISYO_FILE "/usr/local/share/skk/SKK-JISYO.L.cdb" #endif /* JISYO_FILE */ /* max size of a request */ #define BUFSIZE (1024) /* max size of a result */ #define DATASIZE (4096) #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-3.00 " #define DUMMYHOSTNAME "novalue: " /* 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) { exit(EX_CONFIG); } /* init cdb */ cdb_init(&diccdb, dicfd); /* To exit, set ex to non-zero */ ex = 0; /* command loop */ while (!ex) { /* Read from stdin */ length = read(STDIN, &combuf[0], BUFSIZE - 1); if (length < 0) { exit(EX_NOINPUT); } else if (length == 0) { /* EOF detected */ /* exit from the while loop */ ex = 1; break; } /* parse request code */ switch (combuf[0]) { case CLIENT_END: /* End of conversion requested*/ /* exit from the while loop */ ex = 1; break; case CLIENT_VERSION: if (write(STDOUT, VERSION, sizeof(VERSION) - 1) < 0) { exit(EX_IOERR); } break; case CLIENT_HOST: if (write(STDOUT, DUMMYHOSTNAME, sizeof(DUMMYHOSTNAME) - 1) < 0) { exit(EX_IOERR); } 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) { /* invalid keysize */ exit(EX_PROTOCOL); } /* lookup the cdb database */ switch (cdb_find(&diccdb, key, keylen)) { case -1: /* fatal error on cdb_find() */ exit(EX_SOFTWARE); break; case 1: /* found */ if ((datalen = cdb_datalen(&diccdb)) >= DATASIZE - 2) { exit(EX_PROTOCOL); } /* generate the answer string */ p = data; *p++ = SERVER_FOUND; if (cdb_read(&diccdb, p, datalen, cdb_datapos(&diccdb)) < 0) { exit(EX_SOFTWARE); } p += datalen; *p = '\n'; /* sending found code and the result data string with LF */ if (write(STDOUT, data, datalen + 2) < 0) { exit(EX_IOERR); } 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) { exit(EX_IOERR); } break; default: /* unknown cdb return value */ exit(EX_SOFTWARE); break; } break; /* end CLIENT_REQUEST switch clause */ /* unknown request code */ default: exit(EX_PROTOCOL); } /* end request code parsing */ } /* end while loop */ /* close dictionary db file */ cdb_free(&diccdb); if (close(dicfd) != 0) { exit(EX_IOERR); } /* normal exit, finally */ exit(EX_OK); } /* end of program */ dbskkd-cdb-3.00/examples.md000066400000000000000000000013641301177212700155710ustar00rootroot00000000000000# Configuration examples ## For daemontools The following is an example run file for daemontools service directory. *Note: dbskkd-cdb must be invoked from a non-privileged dedicated user account.* #!/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 ## For inetd The following is a set of example inetd.conf 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-3.00/makeskkcdb.sh000077500000000000000000000001351301177212700160620ustar00rootroot00000000000000#!/bin/sh ./skktocdbm.sh < /usr/local/share/skk/SKK-JISYO.L | \ cdb -c -t - SKK-JISYO.L.cdb dbskkd-cdb-3.00/skk-server-protocol.md000066400000000000000000000035051301177212700177050ustar00rootroot00000000000000# SKK server-client protocol for dbskkd-cdb (unofficial) By Kenji Rikitake, last updated 13-NOV-2016 ## Notes * This document is for dbskkd-cdb only * This document does *not* describe the sub-protocols for the server completion,which is unsupported on dbskkd-cdb ## Notation * `0` is an ASCII letter (0x30) * `LF` is ASCII 0x0a * `space` is ASCII 0x20 * `abc` is a string ## Size limits * Maximum request size: 1024 bytes * Maximum result size: 4096 bytes ## Request codes and actions ### CLIENT_END * Request to server: `0` + `space` + `LF` * Server terminates and disconnects after receiving the request ### 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` * The dictionary keys and candidates are all variable-length strings * The dictionary keys and candidates have the same character encoding * The primary encoding set of SKK is ASCII + euc-jp (note: UTF-8 can also be used in some implementations) ### 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 * Implementation on dbskkd-cdb: returns the 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 * Implementation on dbskkd-cdb: returns dummy string `novalue: ` ## Unexpected shutting down on errors * Server disconnects the link and shuts down when received an unknown request * Implementation on dbskkd-cdb: an internal error will cause shutdown such as that invoked by `exit(1)` dbskkd-cdb-3.00/skktocdbm.sh000077500000000000000000000005711301177212700157500ustar00rootroot00000000000000#!/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 "" } '