diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-03-12 21:41:16 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-03-12 21:41:16 +0800 |
commit | edd89e653d6dbb25d9c2330082291d90db5d63d3 (patch) | |
tree | 34d3f27130663d4c9433c53e009ca54731f2f537 | |
parent | 1482e4d5c5887fe0e1822e7753d4f7273cb38aa5 (diff) | |
download | pttbbs-edd89e653d6dbb25d9c2330082291d90db5d63d3.tar pttbbs-edd89e653d6dbb25d9c2330082291d90db5d63d3.tar.gz pttbbs-edd89e653d6dbb25d9c2330082291d90db5d63d3.tar.bz2 pttbbs-edd89e653d6dbb25d9c2330082291d90db5d63d3.tar.lz pttbbs-edd89e653d6dbb25d9c2330082291d90db5d63d3.tar.xz pttbbs-edd89e653d6dbb25d9c2330082291d90db5d63d3.tar.zst pttbbs-edd89e653d6dbb25d9c2330082291d90db5d63d3.zip |
move global variable into local, 587 bytes
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2607 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/announce.c | 90 | ||||
-rw-r--r-- | mbbsd/bbs.c | 3 | ||||
-rw-r--r-- | mbbsd/cal.c | 7 | ||||
-rw-r--r-- | mbbsd/edit.c | 4 | ||||
-rw-r--r-- | mbbsd/mail.c | 9 | ||||
-rw-r--r-- | mbbsd/var.c | 3 |
6 files changed, 65 insertions, 51 deletions
diff --git a/mbbsd/announce.c b/mbbsd/announce.c index ead713a9..c5c78f3e 100644 --- a/mbbsd/announce.c +++ b/mbbsd/announce.c @@ -3,19 +3,30 @@ #define PATHLEN 256 -static char copyfile[PATHLEN]; -static char copytitle[TTLEN + 1]; -static char copyowner[IDLEN + 2]; +struct CopyTmp { + char copyfile[PATHLEN]; + char copytitle[TTLEN + 1]; + char copyowner[IDLEN + 2]; +}; +static struct CopyTmp *copytmp; void a_copyitem(char *fpath, char *title, char *owner, int mode) { - strcpy(copyfile, fpath); - strcpy(copytitle, title); + if(copytmp == NULL) + copytmp = (struct CopyTmp*)malloc(sizeof(struct CopyTmp)); + if(copytmp == NULL) { + if(mode) vmsg("拷貝失敗"); + return; + } + memset(copytmp, 0, sizeof(struct CopyTmp)); + + strcpy(copytmp->copyfile, fpath); + strcpy(copytmp->copytitle, title); if (owner) - strcpy(copyowner, owner); + strcpy(copytmp->copyowner, owner); else - *copyowner = 0; + *copytmp->copyowner = 0; if (mode) { vmsg("檔案標記完成。[注意] 拷貝後才能刪除原文!"); } @@ -313,25 +324,25 @@ a_pasteitem(menu_t * pm, int mode) fileheader_t item; move(b_lines - 1, 1); - if (copyfile[0]) { - if (dashd(copyfile)) { - for (i = 0; copyfile[i] && copyfile[i] == pm->path[i]; i++); - if (!copyfile[i]) { + if (copytmp && copytmp->copyfile[0]) { + if (dashd(copytmp->copyfile)) { + for (i = 0; copytmp->copyfile[i] && copytmp->copyfile[i] == pm->path[i]; i++); + if (!copytmp->copyfile[i]) { vmsg("將目錄拷進自己的子目錄中,會造成無窮迴圈!"); return; } } if (mode) { snprintf(buf, sizeof(buf), - "確定要拷貝[%s]嗎(Y/N)?[N] ", copytitle); + "確定要拷貝[%s]嗎(Y/N)?[N] ", copytmp->copytitle); getdata(b_lines - 1, 1, buf, ans, sizeof(ans), LCECHO); } else ans[0] = 'y'; if (ans[0] == 'y') { strlcpy(newpath, pm->path, sizeof(newpath)); - if (*copyowner) { - char *fname = strrchr(copyfile, '/'); + if (*copytmp->copyowner) { + char *fname = strrchr(copytmp->copyfile, '/'); if (fname) strcat(newpath, fname); @@ -341,30 +352,30 @@ a_pasteitem(menu_t * pm, int mode) mkdir(pm->path, 0755); memset(&item, 0, sizeof(fileheader_t)); strlcpy(item.filename, fname + 1, sizeof(item.filename)); - memcpy(copytitle, "◎", 2); + memcpy(copytmp->copytitle, "◎", 2); if (HAS_PERM(PERM_BBSADM)) - Link(copyfile, newpath); + Link(copytmp->copyfile, newpath); else { - Copy(copyfile, newpath); + Copy(copytmp->copyfile, newpath); } - } else if (dashf(copyfile)) { + } else if (dashf(copytmp->copyfile)) { stampfile(newpath, &item); - memcpy(copytitle, "◇", 2); - Copy(copyfile, newpath); - } else if (dashd(copyfile)) { + memcpy(copytmp->copytitle, "◇", 2); + Copy(copytmp->copyfile, newpath); + } else if (dashd(copytmp->copyfile)) { stampdir(newpath, &item); - memcpy(copytitle, "◆", 2); - copy_file(copyfile, newpath); + memcpy(copytmp->copytitle, "◆", 2); + copy_file(copytmp->copyfile, newpath); } else { outs("無法拷貝!"); igetch(); return; } - strlcpy(item.owner, *copyowner ? copyowner : cuser.userid, + strlcpy(item.owner, *copytmp->copyowner ? copytmp->copyowner : cuser.userid, sizeof(item.owner)); - strlcpy(item.title, copytitle, sizeof(item.title)); + strlcpy(item.title, copytmp->copytitle, sizeof(item.title)); a_additem(pm, &item); - copyfile[0] = '\0'; + copytmp->copyfile[0] = '\0'; } } else { outs("請先執行 copy 命令後再 paste"); @@ -381,19 +392,19 @@ a_appenditem(menu_t * pm, int isask) FILE *fp, *fin; move(b_lines - 1, 1); - if (copyfile[0]) { - if (dashf(copyfile)) { + if (copytmp && copytmp->copyfile[0]) { + if (dashf(copytmp->copyfile)) { snprintf(fname, sizeof(fname), "%s/%s", pm->path, pm->header[pm->now - pm->page].filename); if (dashf(fname)) { if (isask) { snprintf(buf, sizeof(buf), - "確定要將[%s]附加於此嗎(Y/N)?[N] ", copytitle); + "確定要將[%s]附加於此嗎(Y/N)?[N] ", copytmp->copytitle); getdata(b_lines - 2, 1, buf, ans, sizeof(ans), LCECHO); } if (ans[0] == 'y') { if ((fp = fopen(fname, "a+"))) { - if ((fin = fopen(copyfile, "r"))) { + if ((fin = fopen(copytmp->copyfile, "r"))) { memset(buf, '-', 74); buf[74] = '\0'; fprintf(fp, "\n> %s <\n\n", buf); @@ -408,7 +419,7 @@ a_appenditem(menu_t * pm, int isask) fputs(buf, fp); } fclose(fin); - copyfile[0] = '\0'; + copytmp->copyfile[0] = '\0'; } fclose(fp); } @@ -720,14 +731,15 @@ isvisible_man(menu_t * me) return 1; } int -a_menu(char *maintitle, char *path, int lastlevel) +a_menu(char *maintitle, char *path, int lastlevel, char *trans_buffer) { static char Fexit; // 用來跳出 recursion menu_t me; char fname[PATHLEN]; int ch, returnvalue = FULLUPDATE; - trans_buffer[0] = 0; + if(trans_buffer) + trans_buffer[0] = '\0'; Fexit = 0; me.header = (fileheader_t *) calloc(p_lines, FHSZ); @@ -893,7 +905,8 @@ a_menu(char *maintitle, char *path, int lastlevel) while ((more_result = more(fname, YEA))) { /* Ptt 範本精靈 plugin */ - if (currstat == EDITEXP || currstat == OSONG) { + if (trans_buffer && + (currstat == EDITEXP || currstat == OSONG)) { char ans[4]; move(22, 0); @@ -904,8 +917,7 @@ a_menu(char *maintitle, char *path, int lastlevel) "確定要點這首歌嗎?[y/N]", ans, sizeof(ans), LCECHO); if (ans[0] == 'y') { - strlcpy(trans_buffer, - fname, sizeof(trans_buffer)); + strlcpy(trans_buffer, fname, 256); Fexit = 1; if (currstat == OSONG) { /* XXX: 只選歌未點歌可灌排行榜 */ @@ -936,7 +948,7 @@ a_menu(char *maintitle, char *path, int lastlevel) break; } } else if (dashd(fname)) { - a_menu(me.header[me.now - me.page].title, fname, me.level); + a_menu(me.header[me.now - me.page].title, fname, me.level, trans_buffer); /* Ptt 強力跳出recursive */ if (Fexit) { free(me.header); @@ -1074,8 +1086,8 @@ Announce(void) { setutmpmode(ANNOUNCE); a_menu(mytitle, "man", - ((HAS_PERM(PERM_SYSOP) ) ? SYSOP : - NOBODY)); + ((HAS_PERM(PERM_SYSOP) ) ? SYSOP : NOBODY), + NULL); return 0; } diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 093f2854..b3185bae 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1295,7 +1295,8 @@ b_man(void) close(fd); } return a_menu(currboard, buf, HAS_PERM(PERM_ALLBOARD) ? 2 : - (currmode & MODE_BOARD ? 1 : 0)); + (currmode & MODE_BOARD ? 1 : 0), + NULL); } #ifndef NO_GAMBLE diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 8163c2ec..edc96a9c 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -88,6 +88,7 @@ osong(char *defaultid) { char destid[IDLEN + 1], buf[200], genbuf[200], filename[256], say[51]; + char trans_buffer[256]; char receiver[45], ano[3]; FILE *fp, *fp1; //*fp2; @@ -114,12 +115,12 @@ osong(char *defaultid) move(12, 0); clrtobot(); prints("親愛的 %s 歡迎來到歐桑自動點歌系統\n", cuser.userid); - trans_buffer[0] = 0; + trans_buffer[0] = '\0'; if (!defaultid) { getdata(13, 0, "要點給誰呢:[可直接按 Enter 先選歌]", destid, sizeof(destid), DOECHO); while (!destid[0]) { - a_menu("點歌歌本", SONGBOOK, 0); + a_menu("點歌歌本", SONGBOOK, 0, trans_buffer); clear(); getdata(13, 0, "要點給誰呢:[可按 Enter 重新選歌]", destid, sizeof(destid), DOECHO); @@ -144,7 +145,7 @@ osong(char *defaultid) if (!trans_buffer[0]) { outs("\n接著要選歌囉..進入歌本好好的選一首歌吧..^o^"); pressanykey(); - a_menu("點歌歌本", SONGBOOK, 0); + a_menu("點歌歌本", SONGBOOK, 0, trans_buffer); } if (!trans_buffer[0] || strstr(trans_buffer, "home") || strstr(trans_buffer, "boards") || !(fp = fopen(trans_buffer, "r"))) { diff --git a/mbbsd/edit.c b/mbbsd/edit.c index 3de5946c..390e3d30 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -2429,6 +2429,7 @@ vedit(char *fpath, int saveheader, int *islocal) time4_t th = now; int count = 0, tin = 0; textline_t *oldcurrline; + char trans_buffer[256]; currutmp->mode = EDITING; currutmp->destuid = currstat; @@ -2737,7 +2738,8 @@ vedit(char *fpath, int saveheader, int *islocal) unsigned int currstat0 = currstat; setutmpmode(EDITEXP); a_menu("編輯輔助器", "etc/editexp", - (HAS_PERM(PERM_SYSOP) ? SYSOP : NOBODY)); + (HAS_PERM(PERM_SYSOP) ? SYSOP : NOBODY), + trans_buffer); currstat = currstat0; } if (trans_buffer[0]) { diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 44ea13ce..f25a73de 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1159,7 +1159,7 @@ mail_man(void) sethomeman(buf, cuser.userid); snprintf(buf1, sizeof(buf1), "%s 的信件夾", cuser.userid); - a_menu(buf1, buf, HAS_PERM(PERM_MAILLIMIT)); + a_menu(buf1, buf, HAS_PERM(PERM_MAILLIMIT), NULL); currutmp->mode = mode0; currstat = stat0; return FULLUPDATE; @@ -1193,8 +1193,9 @@ mail_cite(int ent, fileheader_t * fhdr, char *direct) if (*xboard && ((bid = getbnum(xboard)) >= 0)){ /* XXXbid */ setapath(fpath, xboard); setutmpmode(ANNOUNCE); - a_menu(xboard, fpath, HAS_PERM(PERM_ALLBOARD) ? 2 : - is_BM_cache(bid) ? 1 : 0); + a_menu(xboard, fpath, + HAS_PERM(PERM_ALLBOARD) ? 2 : is_BM_cache(bid) ? 1 : 0, + NULL); } else { mail_man(); } @@ -1218,7 +1219,7 @@ mail_save(int ent, fileheader_t * fhdr, char *direct) title[TTLEN] = '\0'; a_copyitem(fpath, title, fhdr->owner, 1); sethomeman(fpath, cuser.userid); - a_menu(cuser.userid, fpath, 1); + a_menu(cuser.userid, fpath, 1, NULL); return FULLUPDATE; } return DONOTHING; diff --git a/mbbsd/var.c b/mbbsd/var.c index ccca630a..9a121c85 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -389,9 +389,6 @@ water_t *water, *swater[6], *water_which; water_t water[6], *swater[6], *water_which = &water[0]; #endif -/* announce.c */ -char trans_buffer[256]; - /* chc_play.c */ /* user.c */ |