2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-2000 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 * $Id: conffile.h,v 1.72 2006/07/26 15:17:37 martinea Exp $
30 * interface for config file reading code
38 /* Getting Configuration Values
39 * ============================
41 * Amanda configurations consist of a number of "global" parameters, as well as
42 * named subsections of several types. The global parameters are fetched with
43 * the getconf_CONFTYPE functions, keyed by a confparam_t constant (with prefix
44 * CNF_). The subsection parameters are fetched with SUBSEC_get_PARAM()
45 * macros, e.g., tapetype_get_blocksize(ttyp), where the argument comes from
46 * lookup_SUBSEC(), in this case lookup_tapetype(name).
51 * This module juggles two kinds of types: C types and conftypes. Conftypes include
52 * everything from integers through property lists, and are specific to the needs of
53 * the configuration system. Each conftype has a corresponding C type, which is of course
54 * necessary to actually use the data.
56 * The val_t__CONFTYPE macros represent the canonical correspondance of conftypes to C
57 * types, but in general the relationship is obvious: ints, strings, reals, and so forth
58 * are represented directly. Enumerated conftypes are represented by the corresponding
59 * C enum type. The 'rate' conftype is represented as a 2-element array of doubles, and
60 * the 'intrange' conftype is represented as a 2-element array of ints. exincludes are
61 * a exinclude_t *, and a proplist is represented as a GHashTable *.
65 * Note that, unless specified, all memory in this module is managed by the module
66 * itself; return strings should not be freed by the caller.
70 * All errors and warnings generated by this module are available from get_config_errors().
71 * It is up to the caller to route these messages to the user. The function
72 * config_print_errors() will print the errors to stderr, as a convenience.
78 * This module uses a generic val_t type to hold values of various types -- it's basically
79 * a union with type information and a 'seen' flag. In a way, it's a very simple equivalent
80 * to Glib's GValue. It's worth considering rewriting this with GValue, but for the moment,
81 * this works and it's here.
84 /* holdingdisk types */
86 HOLD_NEVER, /* Always direct to tape */
87 HOLD_AUTO, /* If possible */
88 HOLD_REQUIRED /* Always to holding disk */
91 /* Compression types */
93 COMP_NONE, /* No compression */
94 COMP_FAST, /* Fast compression on client */
95 COMP_BEST, /* Best compression on client */
96 COMP_CUST, /* Custom compression on client */
97 COMP_SERVER_FAST, /* Fast compression on server */
98 COMP_SERVER_BEST, /* Best compression on server */
99 COMP_SERVER_CUST /* Custom compression on server */
102 /* Encryption types */
104 ENCRYPT_NONE, /* No encryption */
105 ENCRYPT_CUST, /* Custom encryption on client */
106 ENCRYPT_SERV_CUST /* Custom encryption on server */
109 /* Estimate strategies */
111 ES_CLIENT, /* client estimate */
112 ES_SERVER, /* server estimate */
113 ES_CALCSIZE, /* calcsize estimate */
116 /* A GSlist where each element is a element_t */
117 typedef GSList *estimatelist_t;
120 AL_OTHER_CONFIG = 1<<0,
121 AL_NON_AMANDA = 1<<1,
122 AL_VOLUME_ERROR = 1<<2,
125 typedef int autolabel_set_t;
127 typedef struct autolabel_s {
129 autolabel_set_t autolabel;
132 /* Dump strategies */
134 DS_SKIP, /* Don't do any dumps at all */
135 DS_STANDARD, /* Standard (0 1 1 1 1 2 2 2 ...) */
136 DS_NOFULL, /* No full's (1 1 1 ...) */
137 DS_NOINC, /* No inc's (0 0 0 ...) */
138 DS_4, /* ? (0 1 2 3 4 5 6 7 8 9 10 11 ...) */
139 DS_5, /* ? (0 1 1 1 1 1 1 1 1 1 1 1 ...) */
140 DS_HANOI, /* Tower of Hanoi (? ? ? ? ? ...) */
141 DS_INCRONLY, /* Forced fulls (0 1 1 2 2 FORCE0 1 1 ...) */
151 ALGO_SMALLESTFIT, /* for internal use */
153 ALGO_LASTFIT, /* for internal use */
154 ALGO_ALGO /* sentinel */
157 /* execute_on types */
158 #define EXECUTE_ON_PRE_AMCHECK 1<<0
159 #define EXECUTE_ON_PRE_DLE_AMCHECK 1<<1
160 #define EXECUTE_ON_PRE_HOST_AMCHECK 1<<2
161 #define EXECUTE_ON_POST_AMCHECK 1<<3
162 #define EXECUTE_ON_POST_DLE_AMCHECK 1<<4
163 #define EXECUTE_ON_POST_HOST_AMCHECK 1<<5
164 #define EXECUTE_ON_PRE_ESTIMATE 1<<6
165 #define EXECUTE_ON_PRE_DLE_ESTIMATE 1<<7
166 #define EXECUTE_ON_PRE_HOST_ESTIMATE 1<<8
167 #define EXECUTE_ON_POST_ESTIMATE 1<<9
168 #define EXECUTE_ON_POST_DLE_ESTIMATE 1<<10
169 #define EXECUTE_ON_POST_HOST_ESTIMATE 1<<11
170 #define EXECUTE_ON_PRE_BACKUP 1<<12
171 #define EXECUTE_ON_PRE_DLE_BACKUP 1<<13
172 #define EXECUTE_ON_PRE_HOST_BACKUP 1<<14
173 #define EXECUTE_ON_POST_BACKUP 1<<15
174 #define EXECUTE_ON_POST_DLE_BACKUP 1<<16
175 #define EXECUTE_ON_POST_HOST_BACKUP 1<<17
176 #define EXECUTE_ON_PRE_RECOVER 1<<18
177 #define EXECUTE_ON_POST_RECOVER 1<<19
178 #define EXECUTE_ON_PRE_LEVEL_RECOVER 1<<20
179 #define EXECUTE_ON_POST_LEVEL_RECOVER 1<<21
180 #define EXECUTE_ON_INTER_LEVEL_RECOVER 1<<22
181 typedef int execute_on_t;
183 typedef int execute_where_t;
187 SEND_AMREPORT_STRANGE,
193 DATA_PATH_AMANDA = 1<<0,
194 DATA_PATH_DIRECTTCP = 1<<1,
197 typedef struct exinclude_s {
209 typedef GHashTable* proplist_t;
210 /* A GSlist where each element is a 'char*' */
211 typedef GSList* identlist_t;
213 /* part_cache_types */
215 PART_CACHE_TYPE_NONE,
216 PART_CACHE_TYPE_MEMORY,
217 PART_CACHE_TYPE_DISK,
227 /* Names for the type of value in a val_t. Mostly for internal use, but useful
228 * for wrapping val_t's, too. */
241 CONFTYPE_ESTIMATELIST,
249 CONFTYPE_APPLICATION,
251 CONFTYPE_EXECUTE_WHERE,
252 CONFTYPE_SEND_AMREPORT_ON,
256 CONFTYPE_PART_CACHE_TYPE,
261 /* A "seen" struct. Rather than allocate strings all over the place, this
262 * string is in the "parsed_filenames" GSList and will be freed when that
263 * GSList is freed. This struct should be opaque to other modules. */
264 typedef struct seen_s {
269 /* This should be considered an opaque type for any other modules. The complete
270 * struct is included here to allow quick access via macros. Access it *only* through
272 typedef struct val_s {
281 exinclude_t exinclude;
284 estimatelist_t estimatelist;
285 identlist_t identlist;
286 autolabel_t autolabel;
287 host_limit_t host_limit;
293 /* Functions to typecheck and extract a particular type of
294 * value from a val_t. All call error() if the type is incorrect,
295 * as this is a programming error. */
296 int val_t_to_int (val_t *);
297 gint64 val_t_to_int64 (val_t *);
298 float val_t_to_real (val_t *);
299 char *val_t_to_str (val_t *); /* (also converts CONFTYPE_IDENT) */
300 char *val_t_to_ident (val_t *); /* (also converts CONFTYPE_STR) */
301 identlist_t val_t_to_identlist(val_t *);
302 time_t val_t_to_time (val_t *);
303 ssize_t val_t_to_size (val_t *);
304 int val_t_to_boolean (val_t *);
305 int val_t_to_no_yes_all(val_t *);
306 comp_t val_t_to_compress (val_t *);
307 encrypt_t val_t_to_encrypt (val_t *);
308 dump_holdingdisk_t val_t_to_holding (val_t *);
309 estimatelist_t val_t_to_estimatelist (val_t *);
310 strategy_t val_t_to_strategy (val_t *);
311 taperalgo_t val_t_to_taperalgo(val_t *);
312 int val_t_to_priority (val_t *);
313 float *val_t_to_rate (val_t *); /* array of two floats */
314 exinclude_t val_t_to_exinclude(val_t *);
315 int *val_t_to_intrange (val_t *); /* array of two ints */
316 proplist_t val_t_to_proplist (val_t *);
317 char *val_t_to_application(val_t *);
318 execute_on_t val_t_to_execute_on(val_t *);
319 execute_where_t val_t_to_execute_where(val_t *);
320 send_amreport_t val_t_to_send_amreport(val_t *);
321 data_path_t val_t_to_data_path(val_t *);
322 autolabel_t val_t_to_autolabel(val_t *);
323 part_cache_type_t val_t_to_part_cache_type(val_t *);
324 host_limit_t *val_t_to_host_limit(val_t *);
326 /* Has the given val_t been seen in a configuration file or config overwrite?
328 * @param val: val_t* to examine
331 #define val_t_seen(val) ((val)->seen.linenum)
333 /* What is the underlying type of this val_t?
335 * @param val: val_t* to examine
336 * @returns: conftype_t
338 #define val_t_type(val) ((val)->type)
340 /* Macros to convert val_t's to a particular type without the benefit of
341 * a typecheck. Use these only if you really know what you're doing!
343 * Implementation note: these macros encode the relationship of conftypes
344 * (in the macro name) to the corresponding union field. The macros work
347 #define val_t__seen(val) ((val)->seen)
348 #define val_t__int(val) ((val)->v.i)
349 #define val_t__int64(val) ((val)->v.int64)
350 #define val_t__real(val) ((val)->v.r)
351 #define val_t__str(val) ((val)->v.s)
352 #define val_t__ident(val) ((val)->v.s)
353 #define val_t__identlist(val) ((val)->v.identlist)
354 #define val_t__time(val) ((val)->v.t)
355 #define val_t__size(val) ((val)->v.size)
356 #define val_t__boolean(val) ((val)->v.i)
357 #define val_t__no_yes_all(val) ((val)->v.i)
358 #define val_t__compress(val) ((val)->v.i)
359 #define val_t__encrypt(val) ((val)->v.i)
360 #define val_t__holding(val) ((val)->v.i)
361 #define val_t__estimatelist(val) ((val)->v.estimatelist)
362 #define val_t__strategy(val) ((val)->v.i)
363 #define val_t__taperalgo(val) ((val)->v.i)
364 #define val_t__send_amreport(val) ((val)->v.i)
365 #define val_t__priority(val) ((val)->v.i)
366 #define val_t__rate(val) ((val)->v.rate)
367 #define val_t__exinclude(val) ((val)->v.exinclude)
368 #define val_t__intrange(val) ((val)->v.intrange)
369 #define val_t__proplist(val) ((val)->v.proplist)
370 #define val_t__application(val) ((val)->v.application)
371 #define val_t__execute_on(val) ((val)->v.i)
372 #define val_t__execute_where(val) ((val)->v.i)
373 #define val_t__data_path(val) ((val)->v.i)
374 #define val_t__autolabel(val) ((val)->v.autolabel)
375 #define val_t__part_cache_type(val) ((val)->v.i)
376 #define val_t__host_limit(val) ((val)->v.host_limit)
381 * Programs get val_t's by giving the index of the parameters they're interested in.
382 * For global parameters, these start with CNF; for subsections, they start with the
383 * name of the subsection.
387 * Global parameter access
409 CNF_APPLICATION_TOOL,
439 CNF_DEVICE_OUTPUT_BUFFER_SIZE,
446 CNF_AMRECOVER_DO_FSF,
447 CNF_AMRECOVER_CHECK_LABEL,
448 CNF_AMRECOVER_CHANGER,
450 CNF_SEND_AMREPORT_ON,
451 CNF_FLUSH_THRESHOLD_DUMPED,
452 CNF_FLUSH_THRESHOLD_SCHEDULED,
464 CNF_DEBUG_AMIDXTAPED,
478 CNF_DEBUG_SENDBACKUP,
479 CNF_RESERVED_UDP_PORT,
480 CNF_RESERVED_TCP_PORT,
481 CNF_UNRESERVED_TCP_PORT,
486 CNF_TAPER_PARALLEL_WRITE,
489 CNF_MAX_DLE_BY_VOLUME,
491 CNF_CNF /* sentinel */
494 /* Given a confparm_key, return a pointer to the corresponding val_t.
496 * @param key: confparm_key
497 * @returns: pointer to value
499 val_t *getconf(confparm_key key);
501 /* (convenience macro) has this global parameter been seen?
503 * @param key: confparm_key
506 #define getconf_seen(key) (val_t_seen(getconf((key))))
507 #define getconf_linenum(key) (val_t_seen(getconf((key))))
509 /* (convenience macros)
510 * Fetch a global parameter of a specific type. Note that these
511 * convenience macros have a different form from those for the
512 * subsections: here you specify a type and a key, while for the
513 * subsections you specify only a key. The difference is historical.
515 * @param key: confparm_key
518 #define getconf_int(key) (val_t_to_int(getconf((key))))
519 #define getconf_int64(key) (val_t_to_int64(getconf((key))))
520 #define getconf_real(key) (val_t_to_real(getconf((key))))
521 #define getconf_str(key) (val_t_to_str(getconf((key))))
522 #define getconf_ident(key) (val_t_to_ident(getconf((key))))
523 #define getconf_identlist(key) (val_t_to_identlist(getconf((key))))
524 #define getconf_time(key) (val_t_to_time(getconf((key))))
525 #define getconf_size(key) (val_t_to_size(getconf((key))))
526 #define getconf_boolean(key) (val_t_to_boolean(getconf((key))))
527 #define getconf_no_yes_all(key) (val_t_to_no_yes_all(getconf((key))))
528 #define getconf_compress(key) (val_t_to_compress(getconf((key))))
529 #define getconf_encrypt(key) (val_t_to_encrypt(getconf((key))))
530 #define getconf_holding(key) (val_t_to_holding(getconf((key))))
531 #define getconf_estimatelist(key) (val_t_to_estimatelist(getconf((key))))
532 #define getconf_strategy(key) (val_t_to_strategy(getconf((key))))
533 #define getconf_taperalgo(key) (val_t_to_taperalgo(getconf((key))))
534 #define getconf_priority(key) (val_t_to_priority(getconf((key))))
535 #define getconf_rate(key) (val_t_to_rate(getconf((key))))
536 #define getconf_exinclude(key) (val_t_to_exinclude(getconf((key))))
537 #define getconf_intrange(key) (val_t_to_intrange(getconf((key))))
538 #define getconf_proplist(key) (val_t_to_proplist(getconf((key))))
539 #define getconf_send_amreport(key) (val_t_to_send_amreport(getconf((key))))
540 #define getconf_autolabel(key) (val_t_to_autolabel(getconf((key))))
541 #define getconf_part_cache_type(key) (val_t_to_part_cache_type(getconf((key))))
542 #define getconf_recovery_limit(key) (val_t_to_host_limit(getconf((key))))
544 /* Get a list of names for subsections of the given type
546 * @param listname: the desired type of subsection
547 * @returns: list of subsection names; caller is responsible for freeing
548 * this list, but not the strings it points to, using g_slist_free().
550 GSList *getconf_list(char *listname);
552 /* Get a configuration value by name, supporting the TYPE:SUBSEC:KEYWORD.
553 * Returns NULL if the configuration value doesnt exist.
555 val_t *getconf_byname(char *key);
560 * Values which aren't directly specified by the configuration, but which
561 * are derived from it.
564 /* Return a divisor which will convert a value in units of kilo-whatevers
565 * to the user's selected display unit.
567 * @returns: long integer divisor
569 long int getconf_unit_divisor(void);
571 /* If any of these globals are true, the corresponding component will
572 * send verbose debugging output to the debug file. The options are
573 * set during config_init, but can be modified at will after that if
576 extern int debug_amandad;
577 extern int debug_recovery;
578 extern int debug_amidxtaped;
579 extern int debug_amindexd;
580 extern int debug_amrecover;
581 extern int debug_auth;
582 extern int debug_event;
583 extern int debug_holding;
584 extern int debug_protocol;
585 extern int debug_planner;
586 extern int debug_driver;
587 extern int debug_dumper;
588 extern int debug_chunker;
589 extern int debug_taper;
590 extern int debug_selfcheck;
591 extern int debug_sendsize;
592 extern int debug_sendbackup;
595 * Tapetype parameter access
602 TAPETYPE_READBLOCKSIZE,
607 TAPETYPE_PART_CACHE_TYPE,
608 TAPETYPE_PART_CACHE_DIR,
609 TAPETYPE_PART_CACHE_MAX_SIZE,
610 TAPETYPE_TAPETYPE /* sentinel */
614 typedef struct tapetype_s tapetype_t;
616 /* Given the name of the tapetype, return a tapetype object. Returns NULL
617 * if no matching tapetype exists. Note that the match is case-insensitive.
619 * @param identifier: name of the desired tapetype
620 * @returns: object or NULL
622 tapetype_t *lookup_tapetype(char *identifier);
624 /* Given a tapetype and a key, return a pointer to the corresponding val_t.
626 * @param ttyp: the tapetype to examine
627 * @param key: tapetype_key (one of the TAPETYPE_* constants)
628 * @returns: pointer to value
630 val_t *tapetype_getconf(tapetype_t *ttyp, tapetype_key key);
632 /* Get the name of this tapetype.
634 * @param ttyp: the tapetype to examine
635 * @returns: name of the tapetype
637 char *tapetype_name(tapetype_t *ttyp);
639 /* (convenience macro) has this parameter been seen in this tapetype? This
640 * applies to the specific parameter *within* the tapetype.
642 * @param key: tapetype_key
645 #define tapetype_seen(ttyp, key) (val_t_seen(tapetype_getconf((ttyp), (key))))
647 /* (convenience macros)
648 * fetch a particular parameter; caller must know the correct type.
650 * @param ttyp: the tapetype to examine
653 #define tapetype_get_comment(ttyp) (val_t_to_str(tapetype_getconf((ttyp), TAPETYPE_COMMENT)))
654 #define tapetype_get_lbl_templ(ttyp) (val_t_to_str(tapetype_getconf((ttyp), TAPETYPE_LBL_TEMPL)))
655 #define tapetype_get_blocksize(ttyp) (val_t_to_size(tapetype_getconf((ttyp), TAPETYPE_BLOCKSIZE)))
656 #define tapetype_get_readblocksize(ttyp) (val_t_to_size(tapetype_getconf((ttyp), TAPETYPE_READBLOCKSIZE)))
657 #define tapetype_get_length(ttyp) (val_t_to_int64(tapetype_getconf((ttyp), TAPETYPE_LENGTH)))
658 #define tapetype_get_filemark(ttyp) (val_t_to_int64(tapetype_getconf((ttyp), TAPETYPE_FILEMARK)))
659 #define tapetype_get_speed(ttyp) (val_t_to_int(tapetype_getconf((ttyp), TAPETYPE_SPEED)))
660 #define tapetype_get_part_size(ttyp) (val_t_to_int64(tapetype_getconf((ttyp), TAPETYPE_PART_SIZE)))
661 #define tapetype_get_part_cache_type(ttyp) (val_t_to_part_cache_type(tapetype_getconf((ttyp), TAPETYPE_PART_CACHE_TYPE)))
662 #define tapetype_get_part_cache_dir(ttyp) (val_t_to_str(tapetype_getconf((ttyp), TAPETYPE_PART_CACHE_DIR)))
663 #define tapetype_get_part_cache_max_size(ttyp) (val_t_to_int64(tapetype_getconf((ttyp), TAPETYPE_PART_CACHE_MAX_SIZE)))
666 * Dumptype parameter access
668 * Note that some parameters are generic to the host
674 DUMPTYPE_SRVCOMPPROG,
675 DUMPTYPE_CLNTCOMPPROG,
676 DUMPTYPE_SRV_ENCRYPT,
677 DUMPTYPE_CLNT_ENCRYPT,
678 DUMPTYPE_AMANDAD_PATH, /* host parameter */
679 DUMPTYPE_CLIENT_USERNAME, /* host parameter */
680 DUMPTYPE_SSH_KEYS, /* host parameter */
681 DUMPTYPE_AUTH, /* host parameter */
686 DUMPTYPE_MAXDUMPS, /* host parameter */
687 DUMPTYPE_MAXPROMOTEDAY,
688 DUMPTYPE_BUMPPERCENT,
694 DUMPTYPE_ESTIMATELIST,
697 DUMPTYPE_SRV_DECRYPT_OPT,
698 DUMPTYPE_CLNT_DECRYPT_OPT,
700 DUMPTYPE_TAPE_SPLITSIZE,
701 DUMPTYPE_FALLBACK_SPLITSIZE,
702 DUMPTYPE_SPLIT_DISKBUFFER,
706 DUMPTYPE_HOLDINGDISK,
710 DUMPTYPE_APPLICATION,
713 DUMPTYPE_CLIENT_PORT,
715 DUMPTYPE_ALLOW_SPLIT,
716 DUMPTYPE_RECOVERY_LIMIT,
718 DUMPTYPE_DUMPTYPE /* sentinel */
722 typedef struct dumptype_s dumptype_t;
724 /* Given the name of the dumptype, return a dumptype object. Returns NULL
725 * if no matching dumptype exists. Note that the match is case-insensitive.
727 * @param identifier: name of the desired dumptype
728 * @returns: object or NULL
730 dumptype_t *lookup_dumptype(char *identifier);
732 /* Given a dumptype and a key, return a pointer to the corresponding val_t.
734 * @param dtyp: the dumptype to examine
735 * @param key: dumptype_key (one of the TAPETYPE_* constants)
736 * @returns: pointer to value
738 val_t *dumptype_getconf(dumptype_t *dtyp, dumptype_key key);
740 /* Get the name of this dumptype.
742 * @param dtyp: the dumptype to examine
743 * @returns: name of the dumptype
745 char *dumptype_name(dumptype_t *dtyp);
747 /* (convenience macro) has this parameter been seen in this dumptype? This
748 * applies to the specific parameter *within* the dumptype.
750 * @param key: dumptype_key
753 #define dumptype_seen(dtyp, key) (val_t_seen(dumptype_getconf((dtyp), (key))))
755 /* (convenience macros)
756 * fetch a particular parameter; caller must know the correct type.
758 * @param dtyp: the dumptype to examine
761 #define dumptype_get_comment(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_COMMENT)))
762 #define dumptype_get_program(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_PROGRAM)))
763 #define dumptype_get_srvcompprog(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SRVCOMPPROG)))
764 #define dumptype_get_clntcompprog(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLNTCOMPPROG)))
765 #define dumptype_get_srv_encrypt(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SRV_ENCRYPT)))
766 #define dumptype_get_clnt_encrypt(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLNT_ENCRYPT)))
767 #define dumptype_get_amandad_path(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_AMANDAD_PATH)))
768 #define dumptype_get_client_username(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLIENT_USERNAME)))
769 #define dumptype_get_ssh_keys(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SSH_KEYS)))
770 #define dumptype_get_auth(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_AUTH)))
771 #define dumptype_get_exclude(dtyp) (val_t_to_exinclude(dumptype_getconf((dtyp), DUMPTYPE_EXCLUDE)))
772 #define dumptype_get_include(dtyp) (val_t_to_exinclude(dumptype_getconf((dtyp), DUMPTYPE_INCLUDE)))
773 #define dumptype_get_priority(dtyp) (val_t_to_priority(dumptype_getconf((dtyp), DUMPTYPE_PRIORITY)))
774 #define dumptype_get_dumpcycle(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_DUMPCYCLE)))
775 #define dumptype_get_maxcycle(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_MAXCYCLE)))
776 #define dumptype_get_frequency(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_FREQUENCY)))
777 #define dumptype_get_maxdumps(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_MAXDUMPS)))
778 #define dumptype_get_maxpromoteday(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_MAXPROMOTEDAY)))
779 #define dumptype_get_bumppercent(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_BUMPPERCENT)))
780 #define dumptype_get_bumpsize(dtyp) (val_t_to_int64(dumptype_getconf((dtyp), DUMPTYPE_BUMPSIZE)))
781 #define dumptype_get_bumpdays(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_BUMPDAYS)))
782 #define dumptype_get_bumpmult(dtyp) (val_t_to_real(dumptype_getconf((dtyp), DUMPTYPE_BUMPMULT)))
783 #define dumptype_get_starttime(dtyp) (val_t_to_time(dumptype_getconf((dtyp), DUMPTYPE_STARTTIME)))
784 #define dumptype_get_strategy(dtyp) (val_t_to_strategy(dumptype_getconf((dtyp), DUMPTYPE_STRATEGY)))
785 #define dumptype_get_estimatelist(dtyp) (val_t_to_estimatelist(dumptype_getconf((dtyp), DUMPTYPE_ESTIMATELIST)))
786 #define dumptype_get_compress(dtyp) (val_t_to_compress(dumptype_getconf((dtyp), DUMPTYPE_COMPRESS)))
787 #define dumptype_get_encrypt(dtyp) (val_t_to_encrypt(dumptype_getconf((dtyp), DUMPTYPE_ENCRYPT)))
788 #define dumptype_get_srv_decrypt_opt(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SRV_DECRYPT_OPT)))
789 #define dumptype_get_clnt_decrypt_opt(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLNT_DECRYPT_OPT)))
790 #define dumptype_get_comprate(dtyp) (val_t_to_rate(dumptype_getconf((dtyp), DUMPTYPE_COMPRATE)))
791 #define dumptype_get_tape_splitsize(dtyp) (val_t_to_int64(dumptype_getconf((dtyp), DUMPTYPE_TAPE_SPLITSIZE)))
792 #define dumptype_get_fallback_splitsize(dtyp) (val_t_to_int64(dumptype_getconf((dtyp), DUMPTYPE_FALLBACK_SPLITSIZE)))
793 #define dumptype_get_split_diskbuffer(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SPLIT_DISKBUFFER)))
794 #define dumptype_get_record(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_RECORD)))
795 #define dumptype_get_skip_incr(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_SKIP_INCR)))
796 #define dumptype_get_skip_full(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_SKIP_FULL)))
797 #define dumptype_get_to_holdingdisk(dtyp) (val_t_to_holding(dumptype_getconf((dtyp), DUMPTYPE_HOLDINGDISK)))
798 #define dumptype_get_kencrypt(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_KENCRYPT)))
799 #define dumptype_get_ignore(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_IGNORE)))
800 #define dumptype_get_index(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_INDEX)))
801 #define dumptype_get_application(dtyp) (val_t_to_application(dumptype_getconf((dtyp), DUMPTYPE_APPLICATION)))
802 #define dumptype_get_scriptlist(dtyp) (val_t_to_identlist(dumptype_getconf((dtyp), DUMPTYPE_SCRIPTLIST)))
803 #define dumptype_get_property(dtyp) (val_t_to_proplist(dumptype_getconf((dtyp), DUMPTYPE_PROPERTY)))
804 #define dumptype_get_client_port(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLIENT_PORT)))
805 #define dumptype_get_data_path(dtyp) (val_t_to_data_path(dumptype_getconf((dtyp), DUMPTYPE_DATA_PATH)))
806 #define dumptype_get_allow_split(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_ALLOW_SPLIT)))
807 #define dumptype_get_recovery_limit(dtyp) (val_t_to_host_limit(dumptype_getconf((dtyp), DUMPTYPE_RECOVERY_LIMIT)))
808 #define dumptype_get_dump_limit(dtyp) (val_t_to_host_limit(dumptype_getconf((dtyp), DUMPTYPE_DUMP_LIMIT)))
811 * Interface parameter access
817 INTER_INTER /* sentinel */
821 typedef struct interface_s interface_t;
823 /* Given the name of the interface, return a interface object. Returns NULL
824 * if no matching interface exists. Note that the match is case-insensitive.
826 * @param identifier: name of the desired interface
827 * @returns: object or NULL
829 interface_t *lookup_interface(char *identifier);
831 /* Given a interface and a key, return a pointer to the corresponding val_t.
833 * @param iface: the interface to examine
834 * @param key: interface_key (one of the TAPETYPE_* constants)
835 * @returns: pointer to value
837 val_t *interface_getconf(interface_t *iface, interface_key key);
839 /* Get the name of this interface.
841 * @param iface: the interface to examine
842 * @returns: name of the interface
844 char *interface_name(interface_t *iface);
846 /* (convenience macro) has this parameter been seen in this interface? This
847 * applies to the specific parameter *within* the interface.
849 * @param key: interface_key
852 #define interface_seen(iface, key) (val_t_seen(interface_getconf((iface), (key))))
854 /* (convenience macros)
855 * fetch a particular parameter; caller must know the correct type.
857 * @param iface: the interface to examine
860 #define interface_get_comment(iface) (val_t_to_str(interface_getconf((iface), INTER_COMMENT)))
861 #define interface_get_maxusage(iface) (val_t_to_int(interface_getconf((iface), INTER_MAXUSAGE)))
864 * Holdingdisk parameter access
872 HOLDING_HOLDING /* sentinel */
876 typedef struct holdingdisk_s holdingdisk_t;
878 /* Given the name of the holdingdisk, return a holdingdisk object. Returns NULL
879 * if no matching holdingdisk exists. Note that the match is case-insensitive.
881 * @param identifier: name of the desired holdingdisk
882 * @returns: object or NULL
884 holdingdisk_t *lookup_holdingdisk(char *identifier);
886 /* Return the whole linked list of holdingdisks.
888 * @returns: first holding disk
890 GSList *getconf_holdingdisks(void);
892 /* Given a holdingdisk and a key, return a pointer to the corresponding val_t.
894 * @param hdisk: the holdingdisk to examine
895 * @param key: holdingdisk_key (one of the TAPETYPE_* constants)
896 * @returns: pointer to value
898 val_t *holdingdisk_getconf(holdingdisk_t *hdisk, holdingdisk_key key);
900 /* Get the name of this holdingdisk.
902 * @param hdisk: the holdingdisk to examine
903 * @returns: name of the holdingdisk
905 char *holdingdisk_name(holdingdisk_t *hdisk);
907 /* (convenience macro) has this parameter been seen in this holdingdisk? This
908 * applies to the specific parameter *within* the holdingdisk.
910 * @param key: holdingdisk_key
913 #define holdingdisk_seen(hdisk, key) (val_t_seen(holdingdisk_getconf((hdisk), (key))))
915 /* (convenience macros)
916 * fetch a particular parameter; caller must know the correct type.
918 * @param hdisk: the holdingdisk to examine
921 #define holdingdisk_get_comment(hdisk) (val_t_to_str(holdingdisk_getconf((hdisk), HOLDING_COMMENT)))
922 #define holdingdisk_get_diskdir(hdisk) (val_t_to_str(holdingdisk_getconf((hdisk), HOLDING_DISKDIR)))
923 #define holdingdisk_get_disksize(hdisk) (val_t_to_int64(holdingdisk_getconf((hdisk), HOLDING_DISKSIZE)))
924 #define holdingdisk_get_chunksize(hdisk) (val_t_to_int64(holdingdisk_getconf((hdisk), HOLDING_CHUNKSIZE)))
926 /* A application-tool interface */
927 typedef enum application_e {
930 APPLICATION_PROPERTY,
931 APPLICATION_CLIENT_NAME,
932 APPLICATION_APPLICATION
936 typedef struct application_s application_t;
938 /* Given the name of the application, return a application object. Returns NULL
939 * if no matching application exists. Note that the match is case-insensitive.
941 * @param identifier: name of the desired application
942 * @returns: object or NULL
945 application_t *lookup_application(char *identifier);
947 /* Given a application and a key, return a pointer to the corresponding val_t.
949 * @param ttyp: the application to examine
950 * @param key: application (one of the APPLICATION_* constants)
951 * @returns: pointer to value
953 val_t *application_getconf(application_t *app, application_key key);
955 /* Get the name of this application.
957 * @param ttyp: the application to examine
958 * @returns: name of the application
960 char *application_name(application_t *app);
962 /* (convenience macro) has this parameter been seen in this application? This
963 * applies to the specific parameter *within* the application.
965 * @param key: application_key
968 #define application_seen(app, key) (val_t_seen(application_getconf((app), (key))))
970 /* (convenience macros)
971 * fetch a particular parameter; caller must know the correct type.
973 * @param ttyp: the application to examine
976 #define application_get_comment(application) (val_t_to_str(application_getconf((application), APPLICATION_COMMENT))
977 #define application_get_plugin(application) (val_t_to_str(application_getconf((application), APPLICATION_PLUGIN)))
978 #define application_get_property(application) (val_t_to_proplist(application_getconf((application), APPLICATION_PROPERTY)))
979 #define application_get_client_name(application) (val_t_to_str(application_getconf((application), APPLICATION_CLIENT_NAME)))
981 /* A pp-script-tool interface */
982 typedef enum pp_script_e {
986 PP_SCRIPT_EXECUTE_ON,
987 PP_SCRIPT_EXECUTE_WHERE,
989 PP_SCRIPT_SINGLE_EXECUTION,
990 PP_SCRIPT_CLIENT_NAME,
995 typedef struct pp_script_s pp_script_t;
997 /* Given the name of the pp_script, return a pp_script object. Returns NULL
998 * if no matching pp_script exists. Note that the match is case-insensitive.
1000 * @param identifier: name of the desired pp_script
1001 * @returns: object or NULL
1004 pp_script_t *lookup_pp_script(char *identifier);
1006 /* Given a pp_script and a key, return a pointer to the corresponding val_t.
1008 * @param ttyp: the pp_script to examine
1009 * @param key: pp_script (one of the PP_SCRIPT_* constants)
1010 * @returns: pointer to value
1012 val_t *pp_script_getconf(pp_script_t *pps, pp_script_key key);
1014 /* Get the name of this pp_script.
1016 * @param ttyp: the pp_script to examine
1017 * @returns: name of the pp_script
1019 char *pp_script_name(pp_script_t *pps);
1021 /* (convenience macro) has this parameter been seen in this pp_script? This
1022 * applies to the specific parameter *within* the pp_script.
1024 * @param key: pp_script_key
1027 #define pp_script_seen(pps, key) (val_t_seen(pp_script_getconf((pps), (key))))
1029 /* (convenience macros)
1030 * fetch a particular parameter; caller must know the correct type.
1032 * @param ttyp: the pp_script to examine
1036 #define pp_script_get_comment(pp_script) (val_t_to_str(pp_script_getconf((pp_script), PP_SCRIPT_COMMENT)))
1037 #define pp_script_get_plugin(pp_script) (val_t_to_str(pp_script_getconf((pp_script), PP_SCRIPT_PLUGIN)))
1038 #define pp_script_get_property(pp_script) (val_t_to_proplist(pp_script_getconf((pp_script), PP_SCRIPT_PROPERTY)))
1039 #define pp_script_get_execute_on(pp_script) (val_t_to_execute_on(pp_script_getconf((pp_script), PP_SCRIPT_EXECUTE_ON)))
1040 #define pp_script_get_execute_where(pp_script) (val_t_to_execute_where(pp_script_getconf((pp_script), PP_SCRIPT_EXECUTE_WHERE)))
1041 #define pp_script_get_order(pp_script) (val_t_to_int(pp_script_getconf((pp_script), PP_SCRIPT_ORDER)))
1042 #define pp_script_get_single_execution(pp_script) (val_t_to_boolean(pp_script_getconf((pp_script), PP_SCRIPT_SINGLE_EXECUTION)))
1043 #define pp_script_get_client_name(pp_script) (val_t_to_str(pp_script_getconf((pp_script), PP_SCRIPT_CLIENT_NAME)))
1045 pp_script_t *lookup_pp_script(char *identifier);
1047 /* A device definition */
1049 DEVICE_CONFIG_COMMENT,
1050 DEVICE_CONFIG_TAPEDEV,
1051 DEVICE_CONFIG_DEVICE_PROPERTY,
1052 DEVICE_CONFIG_DEVICE_CONFIG
1053 } device_config_key;
1056 typedef struct device_config_s device_config_t;
1058 /* Given the name of the device, return a device_config_t object. Returns NULL
1059 * if no matching device exists. Note that the match is case-insensitive.
1061 * @param identifier: name of the desired device
1062 * @returns: object or NULL
1065 device_config_t *lookup_device_config(char *identifier);
1067 /* Given a device_config and a key, return a pointer to the corresponding val_t.
1069 * @param ttyp: the device_config to examine
1070 * @param key: device_config (one of the DEVICE_CONFIG_* constants)
1071 * @returns: pointer to value
1073 val_t *device_config_getconf(device_config_t *devconf, device_config_key key);
1075 /* Get the name of this device_config.
1077 * @param ttyp: the device_config to examine
1078 * @returns: name of the device_config
1080 char *device_config_name(device_config_t *devconf);
1082 /* (convenience macro) has this parameter been seen in this device_config? This
1083 * applies to the specific parameter *within* the device_config.
1085 * @param key: device_config_key
1088 #define device_config_seen(devconf, key) (val_t_seen(device_config_getconf((devconf), (key))))
1090 /* (convenience macros)
1091 * fetch a particular parameter; caller must know the correct type.
1093 * @param devconf: the device_config to examine
1097 #define device_config_get_comment(devconf) (val_t_to_str(device_config_getconf((devconf), DEVICE_CONFIG_COMMENT)))
1098 #define device_config_get_tapedev(devconf) (val_t_to_str(device_config_getconf((devconf), DEVICE_CONFIG_TAPEDEV)))
1099 #define device_config_get_property(devconf) (val_t_to_proplist(device_config_getconf((devconf), DEVICE_CONFIG_DEVICE_PROPERTY)))
1101 device_config_t *lookup_device_config(char *identifier);
1103 /* A changer definition */
1105 CHANGER_CONFIG_COMMENT,
1106 CHANGER_CONFIG_TAPEDEV,
1107 CHANGER_CONFIG_TPCHANGER,
1108 CHANGER_CONFIG_CHANGERDEV,
1109 CHANGER_CONFIG_CHANGERFILE,
1110 CHANGER_CONFIG_PROPERTY,
1111 CHANGER_CONFIG_DEVICE_PROPERTY,
1112 CHANGER_CONFIG_CHANGER_CONFIG
1113 } changer_config_key;
1116 typedef struct changer_config_s changer_config_t;
1118 /* Given the name of the changer, return a changer_config_t object. Returns NULL
1119 * if no matching changer exists. Note that the match is case-insensitive.
1121 * @param identifier: name of the desired changer
1122 * @returns: object or NULL
1125 changer_config_t *lookup_changer_config(char *identifier);
1127 /* Given a changer_config and a key, return a pointer to the corresponding val_t.
1129 * @param ttyp: the changer_config to examine
1130 * @param key: changer_config (one of the DEVICE_CONFIG_* constants)
1131 * @returns: pointer to value
1133 val_t *changer_config_getconf(changer_config_t *devconf, changer_config_key key);
1135 /* Get the name of this changer_config.
1137 * @param ttyp: the changer_config to examine
1138 * @returns: name of the changer_config
1140 char *changer_config_name(changer_config_t *devconf);
1142 /* (convenience macro) has this parameter been seen in this changer_config? This
1143 * applies to the specific parameter *within* the changer_config.
1145 * @param key: changer_config_key
1148 #define changer_config_seen(devconf, key) (val_t_seen(changer_config_getconf((devconf), (key))))
1150 /* (convenience macros)
1151 * fetch a particular parameter; caller must know the correct type.
1153 * @param devconf: the changer_config to examine
1157 #define changer_config_get_comment(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_COMMENT)))
1158 #define changer_config_get_tapedev(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_TAPEDEV)))
1159 #define changer_config_get_tpchanger(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_TPCHANGER)))
1160 #define changer_config_get_changerdev(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_CHANGERDEV)))
1161 #define changer_config_get_changerfile(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_CHANGERFILE)))
1163 changer_config_t *lookup_changer_config(char *identifier);
1165 /* A interacrtivity interface */
1166 typedef enum interactivity_e {
1167 INTERACTIVITY_COMMENT,
1168 INTERACTIVITY_PLUGIN,
1169 INTERACTIVITY_PROPERTY,
1170 INTERACTIVITY_INTERACTIVITY
1171 } interactivity_key;
1174 typedef struct interactivity_s interactivity_t;
1176 /* Given the name of the interactivity, return a interactivity object.
1177 * Returns NULL if no matching interactivity exists.
1178 * Note that the match is case-insensitive.
1180 * @param identifier: name of the desired interactivity
1181 * @returns: object or NULL
1184 interactivity_t *lookup_interactivity(char *identifier);
1186 /* Given a interactivity and a key, return a pointer to the corresponding val_t.
1188 * @param ttyp: the interactivity to examine
1189 * @param key: interactivity (one of the INTERACTIVITY_* constants)
1190 * @returns: pointer to value
1192 val_t *interactivity_getconf(interactivity_t *app, interactivity_key key);
1194 /* Get the name of this interactivity.
1196 * @param ttyp: the interactivity to examine
1197 * @returns: name of the interactivity
1199 char *interactivity_name(interactivity_t *app);
1201 /* (convenience macro) has this parameter been seen in this interactivity?
1202 * This applies to the specific parameter *within* the interactivity.
1204 * @param key: interactivity_key
1207 #define interactivity_seen(app, key) (val_t_seen(interactivity_getconf((app), (key))))
1209 /* (convenience macros)
1210 * fetch a particular parameter; caller must know the correct type.
1212 * @param ttyp: the interactivity to examine
1215 #define interactivity_get_comment(interactivity) (val_t_to_str(interactivity_getconf((interactivity), INTERACTIVITY_COMMENT))
1216 #define interactivity_get_plugin(interactivity) (val_t_to_str(interactivity_getconf((interactivity), INTERACTIVITY_PLUGIN)))
1217 #define interactivity_get_property(interactivity) (val_t_to_proplist(interactivity_getconf((interactivity), INTERACTIVITY_PROPERTY)))
1219 /* A taperscan interface */
1220 typedef enum taperscan_e {
1228 typedef struct taperscan_s taperscan_t;
1230 /* Given the name of the taperscan, return a taperscan object.
1231 * Returns NULL if no matching taperscan exists.
1232 * Note that the match is case-insensitive.
1234 * @param identifier: name of the desired taperscan
1235 * @returns: object or NULL
1238 taperscan_t *lookup_taperscan(char *identifier);
1240 /* Given a taperscan and a key, return a pointer to the corresponding val_t.
1242 * @param ttyp: the taperscan to examine
1243 * @param key: taperscan (one of the TAPERSCAN_* constants)
1244 * @returns: pointer to value
1246 val_t *taperscan_getconf(taperscan_t *app, taperscan_key key);
1248 /* Get the name of this taperscan.
1250 * @param ttyp: the taperscan to examine
1251 * @returns: name of the taperscan
1253 char *taperscan_name(taperscan_t *app);
1255 /* (convenience macro) has this parameter been seen in this taperscan?
1256 * This applies to the specific parameter *within* the taperscan.
1258 * @param key: taperscan_key
1261 #define taperscan_seen(app, key) (val_t_seen(taperscan_getconf((app), (key))))
1263 /* (convenience macros)
1264 * fetch a particular parameter; caller must know the correct type.
1266 * @param ttyp: the taperscan to examine
1269 #define taperscan_get_comment(taperscan) (val_t_to_str(taperscan_getconf((taperscan), TAPERSCAN_COMMENT))
1270 #define taperscan_get_plugin(taperscan) (val_t_to_str(taperscan_getconf((taperscan), TAPERSCAN_PLUGIN)))
1271 #define taperscan_get_property(taperscan) (val_t_to_proplist(taperscan_getconf((taperscan), TAPERSCAN_PROPERTY)))
1279 /* No errors or warnings */
1282 /* warnings were encountered */
1283 CFGERR_WARNINGS = 1,
1285 /* errors (and maybe some warnings too, who knows) were encountered */
1293 /* Get a GSList of all error and warning messages accumulated so far.
1295 * @param (output) errlist: pointer to the list of error strings; allocated
1296 * memory remains the responsibility of the config module. If errlist is
1297 * NULL, the list is not returned.
1298 * @returns: current error level
1300 cfgerr_level_t config_errors(GSList **errlist);
1302 /* Clear any error conditions.
1304 void config_clear_errors(void);
1306 /* Print the list of current error and warning messages, one per line,
1307 * to stderr. This is a convenience function for command-line
1310 void config_print_errors(void);
1312 /* Add an error message to the list of errors, and make sure tha the
1313 * error level is at least LEVEL. This is used by the diskfile module
1314 * to insert its errors into this module's error list.
1316 * @param level: level for this error
1317 * @param errmsg: error message; conffile takes responsibility for freeing
1320 void config_add_error(cfgerr_level_t level, char *errmsg);
1323 * Command-line handling
1327 typedef struct config_overrides_s config_overrides_t;
1329 /* Create a new, empty config_overrides object.
1331 * @param size_estimate: a guess at the number of overwrites; argc/2 is a
1333 * @returns: new object
1335 config_overrides_t *new_config_overrides(int size_estimate);
1337 /* Free a config_overrides object. This usually won't be needed, as
1338 * apply_config_overrides takes ownership of the overwrites for you.
1340 * @param co: config_overrides object
1342 void free_config_overrides(config_overrides_t *co);
1344 /* Add an overwrite to a config_overrides object.
1346 * @param co: the config_overrides object
1347 * @param key: the configuration parameter's key, possibly with the format
1348 * SUBTYPE:NAME:KEYWORD
1349 * @param value: the value for the parameter, as would be seen in amanda.conf
1351 void add_config_override(config_overrides_t *co,
1355 /* Add an overwrite option from the command line to a config_overrides
1356 * object. Calls error() with any errors
1358 * @param co: the config_overrides object
1359 * @param optarg: the value of the command-line option
1361 void add_config_override_opt(config_overrides_t *co,
1364 /* Given a command line, represented as argc/argv, extract any -o options
1365 * as config overwrites. This function modifies argc and argv in place.
1367 * This is the deprecated way to extract config overwrites, for applications
1368 * which do not use getopt. The preferred method is to use getopt and
1369 * call add_config_override_opt for any -o options.
1371 * @param argc: (in/out) command-line length
1372 * @param argv: (in/out) command-line strings
1373 * @returns: newly allocated config_overrides object
1375 config_overrides_t *
1376 extract_commandline_config_overrides(int *argc,
1379 /* Set configuration overwrites to the current configuration and take
1380 * ownership of the config_overrides object.
1382 * @param co: the config_overrides object
1384 void set_config_overrides(config_overrides_t *co);
1390 /* Constants for config_init */
1392 /* Use arg_config_name, if not NULL */
1393 CONFIG_INIT_EXPLICIT_NAME = 1 << 0,
1395 /* Use the current working directory if an explicit name is not available */
1396 CONFIG_INIT_USE_CWD = 1 << 1,
1398 /* This is a client application (server is default) */
1399 CONFIG_INIT_CLIENT = 1 << 2,
1401 /* New configuration should "overlay" existing configuration; this
1402 * is used by clients to load multiple amanda-client.conf files. */
1403 CONFIG_INIT_OVERLAY = 1 << 3,
1404 } config_init_flags;
1406 /* Initialize this application's configuration, with the specific actions
1408 * - if CONFIG_INIT_OVERLAY is not set, configuration values are reset
1410 * - if CONFIG_INIT_EXPLICIT_NAME and arg_config_name is not NULL,
1411 * use CONFIG_DIR/arg_config_name as config_dir arg_config_name as
1413 * - otherwise, if CONFIG_USE_CWD is set, use the directory in which
1414 * the application was started as config_dir, and its filename as
1416 * - otherwise, for the client only, se config_dir to CONFIG_DIR and
1417 * config_name to NULL.
1418 * - depending on CONFIG_INIT_CLIENT, read amanda.conf or amanda-client.conf
1420 * @param flags: flags indicating desired behavior, as above
1421 * @param arg_config_name: config name to use (from e.g., argv[1])
1422 * @returns: current error level
1424 cfgerr_level_t config_init(
1425 config_init_flags flags,
1426 char *arg_config_name);
1428 /* Free all memory allocated for the configuration. This effectively
1429 * reverses the effects of config_init().
1431 void config_uninit(void);
1433 /* Encode any applied config_overrides into a strv format suitale for
1434 * executing another Amanda tool.
1436 * The * result is dynamically allocated and NULL terminated. There is no
1437 * provision to free the result, as this function is always called just
1438 * before execve(..).
1440 * First gives the number of array elements to leave for the caller to
1441 * fill in. The usual calling pattern is this:
1442 * command_line = get_config_options(3);
1443 * command_line[0] = "appname";
1444 * command_line[1] = config_name;
1445 * command_line[2] = "--foo";
1446 * execve(command_line[0], command_line, safe_env());
1448 * @param first: number of unused elements to leave at the beginning of
1450 * @returns: NULL-terminated string array suitable for execve
1452 char **get_config_options(int first);
1454 /* Get the config name */
1455 char *get_config_name(void);
1457 /* Get the config directory */
1458 char *get_config_dir(void);
1460 /* Get the config filename */
1461 char *get_config_filename(void);
1467 /* Security plugins get their configuration information through a callback
1468 * with the signature:
1469 * char *callback(char *key, void *userpointer);
1470 * where key is the name of the desired parameter, which may not match the
1471 * name used in this module. See the implementations of these functions
1472 * to learn which keys they support, or to add new keys.
1474 char *generic_client_get_security_conf(char *, void *);
1475 char *generic_get_security_conf(char *, void *);
1477 /* Dump the current configuration information to stdout, in a format
1478 * that can be re-read by this module. The results will include any
1479 * command-line overwrites.
1481 * This function only dumps the server configuration, and will fail on
1484 void dump_configuration(void);
1486 /* Return a sequence of strings giving the printable representation
1487 * of the given val_t. If str_needs_quotes is true and each string is
1488 * prefixed by the relevant configuration keyword, these strings will
1489 * be parseable by this module, and will reproduce exactly the same
1490 * configuration value. See the implementation of dump_configuration
1493 * If str_needs_quotes is provided, a CONFTYPE_STR value will be returned with
1496 * The result is a NULL-terminated strv, which can be freed with g_strfreev or
1497 * joined with g_strjoinv. Caller is responsible for freeing the memory.
1499 * @param val: the value to analyze
1500 * @param str_needs_quotes: add quotes to CONFTYPE_STR values?
1501 * @returns: NULL-terminated string vector
1503 char **val_t_display_strs(val_t *val, int str_needs_quotes);
1505 /* Read a dumptype; this is used by this module as well as by diskfile.c to
1506 * read the disklist. The two are carefully balanced in their parsing process.
1508 * Nobody else should use this function. Seriously.
1510 dumptype_t *read_dumptype(char *name, FILE *from, char *fname, int *linenum);
1512 /* Every call return a pointer to a string with an increasing number; this is
1513 * used by this module as well as by diskfile.c to read the disklist.
1515 * Nobody else should use this function. Seriously.
1517 * @returns: a pointer to a static string.
1519 char *anonymous_value(void);
1521 /* Extend a relative filename with the current config_dir; if filename is already
1522 * absolute, this is equivalent to stralloc.
1524 * @param filename: filename to extend
1525 * @returns: newly allocated filename
1527 char *config_dir_relative(char *filename);
1529 /* Convert from a symbol back to a name for logging and for dumping
1532 * @param taperalgo: the constant value
1533 * @returns: statically allocated string
1535 char *taperalgo2str(taperalgo_t taperalgo);
1537 /* Looks for a unit value like b, byte, bytes, bps, etc. Technically
1538 * the return value should never be < 1, but we return a signed value
1539 * to help mitigate bad C promotion semantics. Returns 0 on error.
1541 * This is here in this module because it uses the numb_keytable.
1543 * @param casestr: the unit string
1544 * @returns: the corresponding multiplier (e.g., 'M' => 1024*1024)
1546 gint64 find_multiplier(char * casestr);
1548 /* Converts a string matching any of Amanda's names for "true" or
1549 * "false" to a boolean value.
1551 * @param str: string to match
1552 * @returns: 0 or 1 (boolean) or -1 (no match)
1554 int string_to_boolean(const char *str);
1556 /* Return a pointer to a static string for the data_path */
1557 char *data_path_to_string(data_path_t data_path);
1559 /* Return the data_path for the string */
1560 data_path_t data_path_from_string(char *data);
1562 void free_property_t(gpointer p);
1564 /* Converts a string into Amanda property name style.
1566 * @param name: The name to convert.
1567 * @returns: A newly allocated string, with name in lowercase and
1568 * any instances of '_' replaced with '-'.
1570 gchar *amandaify_property_name(const gchar *name);
1572 #endif /* ! CONFFILE_H */