tzwrapper.cc: fixed use of iterator after erase
[barry.git] / contrib / perlbarry / ipd2tgz
blobe425496e9d217acdd67035a183e5665dbba46365
1 #!/usr/bin/perl
3 # ipd2tgz version 0.1
5 # Copyright (C) 2008, ashley willis <barry@venamous.net>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE.
16 # See the GNU General Public License in the COPYING file at the
17 # root directory of this project for more details.
19 # converts file <BASENAME>.ipd to <BASENAME>.tar.gz, in the format of
20 # barrybackup.
22 # NOTES for yet-to-be tgz2ipd:
23 # dbRecordLength = computed
24 # dbVersion = second part of name
25 # dbRecordHandler = (last dbRecordHandler) + (# of records in last db) + 1
26 # recordID = first part of name
28 $BINARY = 0; # must be 0
30 $VERBOSE = 0; # optional
31 $DBID = 1; # must be 1
32 $DBRECORDLENGTH = 1; # must be 1
33 $DBRECORDHANDLER = 1; # must be 1
34 $FIELDLENGTH = 0; # optional
36 if ($VERBOSE) {
37 $DBID = 1;
38 $DBRECORDLENGTH = 1;
39 $DBRECORDHANDLER = 1;
40 $FIELDLENGTH = 1;
43 foreach $file (@ARGV) {
44 open(IN, "$file");
45 $tmpdir = "$0-$$";
46 $tmpdir =~ s/^.*\//\/tmp\//;
47 print "$tmpdir\n";
48 mkdir($tmpdir);
50 # overall header = 42 bytes
51 read(IN, $header, 38);
52 unless ($header =~ /^Inter\@ctive Pager Backup\/Restore File\n$/) {
53 print STDERR "Not a valid IPD file: $file\n";
54 next;
56 read(IN, $ipdVersion, 1);
57 unless ($ipdVersion =~ /\x02/) {
58 print STDERR"Unknown IPD version: " . Bin2dec($ipdVersion) . "\n";
59 next;
61 read(IN, $numberOfDBs, 2);
62 read(IN, $separator, 1); # ==