[svn-commits] dlee: branch dlee/allow-multiple r395707 - in /team/dlee/allow-multiple: ./ c...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 29 15:20:46 CDT 2013


Author: dlee
Date: Mon Jul 29 15:20:43 2013
New Revision: 395707

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395707
Log:
Rename everything Stasis-HTTP to ARI

This renames all files and API calls from several variants of
Stasis-HTTP to ARI including:
* Stasis-HTTP -> ARI
* STASIS_HTTP -> ARI
* stasis_http -> ari (ast_ari for global symbols, file names as well)
* stasis http -> ARI

Review: https://reviewboard.asterisk.org/r/2706/
(closes issue ASTERISK-22136)
........

Merged revisions 395603 from http://svn.asterisk.org/svn/asterisk/trunk

Added:
    team/dlee/allow-multiple/include/asterisk/ari.h
      - copied unchanged from r395603, trunk/include/asterisk/ari.h
    team/dlee/allow-multiple/res/ari/
      - copied from r395603, trunk/res/ari/
    team/dlee/allow-multiple/res/ari.make
      - copied unchanged from r395603, trunk/res/ari.make
    team/dlee/allow-multiple/res/res_ari.c
      - copied unchanged from r395603, trunk/res/res_ari.c
    team/dlee/allow-multiple/res/res_ari.exports.in
      - copied unchanged from r395603, trunk/res/res_ari.exports.in
    team/dlee/allow-multiple/res/res_ari_asterisk.c
      - copied, changed from r395603, trunk/res/res_ari_asterisk.c
    team/dlee/allow-multiple/res/res_ari_bridges.c
      - copied, changed from r395603, trunk/res/res_ari_bridges.c
    team/dlee/allow-multiple/res/res_ari_channels.c
      - copied, changed from r395603, trunk/res/res_ari_channels.c
    team/dlee/allow-multiple/res/res_ari_endpoints.c
      - copied, changed from r395603, trunk/res/res_ari_endpoints.c
    team/dlee/allow-multiple/res/res_ari_events.c
      - copied, changed from r395603, trunk/res/res_ari_events.c
    team/dlee/allow-multiple/res/res_ari_playback.c
      - copied, changed from r395603, trunk/res/res_ari_playback.c
    team/dlee/allow-multiple/res/res_ari_recordings.c
      - copied, changed from r395603, trunk/res/res_ari_recordings.c
    team/dlee/allow-multiple/res/res_ari_sounds.c
      - copied, changed from r395603, trunk/res/res_ari_sounds.c
    team/dlee/allow-multiple/rest-api-templates/ari.make.mustache
      - copied unchanged from r395603, trunk/rest-api-templates/ari.make.mustache
    team/dlee/allow-multiple/rest-api-templates/ari_resource.c.mustache
      - copied unchanged from r395603, trunk/rest-api-templates/ari_resource.c.mustache
    team/dlee/allow-multiple/rest-api-templates/ari_resource.h.mustache
      - copied, changed from r395603, trunk/rest-api-templates/ari_resource.h.mustache
    team/dlee/allow-multiple/rest-api-templates/res_ari_resource.c.mustache
      - copied, changed from r395603, trunk/rest-api-templates/res_ari_resource.c.mustache
    team/dlee/allow-multiple/tests/test_ari.c
      - copied unchanged from r395603, trunk/tests/test_ari.c
Removed:
    team/dlee/allow-multiple/include/asterisk/stasis_http.h
    team/dlee/allow-multiple/res/res_stasis_http.c
    team/dlee/allow-multiple/res/res_stasis_http.exports.in
    team/dlee/allow-multiple/res/res_stasis_http_asterisk.c
    team/dlee/allow-multiple/res/res_stasis_http_bridges.c
    team/dlee/allow-multiple/res/res_stasis_http_channels.c
    team/dlee/allow-multiple/res/res_stasis_http_endpoints.c
    team/dlee/allow-multiple/res/res_stasis_http_events.c
    team/dlee/allow-multiple/res/res_stasis_http_playback.c
    team/dlee/allow-multiple/res/res_stasis_http_recordings.c
    team/dlee/allow-multiple/res/res_stasis_http_sounds.c
    team/dlee/allow-multiple/res/stasis_http/
    team/dlee/allow-multiple/res/stasis_http.make
    team/dlee/allow-multiple/rest-api-templates/res_stasis_http_resource.c.mustache
    team/dlee/allow-multiple/rest-api-templates/stasis_http.make.mustache
    team/dlee/allow-multiple/rest-api-templates/stasis_http_resource.c.mustache
    team/dlee/allow-multiple/rest-api-templates/stasis_http_resource.h.mustache
    team/dlee/allow-multiple/tests/test_stasis_http.c
