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::Header;
9 use base qw(DynaLoader);
10 package Amanda::Headerc;
11 bootstrap Amanda::Header;
12 package Amanda::Header;
15 # ---------- BASE METHODS -------------
17 package Amanda::Header;
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::Header;
52 *C_from_string = *Amanda::Headerc::C_from_string;
54 ############# Class : Amanda::Header::Header ##############
56 package Amanda::Header::Header;
57 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
58 @ISA = qw( Amanda::Header );
61 *swig_type_get = *Amanda::Headerc::Header_type_get;
62 *swig_type_set = *Amanda::Headerc::Header_type_set;
63 *swig_datestamp_get = *Amanda::Headerc::Header_datestamp_get;
64 *swig_datestamp_set = *Amanda::Headerc::Header_datestamp_set;
65 *swig_dumplevel_get = *Amanda::Headerc::Header_dumplevel_get;
66 *swig_dumplevel_set = *Amanda::Headerc::Header_dumplevel_set;
67 *swig_compressed_get = *Amanda::Headerc::Header_compressed_get;
68 *swig_compressed_set = *Amanda::Headerc::Header_compressed_set;
69 *swig_encrypted_get = *Amanda::Headerc::Header_encrypted_get;
70 *swig_encrypted_set = *Amanda::Headerc::Header_encrypted_set;
71 *swig_comp_suffix_get = *Amanda::Headerc::Header_comp_suffix_get;
72 *swig_comp_suffix_set = *Amanda::Headerc::Header_comp_suffix_set;
73 *swig_encrypt_suffix_get = *Amanda::Headerc::Header_encrypt_suffix_get;
74 *swig_encrypt_suffix_set = *Amanda::Headerc::Header_encrypt_suffix_set;
75 *swig_name_get = *Amanda::Headerc::Header_name_get;
76 *swig_name_set = *Amanda::Headerc::Header_name_set;
77 *swig_disk_get = *Amanda::Headerc::Header_disk_get;
78 *swig_disk_set = *Amanda::Headerc::Header_disk_set;
79 *swig_program_get = *Amanda::Headerc::Header_program_get;
80 *swig_program_set = *Amanda::Headerc::Header_program_set;
81 *swig_application_get = *Amanda::Headerc::Header_application_get;
82 *swig_application_set = *Amanda::Headerc::Header_application_set;
83 *swig_srvcompprog_get = *Amanda::Headerc::Header_srvcompprog_get;
84 *swig_srvcompprog_set = *Amanda::Headerc::Header_srvcompprog_set;
85 *swig_clntcompprog_get = *Amanda::Headerc::Header_clntcompprog_get;
86 *swig_clntcompprog_set = *Amanda::Headerc::Header_clntcompprog_set;
87 *swig_srv_encrypt_get = *Amanda::Headerc::Header_srv_encrypt_get;
88 *swig_srv_encrypt_set = *Amanda::Headerc::Header_srv_encrypt_set;
89 *swig_clnt_encrypt_get = *Amanda::Headerc::Header_clnt_encrypt_get;
90 *swig_clnt_encrypt_set = *Amanda::Headerc::Header_clnt_encrypt_set;
91 *swig_recover_cmd_get = *Amanda::Headerc::Header_recover_cmd_get;
92 *swig_recover_cmd_set = *Amanda::Headerc::Header_recover_cmd_set;
93 *swig_uncompress_cmd_get = *Amanda::Headerc::Header_uncompress_cmd_get;
94 *swig_uncompress_cmd_set = *Amanda::Headerc::Header_uncompress_cmd_set;
95 *swig_decrypt_cmd_get = *Amanda::Headerc::Header_decrypt_cmd_get;
96 *swig_decrypt_cmd_set = *Amanda::Headerc::Header_decrypt_cmd_set;
97 *swig_srv_decrypt_opt_get = *Amanda::Headerc::Header_srv_decrypt_opt_get;
98 *swig_srv_decrypt_opt_set = *Amanda::Headerc::Header_srv_decrypt_opt_set;
99 *swig_clnt_decrypt_opt_get = *Amanda::Headerc::Header_clnt_decrypt_opt_get;
100 *swig_clnt_decrypt_opt_set = *Amanda::Headerc::Header_clnt_decrypt_opt_set;
101 *swig_cont_filename_get = *Amanda::Headerc::Header_cont_filename_get;
102 *swig_cont_filename_set = *Amanda::Headerc::Header_cont_filename_set;
103 *swig_dle_str_get = *Amanda::Headerc::Header_dle_str_get;
104 *swig_dle_str_set = *Amanda::Headerc::Header_dle_str_set;
105 *swig_is_partial_get = *Amanda::Headerc::Header_is_partial_get;
106 *swig_is_partial_set = *Amanda::Headerc::Header_is_partial_set;
107 *swig_partnum_get = *Amanda::Headerc::Header_partnum_get;
108 *swig_partnum_set = *Amanda::Headerc::Header_partnum_set;
109 *swig_totalparts_get = *Amanda::Headerc::Header_totalparts_get;
110 *swig_totalparts_set = *Amanda::Headerc::Header_totalparts_set;
111 *swig_blocksize_get = *Amanda::Headerc::Header_blocksize_get;
112 *swig_blocksize_set = *Amanda::Headerc::Header_blocksize_set;
113 *swig_orig_size_get = *Amanda::Headerc::Header_orig_size_get;
114 *swig_orig_size_set = *Amanda::Headerc::Header_orig_size_set;
117 my $self = Amanda::Headerc::new_Header(@_);
118 bless $self, $pkg if defined($self);
121 *to_string = *Amanda::Headerc::Header_to_string;
122 *debug_dump = *Amanda::Headerc::Header_debug_dump;
123 *summary = *Amanda::Headerc::Header_summary;
125 return unless $_[0]->isa('HASH');
126 my $self = tied(%{$_[0]});
127 return unless defined $self;
128 delete $ITERATORS{$self};
129 if (exists $OWNER{$self}) {
130 Amanda::Headerc::delete_Header($self);
131 delete $OWNER{$self};
137 my $ptr = tied(%$self);
143 my $ptr = tied(%$self);
148 # ------- VARIABLE STUBS --------
150 package Amanda::Header;
152 *F_UNKNOWN = *Amanda::Headerc::F_UNKNOWN;
153 *F_WEIRD = *Amanda::Headerc::F_WEIRD;
154 *F_TAPESTART = *Amanda::Headerc::F_TAPESTART;
155 *F_TAPEEND = *Amanda::Headerc::F_TAPEEND;
156 *F_DUMPFILE = *Amanda::Headerc::F_DUMPFILE;
157 *F_CONT_DUMPFILE = *Amanda::Headerc::F_CONT_DUMPFILE;
158 *F_SPLIT_DUMPFILE = *Amanda::Headerc::F_SPLIT_DUMPFILE;
159 *F_EMPTY = *Amanda::Headerc::F_EMPTY;
167 Amanda::Header - Amanda-specific headers prepended to dump files
172 my $hdr = Amanda::Header->new();
173 $hdr->{type} = $Amanda::Header::F_DUMPFILE;
174 $hdr->{name} = "localhost";
175 $hdr->{disk} = "/home";
177 # make a string suitable for use in a dumpfile (NUL-padded)
178 my $block = $hdr->to_string(32768, 32768);
180 # parse a string into a header
181 $hdr = Amanda::Header->from_string($block);
183 print "Working on: ", $hdr->summary(), "\n";
185 =head1 Header Objects
187 Note that, due to the vagaries of SWIG wrapping, headers actually have
188 class C<Amanda::Header::Header>.
190 The constructor creates a new, blank header, which will need at least
191 some of its attributes set before being used. These are set just like
192 any hashref-based object:
194 $hdr->{'dumplevel'} = 13;
196 To construct a new object from a bytestring (as read from the
197 beginning of a dumpfile), use
199 Amanda::Header->from_string($data);
201 To convert a header object into a bytestring, use the C<to_string(min,
202 max)> method. This method takes a minimum and maximum size. If the
203 header is smaller than the minimum size, it is padded with NUL bytes;
204 if it would be larger than the maximum size, the method returns
207 The C<summary> method returns a single-line summary of the header, with
210 As a debugging utility, the C<debug_dump> method dumps the contents of
211 the object to the debug log.
213 To compare a header to a list of dumpspecs (see L<Amanda::Cmdline>), use
215 if ($hdr->matches_dumpspecs([@dumpspecs])) { ... }
217 which is really a call to C<Amanda::Cmdline::header_matches_dumpspecs>.
219 A header object has the following keys:
228 name hostname (F_DUMPFILE) or label (F_TAPESTART)
245 totalparts (-1 == UNKNOWN)
249 C<type> is one of the following constants, which are availble for
250 import in the tag C<:constants>:
262 Some of the header fields are interrelated. The following restrictions apply.
268 C<comp_suffix> is set if and only if C<compressed> is true; the suffix "N" is
269 reserved and cannot be used.
273 C<encrypt_suffix> is set if and only if C<encrypted> is true; the suffix "N" is
274 reserved and cannot be used.
278 If C<totalparts> is not -1, then C<partnum> must be less than or equal to
279 C<totalparts>. Neither parameter can be zero. These parameters are only
280 recorded in a C<F_SPLIT_DUMPFILE> header.
284 The C<blocksize> is intended for the user's convenience only. It is written to
285 the header string, but not parsed on return. C<from_string> will always return
286 a header with blocksize=0.
290 Like C<blocksize>, C<recover_cmd>, C<uncompress_cmd> and C<decrypt_cmd> are
291 intended for the user's convenience noly. The C<uncompress_cmd> and
292 C<decrypt_cmd>, if specified, must end with C<|> (the shell pipe character).
293 Neither can be nonempty unless C<recover_cmd> is also nonempty. When parsing a
294 header with only two commands from a string, it is ambiguous whether the first
295 string is for decryption or uncompression, and this package assumes
304 push @EXPORT_OK, qw(filetype_t_to_strings);
305 push @{$EXPORT_TAGS{"filetype_t"}}, qw(filetype_t_to_strings);
307 my %_filetype_t_VALUES;
308 #Convert a flag value to a list of names for flags that are set.
309 sub filetype_t_to_strings {
313 for my $k (keys %_filetype_t_VALUES) {
314 my $v = $_filetype_t_VALUES{$k};
316 #is this a matching flag?
317 if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
322 #by default, just return the number as a 1-element list
330 push @EXPORT_OK, qw($F_UNKNOWN);
331 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_UNKNOWN);
333 $_filetype_t_VALUES{"F_UNKNOWN"} = $F_UNKNOWN;
335 push @EXPORT_OK, qw($F_WEIRD);
336 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_WEIRD);
338 $_filetype_t_VALUES{"F_WEIRD"} = $F_WEIRD;
340 push @EXPORT_OK, qw($F_TAPESTART);
341 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_TAPESTART);
343 $_filetype_t_VALUES{"F_TAPESTART"} = $F_TAPESTART;
345 push @EXPORT_OK, qw($F_TAPEEND);
346 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_TAPEEND);
348 $_filetype_t_VALUES{"F_TAPEEND"} = $F_TAPEEND;
350 push @EXPORT_OK, qw($F_DUMPFILE);
351 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_DUMPFILE);
353 $_filetype_t_VALUES{"F_DUMPFILE"} = $F_DUMPFILE;
355 push @EXPORT_OK, qw($F_CONT_DUMPFILE);
356 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_CONT_DUMPFILE);
358 $_filetype_t_VALUES{"F_CONT_DUMPFILE"} = $F_CONT_DUMPFILE;
360 push @EXPORT_OK, qw($F_SPLIT_DUMPFILE);
361 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_SPLIT_DUMPFILE);
363 $_filetype_t_VALUES{"F_SPLIT_DUMPFILE"} = $F_SPLIT_DUMPFILE;
365 push @EXPORT_OK, qw($F_EMPTY);
366 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_EMPTY);
368 $_filetype_t_VALUES{"F_EMPTY"} = $F_EMPTY;
370 #copy symbols in filetype_t to constants
371 push @{$EXPORT_TAGS{"constants"}}, @{$EXPORT_TAGS{"filetype_t"}};
374 # SWIG produces a sub-package for the Header "class", in this case named
375 # Amanda::Header::Header. For user convenience, we allow Amanda::Header->new(..) to
376 # do the same thing. This is a wrapper function, and not just a typeglob assignment,
377 # because we want to get the right blessing.
379 shift; # ignore class
380 Amanda::Header::Header->new(@_);
384 shift; # ignore class
385 return C_from_string(@_);
388 package Amanda::Header::Header;
390 # point $hdr->matches_dumpspecs() to Amanda::Cmdline::header_matches_dumpspecs. When
391 # Amanda is built with --without-server, Amanda::Cmdline is missing, so this will fail.
392 # Note that this assumes the user has already use'd Amanda::Cmdline.
393 sub matches_dumpspecs {
394 Amanda::Cmdline::header_matches_dumpspecs(@_);
397 package Amanda::Header;