summaryrefslogtreecommitdiffstats
path: root/util/merge_dir.c
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-08 09:30:42 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-08 09:30:42 +0800
commitc4260474e6e60275a18037c304a67c0afe7087aa (patch)
tree5e59e3be523f4b8b84e8b7ec19e34ab876ae2938 /util/merge_dir.c
parent97699386f7a67e56a3ac191abc9bf0598b1d5d61 (diff)
downloadpttbbs-c4260474e6e60275a18037c304a67c0afe7087aa.tar
pttbbs-c4260474e6e60275a18037c304a67c0afe7087aa.tar.gz
pttbbs-c4260474e6e60275a18037c304a67c0afe7087aa.tar.bz2
pttbbs-c4260474e6e60275a18037c304a67c0afe7087aa.tar.lz
pttbbs-c4260474e6e60275a18037c304a67c0afe7087aa.tar.xz
pttbbs-c4260474e6e60275a18037c304a67c0afe7087aa.tar.zst
pttbbs-c4260474e6e60275a18037c304a67c0afe7087aa.zip
merge dir tools
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1725 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/merge_dir.c')
-rw-r--r--util/merge_dir.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/util/merge_dir.c b/util/merge_dir.c
new file mode 100644
index 00000000..8df9239b
--- /dev/null
+++ b/util/merge_dir.c
@@ -0,0 +1,50 @@
+/* $Id: merge_board.c 1096 2003-08-15 06:13:29Z victor $ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <sys/types.h>
+#include "config.h"
+#include "pttstruct.h"
+
+void usage() {
+ fprintf(stderr, "Usage:\n\n"
+ "merge_dir <dir1> <dir2> \n");
+}
+int
+dir_cmp(fileheader_t *a, fileheader_t *b)
+{
+ if(!a->filename[0] || !b->filename[0]) return 0;
+ return (strcasecmp(a->filename+1, b->filename+1));
+}
+
+
+fileheader_t *fh;
+
+int main(int argc, char **argv) {
+ int pn, sn, i;
+
+ if(argc < 2) {
+ usage();
+ return 1;
+ }
+
+ pn=get_num_records(argv[1], sizeof(fileheader_t));
+ sn=get_num_records(argv[2], sizeof(fileheader_t));
+ if(sn <=0 || pn<=0)
+ {
+ usage();
+ return 1;
+ }
+ fh = (fileheader_t *)malloc( (pn+sn)*sizeof(fileheader_t));
+ get_records(argv[1], fh, sizeof(fileheader_t), 1, pn);
+ get_records(argv[2], fh+pn, sizeof(fileheader_t), 1, sn);
+ qsort(fh, pn+sn, sizeof(boardheader_t), dir_cmp);
+
+ for(i=0; i<pn+sn; i++)
+ {
+ printf("%s %s %s\n",fh[i].date, fh[i].title, fh[i].filename);
+ }
+
+ return 0;
+}