d7589922369dab8c0b83589e73734d54f7997fa6
[debian/amanda] / perl / Amanda / Config.swg
1 /*
2  * Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 as published
6  * by the Free Software Foundation.
7  *
8  * This program 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 General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16  *
17  * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
19  */
20
21 %module "Amanda::Config"
22 %include "amglue/amglue.swg"
23 %include "exception.i"
24
25 %include "Amanda/Config.pod"
26
27 %{
28 #include "conffile.h"
29 %}
30
31 /*
32  * Parameter access
33 */
34
35 /* All of the CNF_ flags from conffile.h */
36
37 amglue_add_enum_tag_fns(confparm_key);
38 amglue_add_constant(CNF_ORG, confparm_key);
39 amglue_add_constant(CNF_CONF, confparm_key);
40 amglue_add_constant(CNF_INDEX_SERVER, confparm_key);
41 amglue_add_constant(CNF_TAPE_SERVER, confparm_key);
42 amglue_add_constant(CNF_AUTH, confparm_key);
43 amglue_add_constant(CNF_SSH_KEYS, confparm_key);
44 amglue_add_constant(CNF_AMANDAD_PATH, confparm_key);
45 amglue_add_constant(CNF_CLIENT_USERNAME, confparm_key);
46 amglue_add_constant(CNF_CLIENT_PORT, confparm_key);
47 amglue_add_constant(CNF_GNUTAR_LIST_DIR, confparm_key);
48 amglue_add_constant(CNF_AMANDATES, confparm_key);
49 amglue_add_constant(CNF_MAILER, confparm_key);
50 amglue_add_constant(CNF_MAILTO, confparm_key);
51 amglue_add_constant(CNF_DUMPUSER, confparm_key);
52 amglue_add_constant(CNF_TAPEDEV, confparm_key);
53 amglue_add_constant(CNF_DEVICE_PROPERTY, confparm_key);
54 amglue_add_constant(CNF_PROPERTY, confparm_key);
55 amglue_add_constant(CNF_CHANGERDEV, confparm_key);
56 amglue_add_constant(CNF_CHANGERFILE, confparm_key);
57 amglue_add_constant(CNF_LABELSTR, confparm_key);
58 amglue_add_constant(CNF_AUTOLABEL, confparm_key);
59 amglue_add_constant(CNF_TAPELIST, confparm_key);
60 amglue_add_constant(CNF_DISKFILE, confparm_key);
61 amglue_add_constant(CNF_INFOFILE, confparm_key);
62 amglue_add_constant(CNF_LOGDIR, confparm_key);
63 amglue_add_constant(CNF_INDEXDIR, confparm_key);
64 amglue_add_constant(CNF_TAPETYPE, confparm_key);
65 amglue_add_constant(CNF_DUMPCYCLE, confparm_key);
66 amglue_add_constant(CNF_RUNSPERCYCLE, confparm_key);
67 amglue_add_constant(CNF_TAPECYCLE, confparm_key);
68 amglue_add_constant(CNF_NETUSAGE, confparm_key);
69 amglue_add_constant(CNF_INPARALLEL, confparm_key);
70 amglue_add_constant(CNF_DUMPORDER, confparm_key);
71 amglue_add_constant(CNF_BUMPPERCENT, confparm_key);
72 amglue_add_constant(CNF_BUMPSIZE, confparm_key);
73 amglue_add_constant(CNF_BUMPMULT, confparm_key);
74 amglue_add_constant(CNF_BUMPDAYS, confparm_key);
75 amglue_add_constant(CNF_TPCHANGER, confparm_key);
76 amglue_add_constant(CNF_RUNTAPES, confparm_key);
77 amglue_add_constant(CNF_MAXDUMPS, confparm_key);
78 amglue_add_constant(CNF_ETIMEOUT, confparm_key);
79 amglue_add_constant(CNF_DTIMEOUT, confparm_key);
80 amglue_add_constant(CNF_CTIMEOUT, confparm_key);
81 amglue_add_constant(CNF_TAPEBUFS, confparm_key);
82 amglue_add_constant(CNF_DEVICE_OUTPUT_BUFFER_SIZE, confparm_key);
83 amglue_add_constant(CNF_PRINTER, confparm_key);
84 amglue_add_constant(CNF_AUTOFLUSH, confparm_key);
85 amglue_add_constant(CNF_RESERVE, confparm_key);
86 amglue_add_constant(CNF_MAXDUMPSIZE, confparm_key);
87 amglue_add_constant(CNF_COLUMNSPEC, confparm_key);
88 amglue_add_constant(CNF_AMRECOVER_DO_FSF, confparm_key);
89 amglue_add_constant(CNF_AMRECOVER_CHECK_LABEL, confparm_key);
90 amglue_add_constant(CNF_AMRECOVER_CHANGER, confparm_key);
91 amglue_add_constant(CNF_TAPERALGO, confparm_key);
92 amglue_add_constant(CNF_FLUSH_THRESHOLD_DUMPED, confparm_key);
93 amglue_add_constant(CNF_FLUSH_THRESHOLD_SCHEDULED, confparm_key);
94 amglue_add_constant(CNF_TAPERFLUSH, confparm_key);
95 amglue_add_constant(CNF_DISPLAYUNIT, confparm_key);
96 amglue_add_constant(CNF_KRB5KEYTAB, confparm_key);
97 amglue_add_constant(CNF_KRB5PRINCIPAL, confparm_key);
98 amglue_add_constant(CNF_LABEL_NEW_TAPES, confparm_key);
99 amglue_add_constant(CNF_USETIMESTAMPS, confparm_key);
100 amglue_add_constant(CNF_REP_TRIES, confparm_key);
101 amglue_add_constant(CNF_CONNECT_TRIES, confparm_key);
102 amglue_add_constant(CNF_REQ_TRIES, confparm_key);
103 amglue_add_constant(CNF_DEBUG_AMANDAD, confparm_key);
104 amglue_add_constant(CNF_DEBUG_RECOVERY, confparm_key);
105 amglue_add_constant(CNF_DEBUG_AMIDXTAPED, confparm_key);
106 amglue_add_constant(CNF_DEBUG_AMINDEXD, confparm_key);
107 amglue_add_constant(CNF_DEBUG_AMRECOVER, confparm_key);
108 amglue_add_constant(CNF_DEBUG_AUTH, confparm_key);
109 amglue_add_constant(CNF_DEBUG_EVENT, confparm_key);
110 amglue_add_constant(CNF_DEBUG_HOLDING, confparm_key);
111 amglue_add_constant(CNF_DEBUG_PROTOCOL, confparm_key);
112 amglue_add_constant(CNF_DEBUG_PLANNER, confparm_key);
113 amglue_add_constant(CNF_DEBUG_DRIVER, confparm_key);
114 amglue_add_constant(CNF_DEBUG_DUMPER, confparm_key);
115 amglue_add_constant(CNF_DEBUG_CHUNKER, confparm_key);
116 amglue_add_constant(CNF_DEBUG_TAPER, confparm_key);
117 amglue_add_constant(CNF_DEBUG_SELFCHECK, confparm_key);
118 amglue_add_constant(CNF_DEBUG_SENDSIZE, confparm_key);
119 amglue_add_constant(CNF_DEBUG_SENDBACKUP, confparm_key);
120 amglue_add_constant(CNF_RESERVED_UDP_PORT, confparm_key);
121 amglue_add_constant(CNF_RESERVED_TCP_PORT, confparm_key);
122 amglue_add_constant(CNF_UNRESERVED_TCP_PORT, confparm_key);
123 amglue_add_constant(CNF_HOLDINGDISK, confparm_key);
124 amglue_add_constant(CNF_SEND_AMREPORT_ON, confparm_key);
125 amglue_copy_to_tag(confparm_key, getconf);
126
127 amglue_add_enum_tag_fns(tapetype_key);
128 amglue_add_constant(TAPETYPE_COMMENT, tapetype_key);
129 amglue_add_constant(TAPETYPE_LBL_TEMPL, tapetype_key);
130 amglue_add_constant(TAPETYPE_BLOCKSIZE, tapetype_key);
131 amglue_add_constant(TAPETYPE_READBLOCKSIZE, tapetype_key);
132 amglue_add_constant(TAPETYPE_LENGTH, tapetype_key);
133 amglue_add_constant(TAPETYPE_FILEMARK, tapetype_key);
134 amglue_add_constant(TAPETYPE_SPEED, tapetype_key);
135 amglue_add_constant(TAPETYPE_FILE_PAD, tapetype_key);
136 amglue_copy_to_tag(tapetype_key, getconf);
137
138 amglue_add_enum_tag_fns(dumptype_key);
139 amglue_add_constant(DUMPTYPE_COMMENT, dumptype_key);
140 amglue_add_constant(DUMPTYPE_PROGRAM, dumptype_key);
141 amglue_add_constant(DUMPTYPE_SRVCOMPPROG, dumptype_key);
142 amglue_add_constant(DUMPTYPE_CLNTCOMPPROG, dumptype_key);
143 amglue_add_constant(DUMPTYPE_SRV_ENCRYPT, dumptype_key);
144 amglue_add_constant(DUMPTYPE_CLNT_ENCRYPT, dumptype_key);
145 amglue_add_constant(DUMPTYPE_AMANDAD_PATH, dumptype_key);
146 amglue_add_constant(DUMPTYPE_CLIENT_USERNAME, dumptype_key);
147 amglue_add_constant(DUMPTYPE_CLIENT_PORT, dumptype_key);
148 amglue_add_constant(DUMPTYPE_SSH_KEYS, dumptype_key);
149 amglue_add_constant(DUMPTYPE_AUTH, dumptype_key);
150 amglue_add_constant(DUMPTYPE_EXCLUDE, dumptype_key);
151 amglue_add_constant(DUMPTYPE_INCLUDE, dumptype_key);
152 amglue_add_constant(DUMPTYPE_PRIORITY, dumptype_key);
153 amglue_add_constant(DUMPTYPE_DUMPCYCLE, dumptype_key);
154 amglue_add_constant(DUMPTYPE_MAXDUMPS, dumptype_key);
155 amglue_add_constant(DUMPTYPE_MAXPROMOTEDAY, dumptype_key);
156 amglue_add_constant(DUMPTYPE_BUMPPERCENT, dumptype_key);
157 amglue_add_constant(DUMPTYPE_BUMPSIZE, dumptype_key);
158 amglue_add_constant(DUMPTYPE_BUMPDAYS, dumptype_key);
159 amglue_add_constant(DUMPTYPE_BUMPMULT, dumptype_key);
160 amglue_add_constant(DUMPTYPE_STARTTIME, dumptype_key);
161 amglue_add_constant(DUMPTYPE_STRATEGY, dumptype_key);
162 amglue_add_constant(DUMPTYPE_ESTIMATELIST, dumptype_key);
163 amglue_add_constant(DUMPTYPE_COMPRESS, dumptype_key);
164 amglue_add_constant(DUMPTYPE_ENCRYPT, dumptype_key);
165 amglue_add_constant(DUMPTYPE_SRV_DECRYPT_OPT, dumptype_key);
166 amglue_add_constant(DUMPTYPE_CLNT_DECRYPT_OPT, dumptype_key);
167 amglue_add_constant(DUMPTYPE_COMPRATE, dumptype_key);
168 amglue_add_constant(DUMPTYPE_TAPE_SPLITSIZE, dumptype_key);
169 amglue_add_constant(DUMPTYPE_FALLBACK_SPLITSIZE, dumptype_key);
170 amglue_add_constant(DUMPTYPE_SPLIT_DISKBUFFER, dumptype_key);
171 amglue_add_constant(DUMPTYPE_RECORD, dumptype_key);
172 amglue_add_constant(DUMPTYPE_SKIP_INCR, dumptype_key);
173 amglue_add_constant(DUMPTYPE_SKIP_FULL, dumptype_key);
174 amglue_add_constant(DUMPTYPE_HOLDINGDISK, dumptype_key);
175 amglue_add_constant(DUMPTYPE_KENCRYPT, dumptype_key);
176 amglue_add_constant(DUMPTYPE_IGNORE, dumptype_key);
177 amglue_add_constant(DUMPTYPE_INDEX, dumptype_key);
178 amglue_add_constant(DUMPTYPE_APPLICATION, dumptype_key);
179 amglue_add_constant(DUMPTYPE_SCRIPTLIST, dumptype_key);
180 amglue_add_constant(DUMPTYPE_PROPERTY, dumptype_key);
181 amglue_add_constant(DUMPTYPE_DATA_PATH, dumptype_key);
182 amglue_copy_to_tag(dumptype_key, getconf);
183
184 amglue_add_enum_tag_fns(interface_key);
185 amglue_add_constant(INTER_COMMENT, interface_key);
186 amglue_add_constant(INTER_MAXUSAGE, interface_key);
187 amglue_copy_to_tag(interface_key, getconf);
188
189 amglue_add_enum_tag_fns(holdingdisk_key);
190 amglue_add_constant(HOLDING_COMMENT, holdingdisk_key);
191 amglue_add_constant(HOLDING_DISKDIR, holdingdisk_key);
192 amglue_add_constant(HOLDING_DISKSIZE, holdingdisk_key);
193 amglue_add_constant(HOLDING_CHUNKSIZE, holdingdisk_key);
194 amglue_copy_to_tag(holdingdisk_key, getconf);
195
196 amglue_add_enum_tag_fns(application_key);
197 amglue_add_constant(APPLICATION_COMMENT, application_key);
198 amglue_add_constant(APPLICATION_PLUGIN, application_key);
199 amglue_add_constant(APPLICATION_PROPERTY, application_key);
200 amglue_copy_to_tag(application_key, getconf);
201
202 amglue_add_enum_tag_fns(pp_script_key);
203 amglue_add_constant(PP_SCRIPT_COMMENT, pp_script_key);
204 amglue_add_constant(PP_SCRIPT_PLUGIN, pp_script_key);
205 amglue_add_constant(PP_SCRIPT_PROPERTY, pp_script_key);
206 amglue_add_constant(PP_SCRIPT_EXECUTE_ON, pp_script_key);
207 amglue_add_constant(PP_SCRIPT_EXECUTE_WHERE, pp_script_key);
208 amglue_add_constant(PP_SCRIPT_ORDER, pp_script_key);
209 amglue_copy_to_tag(pp_script_key, getconf);
210
211 amglue_add_enum_tag_fns(device_config_key);
212 amglue_add_constant(DEVICE_CONFIG_COMMENT, device_config_key);
213 amglue_add_constant(DEVICE_CONFIG_TAPEDEV, device_config_key);
214 amglue_add_constant(DEVICE_CONFIG_DEVICE_PROPERTY, device_config_key);
215 amglue_copy_to_tag(device_config_key, getconf);
216
217 amglue_add_enum_tag_fns(changer_config_key);
218 amglue_add_constant(CHANGER_CONFIG_COMMENT, changer_config_key);
219 amglue_add_constant(CHANGER_CONFIG_TAPEDEV, changer_config_key);
220 amglue_add_constant(CHANGER_CONFIG_TPCHANGER, changer_config_key);
221 amglue_add_constant(CHANGER_CONFIG_CHANGERDEV, changer_config_key);
222 amglue_add_constant(CHANGER_CONFIG_CHANGERFILE, changer_config_key);
223 amglue_add_constant(CHANGER_CONFIG_PROPERTY, changer_config_key);
224 amglue_add_constant(CHANGER_CONFIG_DEVICE_PROPERTY, changer_config_key);
225 amglue_copy_to_tag(changer_config_key, getconf);
226
227 /*
228  * Various enumerated conftypes
229  */
230
231 amglue_add_enum_tag_fns(dump_holdingdisk_t);
232 amglue_add_constant(HOLD_NEVER, dump_holdingdisk_t);
233 amglue_add_constant(HOLD_AUTO, dump_holdingdisk_t);
234 amglue_add_constant(HOLD_REQUIRED, dump_holdingdisk_t);
235 amglue_copy_to_tag(dump_holdingdisk_t, getconf);
236
237 amglue_add_enum_tag_fns(comp_t);
238 amglue_add_constant(COMP_NONE, comp_t);
239 amglue_add_constant(COMP_FAST, comp_t);
240 amglue_add_constant(COMP_BEST, comp_t);
241 amglue_add_constant(COMP_CUST, comp_t);
242 amglue_add_constant(COMP_SERVER_FAST, comp_t);
243 amglue_add_constant(COMP_SERVER_BEST, comp_t);
244 amglue_add_constant(COMP_SERVER_CUST, comp_t);
245 amglue_copy_to_tag(comp_t, getconf);
246
247 amglue_add_enum_tag_fns(encrypt_t);
248 amglue_add_constant(ENCRYPT_NONE, encrypt_t);
249 amglue_add_constant(ENCRYPT_CUST, encrypt_t);
250 amglue_add_constant(ENCRYPT_SERV_CUST, encrypt_t);
251 amglue_copy_to_tag(encrypt_t, getconf);
252
253 amglue_add_enum_tag_fns(strategy_t);
254 amglue_add_constant(DS_SKIP, strategy_t);
255 amglue_add_constant(DS_STANDARD, strategy_t);
256 amglue_add_constant(DS_NOFULL, strategy_t);
257 amglue_add_constant(DS_NOINC, strategy_t);
258 amglue_add_constant(DS_4, strategy_t);
259 amglue_add_constant(DS_5, strategy_t);
260 amglue_add_constant(DS_HANOI, strategy_t);
261 amglue_add_constant(DS_INCRONLY, strategy_t);
262 amglue_copy_to_tag(strategy_t, getconf);
263
264 amglue_add_enum_tag_fns(estimate_t);
265 amglue_add_constant(ES_CLIENT, estimate_t);
266 amglue_add_constant(ES_SERVER, estimate_t);
267 amglue_add_constant(ES_CALCSIZE, estimate_t);
268 amglue_copy_to_tag(estimate_t, getconf);
269
270 amglue_add_enum_tag_fns(autolabel_enum_t);
271 amglue_add_constant(AL_OTHER_CONFIG, autolabel_enum_t);
272 amglue_add_constant(AL_NON_AMANDA, autolabel_enum_t);
273 amglue_add_constant(AL_VOLUME_ERROR, autolabel_enum_t);
274 amglue_add_constant(AL_EMPTY, autolabel_enum_t);
275 amglue_copy_to_tag(autolabel_enum_t, getconf);
276
277 amglue_add_enum_tag_fns(taperalgo_t);
278 amglue_add_constant(ALGO_FIRST, taperalgo_t);
279 amglue_add_constant(ALGO_FIRSTFIT, taperalgo_t);
280 amglue_add_constant(ALGO_LARGEST, taperalgo_t);
281 amglue_add_constant(ALGO_LARGESTFIT, taperalgo_t);
282 amglue_add_constant(ALGO_SMALLEST, taperalgo_t);
283 amglue_add_constant(ALGO_LAST, taperalgo_t);
284 amglue_copy_to_tag(taperalgo_t, getconf);
285
286 amglue_add_enum_tag_fns(execute_on_t);
287 amglue_add_constant(EXECUTE_ON_PRE_DLE_AMCHECK, execute_on_t);
288 amglue_add_constant(EXECUTE_ON_PRE_HOST_AMCHECK, execute_on_t);
289 amglue_add_constant(EXECUTE_ON_POST_DLE_AMCHECK, execute_on_t);
290 amglue_add_constant(EXECUTE_ON_POST_HOST_AMCHECK, execute_on_t);
291 amglue_add_constant(EXECUTE_ON_PRE_DLE_ESTIMATE, execute_on_t);
292 amglue_add_constant(EXECUTE_ON_PRE_HOST_ESTIMATE, execute_on_t);
293 amglue_add_constant(EXECUTE_ON_POST_DLE_ESTIMATE, execute_on_t);
294 amglue_add_constant(EXECUTE_ON_POST_HOST_ESTIMATE, execute_on_t);
295 amglue_add_constant(EXECUTE_ON_PRE_DLE_BACKUP, execute_on_t);
296 amglue_add_constant(EXECUTE_ON_PRE_HOST_BACKUP, execute_on_t);
297 amglue_add_constant(EXECUTE_ON_POST_DLE_BACKUP, execute_on_t);
298 amglue_add_constant(EXECUTE_ON_POST_HOST_BACKUP, execute_on_t);
299 amglue_copy_to_tag(execute_on_t, getconf);
300
301 amglue_add_enum_tag_fns(send_amreport_on_t);
302 amglue_add_constant(SEND_AMREPORT_ALL, send_amreport_on_t);
303 amglue_add_constant(SEND_AMREPORT_STRANGE, send_amreport_on_t);
304 amglue_add_constant(SEND_AMREPORT_ERROR, send_amreport_on_t);
305 amglue_add_constant(SEND_AMREPORT_NEVER, send_amreport_on_t);
306 amglue_copy_to_tag(send_amreport_on_t, getconf);
307
308 amglue_add_enum_tag_fns(data_path_t);
309 amglue_add_constant(DATA_PATH_AMANDA, data_path_t);
310 amglue_add_constant(DATA_PATH_DIRECTTCP, data_path_t);
311 amglue_copy_to_tag(data_path_t, getconf);
312
313 /*
314  * val_t typemaps
315  */
316
317 /* Typemap to convert a val_t, the union in which config values are
318  * stored, to a Perl value of the appropriate type.  This converts:
319  *  - CONFTYPE_SIZE, CONFTYPE_INT, CONFTYPE_INT64,
320  *    CONFTYPE_BOOLEAN -> IV
321  *  - CONFTYPE_REAL -> NV
322  *  - CONFTYPE_STR, CONFTYPE_IDENT -> PV
323  *  - CONFTYPE_APPLICATION -> PV
324  *  - CONFTYPE_TIME -> IV (epoch timestamp)
325  *  - CONFTYPE_COMPRESS, CONFTYPE_ENCRYPT, CONFTYPE_ESTIMATELIST, CONFTYPE_STRATEGY,
326  *    CONFTYPE_TAPERALGO, CONFTYPE_PRIORITY, CONFTYPE_HOLDING, CONFTYPE_EXECUTE_ON,
327  *    CONFTYPE_EXECUTE_WHERE, CONFTYPE_SEND_AMREPORT_ON,
328  *    CONFTYPE_DATA_PATH -> IV (enums)
329  *  - CONFTYPE_RATE -> list of two NVs
330  *  - CONFTYPE_INTRANGE -> list of two IVs
331  *  - CONFTYPE_EXINCLUDE -> hashref with keys 'list' (listref), 'file' (listref),
332  *    and 'optional' (int)
333  *  - CONFTYPE_PROPLIST -> hashref of hashref with keys 'append' (IV), 'priority' (IV),
334  *                                                      'values' (listref)
335  */
336 %typemap (out) val_t * {
337     if (!$1) {
338         $result = &PL_sv_undef;
339         argvi++;
340     } else {
341         switch ($1->type) {
342             case CONFTYPE_RATE: {
343                 $result= sv_newmortal();
344                 sv_setnv($result, val_t__rate($1)[0]);
345                 argvi++;
346
347                 $result= sv_newmortal();
348                 sv_setnv($result, val_t__rate($1)[1]);
349                 argvi++;
350                 break;
351             }
352
353             case CONFTYPE_INTRANGE: {
354                 $result= sv_newmortal();
355                 sv_setiv($result, val_t__intrange($1)[0]);
356                 argvi++;
357
358                 $result= sv_newmortal();
359                 sv_setiv($result, val_t__intrange($1)[1]);
360                 argvi++;
361                 break;
362             }
363
364             case CONFTYPE_EXINCLUDE: {
365                 /* exincludes are represented in perl as {
366                  *      'list' : [ 'list1', 'list2', ..],
367                  *      'file' : [ 'file1', 'file2', ..],
368                  *      'optional' : 1,
369                  * }
370                  */
371                 exinclude_t *ei = &val_t__exinclude($1);
372                 AV *list_entries = (AV *)sv_2mortal((SV *)newAV());
373                 AV *file_entries = (AV *)sv_2mortal((SV *)newAV());
374                 SV *optional = sv_newmortal();
375                 HV *hv;
376                 sle_t *iter;
377
378                 /* first set up each of the hash values */
379
380                 if (ei->sl_list) {
381                     for (iter = ei->sl_list->first; iter != NULL; iter = iter->next) {
382                         av_push(list_entries, newSVpv(iter->name, 0));
383                     }
384                 }
385
386                 if(ei->sl_file) {
387                     for (iter = ei->sl_file->first; iter != NULL; iter = iter->next) {
388                         av_push(file_entries, newSVpv(iter->name, 0));
389                     }
390                 }
391
392                 sv_setiv(optional, ei->optional);
393
394                 /* now build the hash */
395                 hv = (HV *)sv_2mortal((SV *)newHV());
396                 
397                 hv_store(hv, "file", 4, newRV((SV *)file_entries), 0);
398                 hv_store(hv, "list", 4, newRV((SV *)list_entries), 0);
399                 hv_store(hv, "optional", 8, optional, 0);
400                 SvREFCNT_inc(optional);
401
402                 $result = sv_2mortal(newRV((SV *)hv));
403                 argvi++;
404                 break;
405             }
406
407             case CONFTYPE_PROPLIST:
408                 $result = sv_2mortal(g_hash_table_to_hashref_property(val_t__proplist($1)));
409                 argvi++;
410                 break;
411
412             case CONFTYPE_SIZE:
413                 SP += argvi; PUTBACK;
414                 $result = sv_2mortal(amglue_newSVi64(val_t__size($1)));
415                 SPAGAIN; SP -= argvi; argvi++;
416                 break;
417
418             case CONFTYPE_INT64:
419                 SP += argvi; PUTBACK;
420                 $result = sv_2mortal(amglue_newSVi64(val_t__int64($1)));
421                 SPAGAIN; SP -= argvi; argvi++;
422                 break;
423
424             case CONFTYPE_BOOLEAN:          /* all same as INT.. */
425             case CONFTYPE_COMPRESS:
426             case CONFTYPE_ENCRYPT:
427             case CONFTYPE_STRATEGY:
428             case CONFTYPE_TAPERALGO:
429             case CONFTYPE_PRIORITY:
430             case CONFTYPE_HOLDING:
431             case CONFTYPE_EXECUTE_ON:
432             case CONFTYPE_EXECUTE_WHERE:
433             case CONFTYPE_SEND_AMREPORT_ON:
434             case CONFTYPE_DATA_PATH:
435             case CONFTYPE_INT:
436                 SP += argvi; PUTBACK;
437                 $result = sv_2mortal(amglue_newSVi64(val_t__int($1)));
438                 SPAGAIN; SP -= argvi; argvi++;
439                 break;
440
441            case CONFTYPE_ESTIMATELIST: {
442                 AV *elist = newAV();
443                 estimatelist_t el;
444                 for (el=val_t__estimatelist($1); el != NULL; el = el->next) {
445                     av_push(elist, newSVuv(GPOINTER_TO_INT(el->data)));
446                 }
447                 $result = sv_2mortal(newRV_noinc((SV *)elist));
448                 argvi++;
449                 break;
450             }
451
452             case CONFTYPE_TIME:
453                 SP += argvi; PUTBACK;
454                 $result = sv_2mortal(amglue_newSVi64(val_t__time($1)));
455                 SPAGAIN; SP -= argvi; argvi++;
456                 break;
457
458             case CONFTYPE_REAL:
459                 $result = sv_newmortal();
460                 sv_setnv($result, val_t__real($1));
461                 argvi++;
462                 break;
463
464             case CONFTYPE_IDENT:            /* same as STRING */
465             case CONFTYPE_STR:
466             case CONFTYPE_APPLICATION:
467                 $result = sv_newmortal();
468                 sv_setpv($result, val_t__str($1));
469                 argvi++;
470                 break;
471
472             case CONFTYPE_IDENTLIST: {
473                 AV *ilist = newAV();
474
475                 identlist_t il;
476                 for (il=val_t__identlist($1); il != NULL; il = il->next) {
477                     av_push(ilist, newSVpv((char *)il->data, 0));
478                 }
479
480                 $result = sv_2mortal(newRV_noinc((SV *)ilist));
481                 argvi++;
482                 break;
483             }
484
485             case CONFTYPE_AUTOLABEL: {
486                 autolabel_t *autolabel = &val_t__autolabel($1);
487                 HV *hv;
488
489                 /* now build the hash */
490                 hv = (HV *)sv_2mortal((SV *)newHV());
491                 hv_store(hv, "template", 8,
492                         (autolabel->template)? newSVpv(autolabel->template, 0) : newSV(0),
493                         0);
494                 hv_store(hv, "other_config", 12,
495                         (autolabel->autolabel & AL_OTHER_CONFIG)? &PL_sv_yes : &PL_sv_no,
496                         0);
497                 hv_store(hv, "non_amanda", 10,
498                         (autolabel->autolabel & AL_NON_AMANDA)? &PL_sv_yes : &PL_sv_no,
499                         0);
500                 hv_store(hv, "volume_error", 12,
501                         (autolabel->autolabel & AL_VOLUME_ERROR)? &PL_sv_yes : &PL_sv_no,
502                         0);
503                 hv_store(hv, "empty", 5,
504                         (autolabel->autolabel & AL_EMPTY)? &PL_sv_yes : &PL_sv_no,
505                         0);
506
507                 $result = sv_2mortal(newRV((SV *)hv));
508                 argvi++;
509                 break;
510             }
511
512             /* No match yet -> not one of the "complex" types */
513             default:
514                 SWIG_exception(SWIG_TypeError, "Unknown val_t conftype");
515                 break;
516         }
517     }
518 }
519
520 /* Typemap for the return value of getconf_list; this assumes that
521  * the GSList contains strings, and that it should be freed; both
522  * are true for getconf_list.
523  */
524 %typemap (out) GSList * {
525     GSList *it = $1;
526
527     while (it) {
528         $result = sv_2mortal(newSVpv(it->data, 0));
529         argvi++;
530         it = it->next;
531     }
532
533     g_slist_free($1);
534 }
535
536 /* typedef and typemap for getconf_byname_strs, which is like getconf_byname, 
537  * but converts the result with val_t_dispaly_strs
538  */
539 %typemap (out) val_t_strs {
540     char **it = $1;
541
542     while (it && *it) {
543         $result = sv_2mortal(newSVpv(*it, 0));
544         argvi++;
545         it++;
546     }
547     g_strfreev($1);
548 }
549
550 data_path_t data_path_from_string(char *data);
551
552 val_t *getconf(confparm_key key);
553 gboolean getconf_seen(confparm_key key);
554 int getconf_linenum(confparm_key key);
555 val_t *getconf_byname(char *key);
556 GSList *getconf_list(char *listname);
557 %inline %{
558 typedef char **val_t_strs;
559 val_t_strs getconf_byname_strs(char *key, int str_needs_quotes) {
560     val_t *val = getconf_byname(key);
561     if (!val) return NULL;
562     return val_t_display_strs(val, str_needs_quotes);
563 }
564 %}
565
566 amglue_export_tag(getconf,
567     getconf getconf_seen getconf_linenum
568     getconf_byname getconf_byname_strs
569     getconf_list
570 );
571
572 tapetype_t *lookup_tapetype(char *identifier);
573 val_t *tapetype_getconf(tapetype_t *ttyp, tapetype_key key);
574 char *tapetype_name(tapetype_t *ttyp);
575 gboolean tapetype_seen(tapetype_t *ttyp, tapetype_key key);
576 amglue_export_tag(getconf,
577     lookup_tapetype tapetype_getconf tapetype_name
578     tapetype_seen tapetype_seen
579 );
580
581 dumptype_t *lookup_dumptype(char *identifier);
582 val_t *dumptype_getconf(dumptype_t *dtyp, dumptype_key key);
583 char *dumptype_name(dumptype_t *dtyp);
584 gboolean dumptype_seen(dumptype_t *dtyp, dumptype_key key);
585 amglue_export_tag(getconf,
586     lookup_dumptype dumptype_getconf dumptype_name
587     dumptype_seen dumptype_seen
588 );
589
590 interface_t *lookup_interface(char *identifier);
591 val_t *interface_getconf(interface_t *iface, interface_key key);
592 char *interface_name(interface_t *iface);
593 gboolean interface_seen(interface_t *iface, interface_key key);
594 amglue_export_tag(getconf,
595     lookup_interface interface_getconf interface_name
596     interface_seen interface_seen
597 );
598
599 holdingdisk_t *lookup_holdingdisk(char *identifier);
600 GSList *getconf_holdingdisks(void);
601 val_t *holdingdisk_getconf(holdingdisk_t *hdisk, holdingdisk_key key);
602 char *holdingdisk_name(holdingdisk_t *hdisk);
603 gboolean holdingdisk_seen(holdingdisk_t *hdisk, holdingdisk_key key);
604 amglue_export_tag(getconf,
605     lookup_holdingdisk holdingdisk_getconf holdingdisk_name
606     getconf_holdingdisks
607     holdingdisk_seen holdingdisk_seen
608 );
609
610 application_t *lookup_application(char *identifier);
611 val_t *application_getconf(application_t *app, application_key key);
612 char *application_name(application_t *app);
613 gboolean application_seen(application_t *app, application_key key);
614 amglue_export_tag(getconf,
615     lookup_application application_getconf application_name
616     application_seen application_seen
617 );
618
619 pp_script_t *lookup_pp_script(char *identifier);
620 val_t *pp_script_getconf(pp_script_t *pps, pp_script_key key);
621 char *pp_script_name(pp_script_t *pps);
622 gboolean pp_script_seen(pp_script_t *app, pp_script_key key);
623 amglue_export_tag(getconf,
624     lookup_pp_script pp_script_getconf pp_script_name
625     pp_script_seen pp_script_seen
626 );
627
628 device_config_t *lookup_device_config(char *identifier);
629 val_t *device_config_getconf(device_config_t *pps, device_config_key key);
630 char *device_config_name(device_config_t *pps);
631 gboolean device_config_seen(device_config_t *app, device_config_key key);
632 amglue_export_tag(getconf,
633     lookup_device_config device_config_getconf device_config_name
634     device_config_seen device_config_seen
635 );
636
637 changer_config_t *lookup_changer_config(char *identifier);
638 val_t *changer_config_getconf(changer_config_t *pps, changer_config_key key);
639 char *changer_config_name(changer_config_t *pps);
640 gboolean changer_config_seen(changer_config_t *app, changer_config_key key);
641 amglue_export_tag(getconf,
642     lookup_changer_config changer_config_getconf changer_config_name
643     changer_config_seen changer_config_seen
644 );
645
646 %perlcode %{
647 # only those keys with a value of '1' should be shown; the
648 # others are deprecated
649 our %subsection_names = (
650     "tapetype" => 1,
651     "dumptype" => 1,
652     "interface" => 1,
653     "holdingdisk" => 1,
654     "application" => 1,
655     "script" => 1,
656     "application-tool" => 0,
657     "script-tool" => 0,
658     "device" => 1,
659     "changer" => 1,
660 );
661 %}
662 amglue_export_tag(getconf, %subsection_names);
663
664 long int getconf_unit_divisor(void);
665
666 extern int debug_amandad;
667 extern int debug_recovery;
668 extern int debug_amidxtaped;
669 extern int debug_amindexd;
670 extern int debug_amrecover;
671 extern int debug_auth;
672 extern int debug_event;
673 extern int debug_holding;
674 extern int debug_protocol;
675 extern int debug_planner;
676 extern int debug_driver;
677 extern int debug_dumper;
678 extern int debug_chunker;
679 extern int debug_taper;
680 extern int debug_selfcheck;
681 extern int debug_sendsize;
682 extern int debug_sendbackup;
683 amglue_export_tag(getconf,
684     getconf_unit_divisor
685
686     $debug_amandad $debug_recovery $debug_amidxtaped $debug_amindexd $debug_amrecover
687     $debug_auth $debug_event $debug_holding $debug_protocol
688     $debug_planner $debug_driver $debug_dumper $debug_chunker
689     $debug_taper $debug_selfcheck $debug_sendsize $debug_sendbackup
690 );
691
692 /*
693  * Initialization
694  */
695
696 amglue_add_enum_tag_fns(cfgerr_level_t);
697 amglue_add_constant(CFGERR_OK, cfgerr_level_t);
698 amglue_add_constant(CFGERR_WARNINGS, cfgerr_level_t);
699 amglue_add_constant(CFGERR_ERRORS, cfgerr_level_t);
700 amglue_copy_to_tag(cfgerr_level_t, init);
701
702 amglue_add_flag_tag_fns(config_init_flags);
703 amglue_add_constant(CONFIG_INIT_EXPLICIT_NAME, config_init_flags);
704 amglue_add_constant(CONFIG_INIT_USE_CWD, config_init_flags);
705 amglue_add_constant(CONFIG_INIT_CLIENT, config_init_flags);
706 amglue_add_constant(CONFIG_INIT_OVERLAY, config_init_flags);
707 amglue_copy_to_tag(config_init_flags, init);
708
709 cfgerr_level_t config_init(config_init_flags flags,
710                      char *arg_config_name);
711 void config_uninit(void);
712 char **get_config_options(int first);
713 char *get_config_name(void);
714 char *get_config_dir(void);
715 char *get_config_filename(void);
716
717 void config_print_errors(void);
718 void config_clear_errors(void);
719
720 /* Typemap for config_errors' result parameter; this is a GSList of strings
721  * which should *not* be freed. */
722 %typemap(in, numinputs=0) GSList **ERRLIST (GSList *templist) {
723    templist = NULL;
724    $1 = &templist;
725 }
726
727 %typemap (argout) GSList **ERRLIST {
728     GSList *it = *$1;
729
730     while (it) {
731         $result = sv_2mortal(newSVpv(it->data, 0));
732         argvi++;
733         it = it->next;
734     }
735 }
736 cfgerr_level_t config_errors(GSList **ERRLIST);
737
738
739 config_overrides_t *new_config_overrides(int size_estimate);
740 void free_config_overrides(config_overrides_t *co);
741 void add_config_override(config_overrides_t *co,
742                          char *key,
743                          char *value);
744 void add_config_override_opt(config_overrides_t *co,
745                               char *optarg);
746 void set_config_overrides(config_overrides_t *co);
747
748 amglue_export_tag(init,
749     config_init config_uninit get_config_options
750     get_config_name get_config_dir get_config_filename
751     config_print_errors config_clear_errors config_errors
752     new_config_overrides free_config_overrides add_config_override
753     add_config_override_opt set_config_overrides
754 );
755
756 /*
757  * Miscellaneous
758  */
759
760 void dump_configuration(void);
761 %newobject config_dir_relative;
762 char *config_dir_relative(char *filename);
763 char *taperalgo2str(taperalgo_t taperalgo);
764 gint64 find_multiplier(char * casestr);
765
766 amglue_export_ok(
767     dump_configuration config_dir_relative taperalgo2str find_multiplier
768 );
769
770 %rename(C_string_to_boolean) string_to_boolean;
771 int string_to_boolean(const char *str);
772 %perlcode %{
773
774 sub string_to_boolean {
775     my ($str) = @_;
776     my $ret = C_string_to_boolean($str);
777     return undef unless $ret >= 0;
778     return $ret;
779 }
780
781 %}
782
783 amglue_export_ok(string_to_boolean);