[asterisk-commits] dlee: branch dlee/allow-multiple r395399 - in /team/dlee/allow-multiple: res/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 25 09:27:47 CDT 2013


Author: dlee
Date: Thu Jul 25 09:27:45 2013
New Revision: 395399

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395399
Log:
allowMultiple means comma separated; not having the param show multiple times

Added:
    team/dlee/allow-multiple/rest-api-templates/param_cleanup.mustache   (with props)
Modified:
    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/resource_asterisk.h
    team/dlee/allow-multiple/res/stasis_http/resource_bridges.h
    team/dlee/allow-multiple/res/stasis_http/resource_events.c
    team/dlee/allow-multiple/res/stasis_http/resource_events.h
    team/dlee/allow-multiple/res/stasis_http/resource_sounds.h
    team/dlee/allow-multiple/rest-api-templates/param_parsing.mustache
    team/dlee/allow-multiple/rest-api-templates/res_stasis_http_resource.c.mustache
    team/dlee/allow-multiple/rest-api-templates/stasis_http_resource.h.mustache
    team/dlee/allow-multiple/rest-api/api-docs/bridges.json
    team/dlee/allow-multiple/rest-api/api-docs/events.json

Modified: team/dlee/allow-multiple/res/res_stasis_http_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_asterisk.c?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_asterisk.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_asterisk.c Thu Jul 25 09:27:45 2013
@@ -41,12 +41,15 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_asterisk.h"
 #if defined(AST_DEVMODE)
 #include "stasis_http/ari_model_validators.h"
 #endif
+
+#define MAX_VALS 128
 
 /*!
  * \brief Parameter parsing callback for /asterisk/info.
@@ -69,18 +72,45 @@
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "only") == 0) {
-			void *p = ast_realloc(args.only,
-				sizeof(*args.only) * (args.only_count + 1));
-			if (!p) {
+			/* Parse comma separated list */
+			char *vals[MAX_VALS];
+			size_t j;
+
+			args.only_parse = ast_strdup(i->value);
+			if (!args.only_parse) {
 				ast_log(LOG_ERROR, "OOM parsing only\n");
 				continue;
 			}
