[svn-commits] mmichelson: branch group/CCSS r223294 - /team/group/CCSS/main/ccss.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Oct 9 14:19:02 CDT 2009


Author: mmichelson
Date: Fri Oct  9 14:18:58 2009
New Revision: 223294

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=223294
Log:
Move agent and monitor registration functions to
same area, just after config functions.


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=223294&r1=223293&r2=223294
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Fri Oct  9 14:18:58 2009
@@ -72,22 +72,6 @@
 	char cc_callback_macro[AST_MAX_EXTENSION];
 };
 
-AST_RWLIST_HEAD_STATIC(cc_monitor_backends, cc_monitor_backend);
-AST_RWLIST_HEAD_STATIC(cc_agent_backends, cc_agent_backend);
-
-struct cc_monitor_backend {
-	AST_LIST_ENTRY(cc_monitor_backend) next;
-	const struct ast_cc_monitor_callbacks *callbacks;
-};
-
-struct cc_agent_backend {
-	AST_LIST_ENTRY(cc_agent_backend) next;
-	const struct ast_cc_agent_callbacks *callbacks;
-};
-
-#define cc_ref(obj, debug) ({ao2_t_ref((obj), +1, (debug)); (obj);})
-#define cc_unref(obj, debug) ({ao2_t_ref((obj), -1, (debug)); NULL;})
-
 /* XXX I'm making these defaults up right now with no real regard for
  * what they *should* be. This can be revisited.
  */
@@ -397,6 +381,108 @@
 		ast_copy_string(config->cc_callback_macro, value, sizeof(config->cc_callback_macro));
 	}
 }
+
+struct cc_monitor_backend {
+	AST_LIST_ENTRY(cc_monitor_backend) next;
+	const struct ast_cc_monitor_callbacks *callbacks;
+};
+
+AST_RWLIST_HEAD_STATIC(cc_monitor_backends, cc_monitor_backend);
+
+int ast_cc_monitor_register(const struct ast_cc_monitor_callbacks *callbacks)
+{
+	struct cc_monitor_backend *backend = ast_calloc(1, sizeof(*backend));
+
+	if (!backend) {
+		return -1;
+	}
+
+	backend->callbacks = callbacks;
+
+	AST_RWLIST_WRLOCK(&cc_monitor_backends);
+	AST_RWLIST_INSERT_TAIL(&cc_monitor_backends, backend, next);
+	AST_RWLIST_UNLOCK(&cc_monitor_backends);
+	return 0;
+}
+
+static const struct ast_cc_monitor_callbacks *find_monitor_callbacks(const char * const type)
+{
+	struct cc_monitor_backend *backend;
+	const struct ast_cc_monitor_callbacks *callbacks = NULL;
+
+	AST_RWLIST_RDLOCK(&cc_monitor_backends);
+	AST_RWLIST_TRAVERSE(&cc_monitor_backends, backend, next) {
+		if (!strcmp(backend->callbacks->type, type)) {
+			ast_log(LOG_NOTICE, "Returning backend %s\n", backend->callbacks->type);
+			callbacks = backend->callbacks;
+			break;
+		}
+	}
+	AST_RWLIST_UNLOCK(&cc_monitor_backends);
+	return callbacks;
+}
+
+struct cc_agent_backend {
+	AST_LIST_ENTRY(cc_agent_backend) next;
+	const struct ast_cc_agent_callbacks *callbacks;
+};
+
+AST_RWLIST_HEAD_STATIC(cc_agent_backends, cc_agent_backend);
+
+int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks)
+{
+	struct cc_agent_backend *backend = ast_calloc(1, sizeof(*backend));
+
+	if (!backend) {
+		return -1;
+	}
+
+	backend->callbacks = callbacks;
+	AST_RWLIST_WRLOCK(&cc_agent_backends);
+	AST_RWLIST_INSERT_TAIL(&cc_agent_backends, backend, next);
+	AST_RWLIST_UNLOCK(&cc_agent_backends);
+	return 0;
+}
+
+static const struct ast_cc_agent_callbacks *find_agent_callbacks(struct ast_channel *chan)
+{
+	struct cc_agent_backend *backend;
+	const struct ast_cc_agent_callbacks *callbacks = NULL;
+	enum ast_cc_agent_policies agent_policy;
+	const char *type;
+
+	agent_policy = ast_get_cc_agent_policy(ast_channel_get_cc_config_params(chan));
+
+	if (agent_policy == AST_CC_AGENT_GENERIC) {
+		type = "generic";
+	} else if (agent_policy == AST_CC_AGENT_NATIVE) {
+		char chan_name[AST_CHANNEL_NAME];
+		char *slash;
+		ast_copy_string(chan_name, chan->name, sizeof(chan_name));
+		if ((slash = strchr(chan_name, '/'))) {
+			*slash = '\0';
+		}
+		type = chan_name;
+	} else {
+		ast_log(LOG_NOTICE, "Not returning agent callbacks since this channel is configured not to have a CC agent\n");
+		return NULL;
+	}
+
+	AST_RWLIST_RDLOCK(&cc_agent_backends);
+	AST_RWLIST_TRAVERSE(&cc_agent_backends, backend, next) {
+		if (!strcmp(backend->callbacks->type, type)) {
+			ast_log(LOG_NOTICE, "Returning backend %s\n", backend->callbacks->type);
+			callbacks = backend->callbacks;
+			break;
+		}
+	}
+	AST_RWLIST_UNLOCK(&cc_agent_backends);
+	return callbacks;
+}
+
+
+#define cc_ref(obj, debug) ({ao2_t_ref((obj), +1, (debug)); (obj);})
+#define cc_unref(obj, debug) ({ao2_t_ref((obj), -1, (debug)); NULL;})
 
 /* Generic agent callbacks */
 static int cc_generic_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan);
