New filter function to pipe a message to another program. (run_command):
authorJeffrey Stedfast <fejj@ximian.com>
Fri, 10 May 2002 01:12:26 +0000 (01:12 +0000)
committerJeffrey Stedfast <fejj@src.gnome.org>
Fri, 10 May 2002 01:12:26 +0000 (01:12 +0000)
2002-05-09  Jeffrey Stedfast  <fejj@ximian.com>

* 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.

camel/ChangeLog
camel/camel-filter-search.c

index 146e635..4b87d56 100644 (file)
@@ -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  <NotZed@Ximian.com>
 
index a217aee..02362b7 100644 (file)
@@ -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;