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 ############# Class : Amanda::Header::HeaderXML ##############
150 package Amanda::Header::HeaderXML;
151 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
152 @ISA = qw( Amanda::Header );
155 *swig_disk_get = *Amanda::Headerc::HeaderXML_disk_get;
156 *swig_disk_set = *Amanda::Headerc::HeaderXML_disk_set;
157 *swig_device_get = *Amanda::Headerc::HeaderXML_device_get;
158 *swig_device_set = *Amanda::Headerc::HeaderXML_device_set;
159 *swig_program_is_application_api_get = *Amanda::Headerc::HeaderXML_program_is_application_api_get;
160 *swig_program_is_application_api_set = *Amanda::Headerc::HeaderXML_program_is_application_api_set;
161 *swig_program_get = *Amanda::Headerc::HeaderXML_program_get;
162 *swig_program_set = *Amanda::Headerc::HeaderXML_program_set;
163 *swig_estimatelist_get = *Amanda::Headerc::HeaderXML_estimatelist_get;
164 *swig_estimatelist_set = *Amanda::Headerc::HeaderXML_estimatelist_set;
165 *swig_spindle_get = *Amanda::Headerc::HeaderXML_spindle_get;
166 *swig_spindle_set = *Amanda::Headerc::HeaderXML_spindle_set;
167 *swig_compress_get = *Amanda::Headerc::HeaderXML_compress_get;
168 *swig_compress_set = *Amanda::Headerc::HeaderXML_compress_set;
169 *swig_encrypt_get = *Amanda::Headerc::HeaderXML_encrypt_get;
170 *swig_encrypt_set = *Amanda::Headerc::HeaderXML_encrypt_set;
171 *swig_kencrypt_get = *Amanda::Headerc::HeaderXML_kencrypt_get;
172 *swig_kencrypt_set = *Amanda::Headerc::HeaderXML_kencrypt_set;
173 *swig_levellist_get = *Amanda::Headerc::HeaderXML_levellist_get;
174 *swig_levellist_set = *Amanda::Headerc::HeaderXML_levellist_set;
175 *swig_nb_level_get = *Amanda::Headerc::HeaderXML_nb_level_get;
176 *swig_nb_level_set = *Amanda::Headerc::HeaderXML_nb_level_set;
177 *swig_dumpdate_get = *Amanda::Headerc::HeaderXML_dumpdate_get;
178 *swig_dumpdate_set = *Amanda::Headerc::HeaderXML_dumpdate_set;
179 *swig_compprog_get = *Amanda::Headerc::HeaderXML_compprog_get;
180 *swig_compprog_set = *Amanda::Headerc::HeaderXML_compprog_set;
181 *swig_srv_encrypt_get = *Amanda::Headerc::HeaderXML_srv_encrypt_get;
182 *swig_srv_encrypt_set = *Amanda::Headerc::HeaderXML_srv_encrypt_set;
183 *swig_clnt_encrypt_get = *Amanda::Headerc::HeaderXML_clnt_encrypt_get;
184 *swig_clnt_encrypt_set = *Amanda::Headerc::HeaderXML_clnt_encrypt_set;
185 *swig_srv_decrypt_opt_get = *Amanda::Headerc::HeaderXML_srv_decrypt_opt_get;
186 *swig_srv_decrypt_opt_set = *Amanda::Headerc::HeaderXML_srv_decrypt_opt_set;
187 *swig_clnt_decrypt_opt_get = *Amanda::Headerc::HeaderXML_clnt_decrypt_opt_get;
188 *swig_clnt_decrypt_opt_set = *Amanda::Headerc::HeaderXML_clnt_decrypt_opt_set;
189 *swig_record_get = *Amanda::Headerc::HeaderXML_record_get;
190 *swig_record_set = *Amanda::Headerc::HeaderXML_record_set;
191 *swig_create_index_get = *Amanda::Headerc::HeaderXML_create_index_get;
192 *swig_create_index_set = *Amanda::Headerc::HeaderXML_create_index_set;
193 *swig_auth_get = *Amanda::Headerc::HeaderXML_auth_get;
194 *swig_auth_set = *Amanda::Headerc::HeaderXML_auth_set;
195 *swig_exclude_file_get = *Amanda::Headerc::HeaderXML_exclude_file_get;
196 *swig_exclude_file_set = *Amanda::Headerc::HeaderXML_exclude_file_set;
197 *swig_exclude_list_get = *Amanda::Headerc::HeaderXML_exclude_list_get;
198 *swig_exclude_list_set = *Amanda::Headerc::HeaderXML_exclude_list_set;
199 *swig_include_file_get = *Amanda::Headerc::HeaderXML_include_file_get;
200 *swig_include_file_set = *Amanda::Headerc::HeaderXML_include_file_set;
201 *swig_include_list_get = *Amanda::Headerc::HeaderXML_include_list_get;
202 *swig_include_list_set = *Amanda::Headerc::HeaderXML_include_list_set;
203 *swig_exclude_optional_get = *Amanda::Headerc::HeaderXML_exclude_optional_get;
204 *swig_exclude_optional_set = *Amanda::Headerc::HeaderXML_exclude_optional_set;
205 *swig_include_optional_get = *Amanda::Headerc::HeaderXML_include_optional_get;
206 *swig_include_optional_set = *Amanda::Headerc::HeaderXML_include_optional_set;
207 *swig_application_property_get = *Amanda::Headerc::HeaderXML_application_property_get;
208 *swig_application_property_set = *Amanda::Headerc::HeaderXML_application_property_set;
209 *swig_scriptlist_get = *Amanda::Headerc::HeaderXML_scriptlist_get;
210 *swig_scriptlist_set = *Amanda::Headerc::HeaderXML_scriptlist_set;
211 *swig_data_path_get = *Amanda::Headerc::HeaderXML_data_path_get;
212 *swig_data_path_set = *Amanda::Headerc::HeaderXML_data_path_set;
213 *swig_directtcp_list_get = *Amanda::Headerc::HeaderXML_directtcp_list_get;
214 *swig_directtcp_list_set = *Amanda::Headerc::HeaderXML_directtcp_list_set;
215 *swig_next_get = *Amanda::Headerc::HeaderXML_next_get;
216 *swig_next_set = *Amanda::Headerc::HeaderXML_next_set;
219 my $self = Amanda::Headerc::new_HeaderXML(@_);
220 bless $self, $pkg if defined($self);
224 return unless $_[0]->isa('HASH');
225 my $self = tied(%{$_[0]});
226 return unless defined $self;
227 delete $ITERATORS{$self};
228 if (exists $OWNER{$self}) {
229 Amanda::Headerc::delete_HeaderXML($self);
230 delete $OWNER{$self};
236 my $ptr = tied(%$self);
242 my $ptr = tied(%$self);
247 # ------- VARIABLE STUBS --------
249 package Amanda::Header;
251 *F_UNKNOWN = *Amanda::Headerc::F_UNKNOWN;
252 *F_WEIRD = *Amanda::Headerc::F_WEIRD;
253 *F_TAPESTART = *Amanda::Headerc::F_TAPESTART;
254 *F_TAPEEND = *Amanda::Headerc::F_TAPEEND;
255 *F_DUMPFILE = *Amanda::Headerc::F_DUMPFILE;
256 *F_CONT_DUMPFILE = *Amanda::Headerc::F_CONT_DUMPFILE;
257 *F_SPLIT_DUMPFILE = *Amanda::Headerc::F_SPLIT_DUMPFILE;
258 *F_EMPTY = *Amanda::Headerc::F_EMPTY;
266 Amanda::Header - Amanda-specific headers prepended to dump files
271 my $hdr = Amanda::Header->new();
272 $hdr->{type} = $Amanda::Header::F_DUMPFILE;
273 $hdr->{name} = "localhost";
274 $hdr->{disk} = "/home";
276 # make a string suitable for use in a dumpfile (NUL-padded)
277 my $block = $hdr->to_string(32768, 32768);
279 # parse a string into a header
280 $hdr = Amanda::Header->from_string($block);
282 print "Working on: ", $hdr->summary(), "\n";
284 =head1 Header Objects
286 Note that, due to the vagaries of SWIG wrapping, headers actually have
287 class C<Amanda::Header::Header>.
289 The constructor creates a new, blank header, which will need at least
290 some of its attributes set before being used. These are set just like
291 any hashref-based object:
293 $hdr->{'dumplevel'} = 13;
295 To construct a new object from a bytestring (as read from the
296 beginning of a dumpfile), use
298 Amanda::Header->from_string($data);
300 To convert a header object into a bytestring, use the C<to_string(min,
301 max)> method. This method takes a minimum and maximum size. If the
302 header is smaller than the minimum size, it is padded with NUL bytes;
303 if it would be larger than the maximum size, the method returns
306 The C<summary> method returns a single-line summary of the header, with
309 As a debugging utility, the C<debug_dump> method dumps the contents of
310 the object to the debug log.
312 To compare a header to a list of dumpspecs (see L<Amanda::Cmdline>), use
314 if ($hdr->matches_dumpspecs([@dumpspecs])) { ... }
316 which is really a call to C<Amanda::Cmdline::header_matches_dumpspecs>.
318 A header object has the following keys:
327 name hostname (F_DUMPFILE) or label (F_TAPESTART)
344 totalparts (-1 == UNKNOWN)
348 C<type> is one of the following constants, which are availble for
349 import in the tag C<:constants>:
361 Some of the header fields are interrelated. The following restrictions apply.
367 C<comp_suffix> is set if and only if C<compressed> is true; the suffix "N" is
368 reserved and cannot be used.
372 C<encrypt_suffix> is set if and only if C<encrypted> is true; the suffix "N" is
373 reserved and cannot be used.
377 If C<totalparts> is not -1, then C<partnum> must be less than or equal to
378 C<totalparts>. Neither parameter can be zero. These parameters are only
379 recorded in a C<F_SPLIT_DUMPFILE> header.
383 The C<blocksize> is intended for the user's convenience only. It is written to
384 the header string, but not parsed on return. C<from_string> will always return
385 a header with blocksize=0.
389 Like C<blocksize>, C<recover_cmd>, C<uncompress_cmd> and C<decrypt_cmd> are
390 intended for the user's convenience noly. The C<uncompress_cmd> and
391 C<decrypt_cmd>, if specified, must end with C<|> (the shell pipe character).
392 Neither can be nonempty unless C<recover_cmd> is also nonempty. When parsing a
393 header with only two commands from a string, it is ambiguous whether the first
394 string is for decryption or uncompression, and this package assumes
403 push @EXPORT_OK, qw(filetype_t_to_string);
404 push @{$EXPORT_TAGS{"filetype_t"}}, qw(filetype_t_to_string);
406 my %_filetype_t_VALUES;
407 #Convert an enum value to a single string
408 sub filetype_t_to_string {
411 for my $k (keys %_filetype_t_VALUES) {
412 my $v = $_filetype_t_VALUES{$k};
414 #is this a matching flag?
415 if ($enumval == $v) {
420 #default, just return the number
424 push @EXPORT_OK, qw($F_UNKNOWN);
425 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_UNKNOWN);
427 $_filetype_t_VALUES{"F_UNKNOWN"} = $F_UNKNOWN;
429 push @EXPORT_OK, qw($F_WEIRD);
430 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_WEIRD);
432 $_filetype_t_VALUES{"F_WEIRD"} = $F_WEIRD;
434 push @EXPORT_OK, qw($F_TAPESTART);
435 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_TAPESTART);
437 $_filetype_t_VALUES{"F_TAPESTART"} = $F_TAPESTART;
439 push @EXPORT_OK, qw($F_TAPEEND);
440 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_TAPEEND);
442 $_filetype_t_VALUES{"F_TAPEEND"} = $F_TAPEEND;
444 push @EXPORT_OK, qw($F_DUMPFILE);
445 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_DUMPFILE);
447 $_filetype_t_VALUES{"F_DUMPFILE"} = $F_DUMPFILE;
449 push @EXPORT_OK, qw($F_CONT_DUMPFILE);
450 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_CONT_DUMPFILE);
452 $_filetype_t_VALUES{"F_CONT_DUMPFILE"} = $F_CONT_DUMPFILE;
454 push @EXPORT_OK, qw($F_SPLIT_DUMPFILE);
455 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_SPLIT_DUMPFILE);
457 $_filetype_t_VALUES{"F_SPLIT_DUMPFILE"} = $F_SPLIT_DUMPFILE;
459 push @EXPORT_OK, qw($F_EMPTY);
460 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_EMPTY);
462 $_filetype_t_VALUES{"F_EMPTY"} = $F_EMPTY;
464 #copy symbols in filetype_t to constants
465 push @{$EXPORT_TAGS{"constants"}}, @{$EXPORT_TAGS{"filetype_t"}};
468 # SWIG produces a sub-package for the Header "class", in this case named
469 # Amanda::Header::Header. For user convenience, we allow Amanda::Header->new(..) to
470 # do the same thing. This is a wrapper function, and not just a typeglob assignment,
471 # because we want to get the right blessing.
473 shift; # ignore class
474 Amanda::Header::Header->new(@_);
478 shift; # ignore class
479 return C_from_string(@_);
485 if ($self->{'dle_str'}) {
486 return Amanda::Header::HeaderXML->new($self->{'dle_str'});
492 package Amanda::Header::Header;
494 # point $hdr->matches_dumpspecs() to Amanda::Cmdline::header_matches_dumpspecs. When
495 # Amanda is built with --without-server, Amanda::Cmdline is missing, so this will fail.
496 # Note that this assumes the user has already use'd Amanda::Cmdline.
497 sub matches_dumpspecs {
498 Amanda::Cmdline::header_matches_dumpspecs(@_);
501 package Amanda::Header;