Modified:
    team/dlee/allow-multiple/   (props changed)
    team/dlee/allow-multiple/configs/ari.conf.sample
    team/dlee/allow-multiple/main/mixmonitor.c
    team/dlee/allow-multiple/main/stasis_config.c
    team/dlee/allow-multiple/res/Makefile
    team/dlee/allow-multiple/res/ari/resource_asterisk.h
    team/dlee/allow-multiple/res/ari/resource_bridges.c
    team/dlee/allow-multiple/res/ari/resource_bridges.h
    team/dlee/allow-multiple/res/ari/resource_events.c
    team/dlee/allow-multiple/res/ari/resource_events.h
    team/dlee/allow-multiple/res/ari/resource_sounds.h
    team/dlee/allow-multiple/res/res_ari_model.c
    team/dlee/allow-multiple/res/res_ari_model.exports.in
    team/dlee/allow-multiple/res/res_statsd.c
    team/dlee/allow-multiple/rest-api-templates/ari_model_validators.c.mustache
    team/dlee/allow-multiple/rest-api-templates/ari_model_validators.h.mustache
    team/dlee/allow-multiple/rest-api-templates/make_ari_stubs.py
    team/dlee/allow-multiple/rest-api-templates/rest_handler.mustache
    team/dlee/allow-multiple/tests/test_ari_model.c

Propchange: team/dlee/allow-multiple/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jul 29 15:20:43 2013
@@ -1,1 +1,1 @@
-/trunk:1-395588
+/trunk:1-395603

Modified: team/dlee/allow-multiple/configs/ari.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/configs/ari.conf.sample?view=diff&rev=395707&r1=395706&r2=395707
==============================================================================
--- team/dlee/allow-multiple/configs/ari.conf.sample (original)
+++ team/dlee/allow-multiple/configs/ari.conf.sample Mon Jul 29 15:20:43 2013
@@ -1,6 +1,6 @@
 [general]
-enabled = yes		; When set to no, stasis-http support is disabled.
-;pretty = no		; When set to yes, responses from stasis-http are
+enabled = yes		; When set to no, ARI support is disabled.
+;pretty = no		; When set to yes, responses from ARI are
 ;			; formatted to be human readable.
 ;allowed_origins =	; Comma separated list of allowed origins, for
 ;			; Cross-Origin Resource Sharing. May be set to * to

Modified: team/dlee/allow-multiple/main/mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/main/mixmonitor.c?view=diff&rev=395707&r1=395706&r2=395707
==============================================================================
--- team/dlee/allow-multiple/main/mixmonitor.c (original)
+++ team/dlee/allow-multiple/main/mixmonitor.c Mon Jul 29 15:20:43 2013
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 390830 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/lock.h"
 #include "asterisk/logger.h"

Modified: team/dlee/allow-multiple/main/stasis_config.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/main/stasis_config.c?view=diff&rev=395707&r1=395706&r2=395707
==============================================================================
--- team/dlee/allow-multiple/main/stasis_config.c (original)
+++ team/dlee/allow-multiple/main/stasis_config.c Mon Jul 29 15:20:43 2013
@@ -70,7 +70,7 @@
 	struct stasis_threadpool_conf *threadpool;
 };
 
