Imported Upstream version 3.3.2
[debian/amanda] / perl / Amanda / Header.pm
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 2.0.4
3 #
4 # Do not make changes to this file unless you know what you are doing--modify
5 # the SWIG interface file instead.
6
7 package Amanda::Header;
8 use base qw(Exporter);
9 use base qw(DynaLoader);
10 package Amanda::Headerc;
11 bootstrap Amanda::Header;
12 package Amanda::Header;
13 @EXPORT = qw();
14
15 # ---------- BASE METHODS -------------
16
17 package Amanda::Header;
18
19 sub TIEHASH {
20     my ($classname,$obj) = @_;
21     return bless $obj, $classname;
22 }
23
24 sub CLEAR { }
25
26 sub FIRSTKEY { }
27
28 sub NEXTKEY { }
29
30 sub FETCH {
31     my ($self,$field) = @_;
32     my $member_func = "swig_${field}_get";
33     $self->$member_func();
34 }
35
36 sub STORE {
37     my ($self,$field,$newval) = @_;
38     my $member_func = "swig_${field}_set";
39     $self->$member_func($newval);
40 }
41
42 sub this {
43     my $ptr = shift;
44     return tied(%$ptr);
45 }
46
47
48 # ------- FUNCTION WRAPPERS --------
49
50 package Amanda::Header;
51
52 *C_from_string = *Amanda::Headerc::C_from_string;
53
54 ############# Class : Amanda::Header::Header ##############
55
56 package Amanda::Header::Header;
57 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
58 @ISA = qw( Amanda::Header );
59 %OWNER = ();
60 %ITERATORS = ();
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;
115 sub new {
116     my $pkg = shift;
117     my $self = Amanda::Headerc::new_Header(@_);
118     bless $self, $pkg if defined($self);
119 }
120
121 *to_string = *Amanda::Headerc::Header_to_string;
122 *debug_dump = *Amanda::Headerc::Header_debug_dump;
123 *summary = *Amanda::Headerc::Header_summary;
124 sub DESTROY {
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};
132     }
133 }
134
135 sub DISOWN {
136     my $self = shift;
137     my $ptr = tied(%$self);
138     delete $OWNER{$ptr};
139 }
140
141 sub ACQUIRE {
142     my $self = shift;
143     my $ptr = tied(%$self);
144     $OWNER{$ptr} = 1;
145 }
146
147
148 ############# Class : Amanda::Header::HeaderXML ##############
149
150 package Amanda::Header::HeaderXML;
151 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
152 @ISA = qw( Amanda::Header );
153 %OWNER = ();
154 %ITERATORS = ();
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;
217 sub new {
218     my $pkg = shift;
219     my $self = Amanda::Headerc::new_HeaderXML(@_);
220     bless $self, $pkg if defined($self);
221 }
222
223 sub DESTROY {
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};
231     }
232 }
233
234 sub DISOWN {
235     my $self = shift;
236     my $ptr = tied(%$self);
237     delete $OWNER{$ptr};
238 }
239
240 sub ACQUIRE {
241     my $self = shift;
242     my $ptr = tied(%$self);
243     $OWNER{$ptr} = 1;
244 }
245
246
247 # ------- VARIABLE STUBS --------
248
249 package Amanda::Header;
250
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;
259
260 @EXPORT_OK = ();
261 %EXPORT_TAGS = ();
262
263
264 =head1 NAME
265
266 Amanda::Header - Amanda-specific headers prepended to dump files
267
268 =head1 SYNOPSIS
269
270   # create a header
271   my $hdr = Amanda::Header->new();
272   $hdr->{type} = $Amanda::Header::F_DUMPFILE;
273   $hdr->{name} = "localhost";
274   $hdr->{disk} = "/home";
275
276   # make a string suitable for use in a dumpfile (NUL-padded)
277   my $block = $hdr->to_string(32768, 32768);
278
279   # parse a string into a header
280   $hdr = Amanda::Header->from_string($block);
281
282   print "Working on: ", $hdr->summary(), "\n";
283
284 =head1 Header Objects
285
286 Note that, due to the vagaries of SWIG wrapping, headers actually have
287 class C<Amanda::Header::Header>.
288
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:
292
293  $hdr->{'dumplevel'} = 13;
294
295 To construct a new object from a bytestring (as read from the
296 beginning of a dumpfile), use
297
298  Amanda::Header->from_string($data);
299
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
304 C<undef>.
305
306 The C<summary> method returns a single-line summary of the header, with
307 no trailing newline.
308
309 As a debugging utility, the C<debug_dump> method dumps the contents of
310 the object to the debug log.
311
312 To compare a header to a list of dumpspecs (see L<Amanda::Cmdline>), use
313
314   if ($hdr->matches_dumpspecs([@dumpspecs])) { ... }
315
316 which is really a call to C<Amanda::Cmdline::header_matches_dumpspecs>.
317
318 A header object has the following keys:
319
320  type
321  datestamp
322  dumplevel
323  compressed
324  encrypted
325  comp_suffix
326  encrypt_suffix
327  name               hostname (F_DUMPFILE) or label (F_TAPESTART)
328  disk
329  program
330  application
331  srvcompprog
332  clntcompprog
333  srv_encrypt
334  clnt_encrypt
335  recover_cmd
336  uncompress_cmd
337  decrypt_cmd
338  srv_decrypt_opt
339  clnt_decrypt_opt
340  cont_filename
341  dle_str
342  is_partial
343  partnum
344  totalparts         (-1 == UNKNOWN)
345  blocksize
346  orig_size
347
348 C<type> is one of the following constants, which are availble for
349 import in the tag C<:constants>:
350
351  F_UNKNOWN
352  F_WEIRD
353  F_TAPESTART
354  F_TAPEEND
355  F_DUMPFILE
356  F_CONT_DUMPFILE
357  F_SPLIT_DUMPFILE
358  F_EMPTY
359  F_NOOP
360
361 Some of the header fields are interrelated.  The following restrictions apply.
362
363 =over 4
364
365 =item *
366
367 C<comp_suffix> is set if and only if C<compressed> is true; the suffix "N" is
368 reserved and cannot be used.
369
370 =item *
371
372 C<encrypt_suffix> is set if and only if C<encrypted> is true; the suffix "N" is
373 reserved and cannot be used.
374
375 =item *
376
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.
380
381 =item *
382
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.
386
387 =item *
388
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
395 uncompression.
396
397 =back
398
399 =cut
400
401
402
403 push @EXPORT_OK, qw(filetype_t_to_string);
404 push @{$EXPORT_TAGS{"filetype_t"}}, qw(filetype_t_to_string);
405
406 my %_filetype_t_VALUES;
407 #Convert an enum value to a single string
408 sub filetype_t_to_string {
409     my ($enumval) = @_;
410
411     for my $k (keys %_filetype_t_VALUES) {
412         my $v = $_filetype_t_VALUES{$k};
413
414         #is this a matching flag?
415         if ($enumval == $v) {
416             return $k;
417         }
418     }
419
420 #default, just return the number
421     return $enumval;
422 }
423
424 push @EXPORT_OK, qw($F_UNKNOWN);
425 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_UNKNOWN);
426
427 $_filetype_t_VALUES{"F_UNKNOWN"} = $F_UNKNOWN;
428
429 push @EXPORT_OK, qw($F_WEIRD);
430 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_WEIRD);
431
432 $_filetype_t_VALUES{"F_WEIRD"} = $F_WEIRD;
433
434 push @EXPORT_OK, qw($F_TAPESTART);
435 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_TAPESTART);
436
437 $_filetype_t_VALUES{"F_TAPESTART"} = $F_TAPESTART;
438
439 push @EXPORT_OK, qw($F_TAPEEND);
440 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_TAPEEND);
441
442 $_filetype_t_VALUES{"F_TAPEEND"} = $F_TAPEEND;
443
444 push @EXPORT_OK, qw($F_DUMPFILE);
445 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_DUMPFILE);
446
447 $_filetype_t_VALUES{"F_DUMPFILE"} = $F_DUMPFILE;
448
449 push @EXPORT_OK, qw($F_CONT_DUMPFILE);
450 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_CONT_DUMPFILE);
451
452 $_filetype_t_VALUES{"F_CONT_DUMPFILE"} = $F_CONT_DUMPFILE;
453
454 push @EXPORT_OK, qw($F_SPLIT_DUMPFILE);
455 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_SPLIT_DUMPFILE);
456
457 $_filetype_t_VALUES{"F_SPLIT_DUMPFILE"} = $F_SPLIT_DUMPFILE;
458
459 push @EXPORT_OK, qw($F_EMPTY);
460 push @{$EXPORT_TAGS{"filetype_t"}}, qw($F_EMPTY);
461
462 $_filetype_t_VALUES{"F_EMPTY"} = $F_EMPTY;
463
464 #copy symbols in filetype_t to constants
465 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"filetype_t"}};
466
467
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.
472 sub new {
473     shift; # ignore class
474     Amanda::Header::Header->new(@_);
475 }
476
477 sub from_string {
478     shift; # ignore class
479     return C_from_string(@_);
480 }
481
482 sub get_dle {
483     my $self = shift;
484
485     if ($self->{'dle_str'}) {
486         return Amanda::Header::HeaderXML->new($self->{'dle_str'});
487     } else {
488         return undef;
489     }
490 }
491
492 package Amanda::Header::Header;
493
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(@_);
499 }
500
501 package Amanda::Header;
502 1;