[asterisk-commits] kpfleming: branch 1.6.1 r157719 - in /branches/1.6.1: ./ apps/ include/asteri...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 19 07:03:51 CST 2008


Author: kpfleming
Date: Wed Nov 19 07:03:50 2008
New Revision: 157719

URL: http://svn.digium.com/view/asterisk?view=rev&rev=157719
Log:
Merged revisions 157706 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r157706 | kpfleming | 2008-11-19 06:42:19 -0600 (Wed, 19 Nov 2008) | 5 lines
  
  make some corrections to the ast_agi_register_multiple(), ast_agi_unregister_multiple() and ast_agi_fdprintf() API calls to be consistent with API guidelines
  
  also, move UPGRADE.txt to UPGRADE-1.6.txt and make the new UPGRADE.txt contain information about upgrading between Asterisk 1.6 releases
........

Added:
    branches/1.6.1/UPGRADE-1.6.txt
      - copied unchanged from r157706, branches/1.6.0/UPGRADE.txt
    branches/1.6.1/UPGRADE.txt   (contents, props changed)
      - copied, changed from r157706, trunk/UPGRADE.txt
Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/CHANGES
    branches/1.6.1/apps/app_stack.c
    branches/1.6.1/include/asterisk/agi.h
    branches/1.6.1/res/res_agi.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/CHANGES
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/CHANGES?view=diff&rev=157719&r1=157718&r2=157719
==============================================================================
--- branches/1.6.1/CHANGES (original)
+++ branches/1.6.1/CHANGES Wed Nov 19 07:03:50 2008
@@ -68,6 +68,8 @@
    wish to validate or invalidate the password given.  Arguments are:
    "mailbox" "context" "oldpass" "newpass".  See the sample voicemail.conf for
    more details
+ * The voicemail externnotify script now accepts an additional (last) parameter
+   containing the number of urgent messages in the INBOX.
  * Dial has a new option: F(context^extension^pri), which permits a callee to
    continue in the dialplan, at the specified label, if the caller hangs up.
  * ChanSpy and ExtenSpy have a new option, 's' which suppresses speaking the

Copied: branches/1.6.1/UPGRADE.txt (from r157706, trunk/UPGRADE.txt)
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/UPGRADE.txt?view=diff&rev=157719&p1=trunk/UPGRADE.txt&r1=157706&p2=branches/1.6.1/UPGRADE.txt&r2=157719
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ branches/1.6.1/UPGRADE.txt Wed Nov 19 07:03:50 2008
@@ -7,7 +7,7 @@
 === UPGRADE-1.6.txt -- Upgrade info for 1.4 to 1.6
 ===========================================================
 
-From 1.6.0.1 to 1.6.0.2 or later, or 1.6.1 or later:
+From 1.6.0.1 to 1.6.1:
 
 * The ast_agi_register_multiple() and ast_agi_unregister_multiple()
   API calls were added in 1.6.0, so that modules that provide multiple
@@ -25,3 +25,31 @@
   to better match what it really does, and the argument order has been
   changed to be consistent with other API calls that perform similar
   operations.
+
+From 1.6.0.x to 1.6.1:
+
+* The following core commands dealing with dialplan have been deprecated: 'core
+  show globals', 'core set global' and 'core set chanvar'. Use the equivalent
+  'dialplan show globals', 'dialplan set global' and 'dialplan set chanvar'
+  instead.
+
+* In the dialplan expression parser, the logical value of spaces
+  immediately preceding a standalone 0 previously evaluated to
+  true. It now evaluates to false.  This has confused a good many
+  people in the past (typically because they failed to realize the
+  space had any significance).  Since this violates the Principle of
+  Least Surprise, it has been changed.
+
+* While app_directory has always relied on having a voicemail.conf or users.conf file
+  correctly set up, it now is dependent on app_voicemail being compiled as well.
+
+* SIP: All of the functionality in SIPCHANINFO() has been implemented in CHANNEL(),
+  and you should start using that function instead for retrieving information about
+  the channel in a technology-agnostic way.
+
+* If you have any third party modules which use a config file variable whose
+  name ends in a '+', please note that the append capability added to this
+  version may now conflict with that variable naming scheme.  An easy
+  workaround is to ensure that a space occurs between the '+' and the '=',
+  to differentiate your variable from the append operator.  This potential
+  conflict is unlikely, but is documented here to be thorough.

Propchange: branches/1.6.1/UPGRADE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: branches/1.6.1/UPGRADE.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: branches/1.6.1/UPGRADE.txt
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: branches/1.6.1/UPGRADE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: branches/1.6.1/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/apps/app_stack.c?view=diff&rev=157719&r1=157718&r2=157719
==============================================================================
--- branches/1.6.1/apps/app_stack.c (original)
+++ branches/1.6.1/apps/app_stack.c Wed Nov 19 07:03:50 2008
@@ -409,11 +409,11 @@
 		/* Lookup the priority label */
 		if ((priority = ast_findlabel_extension(chan, argv[1], argv[2], argv[3], chan->cid.cid_num)) < 0) {
 			ast_log(LOG_ERROR, "Priority '%s' not found in '%s@%s'\n", argv[3], argv[2], argv[1]);
-			ast_agi_fdprintf(chan, agi->fd, "200 result=-1 Gosub label not found\n");
+			ast_agi_send(agi->fd, chan, "200 result=-1 Gosub label not found\n");
 			return RESULT_FAILURE;
 		}
 	} else if (!ast_exists_extension(chan, argv[1], argv[2], priority, chan->cid.cid_num)) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=-1 Gosub label not found\n");