-/*! \brief Mapping of the stasis http conf struct's globals to the
+/*! \brief Mapping of the stasis conf struct's globals to the
  *         threadpool context in the config file. */
 static struct aco_type threadpool_option = {
         .type = ACO_GLOBAL,

Modified: team/dlee/allow-multiple/res/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/Makefile?view=diff&rev=395707&r1=395706&r2=395707
==============================================================================
--- team/dlee/allow-multiple/res/Makefile (original)
+++ team/dlee/allow-multiple/res/Makefile Mon Jul 29 15:20:43 2013
@@ -73,18 +73,18 @@
 ael/pval.o: ael/pval.c
 
 clean::
-	rm -f snmp/*.[oi] ael/*.[oi] ais/*.[oi] stasis_http/*.[oi]
+	rm -f snmp/*.[oi] ael/*.[oi] ais/*.[oi] ari/*.[oi]
 	rm -f res_sip/*.[oi] stasis/*.[oi]
 	rm -f parking/*.o parking/*.i
 
 $(if $(filter res_parking,$(EMBEDDED_MODS)),modules.link,res_parking.so): $(subst .c,.o,$(wildcard parking/*.c))
 $(subst .c,.o,$(wildcard parking/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_parking)
 
-res_stasis_http.so: stasis_http/cli.o stasis_http/config.o stasis_http/ari_websockets.o
-stasis_http/cli.o stasis_http/config.o stasis_http/ari_websockets.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_stasis_http)
+res_ari.so: ari/cli.o ari/config.o ari/ari_websockets.o
+ari/cli.o ari/config.o ari/ari_websockets.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari)
 
-res_ari_model.so: stasis_http/ari_model_validators.o
-stasis_http/ari_model_validators.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_model)
+res_ari_model.so: ari/ari_model_validators.o
+ari/ari_model_validators.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_model)
 
-# Dependencies for res_stasis_http_*.so are generated, so they're in this file
-include stasis_http.make
+# Dependencies for res_ari_*.so are generated, so they're in this file
+include ari.make

Modified: team/dlee/allow-multiple/res/ari/resource_asterisk.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/ari/resource_asterisk.h?view=diff&rev=395707&r1=395603&r2=395707
==============================================================================
--- team/dlee/allow-multiple/res/ari/resource_asterisk.h (original)
+++ team/dlee/allow-multiple/res/ari/resource_asterisk.h Mon Jul 29 15:20:43 2013
@@ -41,8 +41,12 @@
 
 /*! \brief Argument struct for ast_ari_get_asterisk_info() */
 struct ast_get_asterisk_info_args {
-	/*! \brief Filter information returned */
-	const char *only;
+	/*! \brief Array of Filter information returned */
+	const char **only;
+	/*! \brief Length of only array. */
+	size_t only_count;
+	/*! \brief Parsing context for only. */
+	char *only_parse;
 };
 /*!
  * \brief Gets Asterisk system information.

Modified: team/dlee/allow-multiple/res/ari/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/ari/resource_bridges.c?view=diff&rev=395707&r1=395603&r2=395707
==============================================================================
--- team/dlee/allow-multiple/res/ari/resource_bridges.c (original)
+++ team/dlee/allow-multiple/res/ari/resource_bridges.c Mon Jul 29 15:20:43 2013
@@ -1,4 +1,4 @@
-/* -*- C -*-
+/*
  * Asterisk -- An open source telephony toolkit.
  *
  * Copyright (C) 2012 - 2013, Digium, Inc.
@@ -107,33 +107,95 @@
 	return control;
 }
 
+struct control_list {
+	size_t count;
+	struct stasis_app_control *controls[];
+};
+
+static void control_list_dtor(void *obj) {
+	struct control_list *list = obj;
+	size_t i;
+
+	for (i = 0; i < list->count; ++i) {
+		ao2_cleanup(list->controls[i]);
+		list->controls[i] = NULL;
+	}
+}
+
+static struct control_list *control_list_create(struct stasis_http_response *response, size_t count, const char **channels) {
+	RAII_VAR(struct control_list *, list, NULL, ao2_cleanup);
+	size_t i;
+
+	if (count == 0 || !channels) {
+		stasis_http_response_error(response, 400, "Bad Request", "Missing parameter channel");
+		return NULL;
+	}
+
+	list = ao2_alloc(sizeof(*list) + count * sizeof(list->controls[0]), control_list_dtor);
+	if (!list) {
+		stasis_http_response_alloc_failed(response);
+		return NULL;
+	}
+
+	for (i = 0; i < count; ++i) {
+		if (ast_strlen_zero(channels[i])) {
+			continue;
+		}
+		list->controls[list->count] =
+			find_channel_control(response, channels[i]);
+		if (!list->controls[list->count]) {
+			return NULL;
+		}
+		++list->count;
+	}
+
+	if (list->count == 0) {
+		stasis_http_response_error(response, 400, "Bad Request", "Missing parameter channel");
+		return NULL;
+	}
+
+	ao2_ref(list, +1);
+	return list;
+}
+
 void ast_ari_add_channel_to_bridge(struct ast_variable *headers, struct ast_add_channel_to_bridge_args *args, struct ast_ari_response *response)
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
-	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+	RAII_VAR(struct control_list *, list, NULL, ao2_cleanup);
+	size_t i;
+
 	if (!bridge) {
-		return;
-	}
-
-	control = find_channel_control(response, args->channel);
-	if (!control) {
-		return;
-	}
-
-	stasis_app_control_add_channel_to_bridge(control, bridge);
+		/* Response filled in by find_bridge */
+		return;
+	}
+
+	list = control_list_create(response, args->channel_count, args->channel);
+	if (!list) {
+		/* Response filled in by control_list_create() */
+		return;
+	}
+
+	for (i = 0; i < list->count; ++i) {
+		stasis_app_control_add_channel_to_bridge(list->controls[i], bridge);
+	}
+
 	ast_ari_response_no_content(response);
 }
 
 void ast_ari_remove_channel_from_bridge(struct ast_variable *headers, struct ast_remove_channel_from_bridge_args *args, struct ast_ari_response *response)
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
-	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+	RAII_VAR(struct control_list *, list, NULL, ao2_cleanup);
+	size_t i;
+
 	if (!bridge) {
-		return;
-	}
-
-	control = find_channel_control(response, args->channel);
-	if (!control) {
+		/* Response filled in by find_bridge */
+		return;
+	}
+
+	list = control_list_create(response, args->channel_count, args->channel);
+	if (!list) {
+		/* Response filled in by control_list_create() */
 		return;
 	}
 
