作者chwaian.bbs@processor.tfcis.org (無言) 看板: plan
標題字典
時間動力核心 (2004/02/14 Sat 16:43:32) Updated: 2004/03/28
Dr.Eye 已經暫時關閉好一陣子啦
可以暫時拿WindTop的dictd來替代
先裝dictd (非FreeBSD系統者請自行解決)
http://freebsd.sinica.edu.tw/zh-tut/dict.html
然後把下面的程式加到so目錄底下
/*-------------------------------------------------------*/
/* dictd.c ( YZU WindTOPBBS Ver 3.10 ) */
/*-------------------------------------------------------*/
/* author : statue.bbs@bbs.yzu.edu.tw */
/* target : 字典 */
/* create : 01/11/18 */
/* update : 01/11/18 */
/*-------------------------------------------------------*/
#include "bbs.h"
int
main_dictd()
{
char word[73], word2[128];
char tmp[256];
char fname[64];
uschar *str, *ptr, *pend;
while(1)
{
clear();
move(0, 23);
outs("\033[1;37;44m◎ 多用途字典 ◎\033[m");
move(2, 0);
outs("此字典來源為 FreeBSD 的 dict-database。"
"字典必須輸入完整單字或片語。\n");
move(4, 0);
outs("字典代號 字典說明\n");
outs("=============================================================="
"==============\n");
outs("web1913 Chinese to English dictionary\n");
outs("wn Taiwan MOE computer dictionary\n");
outs("gazetteer Network Terminology\n");
outs("jargon pydict data\n");
outs("devils THE DEVIL'S DICTIONARY "
"((C)1911 Released April 15 1993)\n");
outs("easton Easton's 1897 Bible Dictionary\n");
outs("elements Elements database 20001107\n");
outs("gazetteer U.S. Gazetteer (1990)\n");
outs("gcide The Collaborative International Dictionary of "
"English v.0.44\n");
outs("hitchcock Hitchcock's Bible Names Dictionary (late 1800's)\n");
outs("vera Virtual Entity of Relevant Acronyms "
"(Version 1.9, June 2002)\n");
outs("web1913 Webster's Revised Unabridged Dictionary (1913)\n");
outs("wn WordNet (r) 2.0\n");
outs("world02 CIA World Factbook 2002\n");
outs("world95 The CIA World Factbook (1995)\n");
memset(word, 0, sizeof(word));
memset(word2, 0, sizeof(word2));
if (!vget(22, 0, "word: ", word, sizeof(word) - 1, DOECHO))
return 0;
str = word;
ptr = word2;
pend = str + strlen(word);
while (str < pend)
{
if (*str >= 0x81 && *str < 0xFE && *(str + 1) >= 0x40
&& *(str + 1) <= 0xFE && *(str + 1) != 0x7F) /* 中文字 BIG5+ */
{
if (*(str + 1) == 0x5C)
{
*ptr = *str;
*(ptr + 1) = *(str + 1);
*(ptr + 2) = 0x5C;
ptr++;
}
else
{
*ptr = *str;
*(ptr + 1) = *(str + 1);
}
ptr++;
str++;
}
else
{
*ptr = *str;
/* security reason */
if (*ptr == ';' || *ptr == '"' || *ptr == '|' || *ptr == '&')
return 0;
}
str++;
ptr++;
}
sprintf(fname, "tmp/%s.dictd", cuser.userid);
sprintf(tmp, "/usr/home/bbs/bin/cdict5 \"%s\" > %s", word, fname);
system(tmp);
sprintf(tmp, "/usr/local/bin/dict -h localhost \"%s\" >> %s",
word2, fname);
system(tmp);
more(fname, NULL);
sprintf(tmp, "是否把 %s 的查詢結果寄回自己信箱? (y/N) ", word);
if (vans(tmp) == 'y')
{
sprintf(tmp, "[備 忘 錄] %s 的字典查詢結果", word);
mail_self(fname, cuser.userid, tmp, 0);
}
unlink(fname);
}
return 0;
}
/usr/local/etc/dictd.conf 看你裝了哪些dictd-database 要記得對應修改
程式的位置看你是裝在
/usr/local/bin/dict 還是 /usr/local/sbin/dictd
也要記得改一下
然後把main_dictd加到menu就好啦
如果要改裝cdict5為字典 (就是無名跟狂狷用的那個)
先下載底下這兩個檔案
http://ftp.isu.edu.tw/pub/Unix/BBS/PolyU/cdict5-library.tgz
ftp://ftp.tw.freebsd.org/pub/FreeBSD/ports/local-distfiles/ijliao/cdict5.tgz
然後全部解壓縮放到/usr/local/lib/cdict5底下
然後在這目錄執行make
再執行make index (可以看INSTALL的說明)
如果過程中找不到libgdbm.a
請看看是否在/usr/local/lib底下 把這個檔案拷貝到/usr/lib底下即可
如果找不到gdbm.h
可以下載http://www.klid.dk/pub/gnu/gnu-utils/include/gdbm.h
到cdict5目錄下 然後修改相關需要gdbm.h程式碼的部分
( #include <gdbm.h> 改成 #include "gdbm.h")
然後做完上述兩個動作 ( make ; make index)
會產生一個檔案叫做cdict5
可以把此檔拷貝到/home/bbs/bin底下然後再chown改一下權限 即可
接下來的就跟上面幾篇一樣啦
改掉上面 "/usr/local/bin/dict -h localhost \"%s\"
的部分即可
--
╭┼ Origin: Maple-itoc˙動力核心 processor.tfcis.org
┼╯ Author: chwaian 從 61-216-219-252.HINET-IP.hinet.net 發表精華選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