3bd405161e54573f0fd7c8dec4c0f45d1080601c
[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 sub new {
72     my $pkg = shift;
73     my $self = Amanda::Cmdlinec::new_dumpspec_t(@_);
74     bless $self, $pkg if defined($self);
75 }
76
77 sub DESTROY {
78     return unless $_[0]->isa('HASH');
79     my $self = tied(%{$_[0]});
80     return unless defined $self;
81     delete $ITERATORS{$self};
82     if (exists $OWNER{$self}) {
83         Amanda::Cmdlinec::delete_dumpspec_t($self);
84         delete $OWNER{$self};
85     }
86 }
87
88 *format = *Amanda::Cmdlinec::dumpspec_t_format;
89 sub DISOWN {
90     my $self = shift;
91     my $ptr = tied(%$self);
92     delete $OWNER{$ptr};
93 }
94
95 sub ACQUIRE {
96     my $self = shift;
97     my $ptr = tied(%$self);
98     $OWNER{$ptr} = 1;
99 }
100
101
102 # ------- VARIABLE STUBS --------
103
104 package Amanda::Cmdline;
105
106 *CMDLINE_PARSE_DATESTAMP = *Amanda::Cmdlinec::CMDLINE_PARSE_DATESTAMP;
107 *CMDLINE_PARSE_LEVEL = *Amanda::Cmdlinec::CMDLINE_PARSE_LEVEL;
108 *CMDLINE_EMPTY_TO_WILDCARD = *Amanda::Cmdlinec::CMDLINE_EMPTY_TO_WILDCARD;
109
110 @EXPORT_OK = ();
111 %EXPORT_TAGS = ();
112
113
114 =head1 NAME
115
116 Amanda::Cmdline - utilities for handling command lines
117
118 =head1 SYNOPSIS
119
120   use Amanda::Cmdline;
121
122   my $spec = Amanda::Cmdline::dumpspec_t->new($host, $disk, $datestamp, $level);
123   print "host: $spec->{'host'}; disk: $spec->{'disk'}\n";
124
125   my @specs = Amanda::Cmdline::parse_dumpspecs(["host", "disk", "date"],
126                             $Amanda::Cmdline::CMDLINE_PARSE_DATESTAMP);
127
128 =head1 Amanda::Cmdline::dumpspec_t Objects
129
130 =head2 Instance Variables
131
132 =over
133
134 =item C<$host>
135
136 =item C<$disk>
137
138 =item C<$datestamp>
139
140 =item C<$level>
141
142 =back
143
144 =head2 Methods
145
146 =over
147
148 =item C<format()>
149
150 Format the dumpspec as a string.
151
152 =back
153
154 =head1 Functions
155
156 =over
157
158 =item C<format_dumpspec_components($host, $disk, $datestamp, $level)>
159
160 This function returns a string representing the formatted form of the
161 given dumpspec.  This formatting is the same as performed by
162 C<format_dumpspec_components>, but does not need a C<dumpspec_t>.
163
164 =item C<parse_dumpspecs([@cmdline], $flags)>
165
166 This function parses C<@cmdline> into a list of C<dumpspec_t> objects,
167 according to C<$flags>, which is a logical combination of zero or more
168 of C<$CMDLINE_PARSE_DATESTAMP> to recognize datestamps and
169 C<$CMDLINE_PARSE_LEVEL> to recognize levels.
170
171 =item C<header_matches_dumpspecs($hdr, [@dumpspecs])>
172
173 This function compares a header to a list of dumpspecs, returning true if the
174 header matches at least one dumpspec.  If C<@dumpspecs> is empty, the function
175 returns false.
176
177 =back
178
179 =head1 SEE ALSO
180
181 L<Amanda::Config> handles C<-o> options itself, through
182 C<config_overrides>.
183
184 =cut
185
186
187
188 push @EXPORT_OK, qw(cmdline_parse_dumpspecs_flags_to_strings);
189 push @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}}, qw(cmdline_parse_dumpspecs_flags_to_strings);
190
191 my %_cmdline_parse_dumpspecs_flags_VALUES;
192 #Convert a flag value to a list of names for flags that are set.
193 sub cmdline_parse_dumpspecs_flags_to_strings {
194     my ($flags) = @_;
195     my @result = ();
196
197     for my $k (keys %_cmdline_parse_dumpspecs_flags_VALUES) {
198         my $v = $_cmdline_parse_dumpspecs_flags_VALUES{$k};
199
200         #is this a matching flag?
201         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
202             push @result, $k;
203         }
204     }
205
206 #by default, just return the number as a 1-element list
207     if (!@result) {
208         return ($flags);
209     }
210
211     return @result;
212 }
213
214 push @EXPORT_OK, qw($CMDLINE_PARSE_DATESTAMP);
215 push @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}}, qw($CMDLINE_PARSE_DATESTAMP);
216
217 $_cmdline_parse_dumpspecs_flags_VALUES{"CMDLINE_PARSE_DATESTAMP"} = $CMDLINE_PARSE_DATESTAMP;
218
219 push @EXPORT_OK, qw($CMDLINE_PARSE_LEVEL);
220 push @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}}, qw($CMDLINE_PARSE_LEVEL);
221
222 $_cmdline_parse_dumpspecs_flags_VALUES{"CMDLINE_PARSE_LEVEL"} = $CMDLINE_PARSE_LEVEL;
223
224 push @EXPORT_OK, qw($CMDLINE_EMPTY_TO_WILDCARD);
225 push @{$EXPORT_TAGS{"cmdline_parse_dumpspecs_flags"}}, qw($CMDLINE_EMPTY_TO_WILDCARD);
226
227 $_cmdline_parse_dumpspecs_flags_VALUES{"CMDLINE_EMPTY_TO_WILDCARD"} = $CMDLINE_EMPTY_TO_WILDCARD;
228
229 push @EXPORT_OK, qw(header_matches_dumpspecs);
230 1;