@@ -141,9 +203,14 @@
 	 * the bridge the channel is in. This will be possible once the bridge uniqueid
 	 * is added to the channel snapshot. A 409 response should be issued if the bridge
 	 * uniqueids don't match */
-	if (stasis_app_control_remove_channel_from_bridge(control, bridge)) {
-		ast_ari_response_error(response, 500, "Internal Error",
-			"Could not remove channel from bridge");
+	for (i = 0; i < list->count; ++i) {
+		if (stasis_app_control_remove_channel_from_bridge(list->controls[i], bridge)) {
+			stasis_http_response_error(response, 500, "Internal Error",
+				"Could not remove channel from bridge");
+		}
+	}
+
+	if (response->response_code) {
 		return;
 	}
 

Modified: team/dlee/allow-multiple/res/ari/resource_bridges.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/ari/resource_bridges.h?view=diff&rev=395707&r1=395603&r2=395707
==============================================================================
--- team/dlee/allow-multiple/res/ari/resource_bridges.h (original)
+++ team/dlee/allow-multiple/res/ari/resource_bridges.h Mon Jul 29 15:20:43 2013
@@ -97,8 +97,12 @@
 struct ast_add_channel_to_bridge_args {
 	/*! \brief Bridge's id */
 	const char *bridge_id;
-	/*! \brief Channel's id */
-	const char *channel;
+	/*! \brief Array of Ids of channels to add to bridge */
+	const char **channel;
+	/*! \brief Length of channel array. */
+	size_t channel_count;
+	/*! \brief Parsing context for channel. */
+	char *channel_parse;
 };
 /*!
  * \brief Add a channel to a bridge.
@@ -112,8 +116,12 @@
 struct ast_remove_channel_from_bridge_args {
 	/*! \brief Bridge's id */
 	const char *bridge_id;
-	/*! \brief Channel's id */
-	const char *channel;
+	/*! \brief Array of Ids of channels to remove from bridge */
+	const char **channel;
+	/*! \brief Length of channel array. */
+	size_t channel_count;
+	/*! \brief Parsing context for channel. */
+	char *channel_parse;
 };
 /*!
  * \brief Remove a channel from a bridge.

Modified: team/dlee/allow-multiple/res/ari/resource_events.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/ari/resource_events.c?view=diff&rev=395707&r1=395603&r2=395707
==============================================================================
--- team/dlee/allow-multiple/res/ari/resource_events.c (original)
+++ team/dlee/allow-multiple/res/ari/resource_events.c Mon Jul 29 15:20:43 2013
@@ -143,35 +143,27 @@
 /*!
  * \brief Register for all of the apps given.
  * \param session Session info struct.
- * \param app_list Comma seperated list of app names to register.
- */
-static int session_register_apps(struct event_session *session,
-				 const char *app_list)
-{
-	RAII_VAR(char *, to_free, NULL, ast_free);
-	char *apps, *app_name;
+ * \param app_name Name of application to register.
+ */
+static int session_register_app(struct event_session *session,
+				 const char *app_name)
+{
 	SCOPED_AO2LOCK(lock, session);
 
 	ast_assert(session->ws_session != NULL);
 	ast_assert(session->websocket_apps != NULL);
 
-	if (!app_list) {
+	if (ast_strlen_zero(app_name)) {
 		return -1;
 	}
 
-	to_free = apps = ast_strdup(app_list);
-	if (!apps) {
-		ast_ari_websocket_session_write(session->ws_session, ast_ari_oom_json());
+	if (ast_str_container_add(session->websocket_apps, app_name)) {
+		ast_ari_websocket_session_write(session->ws_session, ari_oom_json());
 		return -1;
 	}
-	while ((app_name = strsep(&apps, ","))) {
-		if (ast_str_container_add(session->websocket_apps, app_name)) {
-			ast_ari_websocket_session_write(session->ws_session, ast_ari_oom_json());
-			return -1;
-		}
-
-		stasis_app_register(app_name, app_handler, session);
-	}
+
+	stasis_app_register(app_name, app_handler, session);
+
 	return 0;
 }
 
@@ -182,6 +174,7 @@
 	RAII_VAR(struct event_session *, session, NULL, session_cleanup);
 	struct ast_json *msg;
 	int res;
+	size_t i;
 
 	ast_debug(3, "/events WebSocket connection\n");
 
@@ -191,7 +184,15 @@
 		return;
 	}
 
-	if (!args->app) {
+	res = 0;
+	for (i = 0; i < args->app_count; ++i) {
+		if (ast_strlen_zero(args->app[i])) {
+			continue;
+		}
+		res |= session_register_app(session, args->app[i]);
+	}
+
+	if (ao2_container_count(session->websocket_apps) == 0) {
 		RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
 
 		msg = ast_json_pack("{s: s, s: [s]}",
@@ -205,7 +206,6 @@
 		return;
 	}
 
-	res = session_register_apps(session, args->app);
 	if (res != 0) {
 		ast_ari_websocket_session_write(ws_session, ast_ari_oom_json());
 		return;

Modified: team/dlee/allow-multiple/res/ari/resource_events.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/ari/resource_events.h?view=diff&rev=395707&r1=395603&r2=395707
==============================================================================
--- team/dlee/allow-multiple/res/ari/resource_events.h (original)
+++ team/dlee/allow-multiple/res/ari/resource_events.h Mon Jul 29 15:20:43 2013
@@ -41,8 +41,12 @@
 
 /*! \brief Argument struct for ast_ari_event_websocket() */
 struct ast_event_websocket_args {
-	/*! \brief Comma seperated list of applications to subscribe to. */
-	const char *app;
+	/*! \brief Array of Applications to subscribe to. */
+	const char **app;
+	/*! \brief Length of app array. */
+	size_t app_count;
+	/*! \brief Parsing context for app. */
+	char *app_parse;
 };
 /*!
  * \brief WebSocket connection for events.

Modified: team/dlee/allow-multiple/res/ari/resource_sounds.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/ari/resource_sounds.h?view=diff&rev=395707&r1=395603&r2=395707
==============================================================================
--- team/dlee/allow-multiple/res/ari/resource_sounds.h (original)
+++ team/dlee/allow-multiple/res/ari/resource_sounds.h Mon Jul 29 15:20:43 2013
@@ -41,7 +41,9 @@
 
 /*! \brief Argument struct for ast_ari_get_sounds() */
 struct ast_get_sounds_args {
+	/*! \brief  */
 	const char *lang;
+	/*! \brief  */
 	const char *format;
 };
 /*!

Copied: team/dlee/allow-multiple/res/res_ari_asterisk.c (from r395603, trunk/res/res_ari_asterisk.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_ari_asterisk.c?view=diff&rev=395707&p1=trunk/res/res_ari_asterisk.c&r1=395603&p2=team/dlee/allow-multiple/res/res_ari_asterisk.c&r2=395707
==============================================================================
--- trunk/res/res_ari_asterisk.c (original)
+++ team/dlee/allow-multiple/res/res_ari_asterisk.c Mon Jul 29 15:20:43 2013
@@ -41,12 +41,15 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "ari/resource_asterisk.h"
 #if defined(AST_DEVMODE)
 #include "ari/ari_model_validators.h"
 #endif
+
+#define MAX_VALS 128
 
 /*!
  * \brief Parameter parsing callback for /asterisk/info.
@@ -59,17 +62,48 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
+	struct ast_get_asterisk_info_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
 
-	struct ast_get_asterisk_info_args args = {};
-	struct ast_variable *i;
-
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "only") == 0) {
-			args.only = (i->value);
+			/* Parse comma separated list */
+			char *vals[MAX_VALS];
+			size_t j;
+
+			args.only_parse = ast_strdup(i->value);
+			if (!args.only_parse) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			args.only_count = ast_app_separate_args(
+				args.only_parse, ',', vals, ARRAY_LEN(vals));
+			if (args.only_count == 0) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			if (args.only_count >= MAX_VALS) {
+				stasis_http_response_error(response, 400,
+					"Bad Request",
+					"Too many values for only");
+				goto fin;
+			}
+
+			args.only = ast_malloc(sizeof(*args.only) * args.only_count);
+			if (!args.only) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			for (j = 0; j < args.only_count; ++j) {
+				args.only[j] = (vals[j]);
+			}
 		} else
 		{}
 	}
@@ -101,6 +135,11 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	ast_free(args.only_parse);
+	ast_free(args.only);
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /asterisk/variable.
@@ -113,13 +152,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
+	struct ast_get_global_var_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_get_global_var_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
@@ -155,6 +193,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /asterisk/variable.
@@ -167,13 +208,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
+	struct ast_set_global_var_args args = {};
+	struct ast_variable *i;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
 #endif /* AST_DEVMODE */
-
-	struct ast_set_global_var_args args = {};
-	struct ast_variable *i;
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
@@ -212,6 +252,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 
 /*! \brief REST handler for /api-docs/asterisk.{format} */

Copied: team/dlee/allow-multiple/res/res_ari_bridges.c (from r395603, trunk/res/res_ari_bridges.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_ari_bridges.c?view=diff&rev=395707&p1=trunk/res/res_ari_bridges.c&r1=395603&p2=team/dlee/allow-multiple/res/res_ari_bridges.c&r2=395707
==============================================================================
--- trunk/res/res_ari_bridges.c (original)
+++ team/dlee/allow-multiple/res/res_ari_bridges.c Mon Jul 29 15:20:43 2013
@@ -41,6 +41,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "ari/resource_bridges.h"
@@ -48,6 +49,8 @@
 #include "ari/ari_model_validators.h"
 #endif
 
+#define MAX_VALS 128
+
 /*!
  * \brief Parameter parsing callback for /bridges.
  * \param get_params GET parameters in the HTTP request.
@@ -59,12 +62,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_bridges_args args = {};
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	ast_ari_get_bridges(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -93,6 +96,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges.
@@ -105,13 +111,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_new_bridge_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "type") == 0) {
@@ -147,6 +152,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}.
@@ -159,13 +167,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_bridge_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
@@ -202,6 +209,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}.
@@ -214,13 +224,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_delete_bridge_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
@@ -257,6 +266,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/addChannel.
@@ -269,17 +281,48 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_add_channel_to_bridge_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "channel") == 0) {
-			args.channel = (i->value);
+			/* Parse comma separated list */
+			char *vals[MAX_VALS];
+			size_t j;
+
+			args.channel_parse = ast_strdup(i->value);
+			if (!args.channel_parse) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			args.channel_count = ast_app_separate_args(
+				args.channel_parse, ',', vals, ARRAY_LEN(vals));
+			if (args.channel_count == 0) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			if (args.channel_count >= MAX_VALS) {
+				stasis_http_response_error(response, 400,
+					"Bad Request",
+					"Too many values for channel");
+				goto fin;
+			}
+
+			args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
+			if (!args.channel) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			for (j = 0; j < args.channel_count; ++j) {
+				args.channel[j] = (vals[j]);
+			}
 		} else
 		{}
 	}
@@ -320,6 +363,11 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	ast_free(args.channel_parse);
+	ast_free(args.channel);
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/removeChannel.
@@ -332,17 +380,48 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_remove_channel_from_bridge_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "channel") == 0) {
-			args.channel = (i->value);
+			/* Parse comma separated list */
+			char *vals[MAX_VALS];
+			size_t j;
+
+			args.channel_parse = ast_strdup(i->value);
+			if (!args.channel_parse) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			args.channel_count = ast_app_separate_args(
+				args.channel_parse, ',', vals, ARRAY_LEN(vals));
+			if (args.channel_count == 0) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			if (args.channel_count >= MAX_VALS) {
+				stasis_http_response_error(response, 400,
+					"Bad Request",
+					"Too many values for channel");
+				goto fin;
+			}
+
+			args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
+			if (!args.channel) {
+				stasis_http_response_alloc_failed(response);
+				goto fin;
+			}
+
+			for (j = 0; j < args.channel_count; ++j) {
+				args.channel[j] = (vals[j]);
+			}
 		} else
 		{}
 	}
