diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-07-03 13:49:45 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-07-03 13:49:45 +0800 |
commit | 2934f2e18f04ee139dd12ff9bfaa924f948ffa55 (patch) | |
tree | 33068e8df712f05b0d4ef2f85f1bd7bcfc3625bd | |
parent | c6ce21a8f241d028c5df5c3275df264b1857fe23 (diff) | |
download | pttbbs-2934f2e18f04ee139dd12ff9bfaa924f948ffa55.tar pttbbs-2934f2e18f04ee139dd12ff9bfaa924f948ffa55.tar.gz pttbbs-2934f2e18f04ee139dd12ff9bfaa924f948ffa55.tar.bz2 pttbbs-2934f2e18f04ee139dd12ff9bfaa924f948ffa55.tar.lz pttbbs-2934f2e18f04ee139dd12ff9bfaa924f948ffa55.tar.xz pttbbs-2934f2e18f04ee139dd12ff9bfaa924f948ffa55.tar.zst pttbbs-2934f2e18f04ee139dd12ff9bfaa924f948ffa55.zip |
add manbuilder.pl
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1003 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rwxr-xr-x | staticweb/manbuilder.pl | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/staticweb/manbuilder.pl b/staticweb/manbuilder.pl new file mode 100755 index 00000000..ecb0972e --- /dev/null +++ b/staticweb/manbuilder.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# $Id: manbuilder.pl,v 1.1 2003/07/03 05:49:45 in2 Exp $ +use lib '/home/bbs/bin/'; +use strict; +use OurNet::FuzzyIndex; +use Getopt::Std; +use DB_File; +use BBSFileHeader; +use Data::Serializer; + +my(%db, %idx, $serial); + +sub main +{ + die usage() unless( @ARGV ); + + $serial = Data::Serializer->new(serializer => 'Storable', + digester => 'MD5', + compress => 0, + ); + + foreach( @ARGV ){ + tie %db, 'DB_File', "$_.db", O_CREAT | O_RDWR, 0666, $DB_HASH; + build("/home/bbs/man/boards/".substr($_, 0, 1)."/$_", ''); + untie %db; + } +} + +sub build($$) +{ + my($basedir, $doffset) = @_; + my(%bfh, $fn, @tdir); + + print "$basedir, $doffset\n"; + tie %bfh, 'BBSFileHeader', $basedir; + foreach( 0..($bfh{num} - 1) ){ + next if( $bfh{"$_.filemode"} & 32 ); # skip HIDDEN + + $fn = $bfh{"$_.filename"}; + if( $bfh{"$_.isdir"} ){ + push @tdir, ["$doffset/$fn/", $bfh{"$_.title"}]; + build("$basedir/$fn", "$doffset/$fn"); + } + else{ + push @tdir, ["$doffset/$fn", $bfh{"$_.title"}]; + $db{"$doffset/$fn"} = $bfh{"$_.content"}; + } + } + $db{"$doffset/"} = $serial->serialize(\@tdir); +} + +sub usage +{ + print ("$0 boardname ...\n"); + exit(0); +} + +main(); +1; |