diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-13 03:35:18 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-13 03:35:18 +0800 |
commit | 4e1ad2af155038106cd14a7f5deeee5771b3a531 (patch) | |
tree | e813b8f55e370ac55aba06c310c648f7e3531a4e | |
parent | 2ec15646e35a5a49bea7eff28963c906afc5fc16 (diff) | |
download | pttbbs-4e1ad2af155038106cd14a7f5deeee5771b3a531.tar pttbbs-4e1ad2af155038106cd14a7f5deeee5771b3a531.tar.gz pttbbs-4e1ad2af155038106cd14a7f5deeee5771b3a531.tar.bz2 pttbbs-4e1ad2af155038106cd14a7f5deeee5771b3a531.tar.lz pttbbs-4e1ad2af155038106cd14a7f5deeee5771b3a531.tar.xz pttbbs-4e1ad2af155038106cd14a7f5deeee5771b3a531.tar.zst pttbbs-4e1ad2af155038106cd14a7f5deeee5771b3a531.zip |
* fix bug: incorrect user's tmp buf filename.
* don't test upper case if getdata with LCECHO flag
* add some comment
* some small code revise
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4585 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/proto.h | 3 | ||||
-rw-r--r-- | include/pttstruct.h | 6 | ||||
-rw-r--r-- | mbbsd/angel.c | 6 | ||||
-rw-r--r-- | mbbsd/bbs.c | 9 | ||||
-rw-r--r-- | mbbsd/card.c | 6 | ||||
-rw-r--r-- | mbbsd/chicken.c | 2 | ||||
-rw-r--r-- | mbbsd/edit.c | 33 | ||||
-rw-r--r-- | mbbsd/mail.c | 2 | ||||
-rw-r--r-- | mbbsd/menu.c | 2 | ||||
-rw-r--r-- | mbbsd/passwd.c | 2 | ||||
-rw-r--r-- | mbbsd/read.c | 13 | ||||
-rw-r--r-- | mbbsd/register.c | 4 | ||||
-rw-r--r-- | mbbsd/talk.c | 7 | ||||
-rw-r--r-- | mbbsd/var.c | 7 | ||||
-rw-r--r-- | mbbsd/vote.c | 4 |
15 files changed, 50 insertions, 56 deletions
diff --git a/include/proto.h b/include/proto.h index bc4d8353..617b5827 100644 --- a/include/proto.h +++ b/include/proto.h @@ -183,7 +183,7 @@ void write_header(FILE *fp, const char *mytitle); void addsignature(FILE *fp, int ifuseanony); void auto_backup(void); void restore_backup(void); -char *ask_tmpbuf(int y); +const char *ask_tmpbuf(int y); /* emaildb */ #ifdef USE_EMAILDB @@ -343,7 +343,6 @@ void del_distinct(const char *fname, const char *line, int casesensitive); void add_distinct(const char *fname, const char *line); void u_exit(const char *mode); void talk_request(int sig); -int reply_connection_request(const userinfo_t *uip); int establish_talk_connection(const userinfo_t *uip); void my_talk(userinfo_t * uin, int fri_stat, char defact); int query_file_money(const fileheader_t *pfh); diff --git a/include/pttstruct.h b/include/pttstruct.h index f560378c..c7a9d57e 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -641,12 +641,6 @@ typedef struct MailQueue { enum {MQ_TEXT, MQ_UUENCODE, MQ_JUSTIFY}; -typedef struct -{ - time4_t chrono; - int recno; -} TagItem; - /* * signature information */ diff --git a/mbbsd/angel.c b/mbbsd/angel.c index e2eef9ec..240e51a2 100644 --- a/mbbsd/angel.c +++ b/mbbsd/angel.c @@ -134,7 +134,7 @@ t_changeangel(){ getdata(b_lines - 1, 0, "更換小天使後就無法換回了喔! 是否要更換小天使? [y/N]", buf, 3, LCECHO); - if (buf[0] == 'y' || buf[0] == 'Y') { + if (buf[0] == 'y') { char buf[100]; snprintf(buf, sizeof(buf), "%s 小主人 %s 換掉 %s 小天使\n", Cdatelite(&now), cuser.userid, cuser.myangel); @@ -195,8 +195,8 @@ t_angelmsg(){ ++i); getdata(b_lines - 2, 0, "(S)儲存 (E)重新來過 (Q)取消?[S]", buf, 4, LCECHO); - } while (buf[0] == 'E' || buf[0] == 'e'); - if (buf[0] == 'Q' || buf[0] == 'q') + } while (buf[0] == 'e'); + if (buf[0] == 'q') return 0; setuserfile(buf, "angelmsg"); if (msg[0][0] == 0) diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 338ac7c2..8099e60d 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -307,11 +307,12 @@ set_board(void) } } +// post 文章不算錢的板 int IsFreeBoardName(const char *brdname) { - if (strcmp(currboard, BN_TEST) == 0) + if (strcmp(brdname, BN_TEST) == 0) return 1; - if (strcmp(currboard, BN_ALLPOST) == 0) + if (strcmp(brdname, BN_ALLPOST) == 0) return 1; return 0; } @@ -3602,9 +3603,9 @@ tar_addqueue(void) } #endif getdata(6, 0, "要備份看板內容嗎(Y/N)?[Y]", ans, sizeof(ans), LCECHO); - bakboard = (ans[0] == 'n' || ans[0] == 'N') ? 0 : 1; + bakboard = (ans[0] == 'n') ? 0 : 1; getdata(7, 0, "要備份精華區內容嗎(Y/N)?[N]", ans, sizeof(ans), LCECHO); - bakman = (ans[0] == 'y' || ans[0] == 'Y') ? 1 : 0; + bakman = (ans[0] == 'y') ? 1 : 0; if (!bakboard && !bakman) { move(8, 0); outs("可是我們只能備份看板或精華區的耶 ^^\"\"\""); diff --git a/mbbsd/card.c b/mbbsd/card.c index c3b33d08..5735c4c6 100644 --- a/mbbsd/card.c +++ b/mbbsd/card.c @@ -477,7 +477,7 @@ card_double_ask(void) if (card_get_money() < JACK) return 0; getdata(20, 0, buf, buf2, sizeof(buf2), LCECHO); - if (buf2[0] == 'y' || buf2[0] == 'Y') + if (buf2[0] == 'y') return 1; return 0; } @@ -497,9 +497,9 @@ card_ask(void) if (buf2[0] == ' ') buf2[0] = buf2[1]; - if (buf2[0] == 'y' || buf2[0] == 'Y') + if (buf2[0] == 'y') return 1; - if (buf2[0] == 'q' || buf2[0] == 'Q') + if (buf2[0] == 'q') return -1; return 0; } diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c index 12921166..32288158 100644 --- a/mbbsd/chicken.c +++ b/mbbsd/chicken.c @@ -890,7 +890,7 @@ recover_chicken(chicken_t * thechicken) outmsg(buf); bell(); getdata(21, 0, " 選擇 (N:坑人嘛/y:請幫幫我): ", buf, 3, LCECHO); - if (buf[0] == 'y' || buf[0] == 'Y') { + if (buf[0] == 'y') { reload_money(); if (cuser.money < price) { outmsg(ANSI_COLOR(33;44) "★靈界守衛" ANSI_COLOR(37;45) " 什麼 錢沒帶夠 " diff --git a/mbbsd/edit.c b/mbbsd/edit.c index 75600d81..50facfb1 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -1084,17 +1084,18 @@ load_file(FILE * fp, off_t offSig) } /* 暫存檔 */ -char * +const char * ask_tmpbuf(int y) { - static char fp_buf[10] = "buf.0"; - static char msg[] = "請選擇暫存檔 (0-9)[0]: "; + static char fp_buf[] = "buf.0"; + char msg[] = "請選擇暫存檔 (0-9)[0]: "; + char choice[2]; msg[19] = fp_buf[4]; do { - if (!getdata(y, 0, msg, fp_buf + 4, 4, DOECHO)) - fp_buf[4] = msg[19]; - } while (fp_buf[4] < '0' || fp_buf[4] > '9'); + getdata(y, 0, msg, choice, sizeof(choice), DOECHO); + } while (choice[0] < '0' || choice[0] > '9'); + fp_buf[4] = choice[0]; return fp_buf; } @@ -1104,7 +1105,7 @@ read_tmpbuf(int n) FILE *fp; char fp_tmpbuf[80]; char tmpfname[] = "buf.0"; - char *tmpf; + const char *tmpf; char ans[4] = "y"; if (curr_buf->totaln >= EDIT_LINE_LIMIT) @@ -2009,26 +2010,28 @@ block_prompt(void) { char fp_tmpbuf[80]; char tmpfname[] = "buf.0"; - char mode[2]; + char mode[2] = "w"; + char choice[2]; move(b_lines - 1, 0); clrtoeol(); - if (!getdata(b_lines - 1, 0, "把區塊移至暫存檔 (0:Cut, 5:Copy, 6-9, q: Cancel)[0] ", tmpfname + 4, 4, LCECHO)) - tmpfname[4] = '0'; + if (!getdata(b_lines - 1, 0, "把區塊移至暫存檔 (0:Cut, 5:Copy, 6-9, q: Cancel)[0] ", choice, sizeof(choice), LCECHO)) + choice[0] = '0'; - if (tmpfname[4] < '0' || tmpfname[4] > '9') + if (choice[0] < '0' || choice[0] > '9') goto cancel_block; - if (tmpfname[4] == '0') { + if (choice[0] == '0') { block_cut(); return; } - else if (tmpfname[4] == '5') { + else if (choice[0] == '5') { block_copy(); return; } + tmpfname[4] = choice[0]; setuserfile(fp_tmpbuf, tmpfname); if (dashf(fp_tmpbuf)) { more(fp_tmpbuf, NA); @@ -3131,7 +3134,7 @@ insert_ansi_code(void) int ch = curr_buf->insert_mode; curr_buf->insert_mode = curr_buf->redraw_everything = YEA; if (!curr_buf->ansimode) - insert_string(reset_color); + insert_string(ANSI_RESET); else { char ans[4]; move(b_lines - 2, 55); @@ -3169,7 +3172,7 @@ insert_ansi_code(void) strcat(color, "m"); insert_string(color); } else - insert_string(reset_color); + insert_string(ANSI_RESET); } curr_buf->insert_mode = ch; } diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 9cf2b13d..f899b673 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1726,7 +1726,7 @@ mail_waterball(int ent GCC_UNUSED, fileheader_t * fhdr, const char *direct GCC_U "模式 0: 精簡模式, 將不含顏色控制碼, 方便以純文字編輯器整理收藏\n" "模式 1: 華麗模式, 包含顏色控制碼等, 方便在 bbs上直接編輯收藏\n"); getdata(b_lines - 1, 0, "使用模式(0/1/Q)? [1]", fname, 3, LCECHO); - if (fname[0] == 'Q' || fname[0] == 'q') { + if (fname[0] == 'q') { outmsg("取消處理"); return FULLUPDATE; } diff --git a/mbbsd/menu.c b/mbbsd/menu.c index a6421bcb..778f10d0 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -276,7 +276,7 @@ movie(int cmdmode) #else out_lines(SHM->notes[i], 11, 0); /* 只印11行就好 */ #endif - outs(reset_color); + outs(ANSI_RESET); } typedef struct { diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c index 0c44d894..1b55952a 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -5,6 +5,8 @@ #error sorry, mbbsd/passwd.c does not support utility mode anymore. please use libcmbbs instead. #endif +static uint32_t latest_numposts; + void passwd_force_update(int flag) { diff --git a/mbbsd/read.c b/mbbsd/read.c index 12c334e3..cdb94944 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -10,6 +10,12 @@ static int last_line; // PTT: last_line 游標可指的最後一個 /* ----------------------------------------------------- */ /* Tag List 標籤 */ /* ----------------------------------------------------- */ +typedef struct +{ + time4_t chrono; + int recno; +} TagItem; + static TagItem *TagList = NULL; /* ascending list */ /** @@ -118,8 +124,6 @@ AskTag(const char *msg) #include <sys/mman.h> -#define BATCH_SIZE 65536 - static char * f_map(const char *fpath, int *fsize) { @@ -976,9 +980,6 @@ i_read_key(const onekey_t * rcmdlist, keeploc_t * locmem, int id; userec_t muser; - strlcpy(currauthor, - headers[locmem->crs_ln - locmem->top_ln].owner, - sizeof(currauthor)); vs_hdr("使用者設定"); move(1, 0); if ((id = getuser(headers[locmem->crs_ln - locmem->top_ln].owner, &muser))) { @@ -1136,7 +1137,7 @@ i_read_key(const onekey_t * rcmdlist, keeploc_t * locmem, // XXX never return -1! static int -get_records_and_bottom(char *direct, fileheader_t* headers, +get_records_and_bottom(const char *direct, fileheader_t* headers, int recbase, int headers_size, int last_line, int bottom_line) { // n: 置底除外的可顯示數目 diff --git a/mbbsd/register.c b/mbbsd/register.c index eaa85fb2..df6fa4eb 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -1185,7 +1185,7 @@ toregister(char *email) char yn[3]; getdata(16, 0, "請再次確認您輸入的手機號碼正確嘛? [y/N]", yn, sizeof(yn), LCECHO); - if (yn[0] == 'Y' || yn[0] == 'y') + if (yn[0] == 'y') break; } else { move(15, 0); clrtobot(); @@ -1221,7 +1221,7 @@ toregister(char *email) getdata(16, 0, "請再次確認您輸入的 E-Mail 位置正確嘛? [y/N]", yn, sizeof(yn), LCECHO); clrtobot(); - if (yn[0] == 'Y' || yn[0] == 'y') + if (yn[0] == 'y') break; #ifdef USE_EMAILDB } diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 130ed593..28873ce5 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1628,7 +1628,6 @@ my_talk(userinfo_t * uin, int fri_stat, char defact) genbuf[0] = defact; ch = uin->mode; - strlcpy(currauthor, uin->userid, sizeof(currauthor)); if (ch == EDITING || ch == TALK || ch == CHATING || ch == PAGE || ch == MAILALL || ch == MONITOR || ch == M_FIVE || ch == CHC || @@ -2751,7 +2750,7 @@ userlist(void) msgque_t msg; getdata(1, 0, "再次確定站長廣播? [N]", ans, sizeof(ans), LCECHO); - if( ans[0] != 'y' && ans[0] != 'Y' ){ + if( ans[0] != 'y'){ vmsg("abort"); break; } @@ -2823,7 +2822,6 @@ userlist(void) if (HasUserPerm(PERM_ACCOUNTS|PERM_SYSOP)) { int id; userec_t muser; - strlcpy(currauthor, uentp->userid, sizeof(currauthor)); vs_hdr("使用者設定"); move(1, 0); if ((id = getuser(uentp->userid, &muser)) > 0) { @@ -2934,7 +2932,6 @@ userlist(void) break; case 'q': - strlcpy(currauthor, uentp->userid, sizeof(currauthor)); my_query(uentp->userid); setutmpmode(LUSERS); redrawall = redraw = 1; @@ -3203,7 +3200,7 @@ t_talk(void) return 0; } -int +static int reply_connection_request(const userinfo_t *uip) { char buf[4], genbuf[200]; diff --git a/mbbsd/var.c b/mbbsd/var.c index 7a19f051..a9f52c73 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -92,10 +92,8 @@ int currbid; char quote_file[80] = "\0"; char quote_user[80] = "\0"; char currtitle[TTLEN + 1] = "\0"; -char currauthor[IDLEN + 2] = "\0"; const char *currboard = "\0"; char currBM[IDLEN * 3 + 10]; -const char reset_color[4] = ANSI_RESET; char margs[64] = "\0"; /* main argv list */ pid_t currpid; /* current process ID */ time4_t login_start_time; @@ -104,7 +102,6 @@ userec_t cuser; /* current user structure */ crosspost_t postrecord; /* anti cross post */ unsigned int currbrdattr; unsigned int currstat; -uint32_t latest_numposts; /* global string variables */ /* filename */ @@ -313,9 +310,9 @@ char * const ModeTypeTable[] = { }; /* term.c */ -int b_lines = 23; // bottom line of screen +int b_lines = 23; // bottom line of screen (= t_lines - 1) int t_lines = 24; // term lines -int p_lines = 20; +int p_lines = 20; // 扣掉 header(3), footer(1), 畫面上可以顯示資料的行數 int t_columns = 80; /* refer to ansi.h for *len */ diff --git a/mbbsd/vote.c b/mbbsd/vote.c index d08107d3..74180714 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -958,8 +958,8 @@ user_vote_one(vote_buffer_t *vbuf, const char *bname, int ind) DOECHO); i++); getdata(b_lines - 2, 0, "(S)儲存 (E)重新來過 " "(Q)取消?[S]", buf, 3, LCECHO); - } while (buf[0] == 'E' || buf[0] == 'e'); - if (buf[0] == 'Q' || buf[0] == 'q') + } while (buf[0] == 'e'); + if (buf[0] == 'q') break; setbfile(b_comments, bname, vbuf->comments); if (mycomments[0][0]) |