ff235016ac4699231afbc37d451dc987c6856f6d
[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., 505 N Mathlida Ave, Suite 120
18  * Sunnyvale, CA 94085, 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 =over
47 =item C<type>;
48 =item C<datestamp>;
49 =item C<dumplevel>;
50 =item C<compressed>;
51 =item C<encrypted>;
52 =item C<comp_suffix>;
53 =item C<encrypt_suffix>;
54 =item C<name> -- hostname or label;
55 =item C<disk>;
56 =item C<program>;
57 =item C<dumper>;
58 =item C<srvcompprog>;
59 =item C<clntcompprog>;
60 =item C<srv_encrypt>;
61 =item C<clnt_encrypt>;
62 =item C<recover_cmd>;
63 =item C<uncompress_cmd>;
64 =item C<encrypt_cmd>;
65 =item C<decrypt_cmd>;
66 =item C<srv_decrypt_opt>;
67 =item C<clnt_decrypt_opt>;
68 =item C<cont_filename>;
69 =item C<is_partial>;
70 =item C<partnum>;
71 =item C<totalparts> (-1 == UNKNOWN); and
72 =item blocksize.
73 =back
74
75 where C<type> is one of the following constants, which are availble
76 for import in the tag C<:filetype_t>:
77 =over
78 =item C<F_UNKNOWN>;
79 =item C<F_WEIRD>;
80 =item C<F_TAPESTART>;
81 =item C<F_TAPEEND>;
82 =item C<F_DUMPFILE>;
83 =item C<F_CONT_DUMPFILE>;
84 =item C<F_SPLIT_DUMPFILE>; or
85 =item C<F_EMPTY>.
86 =back
87
88 NOTE: no methods are currently defined on C<dumpfile_t>; interfaces
89 can be written as needed.
90
91 =cut
92 %}
93
94 amglue_add_flag_tag_fns(filetype_t);
95 amglue_add_constant(F_UNKNOWN, filetype_t);
96 amglue_add_constant(F_WEIRD, filetype_t);
97 amglue_add_constant(F_TAPESTART, filetype_t);
98 amglue_add_constant(F_TAPEEND, filetype_t);
99 amglue_add_constant(F_DUMPFILE, filetype_t);
100 amglue_add_constant(F_CONT_DUMPFILE, filetype_t);
101 amglue_add_constant(F_SPLIT_DUMPFILE, filetype_t);
102 amglue_add_constant(F_EMPTY, filetype_t);
103
104 typedef char string_t[STRMAX];
105 %typemap(memberin) string_t {
106     strncpy($1, $input, STRMAX);
107     if ($1[STRMAX-1] != '\0')
108         SWIG_exception(SWIG_ValueError, "String too large for dumpfile_t");
109 }
110
111 typedef struct {
112
113     filetype_t type;
114     string_t datestamp;
115     int dumplevel;
116     int compressed;
117     int encrypted;
118     string_t comp_suffix;
119     string_t encrypt_suffix;
120     string_t name;      /* hostname or label */
121     string_t disk;
122     string_t program;
123     string_t dumper;
124     string_t srvcompprog;
125     string_t clntcompprog;
126     string_t srv_encrypt;
127     string_t clnt_encrypt;
128     string_t recover_cmd;
129     string_t uncompress_cmd;
130     string_t encrypt_cmd;
131     string_t decrypt_cmd;
132     string_t srv_decrypt_opt;
133     string_t clnt_decrypt_opt;
134     string_t cont_filename;
135     int is_partial;
136     int partnum;
137     int totalparts; /* -1 == UNKNOWN */
138     size_t blocksize;
139
140     %extend {
141         /* constructor */
142         dumpfile_t(void) {
143             dumpfile_t *df = malloc(sizeof(*df));
144             fh_init(df);
145             return df;
146         }
147
148         /* destructor */
149         ~dumpfile_t(void) {
150             free(self);
151         }
152     }
153 } dumpfile_t;
154
155 /* TODO: rename to dump_header */