diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-01-14 19:50:05 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-01-14 19:50:05 +0800 |
commit | a298d6c46128c1b594e39578024933a696de741f (patch) | |
tree | e07278a6e7ddeefa6f308cf83b0085c45e3e42f5 /mbbsd | |
parent | d9e73c38f6bdb4e85ba58ccb2382f15eb9186335 (diff) | |
download | pttbbs-a298d6c46128c1b594e39578024933a696de741f.tar pttbbs-a298d6c46128c1b594e39578024933a696de741f.tar.gz pttbbs-a298d6c46128c1b594e39578024933a696de741f.tar.bz2 pttbbs-a298d6c46128c1b594e39578024933a696de741f.tar.lz pttbbs-a298d6c46128c1b594e39578024933a696de741f.tar.xz pttbbs-a298d6c46128c1b594e39578024933a696de741f.tar.zst pttbbs-a298d6c46128c1b594e39578024933a696de741f.zip |
- bbs: add title for AID display
- xyz: prevent mmap crash for note_ans
- pfterm/screen: add getyx_ansi
- fav: add ASKBOARD to new account default favs
- record: add setaidfile()
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3834 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/bbs.c | 24 | ||||
-rw-r--r-- | mbbsd/fav.c | 5 | ||||
-rw-r--r-- | mbbsd/pfterm.c | 6 | ||||
-rw-r--r-- | mbbsd/record.c | 36 | ||||
-rw-r--r-- | mbbsd/screen.c | 26 | ||||
-rw-r--r-- | mbbsd/xyz.c | 1 |
6 files changed, 90 insertions, 8 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 87b6f140..5ad31a9f 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1568,7 +1568,9 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) // you should disable pre-unlinking unlink(genbuf); Rename(fpath, genbuf); + fhdr->modified = dasht(genbuf); + strlcpy(fhdr->title, save_title, sizeof(fhdr->title)); if (fhdr->modified > 0) { @@ -3204,40 +3206,46 @@ view_postinfo(int ent, const fileheader_t * fhdr, const char *direct, int crs_ln outc(' '); outs(ANSI_CLRTOEND); move(area_l, 0); - prints(" ┌───────────────────────────────────┐\n"); + prints("┌─────────────────────────────────────┐\n"); aidu = fn2aidu((char *)fhdr->filename); if(aidu > 0) { char aidc[10]; + int y, x; aidu2aidc(aidc, aidu); - prints(" │ 此篇文章的" AID_DISPLAYNAME "為: " - ANSI_COLOR(1) "#%s" ANSI_RESET " (%s) [%s]\n", + prints("│ " AID_DISPLAYNAME ": " + ANSI_COLOR(1) "#%s" ANSI_RESET " (%s) [%s] ", aidc, currboard && currboard[0] ? currboard : "未知", MYHOSTNAME); + getyx_ansi(&y, &x); + x = 75 - x; + if (x > 1) + prints("%.*s ", x, fhdr->title); + outs("\n"); } else { - prints(" │\n"); + prints("│\n"); } if(fhdr->filemode & FILE_ANONYMOUS) /* When the file is anonymous posted, fhdr->multi.anon_uid is author. * see do_general() */ - prints(" │ 匿名管理編號: %d (同一人號碼會一樣)", + prints("│ 匿名管理編號: %d (同一人號碼會一樣)", fhdr->multi.anon_uid + (int)currutmp->pid); else { int m = query_file_money(fhdr); if(m < 0) - prints(" │ 特殊文章,無價格記錄。"); + prints("│ 特殊文章,無價格記錄"); else - prints(" │ 這一篇文章值 %d 銀", m); + prints("│ 這一篇文章值 %d 銀", m); } prints("\n"); - prints(" └───────────────────────────────────┘\n"); + prints("└─────────────────────────────────────┘\n"); /* 印對話框的右邊界 */ { diff --git a/mbbsd/fav.c b/mbbsd/fav.c index fae372df..5e851a54 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -1222,6 +1222,11 @@ void reginit_fav(void) if (bid > 0) fav_add_board(bid); #endif +#ifdef GLOBAL_ASKBOARD + bid = getbnum(GLOBAL_ASKBOARD); + if (bid > 0) fav_add_board(bid); +#endif + fav_save(); } diff --git a/mbbsd/pfterm.c b/mbbsd/pfterm.c index 08dec655..2d405311 100644 --- a/mbbsd/pfterm.c +++ b/mbbsd/pfterm.c @@ -2289,6 +2289,12 @@ move_ansi(int y, int x) } void +getyx_ansi(int *y, int *x) +{ + getyx(y, x); +} + +void region_scroll_up(int top, int bottom) { int i; diff --git a/mbbsd/record.c b/mbbsd/record.c index 37d15870..17811fb8 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -626,3 +626,39 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char * return 0; } + +void +setaidfile(char *buf, const char *bn, aidu_t aidu) +{ + // try to load by AID + int bid = 0; + int n = 0, fd = 0; + char bfpath[PATHLEN] = ""; + boardheader_t *bh = NULL; + fileheader_t fh; + + buf[0] = 0; + bid = getbnum(bn); + + if (bid <= 0) return; + assert(0<=bid-1 && bid-1<MAX_BOARD); + bh = getbcache(bid); + if (!HasBoardPerm(bh)) return; + + setbfile(bfpath, bh->brdname, FN_DIR); + n = search_aidu(bfpath, aidu); + + if (n < 0) return; + fd = open(bfpath, O_RDONLY); + if (fd < 0) return; + + lseek(fd, n*sizeof(fileheader_t), SEEK_SET); + memset(&fh, 0, sizeof(fh)); + if (read(fd, &fh, sizeof(fh)) > 0) + { + setbfile(buf, bh->brdname, fh.filename); + if (!dashf(buf)) + buf[0] = 0; + } + close(fd); +} diff --git a/mbbsd/screen.c b/mbbsd/screen.c index 25ec5c22..76a4f34f 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -96,6 +96,32 @@ getyx(int *y, int *x) *x = cur_col; } +void +getyx_ansi(int *py, int *px) +{ + // take ANSI length in consideration + register screenline_t *slp; + int y = cur_ln, x = cur_col; + char c = 0; + + if (y < 0) y = 0; + if (y >= t_lines) y = t_lines -1; + if (x < 0) x = 0; + if (x >= ANSILINELEN) x = ANSILINELEN -1; + + *py = y; *px = x; + + if (y >= scr_lns || x < 1) + return; + + slp = &big_picture[y]; + if (slp->len < 1) + return; + c = slp->data[x]; + *px += (strlen((char*)slp->data) - strlen_noansi((char*)slp->data)); + slp->data[x] = c; +} + static inline screenline_t* GetCurrentLine(){ register int i = cur_ln + roll; diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c index f33d32fe..6de0f0a5 100644 --- a/mbbsd/xyz.c +++ b/mbbsd/xyz.c @@ -207,6 +207,7 @@ note(void) if ((foo = fopen(".note", "a")) == NULL) return 0; + unlink(fn_note_ans); // remove first to prevent mmap(pmore) crash if ((fp = fopen(fn_note_ans, "w")) == NULL) { fclose(fp); return 0; |