[asterisk-commits] kmoore: branch kmoore/stasis-bridging-channel_events r385978 - in /team/kmoor...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 17 13:40:22 CDT 2013


Author: kmoore
Date: Wed Apr 17 13:40:19 2013
New Revision: 385978

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385978
Log:
Factor out some common functions

Modified:
    team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h
    team/kmoore/stasis-bridging-channel_events/main/manager_channels.c
    team/kmoore/stasis-bridging-channel_events/main/stasis_channels.c
    team/kmoore/stasis-bridging-channel_events/res/res_stasis.c

Modified: team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h?view=diff&rev=385978&r1=385977&r2=385978
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h (original)
+++ team/kmoore/stasis-bridging-channel_events/include/asterisk/stasis_channels.h Wed Apr 17 13:40:19 2013
@@ -299,6 +299,34 @@
 struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot);
 
 /*!
+ * \brief Compares the context, exten and priority of two snapshots.
+ * \since 12
+ *
+ * \param old_snapshot Old snapshot
+ * \param new_snapshot New snapshot
+ *
+ * \return True (non-zero) if context, exten or priority are identical.
+ * \return False (zero) if context, exten and priority changed.
+ */
+int ast_channel_snapshot_cep_equal(
+	const struct ast_channel_snapshot *old_snapshot,
+	const struct ast_channel_snapshot *new_snapshot);
+
+/*!
+ * \brief Compares the callerid info of two snapshots.
+ * \since 12
+ *
+ * \param old_snapshot Old snapshot
+ * \param new_snapshot New snapshot
+ *
+ * \return True (non-zero) if callerid are identical.
+ * \return False (zero) if callerid changed.
+ */
+int ast_channel_snapshot_caller_id_equal(
+	const struct ast_channel_snapshot *old_snapshot,
+	const struct ast_channel_snapshot *new_snapshot);
+
+/*!
  * \brief Dispose of the stasis channel topics and message types
  */
 void ast_stasis_channels_shutdown(void);

Modified: team/kmoore/stasis-bridging-channel_events/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/main/manager_channels.c?view=diff&rev=385978&r1=385977&r2=385978
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/main/manager_channels.c (original)
+++ team/kmoore/stasis-bridging-channel_events/main/manager_channels.c Wed Apr 17 13:40:19 2013
@@ -337,34 +337,6 @@
 	return NULL;
 }
 
-/*!
- * \brief Compares the context, exten and priority of two snapshots.
- * \param old_snapshot Old snapshot
- * \param new_snapshot New snapshot
- * \return True (non-zero) if context, exten or priority are identical.
- * \return False (zero) if context, exten and priority changed.
- */
-static inline int cep_equal(
-	const struct ast_channel_snapshot *old_snapshot,
-	const struct ast_channel_snapshot *new_snapshot)
-{
-	ast_assert(old_snapshot != NULL);
-	ast_assert(new_snapshot != NULL);
-
-	/* We actually get some snapshots with CEP set, but before the
-	 * application is set. Since empty application is invalid, we treat
-	 * setting the application from nothing as a CEP change.
-	 */
-	if (ast_strlen_zero(old_snapshot->appl) &&
-	    !ast_strlen_zero(new_snapshot->appl)) {
-		return 0;
-	}
-
-	return old_snapshot->priority == new_snapshot->priority &&
-		strcmp(old_snapshot->context, new_snapshot->context) == 0 &&
-		strcmp(old_snapshot->exten, new_snapshot->exten) == 0;
-}
-
 static struct ast_manager_event_blob *channel_newexten(
 	struct ast_channel_snapshot *old_snapshot,
 	struct ast_channel_snapshot *new_snapshot)
@@ -379,7 +351,7 @@
 		return NULL;
 	}
 
-	if (old_snapshot && cep_equal(old_snapshot, new_snapshot)) {
+	if (old_snapshot && ast_channel_snapshot_cep_equal(old_snapshot, new_snapshot)) {
 		return NULL;
 	}
 
@@ -394,23 +366,6 @@
 		new_snapshot->data);
 }
 
-/*!
- * \brief Compares the callerid info of two snapshots.
- * \param old_snapshot Old snapshot
- * \param new_snapshot New snapshot
- * \return True (non-zero) if callerid are identical.
- * \return False (zero) if callerid changed.
- */
-static inline int caller_id_equal(
-	const struct ast_channel_snapshot *old_snapshot,
-	const struct ast_channel_snapshot *new_snapshot)
-{
-	ast_assert(old_snapshot != NULL);
-	ast_assert(new_snapshot != NULL);
-	return strcmp(old_snapshot->caller_number, new_snapshot->caller_number) == 0 &&
-		strcmp(old_snapshot->caller_name, new_snapshot->caller_name) == 0;
-}
-
 static struct ast_manager_event_blob *channel_new_callerid(
 	struct ast_channel_snapshot *old_snapshot,
 	struct ast_channel_snapshot *new_snapshot)
@@ -420,7 +375,7 @@
 		return NULL;
 	}
 