-			args.only = p;
-			args.only[args.only_count++] = (i->value);
-		} else
+
+			args.only_count = ast_app_separate_args(
+				args.only_parse, ',', vals, ARRAY_LEN(vals));
+			if (args.only_count == 0) {
+				ast_log(LOG_ERROR, "Error parsing only\n");
+				continue;
+			}
+
+			if (args.only_count >= MAX_VALS) {
+				ast_log(LOG_ERROR, "Too many values for only\n");
+				args.only_count = 0;
+				continue;
+			}
+
+			args.only = ast_malloc(sizeof(*args.only) * args.only_count);
+			if (!args.only) {
+				ast_log(LOG_ERROR, "OOM parsing only\n");
+				continue;
+			}
+
+			for (j = 0; j < args.only_count; ++j) {
+				args.only[j] = (vals[j]);
+			}
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_asterisk_info(headers, &args, response);
+
+	ast_free(args.only_parse);
+	ast_free(args.only);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -131,10 +161,11 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
 			args.variable = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_global_var(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -185,13 +216,14 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
 			args.variable = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "value") == 0) {
 			args.value = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_set_global_var(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 

Modified: team/dlee/allow-multiple/res/res_stasis_http_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_bridges.c?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_bridges.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_bridges.c Thu Jul 25 09:27:45 2013
@@ -41,6 +41,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_bridges.h"
@@ -48,6 +49,8 @@
 #include "stasis_http/ari_model_validators.h"
 #endif
 
+#define MAX_VALS 128
+
 /*!
  * \brief Parameter parsing callback for /bridges.
  * \param get_params GET parameters in the HTTP request.
@@ -66,6 +69,7 @@
 
 	struct ast_get_bridges_args args = {};
 	stasis_http_get_bridges(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -116,10 +120,11 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "type") == 0) {
 			args.type = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_new_bridge(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -170,10 +175,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
 			args.bridge_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_bridge(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -225,10 +231,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
 			args.bridge_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_delete_bridge(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -279,24 +286,51 @@
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "channel") == 0) {
-			void *p = ast_realloc(args.channel,
-				sizeof(*args.channel) * (args.channel_count + 1));
-			if (!p) {
+			/* Parse comma separated list */
+			char *vals[MAX_VALS];
+			size_t j;
+
+			args.channel_parse = ast_strdup(i->value);
+			if (!args.channel_parse) {
 				ast_log(LOG_ERROR, "OOM parsing channel\n");
 				continue;
 			}
-			args.channel = p;
-			args.channel[args.channel_count++] = (i->value);
-		} else
+
+			args.channel_count = ast_app_separate_args(
+				args.channel_parse, ',', vals, ARRAY_LEN(vals));
+			if (args.channel_count == 0) {
+				ast_log(LOG_ERROR, "Error parsing channel\n");
+				continue;
+			}
+
+			if (args.channel_count >= MAX_VALS) {
+				ast_log(LOG_ERROR, "Too many values for channel\n");
+				args.channel_count = 0;
+				continue;
+			}
+
+			args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
+			if (!args.channel) {
+				ast_log(LOG_ERROR, "OOM parsing channel\n");
+				continue;
+			}
+
+			for (j = 0; j < args.channel_count; ++j) {
+				args.channel[j] = (vals[j]);
+			}
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
 			args.bridge_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_add_channel_to_bridge(headers, &args, response);
+
+	ast_free(args.channel_parse);
+	ast_free(args.channel);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -349,24 +383,51 @@
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "channel") == 0) {
-			void *p = ast_realloc(args.channel,
-				sizeof(*args.channel) * (args.channel_count + 1));
-			if (!p) {
+			/* Parse comma separated list */
+			char *vals[MAX_VALS];
+			size_t j;
+
+			args.channel_parse = ast_strdup(i->value);
+			if (!args.channel_parse) {
 				ast_log(LOG_ERROR, "OOM parsing channel\n");
 				continue;
 			}
-			args.channel = p;
-			args.channel[args.channel_count++] = (i->value);
-		} else
+
+			args.channel_count = ast_app_separate_args(
+				args.channel_parse, ',', vals, ARRAY_LEN(vals));
+			if (args.channel_count == 0) {
+				ast_log(LOG_ERROR, "Error parsing channel\n");
+				continue;
+			}
+
+			if (args.channel_count >= MAX_VALS) {
+				ast_log(LOG_ERROR, "Too many values for channel\n");
+				args.channel_count = 0;
+				continue;
+			}
+
+			args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
+			if (!args.channel) {
+				ast_log(LOG_ERROR, "OOM parsing channel\n");
+				continue;
+			}
+
+			for (j = 0; j < args.channel_count; ++j) {
+				args.channel[j] = (vals[j]);
+			}
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
 			args.bridge_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_remove_channel_from_bridge(headers, &args, response);
+
+	ast_free(args.channel_parse);
+	ast_free(args.channel);
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -417,25 +478,26 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "media") == 0) {
 			args.media = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "lang") == 0) {
 			args.lang = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "offsetms") == 0) {
 			args.offsetms = atoi(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "skipms") == 0) {
 			args.skipms = atoi(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
 			args.bridge_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_play_on_bridge(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -488,34 +550,35 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "name") == 0) {
 			args.name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "format") == 0) {
 			args.format = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "maxDurationSeconds") == 0) {
 			args.max_duration_seconds = atoi(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "maxSilenceSeconds") == 0) {
 			args.max_silence_seconds = atoi(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "ifExists") == 0) {
 			args.if_exists = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "beep") == 0) {
 			args.beep = ast_true(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "terminateOn") == 0) {
 			args.terminate_on = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "bridgeId") == 0) {
 			args.bridge_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_record_bridge(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 

Modified: team/dlee/allow-multiple/res/res_stasis_http_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_channels.c?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_channels.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_channels.c Thu Jul 25 09:27:45 2013
@@ -41,6 +41,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_channels.h"
@@ -48,6 +49,8 @@
 #include "stasis_http/ari_model_validators.h"
 #endif
 
+#define MAX_VALS 128
+
 /*!
  * \brief Parameter parsing callback for /channels.
  * \param get_params GET parameters in the HTTP request.
@@ -66,6 +69,7 @@
 
 	struct ast_get_channels_args args = {};
 	stasis_http_get_channels(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -116,31 +120,32 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "endpoint") == 0) {
 			args.endpoint = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "extension") == 0) {
 			args.extension = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "context") == 0) {
 			args.context = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "priority") == 0) {
 			args.priority = atol(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "app") == 0) {
 			args.app = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "appArgs") == 0) {
 			args.app_args = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "callerId") == 0) {
 			args.caller_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "timeout") == 0) {
 			args.timeout = atoi(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_originate(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -192,10 +197,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
 			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -247,10 +253,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
 			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_delete_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -302,25 +309,26 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "endpoint") == 0) {
 			args.endpoint = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "extension") == 0) {
 			args.extension = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "context") == 0) {
 			args.context = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "timeout") == 0) {
 			args.timeout = atoi(i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_dial(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -373,22 +381,23 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "context") == 0) {
 			args.context = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "extension") == 0) {
 			args.extension = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "priority") == 0) {
 			args.priority = atoi(i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_continue_in_dialplan(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -441,10 +450,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
 			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_answer_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -497,16 +507,17 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "direction") == 0) {
 			args.direction = (i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_mute_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -559,16 +570,17 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "direction") == 0) {
 			args.direction = (i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_unmute_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -621,10 +633,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
 			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_hold_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -677,10 +690,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
 			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_unhold_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -733,16 +747,17 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "mohClass") == 0) {
 			args.moh_class = (i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_moh_start_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -795,10 +810,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "channelId") == 0) {
 			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_moh_stop_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -851,25 +867,26 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "media") == 0) {
 			args.media = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "lang") == 0) {
 			args.lang = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "offsetms") == 0) {
 			args.offsetms = atoi(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "skipms") == 0) {
 			args.skipms = atoi(i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_play_on_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -922,34 +939,35 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "name") == 0) {
 			args.name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "format") == 0) {
 			args.format = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "maxDurationSeconds") == 0) {
 			args.max_duration_seconds = atoi(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "maxSilenceSeconds") == 0) {
 			args.max_silence_seconds = atoi(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "ifExists") == 0) {
 			args.if_exists = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "beep") == 0) {
 			args.beep = ast_true(i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "terminateOn") == 0) {
 			args.terminate_on = (i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_record_channel(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -1003,16 +1021,17 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
 			args.variable = (i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_channel_var(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -1065,19 +1084,20 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "variable") == 0) {
 			args.variable = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "value") == 0) {
 			args.value = (i->value);
-		} else
-		{}
-	}
-	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "channelId") == 0) {
-			args.channel_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
+		{}
+	}
+	for (i = path_vars; i; i = i->next) {
+		if (strcmp(i->name, "channelId") == 0) {
+			args.channel_id = (i->value);
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_set_channel_var(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 

Modified: team/dlee/allow-multiple/res/res_stasis_http_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_endpoints.c?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_endpoints.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_endpoints.c Thu Jul 25 09:27:45 2013
@@ -41,12 +41,15 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_endpoints.h"
 #if defined(AST_DEVMODE)
 #include "stasis_http/ari_model_validators.h"
 #endif
+
+#define MAX_VALS 128
 
 /*!
  * \brief Parameter parsing callback for /endpoints.
@@ -66,6 +69,7 @@
 
 	struct ast_get_endpoints_args args = {};
 	stasis_http_get_endpoints(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -116,10 +120,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "tech") == 0) {
 			args.tech = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_endpoints_by_tech(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -170,13 +175,14 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "tech") == 0) {
 			args.tech = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "resource") == 0) {
 			args.resource = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_endpoint(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 

Modified: team/dlee/allow-multiple/res/res_stasis_http_events.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_events.c?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_events.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_events.c Thu Jul 25 09:27:45 2013
@@ -41,12 +41,15 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_events.h"
 #if defined(AST_DEVMODE)
 #include "stasis_http/ari_model_validators.h"
 #endif
+
+#define MAX_VALS 128
 
 static void stasis_http_event_websocket_ws_cb(struct ast_websocket *ws_session,
 	struct ast_variable *get_params, struct ast_variable *headers)
@@ -58,15 +61,39 @@
 
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "app") == 0) {
-			void *p = ast_realloc(args.app,
-				sizeof(*args.app) * (args.app_count + 1));
-			if (!p) {
+			/* Parse comma separated list */
+			char *vals[MAX_VALS];
+			size_t j;
+
+			args.app_parse = ast_strdup(i->value);
+			if (!args.app_parse) {
 				ast_log(LOG_ERROR, "OOM parsing app\n");
 				continue;
 			}
-			args.app = p;
-			args.app[args.app_count++] = (i->value);
-		} else
+
+			args.app_count = ast_app_separate_args(
+				args.app_parse, ',', vals, ARRAY_LEN(vals));
+			if (args.app_count == 0) {
+				ast_log(LOG_ERROR, "Error parsing app\n");
+				continue;
+			}
+
+			if (args.app_count >= MAX_VALS) {
+				ast_log(LOG_ERROR, "Too many values for app\n");
+				args.app_count = 0;
+				continue;
+			}
+
+			args.app = ast_malloc(sizeof(*args.app) * args.app_count);
+			if (!args.app) {
+				ast_log(LOG_ERROR, "OOM parsing app\n");
+				continue;
+			}
+
+			for (j = 0; j < args.app_count; ++j) {
+				args.app[j] = (vals[j]);
+			}
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 #if defined(AST_DEVMODE)
@@ -77,9 +104,12 @@
 #endif
 	if (!session) {
 		ast_log(LOG_ERROR, "Failed to create ARI session\n");
-		return;
+	} else {
+		ari_websocket_event_websocket(session, headers, &args);
 	}
-	ari_websocket_event_websocket(session, headers, &args);
+
+	ast_free(args.app_parse);
+	ast_free(args.app);
 }
 
 /*! \brief REST handler for /api-docs/events.{format} */