@@ -1102,42 +1188,6 @@
 	ast_assert(callbacks->destructor != NULL);
 }
 
-static const struct ast_cc_agent_callbacks *find_agent_callbacks(struct ast_channel *chan)
-{
-	struct cc_agent_backend *backend;
-	const struct ast_cc_agent_callbacks *callbacks = NULL;
-	enum ast_cc_agent_policies agent_policy;
-	const char *type;
-
-	agent_policy = ast_get_cc_agent_policy(ast_channel_get_cc_config_params(chan));
-
-	if (agent_policy == AST_CC_AGENT_GENERIC) {
-		type = "generic";
-	} else if (agent_policy == AST_CC_AGENT_NATIVE) {
-		char chan_name[AST_CHANNEL_NAME];
-		char *slash;
-		ast_copy_string(chan_name, chan->name, sizeof(chan_name));
-		if ((slash = strchr(chan_name, '/'))) {
-			*slash = '\0';
-		}
-		type = chan_name;
-	} else {
-		ast_log(LOG_NOTICE, "Not returning agent callbacks since this channel is configured not to have a CC agent\n");
-		return NULL;
-	}
-
-	AST_RWLIST_RDLOCK(&cc_agent_backends);
-	AST_RWLIST_TRAVERSE(&cc_agent_backends, backend, next) {
-		if (!strcmp(backend->callbacks->type, type)) {
-			ast_log(LOG_NOTICE, "Returning backend %s\n", backend->callbacks->type);
-			callbacks = backend->callbacks;
-			break;
-		}
-	}
-	AST_RWLIST_UNLOCK(&cc_agent_backends);
-	return callbacks;
-}
-
 static struct ast_cc_agent *cc_agent_init(struct ast_channel *caller_chan, 
 		const char * const caller_name, const int core_id,
 		struct ast_cc_interface_tree *interface_tree) 
@@ -1465,23 +1515,6 @@
 	}
 
 	ast_free(agent_pvt);
-}
-
-static const struct ast_cc_monitor_callbacks *find_monitor_callbacks(const char * const type)
-{
-	struct cc_monitor_backend *backend;
-	const struct ast_cc_monitor_callbacks *callbacks = NULL;
-
-	AST_RWLIST_RDLOCK(&cc_monitor_backends);
-	AST_RWLIST_TRAVERSE(&cc_monitor_backends, backend, next) {
-		if (!strcmp(backend->callbacks->type, type)) {
-			ast_log(LOG_NOTICE, "Returning backend %s\n", backend->callbacks->type);
-			callbacks = backend->callbacks;
-			break;
-		}
-	}
-	AST_RWLIST_UNLOCK(&cc_monitor_backends);
-	return callbacks;
 }
 
 static void monitor_destroy(void *data)
@@ -2381,37 +2414,6 @@
 	return retval;
 }
 
-int ast_cc_monitor_register(const struct ast_cc_monitor_callbacks *callbacks)
-{
-	struct cc_monitor_backend *backend = ast_calloc(1, sizeof(*backend));
-
-	if (!backend) {
-		return -1;
-	}
-
-	backend->callbacks = callbacks;
-
-	AST_RWLIST_WRLOCK(&cc_monitor_backends);
-	AST_RWLIST_INSERT_TAIL(&cc_monitor_backends, backend, next);
-	AST_RWLIST_UNLOCK(&cc_monitor_backends);
-	return 0;
-}
-
-int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks)
-{
-	struct cc_agent_backend *backend = ast_calloc(1, sizeof(*backend));
-
-	if (!backend) {
-		return -1;
-	}
-
-	backend->callbacks = callbacks;
-	AST_RWLIST_WRLOCK(&cc_agent_backends);
-	AST_RWLIST_INSERT_TAIL(&cc_agent_backends, backend, next);
-	AST_RWLIST_UNLOCK(&cc_agent_backends);
-	return 0;
-}
-
 int ast_cc_monitor_announce_availability(struct ast_cc_monitor *monitor) {
 	return ast_taskprocessor_push(cc_core_taskprocessor, cc_devstate_change, 
 			cc_ref(monitor, "Bump reference count until cc_devstate_change executes"));




More information about the svn-commits mailing list