[asterisk-commits] russell: branch 1.4 r85532 - in /branches/1.4: include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Oct 13 00:24:33 CDT 2007
Author: russell
Date: Sat Oct 13 00:24:33 2007
New Revision: 85532
URL: http://svn.digium.com/view/asterisk?view=rev&rev=85532
Log:
Properly handle the case where read() may return the text for more than one
CLI command at once for a remote console.
(closes issue #10888)
Reported by: jamesgolovich
Patches:
asterisk-climultiple.diff.txt uploaded by jamesgolovich (license 176)
Modified:
branches/1.4/include/asterisk/cli.h
branches/1.4/main/asterisk.c
branches/1.4/main/cli.c
Modified: branches/1.4/include/asterisk/cli.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/cli.h?view=diff&rev=85532&r1=85531&r2=85532
==============================================================================
--- branches/1.4/include/asterisk/cli.h (original)
+++ branches/1.4/include/asterisk/cli.h Sat Oct 13 00:24:33 2007
@@ -108,6 +108,14 @@
*/
int ast_cli_command(int fd, const char *s);
+/*!
+ * \brief Executes multiple CLI commands
+ * Interpret strings separated by '\0' and execute each one, sending output to fd
+ * \param size is the total size of the string
+ * \retval number of commands executed
+ */
+int ast_cli_command_multiple(int fd, size_t size, const char *s);
+
/*! \brief Registers a command or an array of commands
* \param e which cli entry to register
* Register your own command
Modified: branches/1.4/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/asterisk.c?view=diff&rev=85532&r1=85531&r2=85532
==============================================================================
--- branches/1.4/main/asterisk.c (original)
+++ branches/1.4/main/asterisk.c Sat Oct 13 00:24:33 2007
@@ -936,7 +936,7 @@
break;
}
tmp[res] = 0;
- ast_cli_command(con->fd, tmp);
+ ast_cli_command_multiple(con->fd, res, tmp);
}
if (fds[1].revents) {
res = read(con->p[0], tmp, sizeof(tmp));
Modified: branches/1.4/main/cli.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/cli.c?view=diff&rev=85532&r1=85531&r2=85532
==============================================================================
--- branches/1.4/main/cli.c (original)
+++ branches/1.4/main/cli.c Sat Oct 13 00:24:33 2007
@@ -2005,3 +2005,20 @@
return 0;
}
+
+int ast_cli_command_multiple(int fd, size_t size, const char *s)
+{
+ char cmd[512];
+ int x, y = 0, count = 0;
+
+ for (x = 0; x < size; x++) {
+ cmd[y] = s[x];
+ y++;
+ if (s[x] == '\0') {
+ ast_cli_command(fd, cmd);
+ y = 0;
+ count++;
+ }
+ }
+ return count;
+}
More information about the asterisk-commits
mailing list