+		ast_agi_send(agi->fd, chan, "200 result=-1 Gosub label not found\n");
 		return RESULT_FAILURE;
 	}
 
@@ -424,7 +424,7 @@
 
 	if (!(theapp = pbx_findapp("Gosub"))) {
 		ast_log(LOG_ERROR, "Gosub() cannot be found in the list of loaded applications\n");
-		ast_agi_fdprintf(chan, agi->fd, "503 result=-2 Gosub is not loaded\n");
+		ast_agi_send(agi->fd, chan, "503 result=-2 Gosub is not loaded\n");
 		return RESULT_FAILURE;
 	}
 
@@ -458,19 +458,19 @@
 			struct ast_pbx *pbx = chan->pbx;
 			/* Suppress warning about PBX already existing */
 			chan->pbx = NULL;
-			ast_agi_fdprintf(chan, agi->fd, "100 result=0 Trying...\n");
+			ast_agi_send(agi->fd, chan, "100 result=0 Trying...\n");
 			ast_pbx_run(chan);
-			ast_agi_fdprintf(chan, agi->fd, "200 result=0 Gosub complete\n");
+			ast_agi_send(agi->fd, chan, "200 result=0 Gosub complete\n");
 			if (chan->pbx) {
 				ast_free(chan->pbx);
 			}
 			chan->pbx = pbx;
 		} else {
-			ast_agi_fdprintf(chan, agi->fd, "200 result=%d Gosub failed\n", res);
+			ast_agi_send(agi->fd, chan, "200 result=%d Gosub failed\n", res);
 		}
 		ast_free(gosub_args);
 	} else {
-		ast_agi_fdprintf(chan, agi->fd, "503 result=-2 Memory allocation failure\n");
+		ast_agi_send(agi->fd, chan, "503 result=-2 Memory allocation failure\n");
 		return RESULT_FAILURE;
 	}
 

Modified: branches/1.6.1/include/asterisk/agi.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/include/asterisk/agi.h?view=diff&rev=157719&r1=157718&r2=157719
==============================================================================
--- branches/1.6.1/include/asterisk/agi.h (original)
+++ branches/1.6.1/include/asterisk/agi.h Wed Nov 19 07:03:50 2008
@@ -61,11 +61,53 @@
 #define AGI_WEAK
 #endif
 
-int AGI_WEAK ast_agi_fdprintf(struct ast_channel *chan, int fd, char *fmt, ...);
+/*!
+ * \brief
+ *
+ * Sends a string of text to an application connected via AGI.
+ *
+ * \param fd The file descriptor for the AGI session (from struct agi_state)
+ * \param chan Pointer to an associated Asterisk channel, if any
+ * \param fmt printf-style format string
+ * \return 0 for success, -1 for failure
+ *
+ */
+int AGI_WEAK ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...) __attribute__((format(printf, 3, 4)));
 int AGI_WEAK ast_agi_register(struct ast_module *mod, agi_command *cmd);
 int AGI_WEAK ast_agi_unregister(struct ast_module *mod, agi_command *cmd);
-void AGI_WEAK ast_agi_register_multiple(struct ast_module *mod, agi_command *cmd, int len);
-void AGI_WEAK ast_agi_unregister_multiple(struct ast_module *mod, agi_command *cmd, int len);
+
+/*!
+ * \brief
+ *
+ * Registers a group of AGI commands, provided as an array of struct agi_command
+ * entries.
+ *
+ * \param mod Pointer to the module_info structure for the module that is registering the commands
+ * \param cmd Pointer to the first entry in the array of commands
+ * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
+ * \return 0 on success, -1 on failure
+ *
+ * \note If any command fails to register, all commands previously registered during the operation
+ * will be unregistered. In other words, this function registers all the provided commands, or none
+ * of them.
+ */
+int AGI_WEAK ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len);
+
+/*!
+ * \brief
+ *
+ * Unregisters a group of AGI commands, provided as an array of struct agi_command
+ * entries.
+ *
+ * \param mod Pointer to the module_info structure for the module that is unregistering the commands
+ * \param cmd Pointer to the first entry in the array of commands
+ * \param len Length of the array (use the ARRAY_LEN macro to determine this easily)
+ * \return 0 on success, -1 on failure
+ *
+ * \note If any command fails to unregister, this function will continue to unregister the
+ * remaining commands in the array; it will not reregister the already-unregistered commands.
+ */
+int AGI_WEAK ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: branches/1.6.1/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/res/res_agi.c?view=diff&rev=157719&r1=157718&r2=157719
==============================================================================
--- branches/1.6.1/res/res_agi.c (original)
+++ branches/1.6.1/res/res_agi.c Wed Nov 19 07:03:50 2008
@@ -115,7 +115,7 @@
 AST_THREADSTORAGE(agi_buf);
 #define AGI_BUF_INITSIZE 256
 
