diff options
author | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-03-25 06:27:37 +0800 |
---|---|---|
committer | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-03-25 06:27:37 +0800 |
commit | 194d19647bc28b9a4299a6c22e1179178ceabff9 (patch) | |
tree | 9a997203d5a0b954ada275f502ca7661093da472 /mbbsd/record.c | |
parent | af0559d83afbcc141db57d0b0db31d73a96f312d (diff) | |
download | pttbbs-194d19647bc28b9a4299a6c22e1179178ceabff9.tar pttbbs-194d19647bc28b9a4299a6c22e1179178ceabff9.tar.gz pttbbs-194d19647bc28b9a4299a6c22e1179178ceabff9.tar.bz2 pttbbs-194d19647bc28b9a4299a6c22e1179178ceabff9.tar.lz pttbbs-194d19647bc28b9a4299a6c22e1179178ceabff9.tar.xz pttbbs-194d19647bc28b9a4299a6c22e1179178ceabff9.tar.zst pttbbs-194d19647bc28b9a4299a6c22e1179178ceabff9.zip |
simplfy append_record
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1605 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/record.c')
-rw-r--r-- | mbbsd/record.c | 15 |
1 files changed, 8 insertions, 7 deletions
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; } |