2 * Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
22 %module "Amanda::Header"
23 %include "amglue/amglue.swg"
24 %include "exception.i"
26 %include "Amanda/Header.pod"
29 #include "fileheader.h"
32 amglue_add_enum_tag_fns(filetype_t);
33 amglue_add_constant(F_UNKNOWN, filetype_t);
34 amglue_add_constant(F_WEIRD, filetype_t);
35 amglue_add_constant(F_TAPESTART, filetype_t);
36 amglue_add_constant(F_TAPEEND, filetype_t);
37 amglue_add_constant(F_DUMPFILE, filetype_t);
38 amglue_add_constant(F_CONT_DUMPFILE, filetype_t);
39 amglue_add_constant(F_SPLIT_DUMPFILE, filetype_t);
40 amglue_add_constant(F_EMPTY, filetype_t);
41 amglue_copy_to_tag(filetype_t, constants);
43 typedef char string_t[STRMAX];
44 %typemap(memberin) string_t {
45 strncpy($1, $input, STRMAX);
46 if ($1[STRMAX-1] != '\0')
47 SWIG_exception(SWIG_ValueError, "String too large for Amanda::Header");
50 %rename(Header) dumpfile_t;
58 string_t encrypt_suffix;
59 string_t name; /* hostname or label */
64 string_t clntcompprog;
66 string_t clnt_encrypt;
68 string_t uncompress_cmd;
70 string_t srv_decrypt_opt;
71 string_t clnt_decrypt_opt;
72 string_t cont_filename;
76 int totalparts; /* -1 == UNKNOWN */
83 dumpfile_t *df = g_new(dumpfile_t, 1);
85 /* some default values */
96 /* the usual "cheater's typemap" */
97 %typemap(out) SV * "$result = $1; argvi++;";
98 SV *to_string(size_t min_size, size_t max_size) {
99 size_t size = min_size;
102 result = build_header(self, &size, max_size);
104 /* header didn't fit -> return undef; */
107 STRLEN strlen_size = (STRLEN)size;
109 g_assert((size_t)strlen_size == size); /* check for casting overflow */
110 sv = sv_2mortal(newSVpvn(result, (STRLEN)size));
116 void debug_dump(void) {
117 dump_dumpfile_t(self);
121 char *summary(void) {
122 return summarize_header(self);
128 static dumpfile_t *C_from_string(const char *string) {
129 dumpfile_t *result = g_new(dumpfile_t, 1);
130 parse_file_header(string, result, strlen(string));
137 # SWIG produces a sub-package for the Header "class", in this case named
138 # Amanda::Header::Header. For user convenience, we allow Amanda::Header->new(..) to
139 # do the same thing. This is a wrapper function, and not just a typeglob assignment,
140 # because we want to get the right blessing.
142 shift; # ignore class
143 Amanda::Header::Header->new(@_);
147 shift; # ignore class
148 return C_from_string(@_);
154 if ($self->{'dle_str'}) {
155 return Amanda::Header::HeaderXML->new($self->{'dle_str'});
161 package Amanda::Header::Header;
163 # point $hdr->matches_dumpspecs() to Amanda::Cmdline::header_matches_dumpspecs. When
164 # Amanda is built with --without-server, Amanda::Cmdline is missing, so this will fail.
165 # Note that this assumes the user has already use'd Amanda::Cmdline.
166 sub matches_dumpspecs {
167 Amanda::Cmdline::header_matches_dumpspecs(@_);
170 package Amanda::Header;
177 %rename(HeaderXML) dle_t;
181 int program_is_application_api;
183 estimatelist_t estimatelist;
188 levellist_t levellist;
194 char *srv_decrypt_opt;
195 char *clnt_decrypt_opt;
199 am_sl_t *exclude_file;
200 am_sl_t *exclude_list;
201 am_sl_t *include_file;
202 am_sl_t *include_list;
203 int exclude_optional;
204 int include_optional;
205 proplist_t application_property;
206 scriptlist_t scriptlist;
207 data_path_t data_path;
208 GSList *directtcp_list;
209 struct a_dle_s *next;
213 dle_t(char *dle_str) {
216 dle = amxml_parse_node_CHAR(dle_str, &errmsg);