X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=perl%2FAmanda%2FApplication.pm;h=657f6ac20dd7a214accda9e3d747b5018c6b090d;hb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;hp=ec04bce19cc30c00710d12a2c66b35be99f6ddfb;hpb=96f35b20267e8b1a1c846d476f27fcd330e0b018;p=debian%2Famanda diff --git a/perl/Amanda/Application.pm b/perl/Amanda/Application.pm index ec04bce..657f6ac 100644 --- a/perl/Amanda/Application.pm +++ b/perl/Amanda/Application.pm @@ -59,11 +59,6 @@ package Amanda::Application; @EXPORT_OK = (); %EXPORT_TAGS = (); -push @ISA, qw(Amanda::Script_App); -require Amanda::Script_App; - -use strict; -use warnings; =head1 NAME @@ -75,9 +70,8 @@ Amanda::Application - perl utility functions for Applications. use base qw(Amanda::Application); sub new { - my $class = shift; - my ($foo, $bar) = @_; - my $self = $class->SUPER::new(); + my ($class, $config, $foo) = @_; + my $self = $class->SUPER::new($config); $self->{'foo'} = $foo; $self->{'bar'} = $bar; @@ -98,12 +92,36 @@ Amanda::Application - perl utility functions for Applications. my $application = Amanda::Application::my_application->new($opt_foo, $opt_bar); $application->do($cmd); +=head1 INTERFACE + +=head2 write_magic_block + + $self->write_magic_block($type) + +Write a 512 bytes magic block to STDOUT. + +=head2 read_magic_bloc + + $type = $self->read_magic_block() + +Read the 512 bytes magic block from STDIN and return the type. + =cut + +push @ISA, qw(Amanda::Script_App); +require Amanda::Script_App; + +use strict; +use warnings; +use Amanda::Config qw( :init :getconf config_dir_relative ); + + sub new { - my $class = shift; + my $class = shift @_; + my $config_name = shift @_; - my $self = Amanda::Script_App::new($class, "client", "application", @_); + my $self = Amanda::Script_App::new($class, "client", "application", $config_name); $self->{known_commands} = { support => 1, @@ -123,4 +141,41 @@ sub run_calcsize { run_calcsize_C($self->{config}, $program, $self->{disk}, $self->{device}, $self->{level}, undef, undef); } + +sub default_validate { + my $self = shift; + my $buffer; + + do { + sysread STDIN, $buffer, 1048576; + } while (defined $buffer and length($buffer) > 0); +} + +sub write_magic_block { + my $self = shift; + my $type = shift; + + my $dump_str = pack("a512", $type); + print STDOUT $dump_str; +} + +sub read_magic_block { + my $self = shift; + + my $magic_block = Amanda::Util::full_read(0, 512); + #remove '\0' bytes + $magic_block =~ /^([^\0]*)/; + my $type = $1; + + return $type; +} + +sub _set_mesgout { + my $self = shift; + + my $mesgout_fd; + open ($mesgout_fd, '>&=3') || die("Can't open mesgout_fd: $!"); + $self->{mesgout} = $mesgout_fd; +} + 1;