summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-08 10:43:45 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-08 10:43:45 +0800
commitfbc660eda40610fb5ba57fae1f68fe4f2617ca8f (patch)
treefa27b94bc6eed614da6648ba41a698f0459dadd8 /util
parentc4260474e6e60275a18037c304a67c0afe7087aa (diff)
downloadpttbbs-fbc660eda40610fb5ba57fae1f68fe4f2617ca8f.tar
pttbbs-fbc660eda40610fb5ba57fae1f68fe4f2617ca8f.tar.gz
pttbbs-fbc660eda40610fb5ba57fae1f68fe4f2617ca8f.tar.bz2
pttbbs-fbc660eda40610fb5ba57fae1f68fe4f2617ca8f.tar.lz
pttbbs-fbc660eda40610fb5ba57fae1f68fe4f2617ca8f.tar.xz
pttbbs-fbc660eda40610fb5ba57fae1f68fe4f2617ca8f.tar.zst
pttbbs-fbc660eda40610fb5ba57fae1f68fe4f2617ca8f.zip
tool to merge .dir for boards
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1726 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r--util/merge_dir.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/util/merge_dir.c b/util/merge_dir.c
index 8df9239b..e81a9f7e 100644
--- a/util/merge_dir.c
+++ b/util/merge_dir.c
@@ -11,15 +11,13 @@ 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 dir_cmp(fileheader_t *a, fileheader_t *b)
+{
+ return strncasecmp(a->filename, b->filename, 12);
+}
int main(int argc, char **argv) {
int pn, sn, i;
@@ -39,11 +37,14 @@ int main(int argc, char **argv) {
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++)
+ qsort(fh, pn+sn, sizeof(fileheader_t), dir_cmp);
+ for(i=1; i<pn+sn; i++ )
{
- printf("%s %s %s\n",fh[i].date, fh[i].title, fh[i].filename);
+ if(!fh[i].title[0] || !fh[i].filename[0]) continue;
+ if( strcmp(fh[i-1].filename, fh[i].filename))
+ append_record("DIR.merge", &fh[i-1], sizeof(fileheader_t));
+ else
+ fh[i].filemode |= fh[i-1].filemode;
}
return 0;