mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Add filename alias support to the Config Options API
This adds the ability to handle a single filename alias for a config file. This is useful if a config filename has changed, but the old filename should be supported for backwards compatibility. Review: https://reviewboard.asterisk.org/r/1981/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368920 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -136,9 +136,11 @@ typedef int (*aco_pre_apply_config)(void);
|
|||||||
*/
|
*/
|
||||||
typedef void *(*aco_snapshot_alloc)(void);
|
typedef void *(*aco_snapshot_alloc)(void);
|
||||||
|
|
||||||
|
/*! \brief The representation of a single configuration file to be processed */
|
||||||
struct aco_file {
|
struct aco_file {
|
||||||
const char *filename;
|
const char *filename; /*!< \brief The filename to be processed */
|
||||||
const char **preload;
|
const char *alias; /*!< \brief An alias filename to be tried if 'filename' cannot be found */
|
||||||
|
const char **preload; /*!< \brief A null-terminated oredered array of categories to be loaded first */
|
||||||
struct aco_type *types[]; /*!< The list of types for this config. Required. Use a sentinel! */
|
struct aco_type *types[]; /*!< The list of types for this config. Required. Use a sentinel! */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -434,7 +434,13 @@ enum aco_process_status aco_process_config(struct aco_info *info, int reload)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (res != ACO_PROCESS_ERROR && (file = info->files[x++])) {
|
while (res != ACO_PROCESS_ERROR && (file = info->files[x++])) {
|
||||||
if (!(cfg = ast_config_load(file->filename, cfg_flags))) {
|
const char *filename = file->filename;
|
||||||
|
try_alias:
|
||||||
|
if (!(cfg = ast_config_load(filename, cfg_flags))) {
|
||||||
|
if (file->alias && strcmp(file->alias, filename)) {
|
||||||
|
filename = file->alias;
|
||||||
|
goto try_alias;
|
||||||
|
}
|
||||||
ast_log(LOG_ERROR, "Unable to load config file '%s'\n", file->filename);
|
ast_log(LOG_ERROR, "Unable to load config file '%s'\n", file->filename);
|
||||||
res = ACO_PROCESS_ERROR;
|
res = ACO_PROCESS_ERROR;
|
||||||
break;
|
break;
|
||||||
@@ -447,6 +453,10 @@ enum aco_process_status aco_process_config(struct aco_info *info, int reload)
|
|||||||
res = ACO_PROCESS_ERROR;
|
res = ACO_PROCESS_ERROR;
|
||||||
break;
|
break;
|
||||||
} else if (cfg == CONFIG_STATUS_FILEMISSING) {
|
} else if (cfg == CONFIG_STATUS_FILEMISSING) {
|
||||||
|
if (file->alias && strcmp(file->alias, filename)) {
|
||||||
|
filename = file->alias;
|
||||||
|
goto try_alias;
|
||||||
|
}
|
||||||
ast_log(LOG_ERROR, "%s is missing! Cannot load %s\n", file->filename, info->module);
|
ast_log(LOG_ERROR, "%s is missing! Cannot load %s\n", file->filename, info->module);
|
||||||
res = ACO_PROCESS_ERROR;
|
res = ACO_PROCESS_ERROR;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user