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_DLE_AMCHECK 1<<0
159 #define EXECUTE_ON_PRE_HOST_AMCHECK 1<<1
160 #define EXECUTE_ON_POST_DLE_AMCHECK 1<<2
161 #define EXECUTE_ON_POST_HOST_AMCHECK 1<<3
162 #define EXECUTE_ON_PRE_DLE_ESTIMATE 1<<4
163 #define EXECUTE_ON_PRE_HOST_ESTIMATE 1<<5
164 #define EXECUTE_ON_POST_DLE_ESTIMATE 1<<6
165 #define EXECUTE_ON_POST_HOST_ESTIMATE 1<<7
166 #define EXECUTE_ON_PRE_DLE_BACKUP 1<<8
167 #define EXECUTE_ON_PRE_HOST_BACKUP 1<<9
168 #define EXECUTE_ON_POST_DLE_BACKUP 1<<10
169 #define EXECUTE_ON_POST_HOST_BACKUP 1<<11
170 #define EXECUTE_ON_PRE_RECOVER 1<<12
171 #define EXECUTE_ON_POST_RECOVER 1<<13
172 #define EXECUTE_ON_PRE_LEVEL_RECOVER 1<<14
173 #define EXECUTE_ON_POST_LEVEL_RECOVER 1<<15
174 #define EXECUTE_ON_INTER_LEVEL_RECOVER 1<<16
175 typedef int execute_on_t;
177 typedef int execute_where_t;
181 SEND_AMREPORT_STRANGE,
187 DATA_PATH_AMANDA = 1<<0,
188 DATA_PATH_DIRECTTCP = 1<<1,
191 typedef struct exinclude_s {
203 typedef GHashTable* proplist_t;
204 /* A GSlist where each element is a 'char*' */
205 typedef GSList* identlist_t;
207 /* part_cache_types */
209 PART_CACHE_TYPE_NONE,
210 PART_CACHE_TYPE_MEMORY,
211 PART_CACHE_TYPE_DISK,
220 /* Names for the type of value in a val_t. Mostly for internal use, but useful
221 * for wrapping val_t's, too. */
234 CONFTYPE_ESTIMATELIST,
242 CONFTYPE_APPLICATION,
244 CONFTYPE_EXECUTE_WHERE,
245 CONFTYPE_SEND_AMREPORT_ON,
249 CONFTYPE_PART_CACHE_TYPE,
250 CONFTYPE_RECOVERY_LIMIT,
253 /* A "seen" struct. Rather than allocate strings all over the place, this
254 * string is in the "parsed_filenames" GSList and will be freed when that
255 * GSList is freed. This struct should be opaque to other modules. */
256 typedef struct seen_s {
261 /* This should be considered an opaque type for any other modules. The complete
262 * struct is included here to allow quick access via macros. Access it *only* through
264 typedef struct val_s {
273 exinclude_t exinclude;
276 estimatelist_t estimatelist;
277 identlist_t identlist;
278 autolabel_t autolabel;
279 recovery_limit_t recovery_limit;
285 /* Functions to typecheck and extract a particular type of
286 * value from a val_t. All call error() if the type is incorrect,
287 * as this is a programming error. */
288 int val_t_to_int (val_t *);
289 gint64 val_t_to_int64 (val_t *);
290 float val_t_to_real (val_t *);
291 char *val_t_to_str (val_t *); /* (also converts CONFTYPE_IDENT) */
292 char *val_t_to_ident (val_t *); /* (also converts CONFTYPE_STR) */
293 identlist_t val_t_to_identlist(val_t *);
294 time_t val_t_to_time (val_t *);
295 ssize_t val_t_to_size (val_t *);
296 int val_t_to_boolean (val_t *);
297 comp_t val_t_to_compress (val_t *);
298 encrypt_t val_t_to_encrypt (val_t *);
299 dump_holdingdisk_t val_t_to_holding (val_t *);
300 estimatelist_t val_t_to_estimatelist (val_t *);
301 strategy_t val_t_to_strategy (val_t *);
302 taperalgo_t val_t_to_taperalgo(val_t *);
303 int val_t_to_priority (val_t *);
304 float *val_t_to_rate (val_t *); /* array of two floats */
305 exinclude_t val_t_to_exinclude(val_t *);
306 int *val_t_to_intrange (val_t *); /* array of two ints */
307 proplist_t val_t_to_proplist (val_t *);
308 char *val_t_to_application(val_t *);
309 execute_on_t val_t_to_execute_on(val_t *);
310 execute_where_t val_t_to_execute_where(val_t *);
311 send_amreport_t val_t_to_send_amreport(val_t *);
312 data_path_t val_t_to_data_path(val_t *);
313 autolabel_t val_t_to_autolabel(val_t *);
314 part_cache_type_t val_t_to_part_cache_type(val_t *);
315 recovery_limit_t *val_t_to_recovery_limit(val_t *);
317 /* Has the given val_t been seen in a configuration file or config overwrite?
319 * @param val: val_t* to examine
322 #define val_t_seen(val) ((val)->seen.linenum)
324 /* What is the underlying type of this val_t?
326 * @param val: val_t* to examine
327 * @returns: conftype_t
329 #define val_t_type(val) ((val)->type)
331 /* Macros to convert val_t's to a particular type without the benefit of
332 * a typecheck. Use these only if you really know what you're doing!
334 * Implementation note: these macros encode the relationship of conftypes
335 * (in the macro name) to the corresponding union field. The macros work
338 #define val_t__seen(val) ((val)->seen)
339 #define val_t__int(val) ((val)->v.i)
340 #define val_t__int64(val) ((val)->v.int64)
341 #define val_t__real(val) ((val)->v.r)
342 #define val_t__str(val) ((val)->v.s)
343 #define val_t__ident(val) ((val)->v.s)
344 #define val_t__identlist(val) ((val)->v.identlist)
345 #define val_t__time(val) ((val)->v.t)
346 #define val_t__size(val) ((val)->v.size)
347 #define val_t__boolean(val) ((val)->v.i)
348 #define val_t__compress(val) ((val)->v.i)
349 #define val_t__encrypt(val) ((val)->v.i)
350 #define val_t__holding(val) ((val)->v.i)
351 #define val_t__estimatelist(val) ((val)->v.estimatelist)
352 #define val_t__strategy(val) ((val)->v.i)
353 #define val_t__taperalgo(val) ((val)->v.i)
354 #define val_t__send_amreport(val) ((val)->v.i)
355 #define val_t__priority(val) ((val)->v.i)
356 #define val_t__rate(val) ((val)->v.rate)
357 #define val_t__exinclude(val) ((val)->v.exinclude)
358 #define val_t__intrange(val) ((val)->v.intrange)
359 #define val_t__proplist(val) ((val)->v.proplist)
360 #define val_t__application(val) ((val)->v.application)
361 #define val_t__execute_on(val) ((val)->v.i)
362 #define val_t__execute_where(val) ((val)->v.i)
363 #define val_t__data_path(val) ((val)->v.i)
364 #define val_t__autolabel(val) ((val)->v.autolabel)
365 #define val_t__part_cache_type(val) ((val)->v.i)
366 #define val_t__recovery_limit(val) ((val)->v.recovery_limit)
371 * Programs get val_t's by giving the index of the parameters they're interested in.
372 * For global parameters, these start with CNF; for subsections, they start with the
373 * name of the subsection.
377 * Global parameter access
397 CNF_APPLICATION_TOOL,
427 CNF_DEVICE_OUTPUT_BUFFER_SIZE,
434 CNF_AMRECOVER_DO_FSF,
435 CNF_AMRECOVER_CHECK_LABEL,
436 CNF_AMRECOVER_CHANGER,
438 CNF_SEND_AMREPORT_ON,
439 CNF_FLUSH_THRESHOLD_DUMPED,
440 CNF_FLUSH_THRESHOLD_SCHEDULED,
452 CNF_DEBUG_AMIDXTAPED,
466 CNF_DEBUG_SENDBACKUP,
467 CNF_RESERVED_UDP_PORT,
468 CNF_RESERVED_TCP_PORT,
469 CNF_UNRESERVED_TCP_PORT,
473 CNF_TAPER_PARALLEL_WRITE,
475 CNF_CNF /* sentinel */
478 /* Given a confparm_key, return a pointer to the corresponding val_t.
480 * @param key: confparm_key
481 * @returns: pointer to value
483 val_t *getconf(confparm_key key);
485 /* (convenience macro) has this global parameter been seen?
487 * @param key: confparm_key
490 #define getconf_seen(key) (val_t_seen(getconf((key))))
491 #define getconf_linenum(key) (val_t_seen(getconf((key))))
493 /* (convenience macros)
494 * Fetch a global parameter of a specific type. Note that these
495 * convenience macros have a different form from those for the
496 * subsections: here you specify a type and a key, while for the
497 * subsections you specify only a key. The difference is historical.
499 * @param key: confparm_key
502 #define getconf_int(key) (val_t_to_int(getconf((key))))
503 #define getconf_int64(key) (val_t_to_int64(getconf((key))))
504 #define getconf_real(key) (val_t_to_real(getconf((key))))
505 #define getconf_str(key) (val_t_to_str(getconf((key))))
506 #define getconf_ident(key) (val_t_to_ident(getconf((key))))
507 #define getconf_identlist(key) (val_t_to_identlist(getconf((key))))
508 #define getconf_time(key) (val_t_to_time(getconf((key))))
509 #define getconf_size(key) (val_t_to_size(getconf((key))))
510 #define getconf_boolean(key) (val_t_to_boolean(getconf((key))))
511 #define getconf_compress(key) (val_t_to_compress(getconf((key))))
512 #define getconf_encrypt(key) (val_t_to_encrypt(getconf((key))))
513 #define getconf_holding(key) (val_t_to_holding(getconf((key))))
514 #define getconf_estimatelist(key) (val_t_to_estimatelist(getconf((key))))
515 #define getconf_strategy(key) (val_t_to_strategy(getconf((key))))
516 #define getconf_taperalgo(key) (val_t_to_taperalgo(getconf((key))))
517 #define getconf_priority(key) (val_t_to_priority(getconf((key))))
518 #define getconf_rate(key) (val_t_to_rate(getconf((key))))
519 #define getconf_exinclude(key) (val_t_to_exinclude(getconf((key))))
520 #define getconf_intrange(key) (val_t_to_intrange(getconf((key))))
521 #define getconf_proplist(key) (val_t_to_proplist(getconf((key))))
522 #define getconf_send_amreport(key) (val_t_to_send_amreport(getconf((key))))
523 #define getconf_autolabel(key) (val_t_to_autolabel(getconf((key))))
524 #define getconf_part_cache_type(key) (val_t_to_part_cache_type(getconf((key))))
525 #define getconf_recovery_limit(key) (val_t_to_recovery_limit(getconf((key))))
527 /* Get a list of names for subsections of the given type
529 * @param listname: the desired type of subsection
530 * @returns: list of subsection names; caller is responsible for freeing
531 * this list, but not the strings it points to, using g_slist_free().
533 GSList *getconf_list(char *listname);
535 /* Get a configuration value by name, supporting the TYPE:SUBSEC:KEYWORD.
536 * Returns NULL if the configuration value doesnt exist.
538 val_t *getconf_byname(char *key);
543 * Values which aren't directly specified by the configuration, but which
544 * are derived from it.
547 /* Return a divisor which will convert a value in units of kilo-whatevers
548 * to the user's selected display unit.
550 * @returns: long integer divisor
552 long int getconf_unit_divisor(void);
554 /* If any of these globals are true, the corresponding component will
555 * send verbose debugging output to the debug file. The options are
556 * set during config_init, but can be modified at will after that if
559 extern int debug_amandad;
560 extern int debug_recovery;
561 extern int debug_amidxtaped;
562 extern int debug_amindexd;
563 extern int debug_amrecover;
564 extern int debug_auth;
565 extern int debug_event;
566 extern int debug_holding;
567 extern int debug_protocol;
568 extern int debug_planner;
569 extern int debug_driver;
570 extern int debug_dumper;
571 extern int debug_chunker;
572 extern int debug_taper;
573 extern int debug_selfcheck;
574 extern int debug_sendsize;
575 extern int debug_sendbackup;
578 * Tapetype parameter access
585 TAPETYPE_READBLOCKSIZE,
590 TAPETYPE_PART_CACHE_TYPE,
591 TAPETYPE_PART_CACHE_DIR,
592 TAPETYPE_PART_CACHE_MAX_SIZE,
593 TAPETYPE_TAPETYPE /* sentinel */
597 typedef struct tapetype_s tapetype_t;
599 /* Given the name of the tapetype, return a tapetype object. Returns NULL
600 * if no matching tapetype exists. Note that the match is case-insensitive.
602 * @param identifier: name of the desired tapetype
603 * @returns: object or NULL
605 tapetype_t *lookup_tapetype(char *identifier);
607 /* Given a tapetype and a key, return a pointer to the corresponding val_t.
609 * @param ttyp: the tapetype to examine
610 * @param key: tapetype_key (one of the TAPETYPE_* constants)
611 * @returns: pointer to value
613 val_t *tapetype_getconf(tapetype_t *ttyp, tapetype_key key);
615 /* Get the name of this tapetype.
617 * @param ttyp: the tapetype to examine
618 * @returns: name of the tapetype
620 char *tapetype_name(tapetype_t *ttyp);
622 /* (convenience macro) has this parameter been seen in this tapetype? This
623 * applies to the specific parameter *within* the tapetype.
625 * @param key: tapetype_key
628 #define tapetype_seen(ttyp, key) (val_t_seen(tapetype_getconf((ttyp), (key))))
630 /* (convenience macros)
631 * fetch a particular parameter; caller must know the correct type.
633 * @param ttyp: the tapetype to examine
636 #define tapetype_get_comment(ttyp) (val_t_to_str(tapetype_getconf((ttyp), TAPETYPE_COMMENT)))
637 #define tapetype_get_lbl_templ(ttyp) (val_t_to_str(tapetype_getconf((ttyp), TAPETYPE_LBL_TEMPL)))
638 #define tapetype_get_blocksize(ttyp) (val_t_to_size(tapetype_getconf((ttyp), TAPETYPE_BLOCKSIZE)))
639 #define tapetype_get_readblocksize(ttyp) (val_t_to_size(tapetype_getconf((ttyp), TAPETYPE_READBLOCKSIZE)))
640 #define tapetype_get_length(ttyp) (val_t_to_int64(tapetype_getconf((ttyp), TAPETYPE_LENGTH)))
641 #define tapetype_get_filemark(ttyp) (val_t_to_int64(tapetype_getconf((ttyp), TAPETYPE_FILEMARK)))
642 #define tapetype_get_speed(ttyp) (val_t_to_int(tapetype_getconf((ttyp), TAPETYPE_SPEED)))
643 #define tapetype_get_part_size(ttyp) (val_t_to_int64(tapetype_getconf((ttyp), TAPETYPE_PART_SIZE)))
644 #define tapetype_get_part_cache_type(ttyp) (val_t_to_part_cache_type(tapetype_getconf((ttyp), TAPETYPE_PART_CACHE_TYPE)))
645 #define tapetype_get_part_cache_dir(ttyp) (val_t_to_str(tapetype_getconf((ttyp), TAPETYPE_PART_CACHE_DIR)))
646 #define tapetype_get_part_cache_max_size(ttyp) (val_t_to_int64(tapetype_getconf((ttyp), TAPETYPE_PART_CACHE_MAX_SIZE)))
649 * Dumptype parameter access
651 * Note that some parameters are generic to the host
657 DUMPTYPE_SRVCOMPPROG,
658 DUMPTYPE_CLNTCOMPPROG,
659 DUMPTYPE_SRV_ENCRYPT,
660 DUMPTYPE_CLNT_ENCRYPT,
661 DUMPTYPE_AMANDAD_PATH, /* host parameter */
662 DUMPTYPE_CLIENT_USERNAME, /* host parameter */
663 DUMPTYPE_SSH_KEYS, /* host parameter */
664 DUMPTYPE_AUTH, /* host parameter */
669 DUMPTYPE_MAXDUMPS, /* host parameter */
670 DUMPTYPE_MAXPROMOTEDAY,
671 DUMPTYPE_BUMPPERCENT,
677 DUMPTYPE_ESTIMATELIST,
680 DUMPTYPE_SRV_DECRYPT_OPT,
681 DUMPTYPE_CLNT_DECRYPT_OPT,
683 DUMPTYPE_TAPE_SPLITSIZE,
684 DUMPTYPE_FALLBACK_SPLITSIZE,
685 DUMPTYPE_SPLIT_DISKBUFFER,
689 DUMPTYPE_HOLDINGDISK,
693 DUMPTYPE_APPLICATION,
696 DUMPTYPE_CLIENT_PORT,
698 DUMPTYPE_ALLOW_SPLIT,
699 DUMPTYPE_RECOVERY_LIMIT,
700 DUMPTYPE_DUMPTYPE /* sentinel */
704 typedef struct dumptype_s dumptype_t;
706 /* Given the name of the dumptype, return a dumptype object. Returns NULL
707 * if no matching dumptype exists. Note that the match is case-insensitive.
709 * @param identifier: name of the desired dumptype
710 * @returns: object or NULL
712 dumptype_t *lookup_dumptype(char *identifier);
714 /* Given a dumptype and a key, return a pointer to the corresponding val_t.
716 * @param dtyp: the dumptype to examine
717 * @param key: dumptype_key (one of the TAPETYPE_* constants)
718 * @returns: pointer to value
720 val_t *dumptype_getconf(dumptype_t *dtyp, dumptype_key key);
722 /* Get the name of this dumptype.
724 * @param dtyp: the dumptype to examine
725 * @returns: name of the dumptype
727 char *dumptype_name(dumptype_t *dtyp);
729 /* (convenience macro) has this parameter been seen in this dumptype? This
730 * applies to the specific parameter *within* the dumptype.
732 * @param key: dumptype_key
735 #define dumptype_seen(dtyp, key) (val_t_seen(dumptype_getconf((dtyp), (key))))
737 /* (convenience macros)
738 * fetch a particular parameter; caller must know the correct type.
740 * @param dtyp: the dumptype to examine
743 #define dumptype_get_comment(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_COMMENT)))
744 #define dumptype_get_program(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_PROGRAM)))
745 #define dumptype_get_srvcompprog(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SRVCOMPPROG)))
746 #define dumptype_get_clntcompprog(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLNTCOMPPROG)))
747 #define dumptype_get_srv_encrypt(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SRV_ENCRYPT)))
748 #define dumptype_get_clnt_encrypt(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLNT_ENCRYPT)))
749 #define dumptype_get_amandad_path(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_AMANDAD_PATH)))
750 #define dumptype_get_client_username(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLIENT_USERNAME)))
751 #define dumptype_get_ssh_keys(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SSH_KEYS)))
752 #define dumptype_get_auth(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_AUTH)))
753 #define dumptype_get_exclude(dtyp) (val_t_to_exinclude(dumptype_getconf((dtyp), DUMPTYPE_EXCLUDE)))
754 #define dumptype_get_include(dtyp) (val_t_to_exinclude(dumptype_getconf((dtyp), DUMPTYPE_INCLUDE)))
755 #define dumptype_get_priority(dtyp) (val_t_to_priority(dumptype_getconf((dtyp), DUMPTYPE_PRIORITY)))
756 #define dumptype_get_dumpcycle(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_DUMPCYCLE)))
757 #define dumptype_get_maxcycle(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_MAXCYCLE)))
758 #define dumptype_get_frequency(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_FREQUENCY)))
759 #define dumptype_get_maxdumps(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_MAXDUMPS)))
760 #define dumptype_get_maxpromoteday(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_MAXPROMOTEDAY)))
761 #define dumptype_get_bumppercent(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_BUMPPERCENT)))
762 #define dumptype_get_bumpsize(dtyp) (val_t_to_int64(dumptype_getconf((dtyp), DUMPTYPE_BUMPSIZE)))
763 #define dumptype_get_bumpdays(dtyp) (val_t_to_int(dumptype_getconf((dtyp), DUMPTYPE_BUMPDAYS)))
764 #define dumptype_get_bumpmult(dtyp) (val_t_to_real(dumptype_getconf((dtyp), DUMPTYPE_BUMPMULT)))
765 #define dumptype_get_starttime(dtyp) (val_t_to_time(dumptype_getconf((dtyp), DUMPTYPE_STARTTIME)))
766 #define dumptype_get_strategy(dtyp) (val_t_to_strategy(dumptype_getconf((dtyp), DUMPTYPE_STRATEGY)))
767 #define dumptype_get_estimatelist(dtyp) (val_t_to_estimatelist(dumptype_getconf((dtyp), DUMPTYPE_ESTIMATELIST)))
768 #define dumptype_get_compress(dtyp) (val_t_to_compress(dumptype_getconf((dtyp), DUMPTYPE_COMPRESS)))
769 #define dumptype_get_encrypt(dtyp) (val_t_to_encrypt(dumptype_getconf((dtyp), DUMPTYPE_ENCRYPT)))
770 #define dumptype_get_srv_decrypt_opt(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SRV_DECRYPT_OPT)))
771 #define dumptype_get_clnt_decrypt_opt(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLNT_DECRYPT_OPT)))
772 #define dumptype_get_comprate(dtyp) (val_t_to_rate(dumptype_getconf((dtyp), DUMPTYPE_COMPRATE)))
773 #define dumptype_get_tape_splitsize(dtyp) (val_t_to_int64(dumptype_getconf((dtyp), DUMPTYPE_TAPE_SPLITSIZE)))
774 #define dumptype_get_fallback_splitsize(dtyp) (val_t_to_int64(dumptype_getconf((dtyp), DUMPTYPE_FALLBACK_SPLITSIZE)))
775 #define dumptype_get_split_diskbuffer(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_SPLIT_DISKBUFFER)))
776 #define dumptype_get_record(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_RECORD)))
777 #define dumptype_get_skip_incr(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_SKIP_INCR)))
778 #define dumptype_get_skip_full(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_SKIP_FULL)))
779 #define dumptype_get_to_holdingdisk(dtyp) (val_t_to_holding(dumptype_getconf((dtyp), DUMPTYPE_HOLDINGDISK)))
780 #define dumptype_get_kencrypt(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_KENCRYPT)))
781 #define dumptype_get_ignore(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_IGNORE)))
782 #define dumptype_get_index(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_INDEX)))
783 #define dumptype_get_application(dtyp) (val_t_to_application(dumptype_getconf((dtyp), DUMPTYPE_APPLICATION)))
784 #define dumptype_get_scriptlist(dtyp) (val_t_to_identlist(dumptype_getconf((dtyp), DUMPTYPE_SCRIPTLIST)))
785 #define dumptype_get_property(dtyp) (val_t_to_proplist(dumptype_getconf((dtyp), DUMPTYPE_PROPERTY)))
786 #define dumptype_get_client_port(dtyp) (val_t_to_str(dumptype_getconf((dtyp), DUMPTYPE_CLIENT_PORT)))
787 #define dumptype_get_data_path(dtyp) (val_t_to_data_path(dumptype_getconf((dtyp), DUMPTYPE_DATA_PATH)))
788 #define dumptype_get_allow_split(dtyp) (val_t_to_boolean(dumptype_getconf((dtyp), DUMPTYPE_ALLOW_SPLIT)))
789 #define dumptype_get_recovery_limit(dtyp) (val_t_to_recovery_limit(dumptype_getconf((dtyp), DUMPTYPE_RECOVERY_LIMIT)))
792 * Interface parameter access
798 INTER_INTER /* sentinel */
802 typedef struct interface_s interface_t;
804 /* Given the name of the interface, return a interface object. Returns NULL
805 * if no matching interface exists. Note that the match is case-insensitive.
807 * @param identifier: name of the desired interface
808 * @returns: object or NULL
810 interface_t *lookup_interface(char *identifier);
812 /* Given a interface and a key, return a pointer to the corresponding val_t.
814 * @param iface: the interface to examine
815 * @param key: interface_key (one of the TAPETYPE_* constants)
816 * @returns: pointer to value
818 val_t *interface_getconf(interface_t *iface, interface_key key);
820 /* Get the name of this interface.
822 * @param iface: the interface to examine
823 * @returns: name of the interface
825 char *interface_name(interface_t *iface);
827 /* (convenience macro) has this parameter been seen in this interface? This
828 * applies to the specific parameter *within* the interface.
830 * @param key: interface_key
833 #define interface_seen(iface, key) (val_t_seen(interface_getconf((iface), (key))))
835 /* (convenience macros)
836 * fetch a particular parameter; caller must know the correct type.
838 * @param iface: the interface to examine
841 #define interface_get_comment(iface) (val_t_to_str(interface_getconf((iface), INTER_COMMENT)))
842 #define interface_get_maxusage(iface) (val_t_to_int(interface_getconf((iface), INTER_MAXUSAGE)))
845 * Holdingdisk parameter access
853 HOLDING_HOLDING /* sentinel */
857 typedef struct holdingdisk_s holdingdisk_t;
859 /* Given the name of the holdingdisk, return a holdingdisk object. Returns NULL
860 * if no matching holdingdisk exists. Note that the match is case-insensitive.
862 * @param identifier: name of the desired holdingdisk
863 * @returns: object or NULL
865 holdingdisk_t *lookup_holdingdisk(char *identifier);
867 /* Return the whole linked list of holdingdisks.
869 * @returns: first holding disk
871 GSList *getconf_holdingdisks(void);
873 /* Given a holdingdisk and a key, return a pointer to the corresponding val_t.
875 * @param hdisk: the holdingdisk to examine
876 * @param key: holdingdisk_key (one of the TAPETYPE_* constants)
877 * @returns: pointer to value
879 val_t *holdingdisk_getconf(holdingdisk_t *hdisk, holdingdisk_key key);
881 /* Get the name of this holdingdisk.
883 * @param hdisk: the holdingdisk to examine
884 * @returns: name of the holdingdisk
886 char *holdingdisk_name(holdingdisk_t *hdisk);
888 /* (convenience macro) has this parameter been seen in this holdingdisk? This
889 * applies to the specific parameter *within* the holdingdisk.
891 * @param key: holdingdisk_key
894 #define holdingdisk_seen(hdisk, key) (val_t_seen(holdingdisk_getconf((hdisk), (key))))
896 /* (convenience macros)
897 * fetch a particular parameter; caller must know the correct type.
899 * @param hdisk: the holdingdisk to examine
902 #define holdingdisk_get_comment(hdisk) (val_t_to_str(holdingdisk_getconf((hdisk), HOLDING_COMMENT)))
903 #define holdingdisk_get_diskdir(hdisk) (val_t_to_str(holdingdisk_getconf((hdisk), HOLDING_DISKDIR)))
904 #define holdingdisk_get_disksize(hdisk) (val_t_to_int64(holdingdisk_getconf((hdisk), HOLDING_DISKSIZE)))
905 #define holdingdisk_get_chunksize(hdisk) (val_t_to_int64(holdingdisk_getconf((hdisk), HOLDING_CHUNKSIZE)))
907 /* A application-tool interface */
908 typedef enum application_e {
911 APPLICATION_PROPERTY,
912 APPLICATION_APPLICATION
916 typedef struct application_s application_t;
918 /* Given the name of the application, return a application object. Returns NULL
919 * if no matching application exists. Note that the match is case-insensitive.
921 * @param identifier: name of the desired application
922 * @returns: object or NULL
925 application_t *lookup_application(char *identifier);
927 /* Given a application and a key, return a pointer to the corresponding val_t.
929 * @param ttyp: the application to examine
930 * @param key: application (one of the APPLICATION_* constants)
931 * @returns: pointer to value
933 val_t *application_getconf(application_t *app, application_key key);
935 /* Get the name of this application.
937 * @param ttyp: the application to examine
938 * @returns: name of the application
940 char *application_name(application_t *app);
942 /* (convenience macro) has this parameter been seen in this application? This
943 * applies to the specific parameter *within* the application.
945 * @param key: application_key
948 #define application_seen(app, key) (val_t_seen(application_getconf((app), (key))))
950 /* (convenience macros)
951 * fetch a particular parameter; caller must know the correct type.
953 * @param ttyp: the application to examine
956 #define application_get_comment(application) (val_t_to_str(application_getconf((application), APPLICATION_COMMENT))
957 #define application_get_plugin(application) (val_t_to_str(application_getconf((application), APPLICATION_PLUGIN)))
958 #define application_get_property(application) (val_t_to_proplist(application_getconf((application), APPLICATION_PROPERTY)))
960 application_t *read_application(char *name, FILE *from, char *fname, int *linenum);
962 /* A pp-script-tool interface */
963 typedef enum pp_script_e {
967 PP_SCRIPT_EXECUTE_ON,
968 PP_SCRIPT_EXECUTE_WHERE,
974 typedef struct pp_script_s pp_script_t;
976 /* Given the name of the pp_script, return a pp_script object. Returns NULL
977 * if no matching pp_script exists. Note that the match is case-insensitive.
979 * @param identifier: name of the desired pp_script
980 * @returns: object or NULL
983 pp_script_t *lookup_pp_script(char *identifier);
985 /* Given a pp_script and a key, return a pointer to the corresponding val_t.
987 * @param ttyp: the pp_script to examine
988 * @param key: pp_script (one of the PP_SCRIPT_* constants)
989 * @returns: pointer to value
991 val_t *pp_script_getconf(pp_script_t *pps, pp_script_key key);
993 /* Get the name of this pp_script.
995 * @param ttyp: the pp_script to examine
996 * @returns: name of the pp_script
998 char *pp_script_name(pp_script_t *pps);
1000 /* (convenience macro) has this parameter been seen in this pp_script? This
1001 * applies to the specific parameter *within* the pp_script.
1003 * @param key: pp_script_key
1006 #define pp_script_seen(pps, key) (val_t_seen(pp_script_getconf((pps), (key))))
1008 /* (convenience macros)
1009 * fetch a particular parameter; caller must know the correct type.
1011 * @param ttyp: the pp_script to examine
1015 #define pp_script_get_comment(pp_script) (val_t_to_str(pp_script_getconf((pp_script), PP_SCRIPT_COMMENT)))
1016 #define pp_script_get_plugin(pp_script) (val_t_to_str(pp_script_getconf((pp_script), PP_SCRIPT_PLUGIN)))
1017 #define pp_script_get_property(pp_script) (val_t_to_proplist(pp_script_getconf((pp_script), PP_SCRIPT_PROPERTY)))
1018 #define pp_script_get_execute_on(pp_script) (val_t_to_execute_on(pp_script_getconf((pp_script), PP_SCRIPT_EXECUTE_ON)))
1019 #define pp_script_get_execute_where(pp_script) (val_t_to_execute_where(pp_script_getconf((pp_script), PP_SCRIPT_EXECUTE_WHERE)))
1020 #define pp_script_get_order(pp_script) (val_t_to_int(pp_script_getconf((pp_script), PP_SCRIPT_ORDER)))
1022 pp_script_t *read_pp_script(char *name, FILE *from, char *fname, int *linenum);
1023 pp_script_t *lookup_pp_script(char *identifier);
1025 /* A device definition */
1027 DEVICE_CONFIG_COMMENT,
1028 DEVICE_CONFIG_TAPEDEV,
1029 DEVICE_CONFIG_DEVICE_PROPERTY,
1030 DEVICE_CONFIG_DEVICE_CONFIG
1031 } device_config_key;
1034 typedef struct device_config_s device_config_t;
1036 /* Given the name of the device, return a device_config_t object. Returns NULL
1037 * if no matching device exists. Note that the match is case-insensitive.
1039 * @param identifier: name of the desired device
1040 * @returns: object or NULL
1043 device_config_t *lookup_device_config(char *identifier);
1045 /* Given a device_config and a key, return a pointer to the corresponding val_t.
1047 * @param ttyp: the device_config to examine
1048 * @param key: device_config (one of the DEVICE_CONFIG_* constants)
1049 * @returns: pointer to value
1051 val_t *device_config_getconf(device_config_t *devconf, device_config_key key);
1053 /* Get the name of this device_config.
1055 * @param ttyp: the device_config to examine
1056 * @returns: name of the device_config
1058 char *device_config_name(device_config_t *devconf);
1060 /* (convenience macro) has this parameter been seen in this device_config? This
1061 * applies to the specific parameter *within* the device_config.
1063 * @param key: device_config_key
1066 #define device_config_seen(devconf, key) (val_t_seen(device_config_getconf((devconf), (key))))
1068 /* (convenience macros)
1069 * fetch a particular parameter; caller must know the correct type.
1071 * @param devconf: the device_config to examine
1075 #define device_config_get_comment(devconf) (val_t_to_str(device_config_getconf((devconf), DEVICE_CONFIG_COMMENT)))
1076 #define device_config_get_tapedev(devconf) (val_t_to_str(device_config_getconf((devconf), DEVICE_CONFIG_TAPEDEV)))
1077 #define device_config_get_property(devconf) (val_t_to_proplist(device_config_getconf((devconf), DEVICE_CONFIG_DEVICE_PROPERTY)))
1079 device_config_t *read_device_config(char *name, FILE *from, char *fname, int *linenum);
1080 device_config_t *lookup_device_config(char *identifier);
1082 /* A changer definition */
1084 CHANGER_CONFIG_COMMENT,
1085 CHANGER_CONFIG_TAPEDEV,
1086 CHANGER_CONFIG_TPCHANGER,
1087 CHANGER_CONFIG_CHANGERDEV,
1088 CHANGER_CONFIG_CHANGERFILE,
1089 CHANGER_CONFIG_PROPERTY,
1090 CHANGER_CONFIG_DEVICE_PROPERTY,
1091 CHANGER_CONFIG_CHANGER_CONFIG
1092 } changer_config_key;
1095 typedef struct changer_config_s changer_config_t;
1097 /* Given the name of the changer, return a changer_config_t object. Returns NULL
1098 * if no matching changer exists. Note that the match is case-insensitive.
1100 * @param identifier: name of the desired changer
1101 * @returns: object or NULL
1104 changer_config_t *lookup_changer_config(char *identifier);
1106 /* Given a changer_config and a key, return a pointer to the corresponding val_t.
1108 * @param ttyp: the changer_config to examine
1109 * @param key: changer_config (one of the DEVICE_CONFIG_* constants)
1110 * @returns: pointer to value
1112 val_t *changer_config_getconf(changer_config_t *devconf, changer_config_key key);
1114 /* Get the name of this changer_config.
1116 * @param ttyp: the changer_config to examine
1117 * @returns: name of the changer_config
1119 char *changer_config_name(changer_config_t *devconf);
1121 /* (convenience macro) has this parameter been seen in this changer_config? This
1122 * applies to the specific parameter *within* the changer_config.
1124 * @param key: changer_config_key
1127 #define changer_config_seen(devconf, key) (val_t_seen(changer_config_getconf((devconf), (key))))
1129 /* (convenience macros)
1130 * fetch a particular parameter; caller must know the correct type.
1132 * @param devconf: the changer_config to examine
1136 #define changer_config_get_comment(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_COMMENT)))
1137 #define changer_config_get_tapedev(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_TAPEDEV)))
1138 #define changer_config_get_tpchanger(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_TPCHANGER)))
1139 #define changer_config_get_changerdev(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_CHANGERDEV)))
1140 #define changer_config_get_changerfile(devconf) (val_t_to_str(changer_config_getconf((devconf), CHANGER_CONFIG_CHANGERFILE)))
1142 changer_config_t *read_changer_config(char *name, FILE *from, char *fname, int *linenum);
1143 changer_config_t *lookup_changer_config(char *identifier);
1150 /* No errors or warnings */
1153 /* warnings were encountered */
1154 CFGERR_WARNINGS = 1,
1156 /* errors (and maybe some warnings too, who knows) were encountered */
1164 /* Get a GSList of all error and warning messages accumulated so far.
1166 * @param (output) errlist: pointer to the list of error strings; allocated
1167 * memory remains the responsibility of the config module. If errlist is
1168 * NULL, the list is not returned.
1169 * @returns: current error level
1171 cfgerr_level_t config_errors(GSList **errlist);
1173 /* Clear any error conditions.
1175 void config_clear_errors(void);
1177 /* Print the list of current error and warning messages, one per line,
1178 * to stderr. This is a convenience function for command-line
1181 void config_print_errors(void);
1183 /* Add an error message to the list of errors, and make sure tha the
1184 * error level is at least LEVEL. This is used by the diskfile module
1185 * to insert its errors into this module's error list.
1187 * @param level: level for this error
1188 * @param errmsg: error message; conffile takes responsibility for freeing
1191 void config_add_error(cfgerr_level_t level, char *errmsg);
1194 * Command-line handling
1198 typedef struct config_overrides_s config_overrides_t;
1200 /* Create a new, empty config_overrides object.
1202 * @param size_estimate: a guess at the number of overwrites; argc/2 is a
1204 * @returns: new object
1206 config_overrides_t *new_config_overrides(int size_estimate);
1208 /* Free a config_overrides object. This usually won't be needed, as
1209 * apply_config_overrides takes ownership of the overwrites for you.
1211 * @param co: config_overrides object
1213 void free_config_overrides(config_overrides_t *co);
1215 /* Add an overwrite to a config_overrides object.
1217 * @param co: the config_overrides object
1218 * @param key: the configuration parameter's key, possibly with the format
1219 * SUBTYPE:NAME:KEYWORD
1220 * @param value: the value for the parameter, as would be seen in amanda.conf
1222 void add_config_override(config_overrides_t *co,
1226 /* Add an overwrite option from the command line to a config_overrides
1227 * object. Calls error() with any errors
1229 * @param co: the config_overrides object
1230 * @param optarg: the value of the command-line option
1232 void add_config_override_opt(config_overrides_t *co,
1235 /* Given a command line, represented as argc/argv, extract any -o options
1236 * as config overwrites. This function modifies argc and argv in place.
1238 * This is the deprecated way to extract config overwrites, for applications
1239 * which do not use getopt. The preferred method is to use getopt and
1240 * call add_config_override_opt for any -o options.
1242 * @param argc: (in/out) command-line length
1243 * @param argv: (in/out) command-line strings
1244 * @returns: newly allocated config_overrides object
1246 config_overrides_t *
1247 extract_commandline_config_overrides(int *argc,
1250 /* Set configuration overwrites to the current configuration and take
1251 * ownership of the config_overrides object.
1253 * @param co: the config_overrides object
1255 void set_config_overrides(config_overrides_t *co);
1261 /* Constants for config_init */
1263 /* Use arg_config_name, if not NULL */
1264 CONFIG_INIT_EXPLICIT_NAME = 1 << 0,
1266 /* Use the current working directory if an explicit name is not available */
1267 CONFIG_INIT_USE_CWD = 1 << 1,
1269 /* This is a client application (server is default) */
1270 CONFIG_INIT_CLIENT = 1 << 2,
1272 /* New configuration should "overlay" existing configuration; this
1273 * is used by clients to load multiple amanda-client.conf files. */
1274 CONFIG_INIT_OVERLAY = 1 << 3,
1275 } config_init_flags;
1277 /* Initialize this application's configuration, with the specific actions
1279 * - if CONFIG_INIT_OVERLAY is not set, configuration values are reset
1281 * - if CONFIG_INIT_EXPLICIT_NAME and arg_config_name is not NULL,
1282 * use CONFIG_DIR/arg_config_name as config_dir arg_config_name as
1284 * - otherwise, if CONFIG_USE_CWD is set, use the directory in which
1285 * the application was started as config_dir, and its filename as
1287 * - otherwise, for the client only, se config_dir to CONFIG_DIR and
1288 * config_name to NULL.
1289 * - depending on CONFIG_INIT_CLIENT, read amanda.conf or amanda-client.conf
1291 * @param flags: flags indicating desired behavior, as above
1292 * @param arg_config_name: config name to use (from e.g., argv[1])
1293 * @returns: current error level
1295 cfgerr_level_t config_init(
1296 config_init_flags flags,
1297 char *arg_config_name);
1299 /* Free all memory allocated for the configuration. This effectively
1300 * reverses the effects of config_init().
1302 void config_uninit(void);
1304 /* Encode any applied config_overrides into a strv format suitale for
1305 * executing another Amanda tool.
1307 * The * result is dynamically allocated and NULL terminated. There is no
1308 * provision to free the result, as this function is always called just
1309 * before execve(..).
1311 * First gives the number of array elements to leave for the caller to
1312 * fill in. The usual calling pattern is this:
1313 * command_line = get_config_options(3);
1314 * command_line[0] = "appname";
1315 * command_line[1] = config_name;
1316 * command_line[2] = "--foo";
1317 * execve(command_line[0], command_line, safe_env());
1319 * @param first: number of unused elements to leave at the beginning of
1321 * @returns: NULL-terminated string array suitable for execve
1323 char **get_config_options(int first);
1325 /* Get the config name */
1326 char *get_config_name(void);
1328 /* Get the config directory */
1329 char *get_config_dir(void);
1331 /* Get the config filename */
1332 char *get_config_filename(void);
1338 /* Security plugins get their configuration information through a callback
1339 * with the signature:
1340 * char *callback(char *key, void *userpointer);
1341 * where key is the name of the desired parameter, which may not match the
1342 * name used in this module. See the implementations of these functions
1343 * to learn which keys they support, or to add new keys.
1345 char *generic_client_get_security_conf(char *, void *);
1346 char *generic_get_security_conf(char *, void *);
1348 /* Dump the current configuration information to stdout, in a format
1349 * that can be re-read by this module. The results will include any
1350 * command-line overwrites.
1352 * This function only dumps the server configuration, and will fail on
1355 void dump_configuration(void);
1357 /* Return a sequence of strings giving the printable representation
1358 * of the given val_t. If str_needs_quotes is true and each string is
1359 * prefixed by the relevant configuration keyword, these strings will
1360 * be parseable by this module, and will reproduce exactly the same
1361 * configuration value. See the implementation of dump_configuration
1364 * If str_needs_quotes is provided, a CONFTYPE_STR value will be returned with
1367 * The result is a NULL-terminated strv, which can be freed with g_strfreev or
1368 * joined with g_strjoinv. Caller is responsible for freeing the memory.
1370 * @param val: the value to analyze
1371 * @param str_needs_quotes: add quotes to CONFTYPE_STR values?
1372 * @returns: NULL-terminated string vector
1374 char **val_t_display_strs(val_t *val, int str_needs_quotes);
1376 /* Read a dumptype; this is used by this module as well as by diskfile.c to
1377 * read the disklist. The two are carefully balanced in their parsing process.
1379 * Nobody else should use this function. Seriously.
1381 dumptype_t *read_dumptype(char *name, FILE *from, char *fname, int *linenum);
1383 /* Every call return a pointer to a string with an increasing number; this is
1384 * used by this module as well as by diskfile.c to read the disklist.
1386 * Nobody else should use this function. Seriously.
1388 * @returns: a pointer to a static string.
1390 char *anonymous_value(void);
1392 /* Extend a relative filename with the current config_dir; if filename is already
1393 * absolute, this is equivalent to stralloc.
1395 * @param filename: filename to extend
1396 * @returns: newly allocated filename
1398 char *config_dir_relative(char *filename);
1400 /* Convert from a symbol back to a name for logging and for dumping
1403 * @param taperalgo: the constant value
1404 * @returns: statically allocated string
1406 char *taperalgo2str(taperalgo_t taperalgo);
1408 /* Looks for a unit value like b, byte, bytes, bps, etc. Technically
1409 * the return value should never be < 1, but we return a signed value
1410 * to help mitigate bad C promotion semantics. Returns 0 on error.
1412 * This is here in this module because it uses the numb_keytable.
1414 * @param casestr: the unit string
1415 * @returns: the corresponding multiplier (e.g., 'M' => 1024*1024)
1417 gint64 find_multiplier(char * casestr);
1419 /* Converts a string matching any of Amanda's names for "true" or
1420 * "false" to a boolean value.
1422 * @param str: string to match
1423 * @returns: 0 or 1 (boolean) or -1 (no match)
1425 int string_to_boolean(const char *str);
1427 /* Return a pointer to a static string for the data_path */
1428 char *data_path_to_string(data_path_t data_path);
1430 /* Return the data_path for the string */
1431 data_path_t data_path_from_string(char *data);
1433 void free_property_t(gpointer p);
1435 /* Converts a string into Amanda property name style.
1437 * @param name: The name to convert.
1438 * @returns: A newly allocated string, with name in lowercase and
1439 * any instances of '_' replaced with '-'.
1441 gchar *amandaify_property_name(const gchar *name);
1443 #endif /* ! CONFFILE_H */