#!/usr/local/bin/perl5
##
##       This utility is part of AIPS++, a software project centered at
##       the National Radio Astronomy Observatory.
##
##       Copyright (C) 1995,1997,1998,1999,2000
##       Associated Universities, Inc. Washington DC, USA.
## 
##       This utility is free software; you can redistribute it and/or modify
##       it under the same terms as Perl itself, i.e., under the terms of the
##       "Artistic License" or the "GNU General Public License". 
##
## This script simply dumps out the SYMBOL and OBJECT DBM files which are
## created by these patch scripts. The only parameter is the directory
## (containing the DBM files) to be dumped.
##
##	patch_dump /the/check/point/dir
##
BEGIN {@AnyDBM_File::ISA = qw(GDBM_File NDBM_File DB_File SDBM_File ODBM_File);}
use AnyDBM_File;
use POSIX;

$dir = shift(@ARGV);

die "no directory specified" unless $dir;
die "can open \"$dir\"" unless -d $dir && -r _;

die "can't attach to \"$dir/objects\", $!" unless tie( %objs, AnyDBM_File, "$dir/objects", O_RDWR | O_CREAT, 0644);
die "can't attach to \"$dir/symbols\", $!" unless tie( %symbols, AnyDBM_File, "$dir/symbols", O_RDWR | O_CREAT, 0644);

print "------------------------------ OBJECTS ------------------------------\n";
foreach ( keys %objs ) { print "$_: $objs{$_}\n"; }
print "------------------------------ SYMBOLS ------------------------------\n";
foreach ( keys %symbols ) { print "$_: $symbols{$_}\n"; }
untie( %objs );
untie( %symbols );

if ( tie( %changes, AnyDBM_File, "$dir/delta", O_RDWR | O_CREAT, 0644) ) {
    print "------------------------------ CHANGES ------------------------------\n";
    foreach ( keys %changes ) { print "$_: $changes{$_}\n"; }
    untie(%changes);
}