-int ast_agi_fdprintf(struct ast_channel *chan, int fd, char *fmt, ...)
+int ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...)
 {
 	int res = 0;
 	va_list ap;
@@ -582,7 +582,7 @@
 		}
 	}
 
-	if (ast_agi_fdprintf(NULL, s, "agi_network: yes\n") < 0) {
+	if (ast_agi_send(s, NULL, "agi_network: yes\n") < 0) {
 		if (errno != EINTR) {
 			ast_log(LOG_WARNING, "Connect to '%s' failed: %s\n", agiurl, strerror(errno));
 			close(s);
@@ -593,7 +593,7 @@
 	/* If we have a script parameter, relay it to the fastagi server */
 	/* Script parameters take the form of: AGI(agi://my.example.com/?extension=${EXTEN}) */
 	if (!ast_strlen_zero(script))
-		ast_agi_fdprintf(NULL, s, "agi_network_script: %s\n", script);
+		ast_agi_send(s, NULL, "agi_network_script: %s\n", script);
 
 	ast_debug(4, "Wow, connected!\n");
 	fds[0] = s;
@@ -722,40 +722,40 @@
 
 	/* Print initial environment, with agi_request always being the first
 	   thing */
-	ast_agi_fdprintf(chan, fd, "agi_request: %s\n", request);
-	ast_agi_fdprintf(chan, fd, "agi_channel: %s\n", chan->name);
-	ast_agi_fdprintf(chan, fd, "agi_language: %s\n", chan->language);
-	ast_agi_fdprintf(chan, fd, "agi_type: %s\n", chan->tech->type);
-	ast_agi_fdprintf(chan, fd, "agi_uniqueid: %s\n", chan->uniqueid);
-	ast_agi_fdprintf(chan, fd, "agi_version: %s\n", ast_get_version());
+	ast_agi_send(fd, chan, "agi_request: %s\n", request);
+	ast_agi_send(fd, chan, "agi_channel: %s\n", chan->name);
+	ast_agi_send(fd, chan, "agi_language: %s\n", chan->language);
+	ast_agi_send(fd, chan, "agi_type: %s\n", chan->tech->type);
+	ast_agi_send(fd, chan, "agi_uniqueid: %s\n", chan->uniqueid);
+	ast_agi_send(fd, chan, "agi_version: %s\n", ast_get_version());
 
 	/* ANI/DNIS */
-	ast_agi_fdprintf(chan, fd, "agi_callerid: %s\n", S_OR(chan->cid.cid_num, "unknown"));
-	ast_agi_fdprintf(chan, fd, "agi_calleridname: %s\n", S_OR(chan->cid.cid_name, "unknown"));
-	ast_agi_fdprintf(chan, fd, "agi_callingpres: %d\n", chan->cid.cid_pres);
-	ast_agi_fdprintf(chan, fd, "agi_callingani2: %d\n", chan->cid.cid_ani2);
-	ast_agi_fdprintf(chan, fd, "agi_callington: %d\n", chan->cid.cid_ton);
-	ast_agi_fdprintf(chan, fd, "agi_callingtns: %d\n", chan->cid.cid_tns);
-	ast_agi_fdprintf(chan, fd, "agi_dnid: %s\n", S_OR(chan->cid.cid_dnid, "unknown"));
-	ast_agi_fdprintf(chan, fd, "agi_rdnis: %s\n", S_OR(chan->cid.cid_rdnis, "unknown"));
+	ast_agi_send(fd, chan, "agi_callerid: %s\n", S_OR(chan->cid.cid_num, "unknown"));
+	ast_agi_send(fd, chan, "agi_calleridname: %s\n", S_OR(chan->cid.cid_name, "unknown"));
+	ast_agi_send(fd, chan, "agi_callingpres: %d\n", chan->cid.cid_pres);
+	ast_agi_send(fd, chan, "agi_callingani2: %d\n", chan->cid.cid_ani2);
+	ast_agi_send(fd, chan, "agi_callington: %d\n", chan->cid.cid_ton);
+	ast_agi_send(fd, chan, "agi_callingtns: %d\n", chan->cid.cid_tns);
+	ast_agi_send(fd, chan, "agi_dnid: %s\n", S_OR(chan->cid.cid_dnid, "unknown"));
+	ast_agi_send(fd, chan, "agi_rdnis: %s\n", S_OR(chan->cid.cid_rdnis, "unknown"));
 
 	/* Context information */
-	ast_agi_fdprintf(chan, fd, "agi_context: %s\n", chan->context);
-	ast_agi_fdprintf(chan, fd, "agi_extension: %s\n", chan->exten);
-	ast_agi_fdprintf(chan, fd, "agi_priority: %d\n", chan->priority);
-	ast_agi_fdprintf(chan, fd, "agi_enhanced: %s\n", enhanced ? "1.0" : "0.0");
+	ast_agi_send(fd, chan, "agi_context: %s\n", chan->context);
+	ast_agi_send(fd, chan, "agi_extension: %s\n", chan->exten);
+	ast_agi_send(fd, chan, "agi_priority: %d\n", chan->priority);
+	ast_agi_send(fd, chan, "agi_enhanced: %s\n", enhanced ? "1.0" : "0.0");
 
 	/* User information */
-	ast_agi_fdprintf(chan, fd, "agi_accountcode: %s\n", chan->accountcode ? chan->accountcode : "");
-	ast_agi_fdprintf(chan, fd, "agi_threadid: %ld\n", (long)pthread_self());
+	ast_agi_send(fd, chan, "agi_accountcode: %s\n", chan->accountcode ? chan->accountcode : "");
+	ast_agi_send(fd, chan, "agi_threadid: %ld\n", (long)pthread_self());
 
 	/* Send any parameters to the fastagi server that have been passed via the agi application */
 	/* Agi application paramaters take the form of: AGI(/path/to/example/script|${EXTEN}) */
 	for(count = 1; count < argc; count++)
-		ast_agi_fdprintf(chan, fd, "agi_arg_%d: %s\n", count, argv[count]);
+		ast_agi_send(fd, chan, "agi_arg_%d: %s\n", count, argv[count]);
 
 	/* End with empty return */
-	ast_agi_fdprintf(chan, fd, "\n");
+	ast_agi_send(fd, chan, "\n");
 }
 
 static int handle_answer(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
@@ -766,7 +766,7 @@
 	if (chan->_state != AST_STATE_UP)
 		res = ast_answer(chan);
 
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -779,7 +779,7 @@
 	if (sscanf(argv[3], "%d", &to) != 1)
 		return RESULT_SHOWUSAGE;
 	res = ast_waitfordigit_full(chan, to, agi->audio, agi->ctrl);
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -798,7 +798,7 @@
 	   parsing, then here, add a newline at the end of the string
 	   before sending it to ast_sendtext --DUDE */
 	res = ast_sendtext(chan, argv[2]);
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -811,14 +811,14 @@
 
 	res = ast_recvchar(chan,atoi(argv[2]));
 	if (res == 0) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%d (timeout)\n", res);
+		ast_agi_send(agi->fd, chan, "200 result=%d (timeout)\n", res);
 		return RESULT_SUCCESS;
 	}
 	if (res > 0) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+		ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 		return RESULT_SUCCESS;
 	}
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d (hangup)\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d (hangup)\n", res);
 	return RESULT_FAILURE;
 }
 
