/*
- * Copyright (c) Zmanda, Inc. All Rights Reserved.
+ * Copyright (c) 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
*
- * This library is distributed in the hope that it will be useful, but
+ * 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 Lesser General Public
- * License for more details.
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
- * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
+ * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
+ * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
*/
%module "Amanda::Application"
%include "exception.i"
%include "cstring.i"
+%include "Amanda/Application.pod"
+
%perlcode %{
push @ISA, qw(Amanda::Script_App);
require Amanda::Script_App;
use strict;
use warnings;
+use Amanda::Config qw( :init :getconf config_dir_relative );
-=head1 NAME
-
-Amanda::Application - perl utility functions for Applications.
-
-=head1 SYNOPSIS
-
- package Amanda::Application::my_application;
- use base qw(Amanda::Application);
-
- sub new {
- my $class = shift;
- my ($foo, $bar) = @_;
- my $self = $class->SUPER::new();
-
- $self->{'foo'} = $foo;
- $self->{'bar'} = $bar;
-
- return $self;
- }
-
- # Define all command_* subs that you need, e.g.,
- sub command_support {
- my $self = shift;
- # ...
- }
-
- package main;
-
- # .. parse arguments ..
-
- my $application = Amanda::Application::my_application->new($opt_foo, $opt_bar);
- $application->do($cmd);
-
-=cut
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,
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;
+}
%}
/* C interfaces used by the above */
num = av_len(tempav);
for (i=0; i <= num; i++) {
tv = av_fetch(tempav, i, 0);
- level = g_slist_append(level, GINT_TO_POINTER(SvIV(*tv)));
+ /* (gint) cast is required because sizeof(IV) may not be sizeof(gint).
+ * Both will be >= 32 bits, though, and that's sufficient for a level. */
+ level = g_slist_append(level, GINT_TO_POINTER((gint)SvIV(*tv)));
}
$1 = level;
}