Modified: team/dlee/allow-multiple/res/res_stasis_http_playback.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_playback.c?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_playback.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_playback.c Thu Jul 25 09:27:45 2013
@@ -41,12 +41,15 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_playback.h"
 #if defined(AST_DEVMODE)
 #include "stasis_http/ari_model_validators.h"
 #endif
+
+#define MAX_VALS 128
 
 /*!
  * \brief Parameter parsing callback for /playback/{playbackId}.
@@ -70,10 +73,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "playbackId") == 0) {
 			args.playback_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_playback(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -124,10 +128,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "playbackId") == 0) {
 			args.playback_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_stop_playback(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -178,16 +183,17 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "operation") == 0) {
 			args.operation = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "playbackId") == 0) {
 			args.playback_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_control_playback(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 

Modified: team/dlee/allow-multiple/res/res_stasis_http_recordings.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_recordings.c?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_recordings.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_recordings.c Thu Jul 25 09:27:45 2013
@@ -41,6 +41,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_recordings.h"
@@ -48,6 +49,8 @@
 #include "stasis_http/ari_model_validators.h"
 #endif
 
+#define MAX_VALS 128
+
 /*!
  * \brief Parameter parsing callback for /recordings/stored.
  * \param get_params GET parameters in the HTTP request.
@@ -66,6 +69,7 @@
 
 	struct ast_get_stored_recordings_args args = {};
 	stasis_http_get_stored_recordings(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -116,10 +120,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_stored_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -170,10 +175,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_delete_stored_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -220,6 +226,7 @@
 
 	struct ast_get_live_recordings_args args = {};
 	stasis_http_get_live_recordings(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -270,10 +277,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_live_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -324,10 +332,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_cancel_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -378,10 +387,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_stop_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -432,10 +442,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_pause_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -486,10 +497,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_unpause_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -540,10 +552,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_mute_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -594,10 +607,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "recordingName") == 0) {
 			args.recording_name = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_unmute_recording(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 

Modified: team/dlee/allow-multiple/res/res_stasis_http_sounds.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/res_stasis_http_sounds.c?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/res_stasis_http_sounds.c (original)
+++ team/dlee/allow-multiple/res/res_stasis_http_sounds.c Thu Jul 25 09:27:45 2013
@@ -41,12 +41,15 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/app.h"
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_sounds.h"
 #if defined(AST_DEVMODE)
 #include "stasis_http/ari_model_validators.h"
 #endif
+
+#define MAX_VALS 128
 
 /*!
  * \brief Parameter parsing callback for /sounds.
@@ -70,13 +73,14 @@
 	for (i = get_params; i; i = i->next) {
 		if (strcmp(i->name, "lang") == 0) {
 			args.lang = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		if (strcmp(i->name, "format") == 0) {
 			args.format = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_sounds(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 
@@ -127,10 +131,11 @@
 	for (i = path_vars; i; i = i->next) {
 		if (strcmp(i->name, "soundId") == 0) {
 			args.sound_id = (i->value);
-		} else
+		} else /* Intentionally weird newline to make the codegen nicer */
 		{}
 	}
 	stasis_http_get_stored_sound(headers, &args, response);