@@ -831,10 +831,10 @@
 
 	buf = ast_recvtext(chan, atoi(argv[2]));
 	if (buf) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1 (%s)\n", buf);
+		ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", buf);
 		ast_free(buf);
 	} else {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=-1\n");
+		ast_agi_send(agi->fd, chan, "200 result=-1\n");
 	}
 	return RESULT_SUCCESS;
 }
@@ -859,9 +859,9 @@
 	}
 	res = ast_channel_setoption(chan, AST_OPTION_TDD, &x, sizeof(char), 0);
 	if (res != RESULT_SUCCESS) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	} else {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+		ast_agi_send(agi->fd, chan, "200 result=1\n");
 	}
 	return RESULT_SUCCESS;
 }
@@ -878,7 +878,7 @@
 	if (!ast_check_hangup(chan)) {
 		res = 0;
 	}
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -913,7 +913,7 @@
 
 	res = ast_control_streamfile(chan, argv[3], fwd, rev, stop, suspend, NULL, skipms, NULL);
 
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
@@ -935,7 +935,7 @@
 		return RESULT_SHOWUSAGE;
 
 	if (!(fs = ast_openstream(chan, argv[2], chan->language))) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%d endpos=%ld\n", 0, sample_offset);
+		ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", 0, sample_offset);
 		return RESULT_SUCCESS;
 	}
 
@@ -963,7 +963,7 @@
 		/* Stop this command, don't print a result line, as there is a new command */
 		return RESULT_SUCCESS;
 	}
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
+	ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", res, sample_offset);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -990,7 +990,7 @@
 	}
 
 	if (!(fs = ast_openstream(chan, argv[2], chan->language))) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%d endpos=%ld\n", 0, sample_offset);
+		ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", 0, sample_offset);
 		ast_log(LOG_WARNING, "Unable to open %s\n", argv[2]);
 		return RESULT_SUCCESS;
 	}
