summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-23 06:44:42 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-23 06:44:42 +0800
commita9f0a463742a3bb14e73fddb2db726c56546c611 (patch)
treeaa0e5a56714713a66ec49d0d0593d22b77498e7f
parent54b32b30a7e872cde5dcb8717ee46b36ecbd44bf (diff)
downloadpttbbs-a9f0a463742a3bb14e73fddb2db726c56546c611.tar
pttbbs-a9f0a463742a3bb14e73fddb2db726c56546c611.tar.gz
pttbbs-a9f0a463742a3bb14e73fddb2db726c56546c611.tar.bz2
pttbbs-a9f0a463742a3bb14e73fddb2db726c56546c611.tar.lz
pttbbs-a9f0a463742a3bb14e73fddb2db726c56546c611.tar.xz
pttbbs-a9f0a463742a3bb14e73fddb2db726c56546c611.tar.zst
pttbbs-a9f0a463742a3bb14e73fddb2db726c56546c611.zip
fix dark hole tools
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1600 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--util/Makefile5
-rw-r--r--util/checkdir.c72
2 files changed, 75 insertions, 2 deletions
diff --git a/util/Makefile b/util/Makefile
index 6f946f7a..38e0eaca 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -29,7 +29,7 @@ CPROG_WITHOUT_UTIL= \
shmsweep uhash_loader showboard antispam \
countalldice webgrep bbsrf initbbs \
userlist tunepasswd buildir merge_passwd \
- merge_board xchatd bbsmail
+ merge_board xchatd bbsmail
# 下面這些程式會被 install
PROGS= ${UTIL_OBJS} ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} \
@@ -37,7 +37,8 @@ PROGS= ${UTIL_OBJS} ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} \
openticket.sh stock.sh topsong.sh weather.sh \
stock.perl weather.perl toplazyBM.sh toplazyBBM.sh \
dailybackup.pl tarqueue.pl waterball.pl filtermail.pl \
- getbackup.pl udnnews.pl rebuildaloha.pl railway_wrapper.pl
+ getbackup.pl udnnews.pl rebuildaloha.pl railway_wrapper.pl\
+ checkdir
all: ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} ${PROGS}
diff --git a/util/checkdir.c b/util/checkdir.c
new file mode 100644
index 00000000..ac4cafa8
--- /dev/null
+++ b/util/checkdir.c
@@ -0,0 +1,72 @@
+/* $Id: checkdir.c 1356 2003-11-22 02:16:02Z victor $ */
+/*
+typedef struct fileheader_t {
+ char filename[FNLEN];
+ char recommend;
+ char owner[IDLEN + 2];
+ char date[6];
+ char title[TTLEN + 1];
+ int money;
+ unsigned char filemode;
+} fileheader_t;
+
+*/
+#include "bbs.h"
+void dumpfh(fileheader_t fh)
+{
+ char *c;
+ printf("dumping fh\n");
+ for( c= (char*)&fh; (c-(char*)&fh)<sizeof(fh); c++)
+ if(isprint(*c)) printf("%c",*c);
+ else printf("[%02d]",(unsigned int)*c);
+ printf("\n");
+}
+int main(int argc, char **argv) {
+ int count=0;
+ fileheader_t pfh, fh;
+ FILE *fp, *fo=NULL;
+ int offset=0;
+
+ if(argc < 2) {
+ fprintf(stderr, "Usage: %s \n", argv[0]);
+ return 1;
+ }
+
+ if(!(fp=fopen(argv[1],"r")))
+ {printf("fileopen error!\n");
+ return 0;}
+ if(argc >2)
+ fo=fopen(argv[2],"w");
+
+ for(count=0; fread(&fh, sizeof(fh), 1, fp) >0; count++)
+ {
+ if(fh.owner[0]=='M' && fh.owner[1]=='.')
+ {
+ count--;
+ fseek(fp,FNLEN+1-sizeof(fh),SEEK_CUR);
+ printf("%d,offset forth!---dump\n", count);
+ dumpfh(pfh);
+ dumpfh(fh);
+ offset=1;
+ continue;
+ }
+ if(fh.filename[1]!='.' && offset==1)
+ {
+ fseek(fp,-FNLEN-1-sizeof(fh),SEEK_CUR);
+ printf("%d,offset back!\n", count);
+ offset=0;
+ continue;
+ }
+ if(fh.filename[0]==0 || fh.owner[0]==0)
+ {
+ if(fh.filename[0]==0) unlink(fh.filename);
+ continue;
+ }
+ pfh=fh;
+ if(fo)
+ fwrite(&fh, sizeof(fh), 1, fo);
+ }
+ fclose(fp);
+ if(fo) fclose(fo);
+ return 0;
+}