summaryrefslogtreecommitdiffstats
path: root/mbbsd/indict.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
commit1603deaec5d0a94c9a8201b0ba286e8e492a3602 (patch)
treee6405cfd39f8ac166ab7d00752ed6cfa3ac0a928 /mbbsd/indict.c
parent10bda3e57cad194ac33ccdcd01aee2d935f1544a (diff)
downloadpttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.gz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.bz2
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.lz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.xz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.zst
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.zip
indent
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/indict.c')
-rw-r--r--mbbsd/indict.c150
1 files changed, 79 insertions, 71 deletions
diff --git a/mbbsd/indict.c b/mbbsd/indict.c
index ca44033a..5a575211 100644
--- a/mbbsd/indict.c
+++ b/mbbsd/indict.c
@@ -1,30 +1,31 @@
-/* $Id: indict.c,v 1.4 2002/07/02 13:01:43 in2 Exp $ */
+/* $Id: indict.c,v 1.5 2002/07/05 17:10:27 in2 Exp $ */
#include "bbs.h"
#define REFER "etc/dicts"
-static void addword(char word[])
+static void
+addword(char word[])
{
- char buf[150],temp[150],a[3];
- FILE *fp = fopen(database,"r+");
+ char buf[150], temp[150], a[3];
+ FILE *fp = fopen(database, "r+");
- if( fp == NULL ){
+ if (fp == NULL) {
vmsg("database error");
- return ;
+ return;
}
- fgets(buf,130,fp);
- fseek(fp,0,2);
- if(HAVE_PERM(PERM_LOGINOK)) {
+ fgets(buf, 130, fp);
+ fseek(fp, 0, 2);
+ if (HAVE_PERM(PERM_LOGINOK)) {
clear();
- move(4,0);
+ move(4, 0);
outs(" \033[31m警告\033[m:若蓄意填寫假資料將\033[36m砍id\033[m處份\n");
sprintf(temp, "\n輸入範利\n:\033[33m%s\033[m", buf);
outs(temp);
outs("\n請依上列範例輸入一行資料(直接enter放棄)\n");
getdata(10, 0, ":", buf, 65, DOECHO);
- if(buf[0]) {
+ if (buf[0]) {
getdata(13, 0, "確定新增?(Y/n)", a, sizeof(a), LCECHO);
- if(a[0] != 'n')
+ if (a[0] != 'n')
fprintf(fp, "%-65s[%s]\n", buf, cuser.userid);
}
}
@@ -32,29 +33,31 @@ static void addword(char word[])
clear();
}
-static int choose_dict(void) {
- int c;
- FILE *fp;
- char buf[10][21], data[10][21], cho[130];
+static int
+choose_dict(void)
+{
+ int c;
+ FILE *fp;
+ char buf[10][21], data[10][21], cho[130];
move(12, 0);
clrtobot();
outs(" "
"● \033[45;33m字典唷 ◇ 要查哪一本?\033[m ●");
- if((fp = fopen(REFER, "r"))) {
- for(c = 0; fscanf(fp, "%s %s", buf[c], data[c]) != EOF; c++ ) {
- sprintf(cho,"\n "
- "(\033[36m%d\033[m) %-20s大字典",c+1,buf[c]);
- outs(cho);
+ if ((fp = fopen(REFER, "r"))) {
+ for (c = 0; fscanf(fp, "%s %s", buf[c], data[c]) != EOF; c++) {
+ sprintf(cho, "\n "
+ "(\033[36m%d\033[m) %-20s大字典", c + 1, buf[c]);
+ outs(cho);
}
-
+
getdata(22, 14, " ★ 請選擇,[Enter]離開:", cho, 3, LCECHO);
cho[0] -= '1';
- if(cho[1])
+ if (cho[1])
cho[0] = (cho[0] + 1) * 10 + (cho[1] - '1');
-
- if(cho[0] >= 0 && cho[0] < c) {
+
+ if (cho[0] >= 0 && cho[0] < c) {
strcpy(dict, buf[(int)cho[0]]);
strcpy(database, data[(int)cho[0]]);
return 1;
@@ -64,33 +67,37 @@ static int choose_dict(void) {
return 0;
}
-static char *lower(char str[]) {
- int c;
- static char temp[200];
+static char *
+lower(char str[])
+{
+ int c;
+ static char temp[200];
- strcpy(temp,str);
- for(c = 0; temp[c] !=0; c++)
- if(temp[c] >= 'A' && temp[c] <= 'Z')
+ strcpy(temp, str);
+ for (c = 0; temp[c] != 0; c++)
+ if (temp[c] >= 'A' && temp[c] <= 'Z')
temp[c] += 'a' - 'A';
return temp;
}
-int use_dict() {
- FILE *fp;
- char lang[150], word[80] = "";
- char j, f, buf[120], sys[] = "|\033[31me\033[m:編籍字典";
- int i = 0;
-
+int
+use_dict()
+{
+ FILE *fp;
+ char lang[150], word[80] = "";
+ char j, f, buf[120], sys[] = "|\033[31me\033[m:編籍字典";
+ int i = 0;
+
setutmpmode(DICT);
- if(!HAS_PERM(PERM_SYSOP))
- sys[0]=0;
-
+ if (!HAS_PERM(PERM_SYSOP))
+ sys[0] = 0;
+
clear();
-
- sprintf(buf,"\033[45m ●\033[1;44;33m"
+
+ sprintf(buf, "\033[45m ●\033[1;44;33m"
" %-14s\033[3;45m ● ", dict);
- strcpy(&buf[100],"\033[m\n");
- for(;;) {
+ strcpy(&buf[100], "\033[m\n");
+ for (;;) {
move(0, 0);
sprintf(lang, " 請輸入關鍵字串(%s) 或指令(h,t,a)\n", dict);
outs(lang);
@@ -99,27 +106,27 @@ int use_dict() {
outs(lang);
getdata(2, 0, ":", word, 18, DOECHO);
outs("資料搜尋中請稍候....");
- strcpy(word,lower(word));
- if(word[0] == 0)
+ strcpy(word, lower(word));
+ if (word[0] == 0)
return 0;
clear();
move(4, 0);
outs(buf);
- if(strlen(word) == 1) {
- if(word[0] == 'a') {
+ if (strlen(word) == 1) {
+ if (word[0] == 'a') {
clear();
- move(4,0);
+ move(4, 0);
outs(buf);
addword(word);
continue;
- } else if(word[0] == 't')
+ } else if (word[0] == 't')
word[0] = 0;
- else if(word[0] == 'h') {
- more("etc/dict.hlp",YEA);
+ else if (word[0] == 'h') {
+ more("etc/dict.hlp", YEA);
clear();
continue;
- } else if(word[0]=='e') {
- vedit(database,NA, NULL);
+ } else if (word[0] == 'e') {
+ vedit(database, NA, NULL);
clear();
continue;
} else {
@@ -127,43 +134,42 @@ int use_dict() {
continue;
}
}
-
- if((fp = fopen(database,"r"))) {
+ if ((fp = fopen(database, "r"))) {
i = 0;
- while(fgets(lang,150,fp) != NULL) {
- if(lang[65] == '[') {
+ while (fgets(lang, 150, fp) != NULL) {
+ if (lang[65] == '[') {
lang[65] = 0;
f = 1;
} else
f = 0;
- if(strstr(lower(lang),word)) {
- if(f == 1)
+ if (strstr(lower(lang), word)) {
+ if (f == 1)
lang[65] = '[';
outs(lang);
i++;
- if(!((i+1)%17)) {
+ if (!((i + 1) % 17)) {
move(23, 0);
outs("\033[45m "
- "任意鍵繼續 Q:離開 "
+ "任意鍵繼續 Q:離開 "
"\033[m ");
j = igetch();
- if(j == 'q')
+ if (j == 'q')
break;
- else {
+ else {
clear();
- move(4,0);
+ move(4, 0);
outs(buf);
- }
+ }
}
}
}
}
fclose(fp);
- if(i == 0) {
+ if (i == 0) {
getdata(5, 0, "沒這個資料耶,新增嗎?(y/N)", lang, 3, LCECHO);
- if(lang[0] == 'y') {
+ if (lang[0] == 'y') {
clear();
- move(4,0);
+ move(4, 0);
outs(buf);
addword(word);
}
@@ -171,8 +177,10 @@ int use_dict() {
}
}
-int x_dict() {
- if(choose_dict())
+int
+x_dict()
+{
+ if (choose_dict())
use_dict();
return 0;
}