summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-13 00:36:08 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-13 00:36:08 +0800
commitdb8e4abee4060e1bf59f9feac2557dd1a72aa3c2 (patch)
tree046afa14e4d0244d01f4de832710863f93bd02bf
parent2254eb52d8cb36f32c0151e0f1c3be5e5281274b (diff)
downloadpttbbs-db8e4abee4060e1bf59f9feac2557dd1a72aa3c2.tar
pttbbs-db8e4abee4060e1bf59f9feac2557dd1a72aa3c2.tar.gz
pttbbs-db8e4abee4060e1bf59f9feac2557dd1a72aa3c2.tar.bz2
pttbbs-db8e4abee4060e1bf59f9feac2557dd1a72aa3c2.tar.lz
pttbbs-db8e4abee4060e1bf59f9feac2557dd1a72aa3c2.tar.xz
pttbbs-db8e4abee4060e1bf59f9feac2557dd1a72aa3c2.tar.zst
pttbbs-db8e4abee4060e1bf59f9feac2557dd1a72aa3c2.zip
vedit revise
* move global save_title[] to local * vedit() vedit2() interface change * add veditfile() for editing normal file git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4582 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/common.h1
-rw-r--r--include/proto.h17
-rw-r--r--mbbsd/admin.c8
-rw-r--r--mbbsd/announce.c4
-rw-r--r--mbbsd/bbs.c69
-rw-r--r--mbbsd/board.c6
-rw-r--r--mbbsd/cal.c5
-rw-r--r--mbbsd/calendar.c4
-rw-r--r--mbbsd/edit.c60
-rw-r--r--mbbsd/lovepaper.c5
-rw-r--r--mbbsd/mail.c37
-rw-r--r--mbbsd/more.c4
-rw-r--r--mbbsd/user.c8
-rw-r--r--mbbsd/var.c3
-rw-r--r--mbbsd/vote.c8
15 files changed, 123 insertions, 116 deletions
diff --git a/include/common.h b/include/common.h
index 4991036b..d3fee9b5 100644
--- a/include/common.h
+++ b/include/common.h
@@ -251,6 +251,7 @@
#define EDITFLAG_ALLOWLARGE (0x00000004)
#define EDITFLAG_ALLOWTITLE (0x00000008)
// #define EDITFLAG_ANONYMOUS (0x00000010)
+#define EDIT_ABORTED -1
/* ----------------------------------------------------- */
/* Grayout Levels */
diff --git a/include/proto.h b/include/proto.h
index 66226d9d..2bcd16e1 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -69,7 +69,7 @@ int CheckPostPerm(void);
int CheckPostRestriction(int);
void anticrosspost(void);
int Select(void);
-void do_reply_title(int row, const char *title);
+void do_reply_title(int row, const char *title, char result[STRLEN]);
void outgo_post(const fileheader_t *fh, const char *board, const char *userid, const char *username);
int edit_title(int ent, fileheader_t *fhdr, const char *direct);
int whereami(void);
@@ -176,15 +176,14 @@ int main_dark(int fd,userinfo_t *uin);
int dice_main(void);
/* edit */
-int vedit(const char *fpath, int saveheader, int *islocal);
-int vedit2(const char *fpath, int saveheader, int *islocal, int flags);
-void write_header(FILE *fp, char *mytitle);
+int vedit(const char *fpath, int saveheader, int *islocal, char save_title[STRLEN]);
+int vedit2(const char *fpath, int saveheader, int *islocal, char save_title[STRLEN], int flags);
+int veditfile(const char *fpath);
+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);
-void edit_outs(const char *text);
-void edit_outs_n(const char *text, int n);
/* emaildb */
#ifdef USE_EMAILDB
@@ -315,7 +314,7 @@ int m_read(void);
int doforward(const char *direct, const fileheader_t *fh, int mode);
int mail_reply(int ent, fileheader_t *fhdr, const char *direct);
int bsmtp(const char *fpath, const char *title, const char *rcpt, const char *from);
-void hold_mail(const char *fpath, const char *receiver);
+void hold_mail(const char *fpath, const char *receiver, const char *title);
void m_init(void);
int chkmailbox(void);
int mail_man(void);
@@ -630,8 +629,8 @@ int u_detectDBCSAwareEvilClient();
#define ISDBCSAWARE() (cuser.uflag & DBCSAWARE_FLAG)
/* vote */
-void b_suckinfile(FILE *fp, char *fname);
-void b_suckinfile_invis(FILE * fp, char *fname, const char *boardname);
+void b_suckinfile(FILE *fp, const char *fname);
+void b_suckinfile_invis(FILE * fp, const char *fname, const char *boardname);
int b_results(void);
int b_vote(void);
int b_vote_maintain(void);
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index ad986097..cab1089f 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -853,9 +853,9 @@ x_file(void)
case KEY_ENTER: case KEY_RIGHT:
strlcpy(buf, entries[sel], sizeof(buf));
v = strchr(buf, ' '); *v++ = 0;
- i = vedit(buf, NA, NULL);
+ i = veditfile(buf);
// log file change
- if (i != -1)
+ if (i != EDIT_ABORTED)
{
log_filef("log/etc_edit.log", LOG_CREAT,
"%s %s %s # %s\n", Cdate(&now),
@@ -1124,7 +1124,7 @@ give_money(void)
return 1;
}
} else {
- if (vedit("etc/givemoney.txt", NA, NULL) < 0)
+ if (veditfile("etc/givemoney.txt") < 0)
return 1;
}
@@ -1149,7 +1149,7 @@ give_money(void)
move(2, 0);
vmsg("編紅包袋內容");
- if (vedit("etc/givemoney.why", NA, NULL) < 0) {
+ if (veditfile("etc/givemoney.why") < 0) {
fclose(fp2);
return 1;
}
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 1c63105d..cb16cf0b 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -435,7 +435,7 @@ a_newitem(menu_t * pm, int mode)
edflags |= EDITFLAG_ALLOWLARGE;
}
# endif // BN_BBSMOVIE
- if (vedit2(fpath, 0, NULL, edflags) == -1) {
+ if (vedit2(fpath, 0, NULL, NULL, edflags) == -1) {
unlink(fpath);
pressanykey();
return;
@@ -1211,7 +1211,7 @@ a_menu_rec(const char *maintitle, const char *path,
}
# endif // BN_BBSMOVIE
- if (vedit2(fname, NA, NULL, edflags) != -1) {
+ if (vedit2(fname, NA, NULL, NULL, edflags) != -1) {
char fpath[PATHLEN];
fileheader_t fhdr;
strlcpy(fpath, path, sizeof(fpath));
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 549b46c7..338ac7c2 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -827,23 +827,20 @@ solveEdFlagByBoard(const char *bn, int flags)
}
void
-do_reply_title(int row, const char *title)
+do_reply_title(int row, const char *title, char result[STRLEN])
{
char genbuf[200];
char genbuf2[4];
- char tmp_title[STRLEN];
if (strncasecmp(title, str_reply, 4))
- snprintf(tmp_title, sizeof(tmp_title), "Re: %s", title);
+ snprintf(result, STRLEN, "Re: %s", title);
else
- strlcpy(tmp_title, title, sizeof(tmp_title));
- tmp_title[TTLEN - 1] = '\0';
- snprintf(genbuf, sizeof(genbuf), "採用原標題《%.60s》嗎?[Y] ", tmp_title);
+ strlcpy(result, title, STRLEN);
+ result[TTLEN - 1] = '\0';
+ snprintf(genbuf, sizeof(genbuf), "採用原標題《%.60s》嗎?[Y] ", result);
getdata(row, 0, genbuf, genbuf2, 4, LCECHO);
- if (genbuf2[0] == 'n' || genbuf2[0] == 'N')
- getdata(++row, 0, "標題:", tmp_title, TTLEN, DOECHO);
- // don't getdata() on non-local variable save_title directly, to avoid reentrant crash.
- strlcpy(save_title, tmp_title, sizeof(save_title));
+ if (genbuf2[0] == 'n')
+ getdata(++row, 0, "標題:", result, TTLEN, DOECHO);
}
void
@@ -949,12 +946,17 @@ do_general(int isbid)
bid_t bidinfo;
fileheader_t postfile;
char fpath[PATHLEN], buf[STRLEN];
- int aborted, defanony, ifuseanony, i;
+ int i, j;
+ int defanony, ifuseanony;
+ int money = 0;
char genbuf[PATHLEN], *owner;
char ctype[8][5] = {"問題", "建議", "討論", "心得",
"閒聊", "請益", "公告", "情報"};
boardheader_t *bp;
int islocal, posttype=-1, edflags = 0;
+ char save_title[STRLEN];
+
+ save_title[0] = '\0';
ifuseanony = 0;
assert(0<=currbid-1 && currbid-1<MAX_BOARD);
@@ -1009,7 +1011,7 @@ do_general(int isbid)
clrtobot();
}
if (quote_file[0])
- do_reply_title(20, currtitle);
+ do_reply_title(20, currtitle, save_title);
else {
char tmp_title[STRLEN]="";
if (!isbid) {
@@ -1018,8 +1020,8 @@ do_general(int isbid)
for(i=0; i<8 && bp->posttype[i*4]; i++)
strlcpy(ctype[i],bp->posttype+4*i,5);
if(i==0) i=8;
- for(aborted=0; aborted<i; aborted++)
- prints("%d.%4.4s ", aborted+1, ctype[aborted]);
+ for(j=0; j<i; j++)
+ prints("%d.%4.4s ", j+1, ctype[j]);
sprintf(buf,"(1-%d或不選)",i);
getdata(21, 6+7*i, buf, tmp_title, 3, LCECHO);
posttype = tmp_title[0] - '1';
@@ -1075,8 +1077,8 @@ do_general(int isbid)
};
#endif
- aborted = vedit2(fpath, YEA, &islocal, edflags);
- if (aborted == -1) {
+ money = vedit2(fpath, YEA, &islocal, save_title, edflags);
+ if (money == EDIT_ABORTED) {
unlink(fpath);
pressanykey();
return FULLUPDATE;
@@ -1102,33 +1104,33 @@ do_general(int isbid)
// money verification
#ifdef MAX_POST_MONEY
- if (aborted > MAX_POST_MONEY * 2)
- aborted = MAX_POST_MONEY;
+ if (money > MAX_POST_MONEY * 2)
+ money = MAX_POST_MONEY;
else
#endif
- aborted /= 2;
+ money /= 2;
// drop money & numposts for free boards
// including: special boards (e.g. TEST, ALLPOST), bad boards, no BM boards
if (IsFreeBoardName(currboard) || (currbrdattr&BRD_BAD) || bp->BM[0] < ' ')
{
- aborted = 0;
+ money = 0;
}
// also drop for anonymos/bid posts
if(ifuseanony) {
- aborted = 0;
+ money = 0;
postfile.filemode |= FILE_ANONYMOUS;
postfile.multi.anon_uid = currutmp->uid;
}
else if (isbid) {
- aborted = 0;
+ money = 0;
}
else if(!isbid)
{
/* general article */
postfile.modified = dasht(fpath);
- postfile.multi.money = aborted;
+ postfile.multi.money = money;
}
// ---- END OF MONEY VERIFICATION ----
@@ -1203,12 +1205,12 @@ do_general(int isbid)
{
outs("招標文章沒有稿酬。");
}
- else if (aborted > 0)
+ else if (money > 0)
{
- demoney(aborted);
+ demoney(money);
addPost = 1;
prints("這是您的第 %d 篇文章,稿酬 %d 銀。",
- ++cuser.numposts, aborted);
+ ++cuser.numposts, money);
} else {
// no money, no record.
outs("本篇不列入記錄,敬請包涵。");
@@ -1468,6 +1470,8 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct)
time4_t oldmt, newmt;
off_t oldsz;
int edflags = 0;
+ char save_title[STRLEN];
+ save_title[0] = '\0';
#ifdef EDITPOST_SMARTMERGE
char canDoSmartMerge = 1;
@@ -1564,7 +1568,7 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct)
#endif // EDITPOST_SMARTMERGE
- if (vedit2(fpath, 0, NULL, edflags) == -1)
+ if (vedit2(fpath, 0, NULL, save_title, edflags) == EDIT_ABORTED)
break;
newmt = dasht(genbuf);
@@ -1712,7 +1716,7 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct)
#define UPDATE_USEREC (currmode |= MODE_DIRTY)
static int
-cp_IsHiddenBoard(boardheader_t *bp)
+cp_IsHiddenBoard(const boardheader_t *bp)
{
// rules: see HasBoardPerm().
if ((bp->brdattr & BRD_HIDE) && (bp->brdattr & BRD_POSTMASK))
@@ -1858,7 +1862,7 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct)
snprintf(genbuf, sizeof(genbuf), "採用原標題《%.60s》嗎?[Y] ", xtitle);
getdata(2, 0, genbuf, genbuf2, 4, LCECHO);
- if (genbuf2[0] == 'n' || genbuf2[0] == 'N') {
+ if (genbuf2[0] == 'n') {
if (getdata_str(2, 0, "標題:", genbuf, TTLEN, DOECHO, xtitle))
strlcpy(xtitle, genbuf, sizeof(xtitle));
}
@@ -1883,10 +1887,9 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct)
setbfile(fname, currboard, fhdr->filename);
xptr = fopen(xfpath, "w");
- strlcpy(save_title, xfile.title, sizeof(save_title));
save_currboard = currboard;
currboard = xboard;
- write_header(xptr, save_title);
+ write_header(xptr, xfile.title);
currboard = save_currboard;
if (cp_IsHiddenBoard(bp))
@@ -2295,7 +2298,7 @@ hold_gamble(void)
getdata(b_lines - 1, 0, "賭什麼? 請輸入主題 (輸入後編輯內容):",
msg, 20, DOECHO);
if (msg[0] == 0 ||
- vedit(fn_ticket_end, NA, NULL) < 0)
+ veditfile(fn_ticket_end) < 0)
return FULLUPDATE;
clear();
@@ -3633,7 +3636,7 @@ b_note_edit_bname(int bid)
boardheader_t *fh = getbcache(bid);
assert(0<=bid-1 && bid-1<MAX_BOARD);
setbfile(buf, fh->brdname, fn_notes);
- aborted = vedit2(buf, NA, NULL, 0);
+ aborted = veditfile(buf);
if (aborted == -1) {
clear();
outs(msg_cancel);
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 84b46af6..626e9c32 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -207,7 +207,7 @@ b_post_note(void)
getdata(b_lines - 2, 0, "自訂發文注意事項: (y)編輯/(d)刪除/(n)不變? [y/N/d]:",
yn, sizeof(yn), LCECHO);
if (yn[0] == 'y')
- vedit(buf, NA, NULL);
+ veditfile(buf);
else if (yn[0] == 'd')
unlink(buf);
@@ -217,7 +217,7 @@ b_post_note(void)
getdata(b_lines - 2, 0, "自訂競標文章注意事項: (y)編輯/(d)刪除/(n)不變? [y/N/d]:",
yn, sizeof(yn), LCECHO);
if (yn[0] == 'y')
- vedit(buf, NA, NULL);
+ veditfile(buf);
else if (yn[0] == 'd')
unlink(buf);
@@ -260,7 +260,7 @@ b_posttype()
continue;
setbnfile(filepath, bp->brdname, "postsample", i);
- aborted = vedit(filepath, NA, NULL);
+ aborted = veditfile(filepath);
if (aborted == -1) {
clear();
posttype_f &= ~(1<<i);
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index 75ba8857..932b385d 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -98,6 +98,7 @@ osong(void)
//*fp2;
fileheader_t mail;
int nsongs;
+ char save_title[STRLEN];
strlcpy(buf, Cdatedate(&now), sizeof(buf));
@@ -226,7 +227,7 @@ osong(void)
vice(200, "點歌");
}
snprintf(save_title, sizeof(save_title), "%s:%s", sender, say);
- hold_mail(filename, receiver);
+ hold_mail(filename, receiver, save_title);
if (address[0]) {
bsmtp(filename, save_title, address, NULL);
@@ -543,7 +544,7 @@ give_money_ui(const char *userid)
}
if (vans("交易已完成,要修改紅包袋嗎?[y/N] ") == 'y')
- vedit2(fpath, 0, NULL, 0);
+ veditfile(fpath);
sendalert(id, ALERT_NEW_MAIL);
}
return 0;
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c
index db3f4f43..3aeea05d 100644
--- a/mbbsd/calendar.c
+++ b/mbbsd/calendar.c
@@ -264,8 +264,8 @@ u_editcalendar(void)
setutmpmode(EDITPLAN);
sethomefile(genbuf, cuser.userid, "calendar");
- aborted = vedit(genbuf, NA, NULL);
- if (aborted != -1)
+ aborted = veditfile(genbuf);
+ if (aborted != EDIT_ABORTED)
vmsg("行事曆更新完畢");
return 0;
} else if (genbuf[0] == 'd') {
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 298abb86..75600d81 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1440,15 +1440,15 @@ read_file(const char *fpath, int splitSig)
}
void
-write_header(FILE * fp, char *mytitle) // FIXME unused
+write_header(FILE * fp, const char *mytitle) // FIXME unused
{
-
+ assert(mytitle);
if (curredit & EDIT_MAIL || curredit & EDIT_LIST) {
fprintf(fp, "%s %s (%s)\n", str_author1, cuser.userid,
cuser.nickname
);
} else {
- char *ptr = mytitle;
+ const char *ptr = mytitle;
struct {
char author[IDLEN + 1];
char board[IDLEN + 1];
@@ -1527,7 +1527,6 @@ write_header(FILE * fp, char *mytitle) // FIXME unused
#endif /* HAVE_ANONYMOUS */
}
- mytitle[72] = '\0';
fprintf(fp, "標題: %s\n時間: %s\n", mytitle, ctime4(&now));
}
@@ -1665,14 +1664,18 @@ browse_sigs:
static void upload_file(void);
#endif // EXP_EDIT_UPLOAD
+// return EDIT_ABORTED if aborted
+// KEEP_EDITING if keep editing
+// 0 if write ok & exit
static int
-write_file(const char *fpath, int saveheader, int *islocal, char *mytitle, int upload, int chtitle)
+write_file(const char *fpath, int saveheader, int *islocal, char mytitle[STRLEN], int upload, int chtitle)
{
FILE *fp = NULL;
textline_t *p, *v;
char ans[TTLEN], *msg;
int aborted = 0, line = 0, checksum[3], sum = 0, po = 1;
+ assert(!chtitle || mytitle);
vs_hdr("檔案處理");
move(1,0);
@@ -1708,7 +1711,7 @@ write_file(const char *fpath, int saveheader, int *islocal, char *mytitle, int u
switch (ans[0]) {
case 'a':
outs("文章" ANSI_COLOR(1) " 沒有 " ANSI_RESET "存入");
- aborted = -1;
+ aborted = EDIT_ABORTED;
break;
case 'e':
return KEEP_EDITING;
@@ -2651,19 +2654,6 @@ edit_ansi_outs(const char *str, int attr)
return edit_ansi_outs_n(str, strlen(str), attr);
}
-// old compatible API
-void
-edit_outs(const char *text)
-{
- edit_outs_attr(text, 0);
-}
-
-void
-edit_outs_n(const char *text, int n)
-{
- edit_outs_attr_n(text, n, 0);
-}
-
static int
detect_attr(const char *ps, size_t len)
{
@@ -3369,9 +3359,14 @@ upload_file(void)
#endif // EXP_EDIT_UPLOAD
-/* 編輯處理:主程式、鍵盤處理 */
+/** 編輯處理:主程式、鍵盤處理
+ * @param title NULL, 否則長度 STRLEN
+ * @return EDIT_ABORTED abort
+ * >= 0 編輯錢數
+ * 由於各處都以 == EDIT_ABORTED 判斷, 若想傳回其他負值要注意
+ */
int
-vedit2(const char *fpath, int saveheader, int *islocal, int flags)
+vedit2(const char *fpath, int saveheader, int *islocal, char title[STRLEN], int flags)
{
char last = 0; /* the last key you press */
int ch, tmp;
@@ -3383,14 +3378,11 @@ vedit2(const char *fpath, int saveheader, int *islocal, int flags)
time4_t th = now;
int count = 0, tin = 0, quoted = 0;
char trans_buffer[256];
- char mytitle[STRLEN];
STATINC(STAT_VEDIT);
currutmp->mode = EDITING;
currutmp->destuid = currstat;
- strlcpy(mytitle, save_title, sizeof(mytitle));
-
#ifdef DBCSAWARE
mbcs_mode = (cuser.uflag & DBCSAWARE_FLAG) ? 1 : 0;
#endif
@@ -3543,12 +3535,10 @@ vedit2(const char *fpath, int saveheader, int *islocal, int flags)
switch (ch) {
case KEY_F10:
case Ctrl('X'): /* Save and exit */
- tmp = write_file(fpath, saveheader, islocal, mytitle,
+ tmp = write_file(fpath, saveheader, islocal, title,
(flags & EDITFLAG_UPLOAD) ? 1 : 0,
(flags & EDITFLAG_ALLOWTITLE) ? 1 : 0);
if (tmp != KEEP_EDITING) {
- strlcpy(save_title, mytitle, sizeof(save_title));
- save_title[STRLEN-1] = 0;
currutmp->mode = mode0;
currutmp->destuid = destuid0;
@@ -4028,9 +4018,21 @@ vedit2(const char *fpath, int saveheader, int *islocal, int flags)
}
int
-vedit(const char *fpath, int saveheader, int *islocal)
+vedit(const char *fpath, int saveheader, int *islocal, char title[STRLEN])
+{
+ assert(title);
+ return vedit2(fpath, saveheader, islocal, title, EDITFLAG_ALLOWTITLE);
+}
+
+/**
+ * 編輯一般檔案 (非看板文章/信件).
+ *
+ * 因此不會有 header, title, local save 等參數.
+ */
+int
+veditfile(const char *fpath)
{
- return vedit2(fpath, saveheader, islocal, EDITFLAG_ALLOWTITLE);
+ return vedit2(fpath, NA, NULL, NULL, 0);
}
/* vim:sw=4:nofoldenable
diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c
index 93b3a4db..10e5c0e2 100644
--- a/mbbsd/lovepaper.c
+++ b/mbbsd/lovepaper.c
@@ -12,6 +12,7 @@ x_love(void)
FILE *fp, *fpo;
struct tm gtime;
fileheader_t mhdr;
+ char save_title[STRLEN];
setutmpmode(LOVE);
@@ -88,7 +89,7 @@ x_love(void)
fclose(fpo);
strlcpy(save_title, title, sizeof(save_title));
curredit |= EDIT_MAIL;
- if (vedit(path, YEA, NULL) == -1) {
+ if (vedit(path, YEA, NULL, save_title) == EDIT_ABORTED) {
curredit &= ~EDIT_MAIL;
unlink(path);
clear();
@@ -113,7 +114,7 @@ x_love(void)
return -1;
sendalert(receiver, ALERT_NEW_MAIL);
}
- hold_mail(buf1, receiver);
+ hold_mail(buf1, receiver, save_title);
return 1;
} else {
vmsg("本站目前無情書資料庫,請向站長反應。");
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index e0185e4a..9cf2b13d 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -352,7 +352,7 @@ chkmailbox(void)
}
static void
-do_hold_mail(const char *fpath, const char *receiver, const char *holder)
+do_hold_mail(const char *fpath, const char *receiver, const char *holder, const char *save_title)
{
char buf[PATHLEN], title[128];
char holder_dir[PATHLEN];
@@ -378,7 +378,7 @@ do_hold_mail(const char *fpath, const char *receiver, const char *holder)
}
void
-hold_mail(const char *fpath, const char *receiver)
+hold_mail(const char *fpath, const char *receiver, const char *title)
{
char buf[4];
@@ -389,7 +389,7 @@ hold_mail(const char *fpath, const char *receiver)
buf, sizeof(buf), LCECHO);
if (TOBACKUP(buf[0]))
- do_hold_mail(fpath, receiver, cuser.userid);
+ do_hold_mail(fpath, receiver, cuser.userid, title);
}
int
@@ -400,6 +400,7 @@ do_innersend(const char *userid, char *mfpath, const char *title)
char _mfpath[PATHLEN];
int i = 0;
int oldstat = currstat;
+ char save_title[STRLEN];
if (!mfpath)
mfpath = _mfpath;
@@ -411,7 +412,7 @@ do_innersend(const char *userid, char *mfpath, const char *title)
strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
strlcpy(save_title, title, sizeof(save_title));
- if (vedit(mfpath, YEA, NULL) == -1) {
+ if (vedit(mfpath, YEA, NULL, save_title) == EDIT_ABORTED) {
unlink(mfpath);
setutmpmode(oldstat);
return -2;
@@ -444,6 +445,7 @@ do_send(const char *userid, const char *title)
int internet_mail;
userec_t xuser;
int ret = -1;
+ char save_title[STRLEN];
STATINC(STAT_DOSEND);
if (strchr(userid, '@'))
@@ -472,7 +474,7 @@ do_send(const char *userid, const char *title)
sethomepath(fpath, cuser.userid);
stampfile(fpath, &mhdr);
- if (vedit(fpath, NA, NULL) == -1) {
+ if (vedit(fpath, NA, NULL, save_title) == EDIT_ABORTED) {
unlink(fpath);
clear();
return -2;
@@ -489,7 +491,7 @@ do_send(const char *userid, const char *title)
default:
outs("Y\n請稍候, 信件傳遞中...\n");
ret = bsmtp(fpath, save_title, userid, NULL);
- hold_mail(fpath, userid);
+ hold_mail(fpath, userid, save_title);
break;
}
unlink(fpath);
@@ -498,7 +500,7 @@ do_send(const char *userid, const char *title)
ret = do_innersend(userid, fpath, save_title);
if (ret == 0) // success
- hold_mail(fpath, userid);
+ hold_mail(fpath, userid, save_title);
clear();
}
@@ -618,7 +620,7 @@ multi_list(struct Vector *namelist, int *recipient)
}
static void
-multi_send(char *title)
+multi_send(const char *title)
{
FILE *fp;
fileheader_t mymail;
@@ -666,9 +668,10 @@ multi_send(char *title)
clrtobot();
if (recipient) {
+ char save_title[STRLEN];
setutmpmode(SMAIL);
if (title)
- do_reply_title(2, title);
+ do_reply_title(2, title, save_title);
else {
getdata(2, 0, "主題:", fpath, sizeof(fpath), DOECHO);
snprintf(save_title, sizeof(save_title), "[通告] %s", fpath);
@@ -698,7 +701,7 @@ multi_send(char *title)
}
curredit |= EDIT_LIST;
- if (vedit(fpath, YEA, NULL) == -1) {
+ if (vedit(fpath, YEA, NULL, save_title) == EDIT_ABORTED) {
unlink(fpath);
curredit = 0;
Vector_delete(&namelist);
@@ -740,7 +743,7 @@ multi_send(char *title)
vmsg(err_uid);
sendalert(buf, ALERT_NEW_MAIL);
}
- hold_mail(fpath, NULL);
+ hold_mail(fpath, NULL, save_title);
unlink(fpath);
curredit = 0;
Vector_delete(&namelist);
@@ -789,6 +792,7 @@ mail_all(void)
char genbuf[200];
int i, unum;
char *userid;
+ char save_title[STRLEN];
vs_hdr("給所有使用者的系統通告");
setutmpmode(SMAIL);
@@ -807,7 +811,7 @@ mail_all(void)
*quote_file = 0;
curredit |= EDIT_MAIL;
- if (vedit(fpath, YEA, NULL) == -1) {
+ if (vedit(fpath, YEA, NULL, save_title) == EDIT_ABORTED) {
curredit = 0;
unlink(fpath);
outs(msg_cancel);
@@ -873,6 +877,7 @@ static int
m_forward(int ent GCC_UNUSED, fileheader_t * fhdr, const char *direct GCC_UNUSED)
{
char uid[STRLEN];
+ char save_title[STRLEN];
if (!HasUserPerm(PERM_LOGINOK))
return DONOTHING;
@@ -1287,6 +1292,7 @@ mail_reply(int ent, fileheader_t * fhdr, const char *direct)
FILE *fp;
char genbuf[512];
int oent = ent;
+ char save_title[STRLEN];
if (!fhdr || !fhdr->filename[0])
return DONOTHING;
@@ -1332,7 +1338,7 @@ mail_reply(int ent, fileheader_t * fhdr, const char *direct)
strlcpy(uid, quote_user, sizeof(uid));
/* make the title */
- do_reply_title(3, fhdr->title);
+ do_reply_title(3, fhdr->title, save_title);
prints("\n收信人: %s\n標 題: %s\n", uid, save_title);
/* edit, then send the mail */
@@ -1377,7 +1383,7 @@ mail_edit(int ent GCC_UNUSED, fileheader_t * fhdr, const char *direct)
return DONOTHING;
setdirpath(genbuf, direct, fhdr->filename);
- vedit(genbuf, NA, NULL);
+ veditfile(genbuf);
return FULLUPDATE;
}
@@ -1537,10 +1543,9 @@ mail_cross_post(int ent, fileheader_t * fhdr, const char *direct)
xptr = fopen(xfpath, "w");
assert(xptr);
- strlcpy(save_title, xfile.title, sizeof(save_title));
save_currboard = currboard;
currboard = xboard;
- write_header(xptr, save_title);
+ write_header(xptr, xfile.title);
currboard = save_currboard;
fprintf(xptr, "※ [本文轉錄自 %s 信箱]\n\n", cuser.userid);
diff --git a/mbbsd/more.c b/mbbsd/more.c
index acd0e5a7..d33f8e04 100644
--- a/mbbsd/more.c
+++ b/mbbsd/more.c
@@ -45,9 +45,7 @@ int more(const char *fpath, int promptend)
"%u %s %d %s admin edit file=%s\n",
(int)now, Cdate(&now), getpid(), cuser.userid, fpath);
- // no need to allow anything...
- // at least, no need to change title.
- vedit2(fpath, NA, NULL, 0);
+ veditfile(fpath);
break;
case RET_SELECTBRD:
diff --git a/mbbsd/user.c b/mbbsd/user.c
index 0111869c..ebeb53c3 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -1292,8 +1292,8 @@ browse_sigs:
outs(msg_del_ok);
} else {
setutmpmode(EDITSIG);
- aborted = vedit(genbuf, NA, NULL);
- if (aborted != -1)
+ aborted = veditfile(genbuf);
+ if (aborted != EDIT_ABORTED)
outs("簽名檔更新完畢");
}
}
@@ -1315,8 +1315,8 @@ u_editplan(void)
setutmpmode(EDITPLAN);
setuserfile(genbuf, fn_plans);
- aborted = vedit(genbuf, NA, NULL);
- if (aborted != -1)
+ aborted = veditfile(genbuf);
+ if (aborted != EDIT_ABORTED)
outs("名片更新完畢");
pressanykey();
return 0;
diff --git a/mbbsd/var.c b/mbbsd/var.c
index f2e402d2..7a19f051 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -366,9 +366,6 @@ int TagBoard = -1; /* TagBoard = 0 : user's mailbox */
/* TagBoard > 0 : bid where last taged */
char currdirect[64];
-/* edit.c */
-char save_title[STRLEN];
-
/* bbs.c */
char real_name[IDLEN + 1];
char local_article;
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index f64a6f7e..d08107d3 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -28,7 +28,7 @@ typedef struct {
} vote_buffer_t;
void
-b_suckinfile(FILE * fp, char *fname)
+b_suckinfile(FILE * fp, const char *fname)
{
FILE *sfp;
@@ -42,7 +42,7 @@ b_suckinfile(FILE * fp, char *fname)
}
void
-b_suckinfile_invis(FILE * fp, char *fname, const char *boardname)
+b_suckinfile_invis(FILE * fp, const char *fname, const char *boardname)
{
FILE *sfp;
@@ -617,8 +617,8 @@ vote_maintain(const char *bname)
vmsg("按任何鍵開始編輯此次 [投票宗旨]");
setbfile(buf, bname, vbuf.desc);
- aborted = vedit(buf, NA, NULL);
- if (aborted == -1) {
+ aborted = veditfile(buf);
+ if (aborted == EDIT_ABORTED) {
vmsg("取消此次投票");
return FULLUPDATE;
}