-	if (caller_id_equal(old_snapshot, new_snapshot)) {
+	if (ast_channel_snapshot_caller_id_equal(old_snapshot, new_snapshot)) {
 		return NULL;
 	}
 

Modified: team/kmoore/stasis-bridging-channel_events/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/main/stasis_channels.c?view=diff&rev=385978&r1=385977&r2=385978
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/main/stasis_channels.c (original)
+++ team/kmoore/stasis-bridging-channel_events/main/stasis_channels.c Wed Apr 17 13:40:19 2013
@@ -489,6 +489,37 @@
 	return ast_json_ref(json_chan);
 }
 
+int ast_channel_snapshot_cep_equal(
+	const struct ast_channel_snapshot *old_snapshot,
+	const struct ast_channel_snapshot *new_snapshot)
+{
+	ast_assert(old_snapshot != NULL);
+	ast_assert(new_snapshot != NULL);
+
+	/* We actually get some snapshots with CEP set, but before the
+	 * application is set. Since empty application is invalid, we treat
+	 * setting the application from nothing as a CEP change.
+	 */
+	if (ast_strlen_zero(old_snapshot->appl) &&
+	    !ast_strlen_zero(new_snapshot->appl)) {
+		return 0;
+	}
+
+	return old_snapshot->priority == new_snapshot->priority &&
+		strcmp(old_snapshot->context, new_snapshot->context) == 0 &&
+		strcmp(old_snapshot->exten, new_snapshot->exten) == 0;
+}
+
+int ast_channel_snapshot_caller_id_equal(
+	const struct ast_channel_snapshot *old_snapshot,
+	const struct ast_channel_snapshot *new_snapshot)
+{
+	ast_assert(old_snapshot != NULL);
+	ast_assert(new_snapshot != NULL);
+	return strcmp(old_snapshot->caller_number, new_snapshot->caller_number) == 0 &&
+		strcmp(old_snapshot->caller_name, new_snapshot->caller_name) == 0;
+}
+
 void ast_stasis_channels_shutdown(void)
 {
 	ao2_cleanup(channel_snapshot_type);

Modified: team/kmoore/stasis-bridging-channel_events/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/res/res_stasis.c?view=diff&rev=385978&r1=385977&r2=385978
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/res/res_stasis.c (original)
+++ team/kmoore/stasis-bridging-channel_events/res/res_stasis.c Wed Apr 17 13:40:19 2013
@@ -462,34 +462,6 @@
 	return app_event_create(event_name, new_snapshot ? new_snapshot : old_snapshot, json);
 }
 
-/*!
- * \brief Compares the context, exten and priority of two snapshots.
- * \param old_snapshot Old snapshot
- * \param new_snapshot New snapshot
- * \return True (non-zero) if context, exten or priority are identical.
- * \return False (zero) if context, exten and priority changed.
- */
-static inline int cep_equal(
-	const struct ast_channel_snapshot *old_snapshot,
-	const struct ast_channel_snapshot *new_snapshot)
-{
-	ast_assert(old_snapshot != NULL);
-	ast_assert(new_snapshot != NULL);
-
-	/* We actually get some snapshots with CEP set, but before the
-	 * application is set. Since empty application is invalid, we treat
-	 * setting the application from nothing as a CEP change.
-	 */
-	if (ast_strlen_zero(old_snapshot->appl) &&
-	    !ast_strlen_zero(new_snapshot->appl)) {
-		return 0;
-	}
-
-	return old_snapshot->priority == new_snapshot->priority &&
-		strcmp(old_snapshot->context, new_snapshot->context) == 0 &&
-		strcmp(old_snapshot->exten, new_snapshot->exten) == 0;
-}
-
 static struct ast_json *channel_dialplan(
 	struct ast_channel_snapshot *old_snapshot,
 	struct ast_channel_snapshot *new_snapshot)
@@ -506,7 +478,7 @@
 		return NULL;
 	}
 
-	if (old_snapshot && cep_equal(old_snapshot, new_snapshot)) {
+	if (old_snapshot && ast_channel_snapshot_cep_equal(old_snapshot, new_snapshot)) {
 		return NULL;
 	}
 
@@ -520,23 +492,6 @@
 	return app_event_create("channel-event-dialplan", new_snapshot, json);
 }
 
-/*!
- * \brief Compares the callerid info of two snapshots.
- * \param old_snapshot Old snapshot
- * \param new_snapshot New snapshot
- * \return True (non-zero) if callerid are identical.
- * \return False (zero) if callerid changed.
- */
-static inline int caller_id_equal(
-	const struct ast_channel_snapshot *old_snapshot,
-	const struct ast_channel_snapshot *new_snapshot)
-{
-	ast_assert(old_snapshot != NULL);
-	ast_assert(new_snapshot != NULL);
-	return strcmp(old_snapshot->caller_number, new_snapshot->caller_number) == 0 &&
-		strcmp(old_snapshot->caller_name, new_snapshot->caller_name) == 0;
-}
-
 static struct ast_json *channel_callerid(
 	struct ast_channel_snapshot *old_snapshot,
 	struct ast_channel_snapshot *new_snapshot)
@@ -548,7 +503,7 @@
 		return NULL;
 	}
 
-	if (caller_id_equal(old_snapshot, new_snapshot)) {
+	if (ast_channel_snapshot_caller_id_equal(old_snapshot, new_snapshot)) {
 		return NULL;
 	}
 




More information about the asterisk-commits mailing list