@@ -1028,7 +1028,7 @@
 			res=0;
 	}
 
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
+	ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", res, sample_offset);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -1048,7 +1048,7 @@
 	res = ast_say_number_full(chan, num, argv[3], chan->language, argc > 4 ? argv[4] : NULL, agi->audio, agi->ctrl);
 	if (res == 1)
 		return RESULT_SUCCESS;
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -1064,7 +1064,7 @@
 	res = ast_say_digit_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
 	if (res == 1) /* New command */
 		return RESULT_SUCCESS;
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -1078,7 +1078,7 @@
 	res = ast_say_character_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
 	if (res == 1) /* New command */
 		return RESULT_SUCCESS;
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -1093,7 +1093,7 @@
 	res = ast_say_date(chan, num, argv[3], chan->language);
 	if (res == 1)
 		return RESULT_SUCCESS;
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -1108,7 +1108,7 @@
 	res = ast_say_time(chan, num, argv[3], chan->language);
 	if (res == 1)
 		return RESULT_SUCCESS;
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -1142,7 +1142,7 @@
 	if (res == 1)
 		return RESULT_SUCCESS;
 
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -1156,7 +1156,7 @@
 	res = ast_say_phonetic_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
 	if (res == 1) /* New command */
 		return RESULT_SUCCESS;
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 	return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
@@ -1179,11 +1179,11 @@
 	if (res == 2)			/* New command */
 		return RESULT_SUCCESS;
 	else if (res == 1)
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%s (timeout)\n", data);
+		ast_agi_send(agi->fd, chan, "200 result=%s (timeout)\n", data);
 	else if (res < 0 )
-		ast_agi_fdprintf(chan, agi->fd, "200 result=-1\n");
+		ast_agi_send(agi->fd, chan, "200 result=-1\n");
 	else
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%s\n", data);
+		ast_agi_send(agi->fd, chan, "200 result=%s\n", data);
 	return RESULT_SUCCESS;
 }
 
@@ -1193,7 +1193,7 @@
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
 	ast_copy_string(chan->context, argv[2], sizeof(chan->context));
-	ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+	ast_agi_send(agi->fd, chan, "200 result=0\n");
 	return RESULT_SUCCESS;
 }
 
@@ -1202,7 +1202,7 @@
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
 	ast_copy_string(chan->exten, argv[2], sizeof(chan->exten));
-	ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+	ast_agi_send(agi->fd, chan, "200 result=0\n");
 	return RESULT_SUCCESS;
 }
 
@@ -1219,7 +1219,7 @@
 	}
 
 	ast_explicit_goto(chan, NULL, NULL, pri);
-	ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+	ast_agi_send(agi->fd, chan, "200 result=0\n");
 	return RESULT_SUCCESS;
 }
 
@@ -1294,12 +1294,12 @@
 	if (!res)
 		res = ast_waitstream(chan, argv[4]);
 	if (res) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%d (randomerror) endpos=%ld\n", res, sample_offset);
+		ast_agi_send(agi->fd, chan, "200 result=%d (randomerror) endpos=%ld\n", res, sample_offset);
 	} else {
 		fs = ast_writefile(argv[2], argv[3], NULL, O_CREAT | O_WRONLY | (sample_offset ? O_APPEND : 0), 0, AST_FILE_MODE);
 		if (!fs) {
 			res = -1;
-			ast_agi_fdprintf(chan, agi->fd, "200 result=%d (writefile)\n", res);
+			ast_agi_send(agi->fd, chan, "200 result=%d (writefile)\n", res);
 			if (sildet)
 				ast_dsp_free(sildet);
 			return RESULT_FAILURE;
@@ -1319,14 +1319,14 @@
 			res = ast_waitfor(chan, -1);
 			if (res < 0) {
 				ast_closestream(fs);
-				ast_agi_fdprintf(chan, agi->fd, "200 result=%d (waitfor) endpos=%ld\n", res,sample_offset);
+				ast_agi_send(agi->fd, chan, "200 result=%d (waitfor) endpos=%ld\n", res,sample_offset);
 				if (sildet)
 					ast_dsp_free(sildet);
 				return RESULT_FAILURE;
 			}
 			f = ast_read(chan);
 			if (!f) {
-				ast_agi_fdprintf(chan, agi->fd, "200 result=%d (hangup) endpos=%ld\n", -1, sample_offset);
+				ast_agi_send(agi->fd, chan, "200 result=%d (hangup) endpos=%ld\n", -1, sample_offset);
 				ast_closestream(fs);
 				if (sildet)
 					ast_dsp_free(sildet);
@@ -1341,7 +1341,7 @@
 					ast_stream_rewind(fs, 200);
 					ast_truncstream(fs);
 					sample_offset = ast_tellstream(fs);
-					ast_agi_fdprintf(chan, agi->fd, "200 result=%d (dtmf) endpos=%ld\n", f->subclass, sample_offset);
+					ast_agi_send(agi->fd, chan, "200 result=%d (dtmf) endpos=%ld\n", f->subclass, sample_offset);
 					ast_closestream(fs);
 					ast_frfree(f);
 					if (sildet)
@@ -1386,7 +1386,7 @@
 			ast_truncstream(fs);
 			sample_offset = ast_tellstream(fs);
 		}
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%d (timeout) endpos=%ld\n", res, sample_offset);
+		ast_agi_send(agi->fd, chan, "200 result=%d (timeout) endpos=%ld\n", res, sample_offset);
 		ast_closestream(fs);
 	}
 
@@ -1416,7 +1416,7 @@
 		whentohangup.tv_usec = (timeout - whentohangup.tv_sec) * 1000000.0;
 	}
 	ast_channel_setwhentohangup_tv(chan, whentohangup);
