summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTingPing <TingPing@users.noreply.github.com>2013-08-26 12:53:17 -0400
committerTingPing <TingPing@users.noreply.github.com>2013-08-26 12:53:17 -0400
commit616c669d3b50f63dfff36fc861a1b5b621138458 (patch)
tree8170b7ddc7cae75fd0faab13e39e7390cb3a9c40
parentd52cc1a1bd8d7efd4bd5db66bfb6921b4c391a36 (diff)
Fix /exec -o on Windows
-rw-r--r--plugins/exec/exec.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/plugins/exec/exec.c b/plugins/exec/exec.c
index 790278a2..233a884f 100644
--- a/plugins/exec/exec.c
+++ b/plugins/exec/exec.c
@@ -41,6 +41,10 @@ run_command (char *word[], char *word_eol[], void *userdata)
 	time_t start;
 	double timeElapsed;
 
+	char *token;
+	char *context = NULL;
+	int announce = 0;
+
 	HANDLE readPipe;
 	HANDLE writePipe;
 	STARTUPINFO sInfo; 
@@ -59,9 +63,8 @@ run_command (char *word[], char *word_eol[], void *userdata)
 
 		if (!stricmp("-O", word[2]))
 		{
-			/*strcat (commandLine, word_eol[3]);*/
-			hexchat_printf (ph, "Printing Exec output to others is not supported yet.\n");
-			return HEXCHAT_EAT_HEXCHAT;
+			strcat (commandLine, word_eol[3]);
+			announce = 1;
 		}
 		else
 		{
@@ -90,7 +93,19 @@ run_command (char *word[], char *word_eol[], void *userdata)
 				{
 					/* avoid garbage */
 					buffer[dwRead] = '\0';
-					hexchat_printf (ph, "%s", buffer);
+
+					if (announce)
+					{
+						/* Say each line seperately, TODO: improve... */
+						token = strtok_s (buffer, "\n", &context);
+						while (token != NULL)
+						{
+							hexchat_commandf (ph, "SAY %s", token);
+							token = strtok_s (NULL, "\n", &context);
+						}
+					}
+					else
+						hexchat_printf (ph, "%s", buffer);
 				}
 			}
 			else
@@ -103,7 +118,8 @@ run_command (char *word[], char *word_eol[], void *userdata)
 	}
 
 	/* display a newline to separate things */
-	hexchat_printf (ph, "\n");
+	if (!announce)
+		hexchat_printf (ph, "\n");
 
 	if (timeElapsed >= 10)
 	{