2 * Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
21 %module "Amanda::Application"
22 %include "amglue/amglue.swg"
23 %include "exception.i"
26 %include "Amanda/Application.pod"
29 push @ISA, qw(Amanda::Script_App);
30 require Amanda::Script_App;
35 use Amanda::Config qw( :init :getconf config_dir_relative );
40 my $config_name = shift @_;
42 my $self = Amanda::Script_App::new($class, "client", "application", $config_name);
44 $self->{known_commands} = {
59 run_calcsize_C($self->{config}, $program, $self->{disk}, $self->{device}, $self->{level}, undef, undef);
63 sub default_validate {
68 sysread STDIN, $buffer, 1048576;
69 } while (defined $buffer and length($buffer) > 0);
72 sub write_magic_block {
76 my $dump_str = pack("a512", $type);
77 print STDOUT $dump_str;
80 sub read_magic_block {
83 my $magic_block = Amanda::Util::full_read(0, 512);
85 $magic_block =~ /^([^\0]*)/;
94 my $mesgout = IO::Handle->new();
95 $mesgout->fdopen(3,"a") || die("Can't open mesgout_fd: $!");
96 $mesgout->autoflush(1);
97 $self->{mesgout} = $mesgout;
102 /* C interfaces used by the above */
106 #include "client_util.h"
109 %typemap(in) GSList *levels {
111 GSList *level = NULL;
117 croak("Argument $argnum is not a reference.");
118 if (SvTYPE(SvRV($input)) != SVt_PVAV)
119 croak("Argument $argnum is not an array.");
120 tempav = (AV*)SvRV($input);
121 num = av_len(tempav);
122 for (i=0; i <= num; i++) {
123 tv = av_fetch(tempav, i, 0);
124 /* (gint) cast is required because sizeof(IV) may not be sizeof(gint).
125 * Both will be >= 32 bits, though, and that's sufficient for a level. */
126 level = g_slist_append(level, GINT_TO_POINTER((gint)SvIV(*tv)));
131 %typemap(freearg) GSList *levels {
136 %rename(run_calcsize_C) run_calcsize;
138 run_calcsize(char *config, char *program, char *disk, char *dirname,
139 GSList *levels, char *file_exclude, char *file_include);
141 %typemap(in) GSList *levels;
142 %typemap(freearg) GSList *levels;