summaryrefslogtreecommitdiffstats
path: root/mbbsd/record.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-02-13 21:21:45 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-02-13 21:21:45 +0800
commit8757cdfe471d6bbe514b2197e1db7e001aeaaae4 (patch)
tree723d7920b2ba7ab48afdd8c1b3e0528207b729ce /mbbsd/record.c
parentf306175ad4da53773f8458ca88e3dd6cd8ab760a (diff)
downloadpttbbs-8757cdfe471d6bbe514b2197e1db7e001aeaaae4.tar
pttbbs-8757cdfe471d6bbe514b2197e1db7e001aeaaae4.tar.gz
pttbbs-8757cdfe471d6bbe514b2197e1db7e001aeaaae4.tar.bz2
pttbbs-8757cdfe471d6bbe514b2197e1db7e001aeaaae4.tar.lz
pttbbs-8757cdfe471d6bbe514b2197e1db7e001aeaaae4.tar.xz
pttbbs-8757cdfe471d6bbe514b2197e1db7e001aeaaae4.tar.zst
pttbbs-8757cdfe471d6bbe514b2197e1db7e001aeaaae4.zip
SAFE_ARTICLE_DELETE for 'D'
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1534 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/record.c')
-rw-r--r--mbbsd/record.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c
index e1388abe..5e3a4ebe 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -412,6 +412,38 @@ safe_article_delete(int ent, fileheader_t *fhdr, char *direct)
substitute_record(direct, &newfhdr, sizeof(newfhdr), ent);
return 0;
}
+
+int
+safe_article_delete_range(char *direct, int from, int to)
+{
+ fileheader_t newfhdr;
+ int fd;
+ char fn[128], *ptr;
+
+ strlcpy(fn, direct, sizeof(fn));
+ if( (ptr = rindex(fn, '/')) == NULL )
+ return 0;
+
+ ++ptr;
+ if( (fd = open(direct, O_RDWR)) != -1 &&
+ lseek(fd, sizeof(fileheader_t) * (from - 1), SEEK_SET) != -1 ){
+
+ for( ; from <= to ; ++from ){
+ read(fd, &newfhdr, sizeof(fileheader_t));
+ strlcpy(ptr, newfhdr.filename, sizeof(newfhdr.filename));
+ unlink(fn);
+
+ sprintf(newfhdr.title, "(本文已被刪除)");
+ strcpy(newfhdr.filename, ".deleted");
+ strcpy(newfhdr.owner, "-");
+ // because off_t is unsigned, we could NOT seek backward.
+ lseek(fd, sizeof(fileheader_t) * (from - 1), SEEK_SET);
+ write(fd, &newfhdr, sizeof(fileheader_t));
+ }
+ close(fd);
+ }
+ return 0;
+}
#endif
int