diff options
-rw-r--r-- | mbbsd/bbs.c | 9 | ||||
-rw-r--r-- | mbbsd/record.c | 12 |
2 files changed, 14 insertions, 7 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index e984f30c..4dbae34b 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -512,7 +512,7 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath) memcpy(&postfile, fh, sizeof(fileheader_t)); setbpath(newpath, brd); - stampfile(newpath, &postfile); + stampfile_u(newpath, &postfile); nick[0] = '\0'; while (fgets(genbuf, sizeof(genbuf), fin)) { @@ -760,7 +760,7 @@ static int do_general(int isbid) { bid_t bidinfo; - fileheader_t postfile, fh; + fileheader_t postfile; char fpath[80], buf[80]; int aborted, defanony, ifuseanony, i; char genbuf[200], *owner; @@ -944,11 +944,10 @@ do_general(int isbid) } strcpy(genbuf, fpath); setbpath(fpath, currboard); - stampfile(fpath, &fh); - strcpy(postfile.filename, fh.filename); + stampfile_u(fpath, &postfile); // Ptt: stamp file again to make it order // fix the bug that search failure in getindex - // + // stampfile_u is used when you don't want to clear other fields if (append_record(buf, &postfile, sizeof(postfile)) == -1) { unlink(genbuf); diff --git a/mbbsd/record.c b/mbbsd/record.c index 0015e7a4..7a2fc429 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -463,7 +463,9 @@ apply_record(const char *fpath, int (*fptr) (void *item, void *optarg), int size /* mail / post 時,依據時間建立檔案,加上郵戳 */ int -stampfile(char *fpath, fileheader_t * fh) +stampfile_u(char *fpath, fileheader_t * fh) + // Ptt: stampfile_u: won't clear fileheader + // stampfile: will clear fileheader { register char *ip = fpath; time4_t dtime = COMMON_TIME; @@ -488,7 +490,6 @@ stampfile(char *fpath, fileheader_t * fh) } while ((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1); close(fp); #endif - memset(fh, 0, sizeof(fileheader_t)); strlcpy(fh->filename, ip, sizeof(fh->filename)); ptime = localtime4(&dtime); snprintf(fh->date, sizeof(fh->date), @@ -496,6 +497,13 @@ stampfile(char *fpath, fileheader_t * fh) return 0; } +inline int +stampfile(char *fpath, fileheader_t * fh) +{ + memset(fh, 0, sizeof(fileheader_t)); + return stampfile_u(fpath, fh); +} + void stampdir(char *fpath, fileheader_t * fh) { |