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