summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-28 03:19:30 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-28 03:19:30 +0800
commitc95e0fe9deb9628ea33675485f668d81c6e485c5 (patch)
treebfc60863981c3baa9df8102db4fdf8e199d2e727 /mbbsd
parent97aa33dddca788f751a2a53164e2b69f9ea122f8 (diff)
downloadpttbbs-c95e0fe9deb9628ea33675485f668d81c6e485c5.tar
pttbbs-c95e0fe9deb9628ea33675485f668d81c6e485c5.tar.gz
pttbbs-c95e0fe9deb9628ea33675485f668d81c6e485c5.tar.bz2
pttbbs-c95e0fe9deb9628ea33675485f668d81c6e485c5.tar.lz
pttbbs-c95e0fe9deb9628ea33675485f668d81c6e485c5.tar.xz
pttbbs-c95e0fe9deb9628ea33675485f668d81c6e485c5.tar.zst
pttbbs-c95e0fe9deb9628ea33675485f668d81c6e485c5.zip
simplify delete_record
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1617 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/record.c13
1 files changed, 10 insertions, 3 deletions
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