-	ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+	ast_agi_send(agi->fd, chan, "200 result=0\n");
 	return RESULT_SUCCESS;
 }
 
@@ -1427,7 +1427,7 @@
 	if (argc == 1) {
 		/* no argument: hangup the current channel */
 		ast_softhangup(chan,AST_SOFTHANGUP_EXPLICIT);
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+		ast_agi_send(agi->fd, chan, "200 result=1\n");
 		return RESULT_SUCCESS;
 	} else if (argc == 2) {
 		/* one argument: look for info on the specified channel */
@@ -1435,12 +1435,12 @@
 		if (c) {
 			/* we have a matching channel */
 			ast_softhangup(c,AST_SOFTHANGUP_EXPLICIT);
-			ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+			ast_agi_send(agi->fd, chan, "200 result=1\n");
 			ast_channel_unlock(c);
 			return RESULT_SUCCESS;
 		}
 		/* if we get this far no channel name matched the argument given */
-		ast_agi_fdprintf(chan, agi->fd, "200 result=-1\n");
+		ast_agi_send(agi->fd, chan, "200 result=-1\n");
 		return RESULT_SUCCESS;
 	} else {
 		return RESULT_SHOWUSAGE;
@@ -1482,7 +1482,7 @@
 		ast_log(LOG_WARNING, "Could not find application (%s)\n", argv[1]);
 		res = -2;
 	}
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", res);
+	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
 
 	/* Even though this is wrong, users are depending upon this result. */
 	return res;
@@ -1505,7 +1505,7 @@
 		ast_set_callerid(chan, l, n, NULL);
 	}
 
-	ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+	ast_agi_send(agi->fd, chan, "200 result=1\n");
 	return RESULT_SUCCESS;
 }
 
@@ -1514,18 +1514,18 @@
 	struct ast_channel *c;
 	if (argc == 2) {
 		/* no argument: supply info on the current channel */
-		ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", chan->_state);
+		ast_agi_send(agi->fd, chan, "200 result=%d\n", chan->_state);
 		return RESULT_SUCCESS;
 	} else if (argc == 3) {
 		/* one argument: look for info on the specified channel */
 		c = ast_get_channel_by_name_locked(argv[2]);
 		if (c) {
-			ast_agi_fdprintf(chan, agi->fd, "200 result=%d\n", c->_state);
+			ast_agi_send(agi->fd, chan, "200 result=%d\n", c->_state);
 			ast_channel_unlock(c);
 			return RESULT_SUCCESS;
 		}
 		/* if we get this far no channel name matched the argument given */
-		ast_agi_fdprintf(chan, agi->fd, "200 result=-1\n");
+		ast_agi_send(agi->fd, chan, "200 result=-1\n");
 		return RESULT_SUCCESS;
 	} else {
 		return RESULT_SHOWUSAGE;
@@ -1537,7 +1537,7 @@
 	if (argv[3])
 		pbx_builtin_setvar_helper(chan, argv[2], argv[3]);
 
-	ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+	ast_agi_send(agi->fd, chan, "200 result=1\n");
 	return RESULT_SUCCESS;
 }
 
@@ -1557,9 +1557,9 @@
 	}
 
 	if (ret)
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1 (%s)\n", ret);
+		ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", ret);
 	else
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 
 	return RESULT_SUCCESS;
 }
@@ -1578,9 +1578,9 @@
 	}
 	if (chan2) {
 		pbx_substitute_variables_helper(chan2, argv[3], tmp, sizeof(tmp) - 1);
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1 (%s)\n", tmp);
+		ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", tmp);
 	} else {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	}
 	if (chan2 && (chan2 != chan))
 		ast_channel_unlock(chan2);
@@ -1599,7 +1599,7 @@
 
 	ast_verb(level, "%s: %s\n", chan->data, argv[1]);
 
-	ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+	ast_agi_send(agi->fd, chan, "200 result=1\n");
 
 	return RESULT_SUCCESS;
 }
@@ -1613,9 +1613,9 @@
 		return RESULT_SHOWUSAGE;
 	res = ast_db_get(argv[2], argv[3], tmp, sizeof(tmp));
 	if (res)
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	else
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1 (%s)\n", tmp);
+		ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", tmp);
 
 	return RESULT_SUCCESS;
 }
@@ -1627,7 +1627,7 @@
 	if (argc != 5)
 		return RESULT_SHOWUSAGE;
 	res = ast_db_put(argv[2], argv[3], argv[4]);
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%c\n", res ? '0' : '1');
+	ast_agi_send(agi->fd, chan, "200 result=%c\n", res ? '0' : '1');
 	return RESULT_SUCCESS;
 }
 
@@ -1638,7 +1638,7 @@
 	if (argc != 4)
 		return RESULT_SHOWUSAGE;
 	res = ast_db_del(argv[2], argv[3]);
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%c\n", res ? '0' : '1');
+	ast_agi_send(agi->fd, chan, "200 result=%c\n", res ? '0' : '1');
 	return RESULT_SUCCESS;
 }
 
@@ -1653,7 +1653,7 @@
 	else
 		res = ast_db_deltree(argv[2], NULL);
 
