[asterisk-commits] twilson: trunk r368920 - in /trunk: include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 14 08:35:14 CDT 2012


Author: twilson
Date: Thu Jun 14 08:35:07 2012
New Revision: 368920

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=368920
Log:
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.

Modified:
    trunk/include/asterisk/config_options.h
    trunk/main/config_options.c

Modified: trunk/include/asterisk/config_options.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/config_options.h?view=diff&rev=368920&r1=368919&r2=368920
==============================================================================
--- trunk/include/asterisk/config_options.h (original)
+++ trunk/include/asterisk/config_options.h Thu Jun 14 08:35:07 2012
@@ -136,9 +136,11 @@
  */
 typedef void *(*aco_snapshot_alloc)(void);
 
+/*! \brief The representation of a single configuration file to be processed */
 struct aco_file {
-	const char *filename;
-	const char **preload;
+	const char *filename; /*!< \brief The filename to be processed */
+	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! */
 };
 

Modified: trunk/main/config_options.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/config_options.c?view=diff&rev=368920&r1=368919&r2=368920
==============================================================================
--- trunk/main/config_options.c (original)
+++ trunk/main/config_options.c Thu Jun 14 08:35:07 2012
@@ -434,7 +434,13 @@
 	}
 
 	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);
 			res = ACO_PROCESS_ERROR;
 			break;
@@ -447,6 +453,10 @@
 			res = ACO_PROCESS_ERROR;
 			break;
 		} 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);
 			res = ACO_PROCESS_ERROR;
 			break;




More information about the asterisk-commits mailing list