1 # This file was automatically generated by SWIG (http://www.swig.org).
4 # Do not make changes to this file unless you know what you are doing--modify
5 # the SWIG interface file instead.
7 package Amanda::Application;
9 use base qw(DynaLoader);
10 package Amanda::Applicationc;
11 bootstrap Amanda::Application;
12 package Amanda::Application;
15 # ---------- BASE METHODS -------------
17 package Amanda::Application;
20 my ($classname,$obj) = @_;
21 return bless $obj, $classname;
31 my ($self,$field) = @_;
32 my $member_func = "swig_${field}_get";
33 $self->$member_func();
37 my ($self,$field,$newval) = @_;
38 my $member_func = "swig_${field}_set";
39 $self->$member_func($newval);
48 # ------- FUNCTION WRAPPERS --------
50 package Amanda::Application;
52 *run_calcsize_C = *Amanda::Applicationc::run_calcsize_C;
54 # ------- VARIABLE STUBS --------
56 package Amanda::Application;
65 Amanda::Application - perl utility functions for Applications.
69 package Amanda::Application::my_application;
70 use base qw(Amanda::Application);
73 my ($class, $config, $foo) = @_;
74 my $self = $class->SUPER::new($config);
76 $self->{'foo'} = $foo;
77 $self->{'bar'} = $bar;
82 # Define all command_* subs that you need, e.g.,
90 # .. parse arguments ..
92 my $application = Amanda::Application::my_application->new($opt_foo, $opt_bar);
93 $application->do($cmd);
97 =head2 write_magic_block
99 $self->write_magic_block($type)
101 Write a 512 bytes magic block to STDOUT.
103 =head2 read_magic_bloc
105 $type = $self->read_magic_block()
107 Read the 512 bytes magic block from STDIN and return the type.
112 push @ISA, qw(Amanda::Script_App);
113 require Amanda::Script_App;
118 use Amanda::Config qw( :init :getconf config_dir_relative );
122 my $class = shift @_;
123 my $config_name = shift @_;
125 my $self = Amanda::Script_App::new($class, "client", "application", $config_name);
127 $self->{known_commands} = {
142 run_calcsize_C($self->{config}, $program, $self->{disk}, $self->{device}, $self->{level}, undef, undef);
146 sub default_validate {
151 sysread STDIN, $buffer, 1048576;
152 } while (defined $buffer and length($buffer) > 0);
155 sub write_magic_block {
159 my $dump_str = pack("a512", $type);
160 print STDOUT $dump_str;
163 sub read_magic_block {
166 my $magic_block = Amanda::Util::full_read(0, 512);
168 $magic_block =~ /^([^\0]*)/;
177 my $mesgout = IO::Handle->new();
178 $mesgout->fdopen(3,"a") || die("Can't open mesgout_fd: $!");
179 $mesgout->autoflush(1);
180 $self->{mesgout} = $mesgout;