-	ast_agi_fdprintf(chan, agi->fd, "200 result=%c\n", res ? '0' : '1');
+	ast_agi_send(agi->fd, chan, "200 result=%c\n", res ? '0' : '1');
 	return RESULT_SUCCESS;
 }
 
@@ -1688,7 +1688,7 @@
 
 static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, char *argv[])
 {
-	ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+	ast_agi_send(agi->fd, chan, "200 result=0\n");
 	return RESULT_SUCCESS;
 }
 
@@ -1698,7 +1698,7 @@
 		ast_moh_start(chan, argc > 3 ? argv[3] : NULL, NULL);
 	else if (!strncasecmp(argv[2], "off", 3))
 		ast_moh_stop(chan);
-	ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+	ast_agi_send(agi->fd, chan, "200 result=0\n");
 	return RESULT_SUCCESS;
 }
 
@@ -1706,14 +1706,14 @@
 {
 	/* If a structure already exists, return an error */
         if (agi->speech) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
 	if ((agi->speech = ast_speech_new(argv[2], AST_FORMAT_SLINEAR)))
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+		ast_agi_send(agi->fd, chan, "200 result=1\n");
 	else
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 
 	return RESULT_SUCCESS;
 }
@@ -1726,12 +1726,12 @@
 
 	/* Check to make sure speech structure exists */
 	if (!agi->speech) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
 	ast_speech_change(agi->speech, argv[2], argv[3]);
-	ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+	ast_agi_send(agi->fd, chan, "200 result=1\n");
 
 	return RESULT_SUCCESS;
 }
@@ -1741,9 +1741,9 @@
 	if (agi->speech) {
 		ast_speech_destroy(agi->speech);
 		agi->speech = NULL;
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+		ast_agi_send(agi->fd, chan, "200 result=1\n");
 	} else {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	}
 
 	return RESULT_SUCCESS;
@@ -1755,14 +1755,14 @@
 		return RESULT_SHOWUSAGE;
 
 	if (!agi->speech) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
 	if (ast_speech_grammar_load(agi->speech, argv[3], argv[4]))
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	else
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+		ast_agi_send(agi->fd, chan, "200 result=1\n");
 
 	return RESULT_SUCCESS;
 }
@@ -1773,14 +1773,14 @@
 		return RESULT_SHOWUSAGE;
 
 	if (!agi->speech) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
 	if (ast_speech_grammar_unload(agi->speech, argv[3]))
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	else
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+		ast_agi_send(agi->fd, chan, "200 result=1\n");
 
 	return RESULT_SUCCESS;
 }
@@ -1791,14 +1791,14 @@
 		return RESULT_SHOWUSAGE;
 
 	if (!agi->speech) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
 	if (ast_speech_grammar_activate(agi->speech, argv[3]))
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	else
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+		ast_agi_send(agi->fd, chan, "200 result=1\n");
 
 	return RESULT_SUCCESS;
 }
@@ -1809,14 +1809,14 @@
 		return RESULT_SHOWUSAGE;
 
 	if (!agi->speech) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
 	if (ast_speech_grammar_deactivate(agi->speech, argv[3]))
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 	else
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1\n");
+		ast_agi_send(agi->fd, chan, "200 result=1\n");
 
 	return RESULT_SUCCESS;
 }
@@ -1856,7 +1856,7 @@
 		return RESULT_SHOWUSAGE;
 
 	if (!speech) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
@@ -1870,7 +1870,7 @@
 	/* We want frames coming in signed linear */
 	old_read_format = chan->readformat;
 	if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
@@ -1975,13 +1975,13 @@
 			i++;
 		}
                 /* Print out */
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1 (speech) endpos=%ld results=%d %s\n", current_offset, i, tmp);
+		ast_agi_send(agi->fd, chan, "200 result=1 (speech) endpos=%ld results=%d %s\n", current_offset, i, tmp);
 	} else if (!strcasecmp(reason, "dtmf")) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1 (digit) digit=%c endpos=%ld\n", dtmf, current_offset);
+		ast_agi_send(agi->fd, chan, "200 result=1 (digit) digit=%c endpos=%ld\n", dtmf, current_offset);
 	} else if (!strcasecmp(reason, "hangup") || !strcasecmp(reason, "timeout")) {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=1 (%s) endpos=%ld\n", reason, current_offset);
+		ast_agi_send(agi->fd, chan, "200 result=1 (%s) endpos=%ld\n", reason, current_offset);
 	} else {
-		ast_agi_fdprintf(chan, agi->fd, "200 result=0 endpos=%ld\n", current_offset);
+		ast_agi_send(agi->fd, chan, "200 result=0 endpos=%ld\n", current_offset);
 	}
 
 	return RESULT_SUCCESS;
@@ -1989,7 +1989,7 @@
 
 static int handle_asyncagi_break(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
 {
-	ast_agi_fdprintf(chan, agi->fd, "200 result=0\n");
+	ast_agi_send(agi->fd, chan, "200 result=0\n");
 	return AST_PBX_KEEPALIVE;
 }
 
@@ -2404,21 +2404,50 @@
 	return unregistered;
 }
 