@@ -380,6 +459,11 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	ast_free(args.channel_parse);
+	ast_free(args.channel);
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/play.
@@ -392,13 +476,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_play_on_bridge_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "media") == 0) {
@@ -451,6 +534,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /bridges/{bridgeId}/record.
@@ -463,13 +549,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_record_bridge_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "name") == 0) {
@@ -529,6 +614,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 
 /*! \brief REST handler for /api-docs/bridges.{format} */

Copied: team/dlee/allow-multiple/res/res_ari_channels.c (from r395603, trunk/res/res_ari_channels.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_ari_channels.c?view=diff&rev=395707&p1=trunk/res/res_ari_channels.c&r1=395603&p2=team/dlee/allow-multiple/res/res_ari_channels.c&r2=395707
==============================================================================
--- trunk/res/res_ari_channels.c (original)
+++ team/dlee/allow-multiple/res/res_ari_channels.c Mon Jul 29 15:20:43 2013
@@ -41,6 +41,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "ari/resource_channels.h"
@@ -48,6 +49,8 @@
 #include "ari/ari_model_validators.h"
 #endif
 
+#define MAX_VALS 128
+
 /*!
  * \brief Parameter parsing callback for /channels.
  * \param get_params GET parameters in the HTTP request.
@@ -59,12 +62,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_channels_args args = {};
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
+
 	ast_ari_get_channels(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
@@ -93,6 +96,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels.
@@ -105,13 +111,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_originate_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "endpoint") == 0) {
@@ -169,6 +174,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}.
@@ -181,13 +189,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_get_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -224,6 +231,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}.
@@ -236,13 +246,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_delete_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -279,6 +288,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/dial.
@@ -291,13 +303,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_dial_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "endpoint") == 0) {
@@ -350,6 +361,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/continue.
@@ -362,13 +376,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_continue_in_dialplan_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "context") == 0) {
@@ -418,6 +431,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/answer.
@@ -430,13 +446,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_answer_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -474,6 +489,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/mute.
@@ -486,13 +504,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_mute_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "direction") == 0) {
@@ -536,6 +553,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/unmute.
@@ -548,13 +568,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_unmute_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "direction") == 0) {
@@ -598,6 +617,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/hold.
@@ -610,13 +632,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;
-#endif /* AST_DEVMODE */
-
 	struct ast_hold_channel_args args = {};
 	struct ast_variable *i;
+#if defined(AST_DEVMODE)
+	int is_valid;
+	int code;
+#endif /* AST_DEVMODE */
 
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
@@ -654,6 +675,9 @@
 			"Internal Server Error", "Response validation failed");
 	}
 #endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
 }
 /*!
  * \brief Parameter parsing callback for /channels/{channelId}/unhold.
@@ -666,13 +690,12 @@
 	struct ast_variable *get_params, struct ast_variable *path_vars,
 	struct ast_variable *headers, struct ast_ari_response *response)
 {
-#if defined(AST_DEVMODE)
-	int is_valid;
-	int code;

[... 1651 lines stripped ...]



More information about the svn-commits mailing list