summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-09 15:29:42 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-09 15:29:42 +0800
commit588112ef68e87944a78e349efb5605b74fa6b804 (patch)
tree95367ab8c76cfd664994d8d5946e067f2acbdf33 /mbbsd
parent19a4185ac28f06c1dcd55d55aad67336c14e5e8e (diff)
downloadpttbbs-588112ef68e87944a78e349efb5605b74fa6b804.tar
pttbbs-588112ef68e87944a78e349efb5605b74fa6b804.tar.gz
pttbbs-588112ef68e87944a78e349efb5605b74fa6b804.tar.bz2
pttbbs-588112ef68e87944a78e349efb5605b74fa6b804.tar.lz
pttbbs-588112ef68e87944a78e349efb5605b74fa6b804.tar.xz
pttbbs-588112ef68e87944a78e349efb5605b74fa6b804.tar.zst
pttbbs-588112ef68e87944a78e349efb5605b74fa6b804.zip
add safe_delete_range for SAFE_ARTICLE_DELETE
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1734 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/record.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c
index e6d88fda..276e0b13 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -277,6 +277,32 @@ title_body(char *title)
#endif
+#ifdef SAFE_ARTICLE_DELETE
+void safe_delete_range(char *fpath, int id1, int id2)
+{
+ int fd, i;
+ fileheader_t fhdr;
+ char fullpath[STRLEN], *t;
+ strlcpy(fullpath, fpath, sizeof(fullpath));
+ t = strrchr(fullpath, '/');
+ assert(t);
+ t++;
+ if( (fd = open(fpath, O_RDONLY)) == -1 )
+ return;
+ for( i = 1 ; (read(fd, &fhdr, sizeof(fileheader_t)) ==
+ sizeof(fileheader_t)) ; ++i ){
+ strcpy(t, fhdr.filename);
+ /* rocker.011018: add new tag delete */
+ if (!((fhdr.filemode & FILE_MARKED) || /* ¼Ð°O */
+ (fhdr.filemode & FILE_DIGEST) || /* ¤åºK */
+ (id1 && (i < id1 || i > id2)) || /* range */
+ (!id1 && Tagger(atoi(t + 2), i, TAG_NIN)))) /* TagList */
+ safe_article_delete(i, &fhdr, fpath);
+ }
+ close(fd);
+}
+#endif
+
int
delete_range(char *fpath, int id1, int id2)
{
@@ -286,6 +312,13 @@ delete_range(char *fpath, int id1, int id2)
int fdr, fdw, fd;
int count;
+#ifdef SAFE_ARTICLE_DELETE
+ if( fpath[0] == 'b' ){
+ safe_delete_range(fpath, id1, id2);
+ return 0;
+ }
+#endif
+
nolfilename(&my, fpath);
if ((fd = open(my.lockfn, O_RDWR | O_CREAT | O_APPEND, 0644)) == -1)