-void ast_agi_register_multiple(struct ast_module *mod, agi_command *cmd, int len)
-{
-	int i;
-
-	for (i = 0; i < len; i++)
-		ast_agi_register(mod, cmd + i);
-
-}
-
-void ast_agi_unregister_multiple(struct ast_module *mod, agi_command *cmd, int len)
-{
-	int i;
-
-	for (i = 0; i < len; i++)
-		ast_agi_unregister(mod, cmd + i);
+int ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len)
+{
+	unsigned int i, x = 0;
+
+	for (i = 0; i < len; i++) {
+		if (ast_agi_register(mod, cmd + i) == 1) {
+			x++;
+			continue;
+		}
+
+		/* registration failed, unregister everything
+		   that had been registered up to that point
+		*/
+		for (; x > 0; x--) {
+			/* we are intentionally ignoring the
+			   result of ast_agi_unregister() here,
+			   but it should be safe to do so since
+			   we just registered these commands and
+			   the only possible way for unregistration
+			   to fail is if the command is not
+			   registered
+			*/
+			(void) ast_agi_unregister(mod, cmd + x - 1);
+		}
+		return -1;
+	}
+
+	return 0;
+}
+
+int ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len)
+{
+	unsigned int i;
+	int res = 0;
+
+	for (i = 0; i < len; i++) {
+		/* remember whether any of the unregistration
+		   attempts failed... there is no recourse if
+		   any of them do
+		*/
+		res |= ast_agi_unregister(mod, cmd + i);
+	}
+
+	return res;
 }
 
 static agi_command *find_command(char *cmds[], int exact)
@@ -2560,9 +2589,9 @@
 				"Result: %s\r\n", chan->name, command_id, ami_cmd, resultcode, ami_res);
 		switch(res) {
 		case RESULT_SHOWUSAGE:
-			ast_agi_fdprintf(chan, agi->fd, "520-Invalid command syntax.  Proper usage follows:\n");
-			ast_agi_fdprintf(chan, agi->fd, c->usage);
-			ast_agi_fdprintf(chan, agi->fd, "520 End of proper usage.\n");
+			ast_agi_send(agi->fd, chan, "520-Invalid command syntax.  Proper usage follows:\n");
+			ast_agi_send(agi->fd, NULL, "%s", c->usage);
+			ast_agi_send(agi->fd, chan, "520 End of proper usage.\n");
 			break;
 		case AST_PBX_KEEPALIVE:
 			/* We've been asked to keep alive, so do so */
@@ -2574,7 +2603,7 @@
 			return -1;
 		}
 	} else if ((c = find_command(argv, 0))) {
-		ast_agi_fdprintf(chan, agi->fd, "511 Command Not Permitted on a dead channel\n");
+		ast_agi_send(agi->fd, chan, "511 Command Not Permitted on a dead channel\n");
 		manager_event(EVENT_FLAG_CALL, "AGIExec",
 				"SubEvent: End\r\n"
 				"Channel: %s\r\n"
@@ -2583,7 +2612,7 @@
 				"ResultCode: 511\r\n"
 				"Result: Command not permitted on a dead channel\r\n", chan->name, command_id, ami_cmd);
 	} else {
-		ast_agi_fdprintf(chan, agi->fd, "510 Invalid or unknown command\n");
+		ast_agi_send(agi->fd, chan, "510 Invalid or unknown command\n");
 		manager_event(EVENT_FLAG_CALL, "AGIExec",
 				"SubEvent: End\r\n"
 				"Channel: %s\r\n"
@@ -3004,7 +3033,10 @@
 static int unload_module(void)
 {
 	ast_cli_unregister_multiple(cli_agi, sizeof(cli_agi) / sizeof(struct ast_cli_entry));
-	ast_agi_unregister_multiple(ast_module_info->self, commands, sizeof(commands) / sizeof(struct agi_command));
+	/* we can safely ignore the result of ast_agi_unregister_multiple() here, since it cannot fail, as
+	   we know that these commands were registered by this module and are still registered
+	*/
+	(void) ast_agi_unregister_multiple(ast_module_info->self, commands, ARRAY_LEN(commands));
 	ast_unregister_application(eapp);
 	ast_unregister_application(deadapp);
 	ast_manager_unregister("AGI");
@@ -3014,7 +3046,10 @@
 static int load_module(void)
 {
 	ast_cli_register_multiple(cli_agi, sizeof(cli_agi) / sizeof(struct ast_cli_entry));
-	ast_agi_register_multiple(ast_module_info->self, commands, sizeof(commands) / sizeof(struct agi_command));
+	/* we can safely ignore the result of ast_agi_register_multiple() here, since it cannot fail, as
+	   no other commands have been registered yet
+	*/
+	(void) ast_agi_register_multiple(ast_module_info->self, commands, ARRAY_LEN(commands));
 	ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
 	ast_register_application(eapp, eagi_exec, esynopsis, descrip);
 	ast_manager_register2("AGI", EVENT_FLAG_CALL, action_add_agi_cmd, "Add an AGI command to execute by Async AGI", mandescr_asyncagi);




More information about the asterisk-commits mailing list