+
 #if defined(AST_DEVMODE)
 	code = response->response_code;
 

Modified: team/dlee/allow-multiple/res/stasis_http/resource_asterisk.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/stasis_http/resource_asterisk.h?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/stasis_http/resource_asterisk.h (original)
+++ team/dlee/allow-multiple/res/stasis_http/resource_asterisk.h Thu Jul 25 09:27:45 2013
@@ -41,9 +41,12 @@
 
 /*! \brief Argument struct for stasis_http_get_asterisk_info() */
 struct ast_get_asterisk_info_args {
-	/*! \brief Filter information returned */
+	/*! \brief Array of Filter information returned */
 	const char **only;
-	int only_count;
+	/*! \brief Lenght 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/stasis_http/resource_bridges.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/stasis_http/resource_bridges.h?view=diff&rev=395399&r1=395398&r2=395399
==============================================================================
--- team/dlee/allow-multiple/res/stasis_http/resource_bridges.h (original)
+++ team/dlee/allow-multiple/res/stasis_http/resource_bridges.h Thu Jul 25 09:27:45 2013
@@ -97,9 +97,12 @@
 struct ast_add_channel_to_bridge_args {
 	/*! \brief Bridge's id */
 	const char *bridge_id;
-	/*! \brief Channel's id */
+	/*! \brief Array of Ids of channels to add to bridge */
 	const char **channel;
-	int channel_count;
+	/*! \brief Lenght of channel array. */
+	size_t channel_count;
+	/*! \brief Parsing context for channel. */
+	char *channel_parse;
 };
 /*!
  * \brief Add a channel to a bridge.
@@ -113,9 +116,12 @@
 struct ast_remove_channel_from_bridge_args {
 	/*! \brief Bridge's id */
 	const char *bridge_id;
-	/*! \brief Channel's id */
+	/*! \brief Array of Ids of channels to remove from bridge */
 	const char **channel;
-	int channel_count;
+	/*! \brief Lenght of channel array. */

[... 339 lines stripped ...]



More information about the asterisk-commits mailing list