[asterisk-commits] file: branch file/res_sorcery_realtime r384613 - in /team/file/res_sorcery_re...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 3 10:22:26 CDT 2013


Author: file
Date: Wed Apr  3 10:22:23 2013
New Revision: 384613

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384613
Log:
For the purposes of testing allow a realtime mapping to be added programatically.

Modified:
    team/file/res_sorcery_realtime/include/asterisk/config.h
    team/file/res_sorcery_realtime/main/config.c
    team/file/res_sorcery_realtime/tests/test_sorcery_realtime.c

Modified: team/file/res_sorcery_realtime/include/asterisk/config.h
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_realtime/include/asterisk/config.h?view=diff&rev=384613&r1=384612&r2=384613
==============================================================================
--- team/file/res_sorcery_realtime/include/asterisk/config.h (original)
+++ team/file/res_sorcery_realtime/include/asterisk/config.h Wed Apr  3 10:22:23 2013
@@ -588,6 +588,19 @@
  * \retval 0 if it is not
  */
 int ast_realtime_is_mapping_defined(const char *family);
+
+/*!
+ * \brief Add an explicit mapping for a family
+ *
+ * \param name Family name
+ * \param driver Driver to use
+ * \param database Database to access
+ * \param table Table to use
+ * \param priority Priority of this mapping
+ */
+#ifdef TEST_FRAMEWORK
+int ast_realtime_append_mapping(const char *name, const char *driver, const char *database, const char *table, int priority);
+#endif
 
 /*!
  * \brief Exposed initialization method for core process

Modified: team/file/res_sorcery_realtime/main/config.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_realtime/main/config.c?view=diff&rev=384613&r1=384612&r2=384613
==============================================================================
--- team/file/res_sorcery_realtime/main/config.c (original)
+++ team/file/res_sorcery_realtime/main/config.c Wed Apr  3 10:22:23 2013
@@ -2214,7 +2214,11 @@
 	}
 }
 
-static int append_mapping(const char *name, const char *driver, const char *database, const char *table, int priority)
+#ifdef TEST_FRAMEWORK
+int ast_realtime_append_mapping(const char *name, const char *driver, const char *database, const char *table, int priority)
+#else
+static int ast_realtime_append_mapping(const char *name, const char *driver, const char *database, const char *table, int priority)
+#endif
 {
 	struct ast_config_map *map;
 	char *dst;
@@ -2317,13 +2321,13 @@
 			continue;
 		if (!strcasecmp(v->name, "sipfriends")) {
 			ast_log(LOG_WARNING, "The 'sipfriends' table is obsolete, update your config to use sippeers instead.\n");
-			append_mapping("sippeers", driver, database, table ? table : "sipfriends", pri);
+			ast_realtime_append_mapping("sippeers", driver, database, table ? table : "sipfriends", pri);
 		} else if (!strcasecmp(v->name, "iaxfriends")) {
 			ast_log(LOG_WARNING, "The 'iaxfriends' table is obsolete, update your config to use iaxusers and iaxpeers, though they can point to the same table.\n");
-			append_mapping("iaxusers", driver, database, table ? table : "iaxfriends", pri);
-			append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends", pri);
+			ast_realtime_append_mapping("iaxusers", driver, database, table ? table : "iaxfriends", pri);
+			ast_realtime_append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends", pri);
 		} else
-			append_mapping(v->name, driver, database, table, pri);
+			ast_realtime_append_mapping(v->name, driver, database, table, pri);
 	}
 
 	ast_config_destroy(config);

Modified: team/file/res_sorcery_realtime/tests/test_sorcery_realtime.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_sorcery_realtime/tests/test_sorcery_realtime.c?view=diff&rev=384613&r1=384612&r2=384613
==============================================================================
--- team/file/res_sorcery_realtime/tests/test_sorcery_realtime.c (original)
+++ team/file/res_sorcery_realtime/tests/test_sorcery_realtime.c Wed Apr  3 10:22:23 2013
@@ -773,6 +773,7 @@
 static int load_module(void)
 {
 	ast_config_engine_register(&sorcery_config_engine);
+	ast_realtime_append_mapping("sorcery_realtime_test", "sorcery_realtime_test", "test", "test", 1);
 	AST_TEST_REGISTER(object_create);
 	AST_TEST_REGISTER(object_retrieve_id);
 	AST_TEST_REGISTER(object_retrieve_field);




More information about the asterisk-commits mailing list