summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/announce.c6
-rw-r--r--mbbsd/bbs.c58
-rw-r--r--mbbsd/mail.c44
-rw-r--r--mbbsd/record.c47
-rw-r--r--mbbsd/var.c1
5 files changed, 60 insertions, 96 deletions
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 4d44ff15..663a9daa 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -911,10 +911,8 @@ a_menu(char *maintitle, char *path, int lastlevel)
Fexit = 1;
if (currstat == OSONG) {
/* XXX: 只選歌未點歌可灌排行榜 */
- char buf[128];
- snprintf(buf, sizeof(buf),
- "%s\n", fhdr->title);
- log_file(FN_USSONG, buf, 1);
+ log_file(FN_USSONG, 1,
+ "%s\n", fhdr->title);
}
free(me.header);
return FULLUPDATE;
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 8136fbcd..a65e8a20 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -235,18 +235,6 @@ readdoent(int num, fileheader_t * ent)
}
int
-cmpfilename(fileheader_t * fhdr)
-{
- return (!strcmp(fhdr->filename, currfile));
-}
-
-int
-cmpfmode(fileheader_t * fhdr)
-{
- return (fhdr->filemode & currfmode);
-}
-
-int
whereami(int ent, fileheader_t * fhdr, char *direct)
{
boardheader_t *bh, *p[32], *root;
@@ -273,30 +261,7 @@ whereami(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
}
-static int
-substitute_ref_record(char *direct, fileheader_t * fhdr, int ent)
-{
- fileheader_t hdr;
- char genbuf[100];
- int num = 0;
-
- /* rocker.011018: 串接模式用reference增進效率 */
- if ((fhdr->money & FHR_REFERENCE) &&
- (num = fhdr->money & ~FHR_REFERENCE)){
- setbdir(genbuf, currboard);
- get_record(genbuf, &hdr, sizeof(hdr), num);
- if (strcmp(hdr.filename, fhdr->filename))
- {
- if((num = getindex(genbuf, fhdr->filename)))
- substitute_record(genbuf, fhdr, sizeof(*fhdr), num);
- fhdr->money = FHR_REFERENCE | num ; // Ptt: update now!
- }
- else
- substitute_record(genbuf, fhdr, sizeof(*fhdr), num);
- }
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- return num;
-}
+
static int
do_select(int ent, fileheader_t * fhdr, char *direct)
{
@@ -809,26 +774,6 @@ do_generalboardreply(fileheader_t * fhdr)
*quote_file = 0;
}
-int
-getindex(char *fpath, char *fname)
-{
-#define READSIZE 64 // 8192 / sizeof(fileheader_t)
- int fd, i, len, now = 1; /* now starts from 1 */
- fileheader_t fhdrs[READSIZE];
-
- if ((fd = open(fpath, O_RDONLY, 0)) != -1) {
- while( (len = read(fd, fhdrs, sizeof(fhdrs))) > 0 ){
- len /= sizeof(fileheader_t);
- for( i = 0 ; i < len ; ++i, ++now )
- if (!strcmp(fhdrs[i].filename, fname)) {
- close(fd);
- return now;
- }
- }
- close(fd);
- }
- return 0;
-}
int
invalid_brdname(char *brd)
@@ -1719,7 +1664,6 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
}
getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO);
if (genbuf[0] == 'y') {
- strlcpy(currfile, fhdr->filename, sizeof(currfile));
if(
#ifdef SAFE_ARTICLE_DELETE
(bp->nuser>20 && !safe_article_delete(ent, fhdr, direct)) ||
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index f4a53dfa..731f37cf 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -823,22 +823,19 @@ mail_del(int ent, fileheader_t * fhdr, char *direct)
if (fhdr->filemode & FILE_MARKED)
return DONOTHING;
- getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO);
- if (genbuf[0] == 'y') {
- strlcpy(currfile, fhdr->filename, sizeof(currfile));
+ if (currmode & MODE_SELECT) {
+ vmsg("請先回到正常模式後再進行刪除...");
+ return READ_REDRAW;
+ }
+
+ if (getans(msg_del_ny) == 'y') {
if (!delete_record(direct, sizeof(*fhdr), ent)) {
setdirpath(genbuf, direct, fhdr->filename);
unlink(genbuf);
- if ((currmode & MODE_SELECT)) {
- int index;
- sethomedir(genbuf, cuser.userid);
- index = getindex(genbuf, fhdr->filename);
- delete_record(genbuf, sizeof(fileheader_t), index);
- }
return DIRCHANGED;
}
}
- return TITLE_REDRAW;
+ return READ_REDRAW;
}
static int
@@ -856,14 +853,7 @@ mail_read(int ent, fileheader_t * fhdr, char *direct)
if (more_result != -1) {
fhdr->filemode |= FILE_READ;
- if ((currmode & MODE_SELECT)) {
- int index;
-
- index = getindex(currmaildir, fhdr->filename);
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- } else
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent);
+ substitute_ref_record(direct, fhdr, ent);
}
switch (more_result) {
case 999:
@@ -900,14 +890,7 @@ mail_read(int ent, fileheader_t * fhdr, char *direct)
mail_del(ent, fhdr, direct);
else {
fhdr->filemode |= FILE_READ;
- if ((currmode & MODE_SELECT)) {
- int index;
-
- index = getindex(currmaildir, fhdr->filename);
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- } else
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent);
+ substitute_ref_record(direct, fhdr, ent);
}
return FULLUPDATE;
}
@@ -999,14 +982,7 @@ mail_mark(int ent, fileheader_t * fhdr, char *direct)
{
fhdr->filemode ^= FILE_MARKED;
- if ((currmode & MODE_SELECT)) {
- int index;
-
- index = getindex(currmaildir, fhdr->filename);
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- } else
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent);
+ substitute_ref_record(direct, fhdr, ent);
return PART_REDRAW;
}
diff --git a/mbbsd/record.c b/mbbsd/record.c
index efc1089c..e551db61 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -127,6 +127,53 @@ substitute_record(char *fpath, void *rptr, int size, int id)
return 0;
}
+int
+substitute_ref_record(char *direct, fileheader_t * fhdr, int ent)
+{
+ fileheader_t hdr;
+ char genbuf[256];
+ int num = 0;
+
+ /* rocker.011018: 串接模式用reference增進效率 */
+ if ((fhdr->money & FHR_REFERENCE) &&
+ (num = fhdr->money & ~FHR_REFERENCE)){
+ setdirpath(genbuf, direct, ".DIR");
+ get_record(genbuf, &hdr, sizeof(hdr), num);
+ if (strcmp(hdr.filename, fhdr->filename))
+ {
+ if((num = getindex(genbuf, fhdr->filename, num)))
+ substitute_record(genbuf, fhdr, sizeof(*fhdr), num);
+ fhdr->money = FHR_REFERENCE | num ; // Ptt: update now!
+ }
+ else
+ substitute_record(genbuf, fhdr, sizeof(*fhdr), num);
+ }
+ substitute_record(direct, fhdr, sizeof(*fhdr), ent);
+ return num;
+}
+
+int
+getindex(char *fpath, char *fname, int start)
+{ // Ptt: 從前面找很費力 太暴力
+#define READSIZE 64 // 8192 / sizeof(fileheader_t)
+ int fd, i, len, n = 1; /* n starts from 1 */
+ fileheader_t fhdrs[READSIZE];
+
+ if ((fd = open(fpath, O_RDONLY, 0)) != -1) {
+ while( (len = read(fd, fhdrs, sizeof(fhdrs))) > 0 ){
+ len /= sizeof(fileheader_t);
+ for( i = 0 ; i < len ; ++i, ++n )
+ if (!strcmp(fhdrs[i].filename, fname)) {
+ close(fd);
+ return now;
+ }
+ }
+ close(fd);
+ }
+ return 0;
+}
+
+
/* rocker.011022: 避免lock檔開啟時不正常斷線,造成永久lock */
#ifndef _BBS_UTIL_C_
static int
diff --git a/mbbsd/var.c b/mbbsd/var.c
index dff359b6..3ff019f0 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -85,7 +85,6 @@ char paste_path[256];
char currtitle[TTLEN + 1] = "\0";
char vetitle[TTLEN + 1] = "\0";
char currauthor[IDLEN + 2] = "\0";
-char currfile[FNLEN];/* current file name @ bbs.c mail.c */
char *currboard = "\0";
char currBM[IDLEN * 3 + 10];
char reset_color[4] = "\033[m";