📄 conffile.h
字号:
* * @param iface: the interface to examine * @returns: name of the interface */char *interface_name(interface_t *iface);/* (convenience macro) has this parameter been seen in this interface? This * applies to the specific parameter *within* the interface. * * @param key: interface_key * @returns: boolean */#define interface_seen(iface, key) (val_t_seen(interface_getconf((iface), (key))))/* (convenience macros) * fetch a particular parameter; caller must know the correct type. * * @param iface: the interface to examine * @returns: various */#define interface_get_comment(iface) (val_t_to_str(interface_getconf((iface), INTER_COMMENT)))#define interface_get_maxusage(iface) (val_t_to_int(interface_getconf((iface), INTER_MAXUSAGE)))/* * Holdingdisk parameter access */typedef enum { HOLDING_COMMENT, HOLDING_DISKDIR, HOLDING_DISKSIZE, HOLDING_CHUNKSIZE, HOLDING_HOLDING /* sentinel */} holdingdisk_key;/* opaque object */typedef struct holdingdisk_s holdingdisk_t;/* Given the name of the holdingdisk, return a holdingdisk object. Returns NULL * if no matching holdingdisk exists. Note that the match is case-insensitive. * * @param identifier: name of the desired holdingdisk * @returns: object or NULL */holdingdisk_t *lookup_holdingdisk(char *identifier);/* Return the whole linked list of holdingdisks. Use holdingdisk_next * to traverse the list. * * @returns: first holding disk */holdingdisk_t *getconf_holdingdisks(void);/* Return the next holdingdisk in the list. * * @param hdisk: holding disk * @returns: NULL if hdisk is the last disk, otherwise the next holding * disk */holdingdisk_t *holdingdisk_next(holdingdisk_t *hdisk);/* Given a holdingdisk and a key, return a pointer to the corresponding val_t. * * @param hdisk: the holdingdisk to examine * @param key: holdingdisk_key (one of the TAPETYPE_* constants) * @returns: pointer to value */val_t *holdingdisk_getconf(holdingdisk_t *hdisk, holdingdisk_key key);/* Get the name of this holdingdisk. * * @param hdisk: the holdingdisk to examine * @returns: name of the holdingdisk */char *holdingdisk_name(holdingdisk_t *hdisk);/* (convenience macro) has this parameter been seen in this holdingdisk? This * applies to the specific parameter *within* the holdingdisk. * * @param key: holdingdisk_key * @returns: boolean */#define holdingdisk_seen(hdisk, key) (val_t_seen(holdingdisk_getconf((hdisk), (key))))/* (convenience macros) * fetch a particular parameter; caller must know the correct type. * * @param hdisk: the holdingdisk to examine * @returns: various */#define holdingdisk_get_comment(hdisk) (val_t_to_str(holdingdisk_getconf((hdisk), HOLDING_COMMENT)))#define holdingdisk_get_diskdir(hdisk) (val_t_to_str(holdingdisk_getconf((hdisk), HOLDING_DISKDIR)))#define holdingdisk_get_disksize(hdisk) (val_t_to_am64(holdingdisk_getconf((hdisk), HOLDING_DISKSIZE)))#define holdingdisk_get_chunksize(hdisk) (val_t_to_am64(holdingdisk_getconf((hdisk), HOLDING_CHUNKSIZE)))/* * Command-line handling *//* opaque type */typedef struct config_overwrites_s config_overwrites_t;/* Create a new, empty config_overwrites object. * * @param size_estimate: a guess at the number of overwrites; argc/2 is a * good estimate. * @returns: new object */config_overwrites_t *new_config_overwrites(int size_estimate);/* Free a config_overwrites object. This usually won't be needed, as * apply_config_overwrites takes ownership of the overwrites for you. * * @param co: config_overwrites object */void free_config_overwrites(config_overwrites_t *co);/* Add an overwrite to a config_overwrites object. * * @param co: the config_overwrites object * @param key: the configuration parameter's key, possibly with the format * SUBTYPE:NAME:KEYWORD * @param value: the value for the parameter, as would be seen in amanda.conf */void add_config_overwrite(config_overwrites_t *co, char *key, char *value);/* Add an overwrite option from the command line to a config_overwrites * object. Calls error() with any errors * * @param co: the config_overwrites object * @param optarg: the value of the command-line option */void add_config_overwrite_opt(config_overwrites_t *co, char *optarg);/* Given a command line, represented as argc/argv, extract any -o options * as config overwrites. This function modifies argc and argv in place. * * This is the deprecated way to extract config overwrites, for applications * which do not use getopt. The preferred method is to use getopt and * call add_config_overwrite_opt for any -o options. * * @param argc: (in/out) command-line length * @param argv: (in/out) command-line strings * @returns: newly allocated config_overwrites object */config_overwrites_t *extract_commandline_config_overwrites(int *argc, char ***argv);/* Apply configuration overwrites to the current configuration and take * ownership of the config_overwrites object. * * If any parameters are not matched in the current symbol table, or * correspond to named subsections which do not exist, this function calls * error() and does not return. * * @param co: the config_overwrites object */void apply_config_overwrites(config_overwrites_t *co);/* * Initialization *//* Constants for config_init */typedef enum { /* Use arg_config_name, if not NULL */ CONFIG_INIT_EXPLICIT_NAME = 1 << 0, /* Use the current working directory if an explicit name is not available */ CONFIG_INIT_USE_CWD = 1 << 1, /* This is a client application (server is default) */ CONFIG_INIT_CLIENT = 1 << 2, /* New configuration should "overlay" existing configuration; this * is used by clients to load multiple amanda-client.conf files. */ CONFIG_INIT_OVERLAY = 1 << 3, /* If the file doesn't exist, halt with an error. */ CONFIG_INIT_FATAL = 1 << 4,} config_init_flags;/* Initialize this application's configuration, with the specific actions * based on 'flags': * - if CONFIG_INIT_OVERLAY is not set, configuration values are reset * to their defaults * - if CONFIG_INIT_EXPLICIT_NAME and arg_config_name is not NULL, * use CONFIG_DIR/arg_config_name as config_dir arg_config_name as * config_name. * - otherwise, if CONFIG_USE_CWD is set, use the directory in which * the application was started as config_dir, and its filename as * config_name. * - otherwise, for the client only, se config_dir to CONFIG_DIR and * config_name to NULL. * - depending on CONFIG_INIT_CLIENT, read amanda.conf or amanda-client.conf * - in the event of an error, call error() if CONFIG_INIT_FATAL, otherwise * record a message in the debug log and return false. * * @param flags: flags indicating desired behavior, as above * @param arg_config_name: config name to use (from e.g., argv[1]) * @returns: true on success, false on failure, unless CONFIG_INIT_FATAL */gboolean config_init(config_init_flags flags, char *arg_config_name);/* Free all memory allocated for the configuration. This effectively * reverses the effects of config_init(). */void config_uninit(void);/* Encode any applied config_overwrites into a strv format suitale for * executing another Amanda tool. * * The * result is dynamically allocated and NULL terminated. There is no * provision to free the result, as this function is always called just * before execve(..). * * First gives the number of array elements to leave for the caller to * fill in. The usual calling pattern is this: * command_line = get_config_options(3); * command_line[0] = "appname"; * command_line[1] = config_name; * command_line[2] = "--foo"; * execve(command_line[0], command_line, safe_env()); * * @param first: number of unused elements to leave at the beginning of * the array. * @returns: NULL-terminated string array suitable for execve */char **get_config_options(int first);/* The name of the configuration under which this application is running. * This variable is initialized by config_init, and should be treated as * read-only. */extern char *config_name;/* The directory containing the configuration for this application. This * variable is initialized by config_init, and should be treated as read-only. */extern char *config_dir;/* The most recently read top-level configuration file. This variable is * initialized by config_init, and should be treated as read-only. */extern char *config_filename;/* * Utilities *//* Security plugins get their configuration information through a callback * with the signature: * char *callback(char *key, void *userpointer); * where key is the name of the desired parameter, which may not match the * name used in this module. See the implementations of these functions * to learn which keys they support, or to add new keys. */char *generic_client_get_security_conf(char *, void *);char *generic_get_security_conf(char *, void *);/* Dump the current configuration information to stdout, in a format * that can be re-read by this module. The results will include any * command-line overwrites. * * This function only dumps the server configuration, and will fail on * clients. */void dump_configuration(void);/* Return a sequence of strings giving the printable representation * of the given val_t. If str_needs_quotes is true and each string is * prefixed by the relevant configuration keyword, these strings will * be parseable by this module, and will reproduce exactly the same * configuration value. See the implementation of dump_configuration * for details. * * If str_needs_quotes is provided, a CONFTYPE_STR value will be returned with * quotes. * * The result is a NULL-terminated strv, which can be freed with g_strfreev or * joined with g_strjoinv. Caller is responsible for freeing the memory. * * @param val: the value to analyze * @param str_needs_quotes: add quotes to CONFTYPE_STR values? * @returns: NULL-terminated string vector */char **val_t_display_strs(val_t *val, int str_needs_quotes);/* Read a dumptype; this is used by this module as well as by diskfile.c to * read the disklist. The two are carefully balanced in their parsing process. * * Nobody else should use this function. Seriously. */dumptype_t *read_dumptype(char *name, FILE *from, char *fname, int *linenum);/* Extend a relative filename with the current config_dir; if filename is already * absolute, this is equivalent to stralloc. * * @param filename: filename to extend * @returns: newly allocated filename */char *config_dir_relative(char *filename);/* Convert from a symbol back to a name for logging and for dumping * config values * * @param taperalgo: the constant value * @returns: statically allocated string */char *taperalgo2str(taperalgo_t taperalgo);/* Looks for a unit value like b, byte, bytes, bps, etc. Technically * the return value should never be < 1, but we return a signed value * to help mitigate bad C promotion semantics. Returns 0 on error. * * This is here in this module because it uses the numb_keytable. * * @param casestr: the unit string * @returns: the corresponding multiplier (e.g., 'M' => 1024*1024) */gint64 find_multiplier(char * casestr);#endif /* ! CONFFILE_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -