[svn-commits] dlee: branch dlee/ASTERISK-21969 r396840 - in /team/dlee/ASTERISK-21969: res/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Aug 16 10:46:20 CDT 2013


Author: dlee
Date: Fri Aug 16 10:46:18 2013
New Revision: 396840

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396840
Log:
Handle empty apps argument

Modified:
    team/dlee/ASTERISK-21969/res/res_ari_asterisk.c
    team/dlee/ASTERISK-21969/res/res_ari_bridges.c
    team/dlee/ASTERISK-21969/res/res_ari_events.c
    team/dlee/ASTERISK-21969/rest-api-templates/param_parsing.mustache
    team/dlee/ASTERISK-21969/rest-api-templates/res_ari_resource.c.mustache

Modified: team/dlee/ASTERISK-21969/res/res_ari_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/res/res_ari_asterisk.c?view=diff&rev=396840&r1=396839&r2=396840
==============================================================================
--- team/dlee/ASTERISK-21969/res/res_ari_asterisk.c (original)
+++ team/dlee/ASTERISK-21969/res/res_ari_asterisk.c Fri Aug 16 10:46:18 2013
@@ -81,8 +81,16 @@
 				goto fin;
 			}
 
-			args.only_count = ast_app_separate_args(
-				args.only_parse, ',', vals, ARRAY_LEN(vals));
+			if (strlen(args.only_parse) == 0) {
+				/* ast_app_separate_args can't handle "" */
+				args.only_count = 1;
+				vals[0] = args.only_parse;
+			} else {
+				args.only_count = ast_app_separate_args(
+					args.only_parse, ',', vals,
+					ARRAY_LEN(vals));
+			}
+
 			if (args.only_count == 0) {
 				ast_ari_response_alloc_failed(response);
 				goto fin;

Modified: team/dlee/ASTERISK-21969/res/res_ari_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/res/res_ari_bridges.c?view=diff&rev=396840&r1=396839&r2=396840
==============================================================================
--- team/dlee/ASTERISK-21969/res/res_ari_bridges.c (original)
+++ team/dlee/ASTERISK-21969/res/res_ari_bridges.c Fri Aug 16 10:46:18 2013
@@ -300,8 +300,16 @@
 				goto fin;
 			}
 
-			args.channel_count = ast_app_separate_args(
-				args.channel_parse, ',', vals, ARRAY_LEN(vals));
+			if (strlen(args.channel_parse) == 0) {
+				/* ast_app_separate_args can't handle "" */
+				args.channel_count = 1;
+				vals[0] = args.channel_parse;
+			} else {
+				args.channel_count = ast_app_separate_args(
+					args.channel_parse, ',', vals,
+					ARRAY_LEN(vals));
+			}
+
 			if (args.channel_count == 0) {
 				ast_ari_response_alloc_failed(response);
 				goto fin;
@@ -402,8 +410,16 @@
 				goto fin;
 			}
 
-			args.channel_count = ast_app_separate_args(
-				args.channel_parse, ',', vals, ARRAY_LEN(vals));
+			if (strlen(args.channel_parse) == 0) {
+				/* ast_app_separate_args can't handle "" */
+				args.channel_count = 1;
+				vals[0] = args.channel_parse;
+			} else {
+				args.channel_count = ast_app_separate_args(
+					args.channel_parse, ',', vals,
+					ARRAY_LEN(vals));
+			}
+
 			if (args.channel_count == 0) {
 				ast_ari_response_alloc_failed(response);
 				goto fin;

Modified: team/dlee/ASTERISK-21969/res/res_ari_events.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/res/res_ari_events.c?view=diff&rev=396840&r1=396839&r2=396840
==============================================================================
--- team/dlee/ASTERISK-21969/res/res_ari_events.c (original)
+++ team/dlee/ASTERISK-21969/res/res_ari_events.c Fri Aug 16 10:46:18 2013
@@ -89,8 +89,16 @@
 				goto fin;
 			}
 
-			args.app_count = ast_app_separate_args(
-				args.app_parse, ',', vals, ARRAY_LEN(vals));
+			if (strlen(args.app_parse) == 0) {
+				/* ast_app_separate_args can't handle "" */
+				args.app_count = 1;
+				vals[0] = args.app_parse;
+			} else {
+				args.app_count = ast_app_separate_args(
+					args.app_parse, ',', vals,
+					ARRAY_LEN(vals));
+			}
+
 			if (args.app_count == 0) {
 				ast_ari_response_alloc_failed(response);
 				goto fin;
@@ -126,14 +134,16 @@
 		 * negotiation. Param parsing should happen earlier, but we
 		 * need a way to pass it through the WebSocket code to the
 		 * callback */
-		RAII_VAR(char *, msg, NULL, ast_free);
+		RAII_VAR(char *, msg, NULL, ast_json_free);
 		if (response->message) {
 			msg = ast_json_dump_string(response->message);
 		} else {
-			msg = ast_strdup("?");
+			ast_log(LOG_ERROR, "Missing response message\n");
 		}
-		ast_websocket_write(ws_session, AST_WEBSOCKET_OPCODE_TEXT, msg,
-			strlen(msg));
+		if (msg) {
+			ast_websocket_write(ws_session,
+				AST_WEBSOCKET_OPCODE_TEXT, msg,	strlen(msg));
+		}
 	}
 	ast_free(args.app_parse);
 	ast_free(args.app);

Modified: team/dlee/ASTERISK-21969/rest-api-templates/param_parsing.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/rest-api-templates/param_parsing.mustache?view=diff&rev=396840&r1=396839&r2=396840
==============================================================================
--- team/dlee/ASTERISK-21969/rest-api-templates/param_parsing.mustache (original)
+++ team/dlee/ASTERISK-21969/rest-api-templates/param_parsing.mustache Fri Aug 16 10:46:18 2013
@@ -36,8 +36,16 @@
 				goto fin;
 			}
 
-			args.{{c_name}}_count = ast_app_separate_args(
-				args.{{c_name}}_parse, ',', vals, ARRAY_LEN(vals));
+			if (strlen(args.{{c_name}}_parse) == 0) {
+				/* ast_app_separate_args can't handle "" */
+				args.{{c_name}}_count = 1;
+				vals[0] = args.{{c_name}}_parse;
+			} else {
+				args.{{c_name}}_count = ast_app_separate_args(
+					args.{{c_name}}_parse, ',', vals,
+					ARRAY_LEN(vals));
+			}
+
 			if (args.{{c_name}}_count == 0) {
 				ast_ari_response_alloc_failed(response);
 				goto fin;

Modified: team/dlee/ASTERISK-21969/rest-api-templates/res_ari_resource.c.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21969/rest-api-templates/res_ari_resource.c.mustache?view=diff&rev=396840&r1=396839&r2=396840
==============================================================================
--- team/dlee/ASTERISK-21969/rest-api-templates/res_ari_resource.c.mustache (original)
+++ team/dlee/ASTERISK-21969/rest-api-templates/res_ari_resource.c.mustache Fri Aug 16 10:46:18 2013
@@ -174,14 +174,16 @@
 		 * negotiation. Param parsing should happen earlier, but we
 		 * need a way to pass it through the WebSocket code to the
 		 * callback */
-		RAII_VAR(char *, msg, NULL, ast_free);
+		RAII_VAR(char *, msg, NULL, ast_json_free);
 		if (response->message) {
 			msg = ast_json_dump_string(response->message);
 		} else {
-			msg = ast_strdup("?");
+			ast_log(LOG_ERROR, "Missing response message\n");
 		}
-		ast_websocket_write(ws_session, AST_WEBSOCKET_OPCODE_TEXT, msg,
-			strlen(msg));
+		if (msg) {
+			ast_websocket_write(ws_session,
+				AST_WEBSOCKET_OPCODE_TEXT, msg,	strlen(msg));
+		}
 	}
 {{> param_cleanup}}
 }




More information about the svn-commits mailing list