Imported Upstream version 2.6.1p2
[debian/amanda] / perl / Amanda / Types.swg
1 /*
2  * Copyright (c) Zmanda, Inc.  All Rights Reserved.
3  *
4  * This library is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 2.1
6  * as published by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
11  * License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation,
15  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
16  *
17  * Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
18  * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19  */
20
21 %module "Amanda::Types"
22 %include "amglue/amglue.swg"
23 %include "exception.i"
24
25 %{
26 #include "fileheader.h"
27 %}
28
29 %perlcode %{
30 =head1 NAME
31
32 Amanda::Types - Amanda data structures that are shared by several modules
33
34 =head1 SYNOPSIS
35
36 This module includes several types which are not specific to any
37 single other module.
38
39 =head1 API STATUS
40
41 New structures may be added, but existing types are stable.
42
43 =head1 dumpfile_t
44
45 An in-memory representation of an Amanda header, with keys
46
47 =over
48
49 =item C<type>;
50
51 =item C<datestamp>;
52
53 =item C<dumplevel>;
54
55 =item C<compressed>;
56
57 =item C<encrypted>;
58
59 =item C<comp_suffix>;
60
61 =item C<encrypt_suffix>;
62
63 =item C<name> -- hostname or label;
64
65 =item C<disk>;
66
67 =item C<program>;
68
69 =item C<application>;
70
71 =item C<srvcompprog>;
72
73 =item C<clntcompprog>;
74
75 =item C<srv_encrypt>;
76
77 =item C<clnt_encrypt>;
78
79 =item C<recover_cmd>;
80
81 =item C<uncompress_cmd>;
82
83 =item C<encrypt_cmd>;
84
85 =item C<decrypt_cmd>;
86
87 =item C<srv_decrypt_opt>;
88
89 =item C<clnt_decrypt_opt>;
90
91 =item C<cont_filename>;
92
93 =itme C<dle_str>;
94
95 =item C<is_partial>;
96
97 =item C<partnum>;
98
99 =item C<totalparts> (-1 == UNKNOWN); and
100
101 =item C<blocksize>.
102
103 =back
104
105 where C<type> is one of the following constants, which are availble
106 for import in the tag C<:filetype_t>:
107
108 =over
109
110 =item C<F_UNKNOWN>;
111
112 =item C<F_WEIRD>;
113
114 =item C<F_TAPESTART>;
115
116 =item C<F_TAPEEND>;
117
118 =item C<F_DUMPFILE>;
119
120 =item C<F_CONT_DUMPFILE>;
121
122 =item C<F_SPLIT_DUMPFILE>; or
123
124 =item C<F_EMPTY>.
125
126 =back
127
128 NOTE: no methods are currently defined on C<dumpfile_t>; interfaces
129 can be written as needed.  A new dumpfile is created with
130
131     my $hdr = Amanda::Types::dumpfile_t->new();
132
133 =cut
134 %}
135
136 amglue_add_flag_tag_fns(filetype_t);
137 amglue_add_constant(F_UNKNOWN, filetype_t);
138 amglue_add_constant(F_WEIRD, filetype_t);
139 amglue_add_constant(F_TAPESTART, filetype_t);
140 amglue_add_constant(F_TAPEEND, filetype_t);
141 amglue_add_constant(F_DUMPFILE, filetype_t);
142 amglue_add_constant(F_CONT_DUMPFILE, filetype_t);
143 amglue_add_constant(F_SPLIT_DUMPFILE, filetype_t);
144 amglue_add_constant(F_EMPTY, filetype_t);
145
146 typedef char string_t[STRMAX];
147 %typemap(memberin) string_t {
148     strncpy($1, $input, STRMAX);
149     if ($1[STRMAX-1] != '\0')
150         SWIG_exception(SWIG_ValueError, "String too large for dumpfile_t");
151 }
152
153 typedef struct {
154
155     filetype_t type;
156     string_t datestamp;
157     int dumplevel;
158     int compressed;
159     int encrypted;
160     string_t comp_suffix;
161     string_t encrypt_suffix;
162     string_t name;      /* hostname or label */
163     string_t disk;
164     string_t program;
165     string_t application;
166     string_t srvcompprog;
167     string_t clntcompprog;
168     string_t srv_encrypt;
169     string_t clnt_encrypt;
170     string_t recover_cmd;
171     string_t uncompress_cmd;
172     string_t encrypt_cmd;
173     string_t decrypt_cmd;
174     string_t srv_decrypt_opt;
175     string_t clnt_decrypt_opt;
176     string_t cont_filename;
177     char *dle_str;
178     int is_partial;
179     int partnum;
180     int totalparts; /* -1 == UNKNOWN */
181     size_t blocksize;
182
183     %extend {
184         /* constructor */
185         dumpfile_t(void) {
186             dumpfile_t *df = malloc(sizeof(*df));
187             fh_init(df);
188             return df;
189         }
190
191         /* destructor */
192         ~dumpfile_t(void) {
193             free(self);
194         }
195     }
196 } dumpfile_t;
197
198 /* TODO: rename to dump_header */