From 194d19647bc28b9a4299a6c22e1179178ceabff9 Mon Sep 17 00:00:00 2001 From: ptt Date: Wed, 24 Mar 2004 22:27:37 +0000 Subject: simplfy append_record git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1605 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/record.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'mbbsd/record.c') diff --git a/mbbsd/record.c b/mbbsd/record.c index 17f8b482..00568f3e 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -553,9 +553,9 @@ stamplink(char *fpath, fileheader_t * fh) } int -do_append(char *fpath, fileheader_t * record, int size) +append_record(char *fpath, fileheader_t * record, int size) { - int fd, fsize=0; + int fd, fsize=0, index; struct stat st; if ((fd = open(fpath, O_WRONLY | O_CREAT, 0644)) == -1) { @@ -567,17 +567,18 @@ do_append(char *fpath, fileheader_t * record, int size) if(fstat(fd, &st)!=-1) fsize = st.st_size; - lseek(fd, (fsize / size) * size, SEEK_SET); // avoid offset + index = fsize / size; + lseek(fd, index * size, SEEK_SET); // avoid offset safewrite(fd, record, size); flock(fd, LOCK_UN); close(fd); - return 0; + return index + 1; } int -append_record(char *fpath, fileheader_t * record, int size) +append_record_forward(char *fpath, fileheader_t * record, int size) { #if !defined(_BBS_UTIL_C_) int m, n; @@ -596,7 +597,7 @@ append_record(char *fpath, fileheader_t * record, int size) if (buf[0] != 0 && buf[0] != ' ') { buf[n + 1] = 0; strcat(buf, record->filename); - do_append(fpath, record, size); + append_record(fpath, record, size); #ifndef USE_BSMTP bbs_sendmail(buf, record->title, address); #else @@ -608,7 +609,7 @@ append_record(char *fpath, fileheader_t * record, int size) } #endif - do_append(fpath, record, size); + append_record(fpath, record, size); return 0; } -- cgit v1.2.3