From 409f147b81748829457ee9110ccd0488ad9bfbf4 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 10 May 2002 01:12:26 +0000 Subject: New filter function to pipe a message to another program. (run_command): 2002-05-09 Jeffrey Stedfast * camel-filter-search.c (shell_exec): New filter function to pipe a message to another program. (run_command): Fixed some bugs to make this work. svn path=/trunk/; revision=16742 --- camel/ChangeLog | 1 + camel/camel-filter-search.c | 19 ++++++------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 146e635d65..4b87d56e95 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -2,6 +2,7 @@ * camel-filter-search.c (shell_exec): New filter function to pipe a message to another program. + (run_command): Fixed some bugs to make this work. 2002-05-09 Not Zed diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c index a217aeed57..02362b7e2b 100644 --- a/camel/camel-filter-search.c +++ b/camel/camel-filter-search.c @@ -546,12 +546,13 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa } args = g_ptr_array_new (); - for (i = 0; i < argc; i++) { + g_ptr_array_add (args, g_basename (argv[0]->value.string)); + for (i = 1; i < argc; i++) { g_ptr_array_add (args, argv[i]->value.string); } g_ptr_array_add (args, NULL); - execvp (argv[i]->value.string, (char **) args->pdata); + execvp (argv[0]->value.string, (char **) args->pdata); g_ptr_array_free (args, TRUE); @@ -573,16 +574,8 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa message = camel_filter_search_get_message (fms, f); - if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream) == -1 || - camel_stream_flush (stream) == -1) { - if (errno == EINTR) - camel_exception_set (fms->ex, CAMEL_EXCEPTION_USER_CANCEL, "User Cancelled"); - else - camel_exception_setv (fms->ex, CAMEL_EXCEPTION_SYSTEM, - _("Failed to write message to '%s': %s"), - argv[0]->value.string, g_strerror (errno)); - } - + camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream); + camel_stream_flush (stream); camel_object_unref (CAMEL_OBJECT (stream)); result = waitpid (pid, &status, 0); @@ -600,7 +593,7 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa } } - if (!camel_exception_is_set (fms->ex) && result != -1 && WIFEXITED (status)) + if (result != -1 && WIFEXITED (status)) return WEXITSTATUS (status); else return -1; -- cgit v1.2.3