From c95e0fe9deb9628ea33675485f668d81c6e485c5 Mon Sep 17 00:00:00 2001 From: ptt Date: Sat, 27 Mar 2004 19:19:30 +0000 Subject: simplify delete_record git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1617 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/record.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/record.c b/mbbsd/record.c index c56e79e0..0216fa45 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -161,7 +161,7 @@ nolfilename(nol_t * n, char *fpath) } int -delete_record(char fpath[], int size, int id) +delete_records(char fpath[], int size, int id, int num) { char abuf[BUFSIZE]; int fi, fo, locksize=0, readsize=0, offset = size * (id - 1), c, d=0; @@ -181,7 +181,7 @@ delete_record(char fpath[], int size, int id) { close(fo); close(fi); return -1;} locksize = st.st_size - offset; - readsize = locksize - size; + readsize = locksize - size*num; if (locksize < 0 ) { close(fo); close(fi); return -1;} @@ -197,13 +197,19 @@ delete_record(char fpath[], int size, int id) } } close(fi); - ftruncate(fo, st.st_size - size); + ftruncate(fo, st.st_size - size*num); PttLock(fo, offset, locksize, F_UNLCK); close(fo); return 0; } + +int delete_record(char fpath[], int size, int id) +{ + return delete_records(fpath, size, id, 1); +} + #if 0 int delete_record(char fpath[], int size, int id) @@ -268,6 +274,7 @@ title_body(char *title) } return title; } + #endif int -- cgit v1.2.3