Imported Upstream version 3.2.0
[debian/amanda] / perl / Amanda / Cmdline.pm
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 1.3.39
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::Cmdline;
8 use base qw(Exporter);
9 use base qw(DynaLoader);
10 package Amanda::Cmdlinec;
11 bootstrap Amanda::Cmdline;
12 package Amanda::Cmdline;
13 @EXPORT = qw();
14
15 # ---------- BASE METHODS -------------
16
17 package Amanda::Cmdline;
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::Cmdline;
51
52 *format_dumpspec_components = *Amanda::Cmdlinec::format_dumpspec_components;
53 *parse_dumpspecs = *Amanda::Cmdlinec::parse_dumpspecs;
54 *header_matches_dumpspecs = *Amanda::Cmdlinec::header_matches_dumpspecs;
55
56 ############# Class : Amanda::Cmdline::dumpspec_t ##############
57
58 package Amanda::Cmdline::dumpspec_t;
59 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
60 @ISA = qw( Amanda::Cmdline );
61 %OWNER = ();
62 %ITERATORS = ();
63 *swig_host_get = *Amanda::Cmdlinec::dumpspec_t_host_get;
64 *swig_host_set = *Amanda::Cmdlinec::dumpspec_t_host_set;
65 *swig_disk_get = *Amanda::Cmdlinec::dumpspec_t_disk_get;
66 *swig_disk_set = *Amanda::Cmdlinec::dumpspec_t_disk_set;
67 *swig_datestamp_get = *Amanda::Cmdlinec::dumpspec_t_datestamp_get;
68 *swig_datestamp_set = *Amanda::Cmdlinec::dumpspec_t_datestamp_set;
69 *swig_level_get = *Amanda::Cmdlinec::dumpspec_t_level_get;
70 *swig_level_set = *Amanda::Cmdlinec::dumpspec_t_level_set;
71 *swig_write_timestamp_get = *Amanda::Cmdlinec::dumpspec_t_write_timestamp_get;
72 *swig_write_timestamp_set = *Amanda::Cmdlinec::dumpspec_t_write_timestamp_set;
73 sub new {
74     my $pkg = shift;
75     my $self = Amanda::Cmdlinec::new_dumpspec_t(@_);
76     bless $self, $pkg if defined($self);
77 }
78
79 sub DESTROY {
80     return unless $_[0]->isa('HASH');
81     my $self = tied(%{$_[0]});
82     return unless defined $self;
83     delete $ITERATORS{$self};
84     if (exists $OWNER{$self}) {
85         Amanda::Cmdlinec::delete_dumpspec_t($self);
86         delete $OWNER{$self};
87     }
88 }
89
90 *format = *Amanda::Cmdlinec::dumpspec_t_format;
91 sub DISOWN {
92     my $self = shift;
93     my $ptr = tied(%$self);
94     delete $OWNER{$ptr};
95 }
96
97 sub ACQUIRE {
98     my $self = shift;
99     my $ptr = tied(%$self);
100     $OWNER{$ptr} = 1;
101 }
102
103
104 # ------- VARIABLE STUBS --------
105
106 package Amanda::Cmdline;
107
108 *CMDLINE_PARSE_DATESTAMP = *Amanda::Cmdlinec::CMDLINE_PARSE_DATESTAMP;
109 *CMDLINE_PARSE_LEVEL = *Amanda::Cmdlinec::CMDLINE_PARSE_LEVEL;
110 *CMDLINE_EMPTY_TO_WILDCARD = *Amanda::Cmdlinec::CMDLINE_EMPTY_TO_WILDCARD;
111
112 @EXPORT_OK = ();
113 %EXPORT_TAGS = ();
114
115
116 =head1 NAME
117
118 Amanda::Cmdline - utilities for handling command lines
119
120 =head1 SYNOPSIS
121
122   use Amanda::Cmdline;
123
124   my $spec = Amanda::Cmdline::dumpspec_t->new($host, $disk, $datestamp, $level, $write_timestamp);
125   print "host: $spec->{'host'}; disk: $spec->{'disk'}\n";
126
127   my @specs = Amanda::Cmdline::parse_dumpspecs(["host", "disk", "date"],
128                             $Amanda::Cmdline::CMDLINE_PARSE_DATESTAMP);
129
130 =head1 Amanda::Cmdline::dumpspec_t Objects
131
132 Note that this class was called C<Amanda::Cmdline::dumpspec_t> in older versions;
133 that name will still work, but is deprecated.
134
135 =head2 Keys
136
137 Each key contains a match expression, in the form of a string, or undef.  Note
138 that the values of these keys are read-only.
139
140 =over
141
142 =item C<< $ds->{'host'} >>
143
144 Hostname
145
146 =item C<< $ds->{'disk'} >>
147
148 Disk name
149
150 =item C<< $ds->{'datestamp'} >>
151
152 Dump timestamp.
153
154 =item C<< $ds->{'level'} >>
155
156 Dump level
157
158 =item C<< $ds->{'write_timestamp'} >>
159
160 Timestamp when the dump is written to storage media.
161
162 =back
163
164 =head2 Methods
165
166 =over
167
168 =item C<< $ds->format() >>
169
170 Format the dumpspec as a string.
171
172 =back
173
174 =head1 Package Functions
175
176 =over
177
178 =item C<format_dumpspec_components($host, $disk, $datestamp, $level)>
179
180 This function returns a string representing the formatted form of the
181 given dumpspec.  This formatting is the same as performed by
182 C<< $ds->format() >>, but does not need a C<Dumpspec>.
183
184 =item C<parse_dumpspecs([@cmdline], $flags)>
185
186 This function parses C<@cmdline> into a list of C<Dumpspec> objects,
187 according to C<$flags>, which is a logical combination of zero or more
188 of
189
190  $CMDLINE_PARSE_DATESTAMP - recognize datestamps
191  $CMDLINE_PARSE_LEVEL - recognize levels
192  $CMDLINE_EMPTY_TO_WILDCARD - if @cmdline is empty, make a wildcard dumpspec
193
194 These constants are available in export tag C<:constants>.  The command-line
195 format is
196
197   [host [disk [datestamp [level [host [..]]]]]]
198
199 Note that there is no facility for specifying C<write_timestamp> on the command
200 line.
201
202 =item C<header_matches_dumpspecs($hdr, [@dumpspecs])>
203
204 This function compares a header to a list of dumpspecs, returning true if the
205 header matches at least one dumpspec.  If C<@dumpspecs> is empty, the function
206 returns false.
207
208 =back
209
210 =head1 SEE ALSO
211
212 L<Amanda::Config> handles C<-o> options itself, through
213 C<config_overrides>.
214
215 =cut
216
217
218
219 push @EXPORT_OK, qw(cmdline_parse_dumpspecs_flags_to_strings);
220 push @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}}, qw(cmdline_parse_dumpspecs_flags_to_strings);
221
222 my %_cmdline_parse_dumpspecs_flags_VALUES;
223 #Convert a flag value to a list of names for flags that are set.
224 sub cmdline_parse_dumpspecs_flags_to_strings {
225     my ($flags) = @_;
226     my @result = ();
227
228     for my $k (keys %_cmdline_parse_dumpspecs_flags_VALUES) {
229         my $v = $_cmdline_parse_dumpspecs_flags_VALUES{$k};
230
231         #is this a matching flag?
232         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
233             push @result, $k;
234         }
235     }
236
237 #by default, just return the number as a 1-element list
238     if (!@result) {
239         return ($flags);
240     }
241
242     return @result;
243 }
244
245 push @EXPORT_OK, qw($CMDLINE_PARSE_DATESTAMP);
246 push @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}}, qw($CMDLINE_PARSE_DATESTAMP);
247
248 $_cmdline_parse_dumpspecs_flags_VALUES{"CMDLINE_PARSE_DATESTAMP"} = $CMDLINE_PARSE_DATESTAMP;
249
250 push @EXPORT_OK, qw($CMDLINE_PARSE_LEVEL);
251 push @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}}, qw($CMDLINE_PARSE_LEVEL);
252
253 $_cmdline_parse_dumpspecs_flags_VALUES{"CMDLINE_PARSE_LEVEL"} = $CMDLINE_PARSE_LEVEL;
254
255 push @EXPORT_OK, qw($CMDLINE_EMPTY_TO_WILDCARD);
256 push @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}}, qw($CMDLINE_EMPTY_TO_WILDCARD);
257
258 $_cmdline_parse_dumpspecs_flags_VALUES{"CMDLINE_EMPTY_TO_WILDCARD"} = $CMDLINE_EMPTY_TO_WILDCARD;
259
260 #copy symbols in cmdline_parse_dumpspecs_flags to constants
261 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}};
262
263 push @EXPORT_OK, qw(header_matches_dumpspecs parse_dumpspecs format_dumpspec_components);
264 1;