📄 reipd
字号:
#!/usr/bin/perl# reipd version 0.1# Copyright (C) 2008, ashley willis <barry@venamous.net>## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.# # This program is distributed in the hope that it will be useful, but# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY# or FITNESS FOR A PARTICULAR PURPOSE.# # See the GNU General Public License in the COPYING file at the# root directory of this project for more details.# reconstructs an .ipd file to <BASENAME>.ipd2. Argument to reipd is the# directory containing the .deipd files, or the <BASENAME>.info file. No# argument needed if in the directory containing these files. This will# recreate the original .ipd file byte-for-byte if the data was unchanged.# Alternatively, .deipd files can be given on the command line, with output# to "new.ipd2".use Cwd;if (@ARGV) { if (($count == 1) and !($ARGV[0] =~ /\.deipd2?$/) ) { $arg = $ARGV[0]; if ($arg =~ /\.info$/) { open(DBNAMES,"$arg") || die; $basename = $arg; $basename =~ s/\.info$//; $basename =~ s/^(.*)\///g; $dir = $1; } else { $arg =~ s/\/$//; $basename = $arg; $basename =~ s/^(.*)\///g; open(DBNAMES,"$arg/$basename.info") || die; $dir = $arg; } ($dir) or $dir = "."; print STDERR "dir=\"$dir\"\n"; print STDERR "base=\"$basename\"\n"; while(<DBNAMES>) { chomp $_; (/^$/) or $dbname[$i++] = $_; } } else { $dir = "."; $basename = "new"; foreach (@ARGV) { s/\.deipd2?$// || die; $dbname[$i++] = $_; } }}else { $dir = cwd(); #chomp $dir; $basename = $dir; $basename =~ s/^(.*)\///g; print STDERR "dir=\"$dir\"\n"; print STDERR "base=\"$basename\"\n"; open(DBNAMES,"$basename.info") || die "$basename.info not found!\n"; while(<DBNAMES>) { chomp $_; (/^$/) or $dbname[$i++] = $_; }}$numOfDB = @dbname;$numOfDBBIN = reverse(dec2Bin($numOfDB,2));open(OUT, ">$basename.ipd2") || die;print OUT "Inter\@ctive Pager Backup/Restore File\n" . $numOfDBBIN . "