summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-12-17 09:57:04 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-12-17 09:57:04 +0800
commite12b8fb5f87d5bede1af88074cd6c85be93b121c (patch)
tree82dc7124e08ccd199c0b22f725de1dd4e4eec5e5 /mbbsd
parentd8c7f000c0d4db5ede07dbe23acc860c23fc76b8 (diff)
downloadpttbbs-e12b8fb5f87d5bede1af88074cd6c85be93b121c.tar
pttbbs-e12b8fb5f87d5bede1af88074cd6c85be93b121c.tar.gz
pttbbs-e12b8fb5f87d5bede1af88074cd6c85be93b121c.tar.bz2
pttbbs-e12b8fb5f87d5bede1af88074cd6c85be93b121c.tar.lz
pttbbs-e12b8fb5f87d5bede1af88074cd6c85be93b121c.tar.xz
pttbbs-e12b8fb5f87d5bede1af88074cd6c85be93b121c.tar.zst
pttbbs-e12b8fb5f87d5bede1af88074cd6c85be93b121c.zip
- optimize big I formatting
- disable mail pre-check permission until someone fix it git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3697 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/bbs.c47
-rw-r--r--mbbsd/board.c179
-rw-r--r--mbbsd/mail.c6
3 files changed, 89 insertions, 143 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 0744ad7c..e58e3909 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -3,24 +3,9 @@
#ifdef EDITPOST_SMARTMERGE
-#ifdef SMARTMERGE_MD5
-
-// To enable SmartMerge/MD5,
-// please get MD5 from XySSL or other systems:
-// http://xyssl.org/code/source/md5/
-#include "md5.h"
-#include "md5.c"
-
-#define SMHASHLEN (16)
-
-#else // !SMARTMERGE_MD5, use FNV64
-
#include "fnv_hash.h"
-
#define SMHASHLEN (64/8)
-#endif // !SMARTMERGE_MD5
-
#endif // EDITPOST_SMARTMERGE
#define WHEREAMI_LEVEL 16
@@ -1308,18 +1293,9 @@ hash_partial_file( char *path, size_t sz, unsigned char output[SMHASHLEN] )
size_t n;
unsigned char buf[1024];
-#ifdef SMARTMERGE_MD5
-
- md5_context ctx;
- md5_starts( &ctx );
-
-#else // !SMARTMERGE_MD5, use FNV64
-
Fnv64_t fnvseed = FNV1_64_INIT;
assert(SMHASHLEN == sizeof(fnvseed));
-#endif // SMARTMERGE_MD5
-
fd = open(path, O_RDONLY);
if (fd < 0)
return 1;
@@ -1328,13 +1304,7 @@ hash_partial_file( char *path, size_t sz, unsigned char output[SMHASHLEN] )
(n = read(fd, buf, sizeof(buf))) > 0 )
{
if (n > sz) n = sz;
-
-#ifdef SMARTMERGE_MD5
- md5_update( &ctx, buf, (int) n );
-#else // !SMARTMERGE_MD5, use FNV64
fnvseed = fnv_64_buf(buf, (int) n, fnvseed);
-#endif //!SMARTMERGE_MD5
-
sz -= n;
}
close(fd);
@@ -1342,12 +1312,7 @@ hash_partial_file( char *path, size_t sz, unsigned char output[SMHASHLEN] )
if (sz > 0) // file is different
return 2;
-#ifdef SMARTMERGE_MD5
- md5_finish( &ctx, output );
-#else // !SMARTMERGE_MD5, use FNV64
memcpy(output, (void*) &fnvseed, sizeof(fnvseed));
-#endif //!SMARTMERGE_MD5
-
return HASHPF_RET_OK;
}
#endif // EDITPOST_SMARTMERGE
@@ -3263,16 +3228,6 @@ b_notes_edit(void)
}
static int
-can_vote_edit(void)
-{
- if (currmode & MODE_BOARD) {
- friend_edit(FRIEND_CANVOTE);
- return FULLUPDATE;
- }
- return 0;
-}
-
-static int
bh_title_edit(void)
{
boardheader_t *bp;
@@ -3637,7 +3592,7 @@ const onekey_t read_comms[] = {
{ 0, NULL }, // 'l'
{ 1, mark_post }, // 'm'
{ 0, NULL }, // 'n'
- { 0, can_vote_edit }, // 'o'
+ { 0, b_moved_to_config }, // 'o'
{ 0, NULL }, // 'p'
{ 0, NULL }, // 'q'
{ 1, read_post }, // 'r'
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 09a4f2a5..74ba0e59 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -178,56 +178,38 @@ HasBoardPerm(boardheader_t *bptr)
}
// board configuration utilities
-static int
-b_visible_edit(void)
-{
- if (currmode & MODE_BOARD) {
- friend_edit(BOARD_VISABLE);
- assert(0<=currbid-1 && currbid-1<MAX_BOARD);
- hbflreload(currbid);
- return FULLUPDATE;
- }
- return 0;
-}
-
-static int
-b_water_edit(void)
-{
- if (currmode & MODE_BOARD) {
- friend_edit(BOARD_WATER);
- return FULLUPDATE;
- }
- return 0;
-}
static int
b_post_note(void)
{
char buf[200], yn[3];
- if (currmode & MODE_BOARD) {
- setbfile(buf, currboard, FN_POST_NOTE);
- if (more(buf, NA) == -1)
- more("etc/" FN_POST_NOTE, NA);
- getdata(b_lines - 2, 0, "是否要用自訂發文注意事項? [y/N]",
- yn, sizeof(yn), LCECHO);
- if (yn[0] == 'y')
- vedit(buf, NA, NULL);
- else
- unlink(buf);
-
- setbfile(buf, currboard, FN_POST_BID);
- if (more(buf, NA) == -1)
- more("etc/" FN_POST_BID, NA);
- getdata(b_lines - 2, 0, "是否要用自訂競標文章注意事項? [y/N]",
- yn, sizeof(yn), LCECHO);
- if (yn[0] == 'y')
- vedit(buf, NA, NULL);
- else
- unlink(buf);
- return FULLUPDATE;
- }
- return 0;
+ // if(!(currmode & MODE_BOARD)) return DONOTHING;
+ stand_title("自訂注意事項");
+
+ setbfile(buf, currboard, FN_POST_NOTE);
+ move(b_lines-2, 0); clrtobot();
+
+ if (more(buf, NA) == -1)
+ more("etc/" FN_POST_NOTE, NA);
+ getdata(b_lines - 2, 0, "是否要用自訂發文注意事項? [y/N]",
+ yn, sizeof(yn), LCECHO);
+ if (yn[0] == 'y')
+ vedit(buf, NA, NULL);
+ else
+ unlink(buf);
+
+ setbfile(buf, currboard, FN_POST_BID);
+ if (more(buf, NA) == -1)
+ more("etc/" FN_POST_BID, NA);
+ getdata(b_lines - 2, 0, "是否要用自訂競標文章注意事項? [y/N]",
+ yn, sizeof(yn), LCECHO);
+ if (yn[0] == 'y')
+ vedit(buf, NA, NULL);
+ else
+ unlink(buf);
+
+ return FULLUPDATE;
}
static int
@@ -237,30 +219,31 @@ b_posttype()
int i, aborted;
char filepath[PATHLEN], genbuf[60], title[5], posttype_f, posttype[33]="";
- if(!(currmode & MODE_BOARD)) return DONOTHING;
+ // if(!(currmode & MODE_BOARD)) return DONOTHING;
assert(0<=currbid-1 && currbid-1<MAX_BOARD);
bp = getbcache(currbid);
+ stand_title("設定文章類別");
move(2,0);
clrtobot();
posttype_f = bp->posttype_f;
for( i = 0 ; i < 8 ; ++i ){
- move(2,0);
+ move(2+i,0);
outs("文章種類: ");
strlcpy(genbuf, bp->posttype + i * 4, 5);
sprintf(title, "%d.", i + 1);
- if( !getdata_buf(2, 11, title, genbuf, 5, DOECHO) )
+ if( !getdata_buf(2+i, 11, title, genbuf, 5, DOECHO) )
break;
sprintf(posttype + i * 4, "%-4.4s", genbuf);
if( posttype_f & (1<<i) ){
- if( getdata(2, 20, "設定範本格式?(Y/n)", genbuf, 3, LCECHO) &&
+ if( getdata(2+i, 20, "設定範本格式?(Y/n)", genbuf, 3, LCECHO) &&
genbuf[0]=='n' ){
posttype_f &= ~(1<<i);
continue;
}
}
- else if ( !getdata(2, 20, "設定範本格式?(y/N)", genbuf, 3, LCECHO) ||
+ else if ( !getdata(2+i, 20, "設定範本格式?(y/N)", genbuf, 3, LCECHO) ||
genbuf[0] != 'y' )
continue;
@@ -291,20 +274,24 @@ b_config(void)
int touched = 0, finished = 0;
bp = getbcache(currbid);
int i = 0, attr = 0, ipostres;
+ char isBM = (currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP);
-#define LNBOARDINFO (18)
-#define LNPOSTRES (10)
+#define LNBOARDINFO (17)
+#define LNPOSTRES (12)
#define COLPOSTRES (50)
- const int ytitle = b_lines -
-#ifndef OLDRECOMMEND
- (LNBOARDINFO+1); // new format
-#else // OLDRECOMMEND
- (LNBOARDINFO); // old (less)
+ int ytitle = b_lines - LNBOARDINFO;
+
+#ifdef OLDRECOMMEND
+ ytitle ++;
#endif // OLDRECOMMEND
grayout_lines(0, ytitle-1, 0);
+ // available hotkeys yet:
+ // a b d j k m p q z
+ // 2 3 4 5 6 7 9 0
+ // better not: l
while(!finished) {
move(ytitle-1, 0); clrtobot();
@@ -322,7 +309,7 @@ b_config(void)
prints(" 中文敘述: %s\n", bp->title);
prints(" 板主名單: %s\n", (bp->BM[0] > ' ')? bp->BM : "(無)");
- outs("\n");
+ outs(" \n"); // at least one character, for move_ansi.
prints( " " ANSI_COLOR(1;36) "h" ANSI_RESET
" - 公開狀態(是否隱形): %s " ANSI_RESET "\n",
@@ -383,7 +370,7 @@ b_config(void)
);
#endif
- prints( " " ANSI_COLOR(1;36) "o" ANSI_RESET
+ prints( " " ANSI_COLOR(1;36) "L" ANSI_RESET
" - 若有轉信則發文時預設 %s " ANSI_RESET "\n",
(bp->brdattr & BRD_LOCALSAVE) ?
"站內存檔(不轉出)" : ANSI_COLOR(1)"站際存檔(轉出)" );
@@ -405,16 +392,9 @@ b_config(void)
(bp->brdattr & BRD_RESTRICTEDPOST) ?
ANSI_COLOR(1)"只有板友才可發文" : "無特別設定" );
- prints("\n " ANSI_COLOR(1;32) "名單編輯與其它:" ANSI_RESET " "
- ANSI_COLOR(1;36) "v" ANSI_RESET ")可見名單 "
- ANSI_COLOR(1;36) "w" ANSI_RESET ")水桶名單 "
- ANSI_COLOR(1;36) "n" ANSI_RESET ")發文注意事項 "
- ANSI_COLOR(1;36) "c" ANSI_RESET ")文章類別 "
- "\n");
-
ipostres = b_lines - LNPOSTRES;
move_ansi(ipostres++, COLPOSTRES-2);
- prints("發文限制");
+ outs(ANSI_COLOR(1;32) "發文限制" ANSI_RESET);
#define POSTRESTRICTION(msg,utag) \
prints(msg, attr ? ANSI_COLOR(1) : "", i, attr ? ANSI_RESET : "")
@@ -461,8 +441,24 @@ b_config(void)
);
}
+ // if (isBM)
+ {
+ ipostres ++;
+ move_ansi(ipostres++, COLPOSTRES-2);
+ outs(ANSI_COLOR(1;32) "名單編輯與其它:" ANSI_RESET);
+ move_ansi(ipostres++, COLPOSTRES);
+ outs(ANSI_COLOR(1;36) "v" ANSI_RESET ")可見名單 "
+ ANSI_COLOR(1;36) "w" ANSI_RESET ")水桶名單 ");
+ move_ansi(ipostres++, COLPOSTRES);
+ outs(ANSI_COLOR(1;36) "o" ANSI_RESET ")投票名單 ");
+ //ANSI_COLOR(1;36) "w" ANSI_RESET ")水桶名單 ");
+ move_ansi(ipostres++, COLPOSTRES);
+ outs(ANSI_COLOR(1;36) "c" ANSI_RESET ")文章類別 "
+ ANSI_COLOR(1;36) "n" ANSI_RESET ")發文注意事項 ");
+ }
+
move(b_lines, 0);
- if (!((currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP)))
+ if (!isBM)
{
vmsg("您對此板無管理權限");
return FULLUPDATE;
@@ -476,7 +472,7 @@ b_config(void)
touched = 1;
break;
#endif
- case 'o':
+ case 'l':
bp->brdattr ^= BRD_LOCALSAVE;
touched = 1;
break;
@@ -580,43 +576,34 @@ b_config(void)
break;
case 'v':
- if (currmode & MODE_BOARD)
- {
- b_visible_edit();
- clear();
- } else {
- vmsg("此項設定需要板主權限");
- }
+ clear();
+ friend_edit(BOARD_VISABLE);
+ assert(0<=currbid-1 && currbid-1<MAX_BOARD);
+ hbflreload(currbid);
+ clear();
break;
+ case 'o':
+ clear();
+ friend_edit(FRIEND_CANVOTE);
+ clear();
+
case 'w':
- if (currmode & MODE_BOARD)
- {
- b_water_edit();
- clear();
- } else {
- vmsg("此項設定需要板主權限");
- }
+ clear();
+ friend_edit(BOARD_WATER);
+ clear();
break;
case 'n':
- if (currmode & MODE_BOARD)
- {
- b_post_note();
- clear();
- } else {
- vmsg("此項設定需要板主權限");
- }
+ clear();
+ b_post_note();
+ clear();
break;
case 'c':
- if (currmode & MODE_BOARD)
- {
- b_posttype();
- clear();
- } else {
- vmsg("此項設定需要板主權限");
- }
+ clear();
+ b_posttype();
+ clear();
break;
case 'y':
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 6c5e5efc..a3f00b99 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -1283,6 +1283,10 @@ mail_cross_post(int ent, fileheader_t * fhdr, const char *direct)
char genbuf[200];
char genbuf2[4];
+#if 0
+ // 除非有人明白為何要先 ChekPostPerm 並修復,
+ // 否則先 disable 這段 code - 目前常造成 crash。
+ //
// XXX (will crash sometimes because currborad is not defined yet)
// 麻煩 in2 來修復這裡: 確認轉錄為何要先 CheckPostPerm
if (!currboard || currboard[0] == 0)
@@ -1295,6 +1299,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, const char *direct)
vmsg("對不起,您目前無法轉錄文章!");
return FULLUPDATE;
}
+#endif
move(2, 0);
clrtoeol();
@@ -1325,7 +1330,6 @@ mail_cross_post(int ent, fileheader_t * fhdr, const char *direct)
assert(0<=ent-1 && ent-1<MAX_BOARD);
if (!CheckPostRestriction(ent))
{
- move(5, 10); // why move (5, 10)?
vmsg("你不夠資深喔! (可在看板內按大寫 I 查看限制)");
return FULLUPDATE;
}