Show
Ignore:
Timestamp:
2000-06-15 14:15:51 (8 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

patch-1.2.bbell.display_filter.2.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • commands.c

    r1896 r1909  
    2626#include "mx.h" 
    2727#include "pager.h" 
     28#include <sys/types.h> 
     29#include <sys/stat.h> 
     30#include <fcntl.h> 
    2831 
    2932#ifdef USE_IMAP 
     
    6265  int rc = 0, builtin = 0; 
    6366  int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV; 
    64   FILE *fpout; 
     67  FILE *fpout = NULL; 
     68  FILE *fpfilterout = NULL; 
     69  pid_t filterpid; 
     70  int res; 
    6571 
    6672  snprintf (buf, sizeof (buf), "%s/%s", TYPE (cur->content), 
     
    108114  } 
    109115 
    110    mutt_message_hook (cur, M_DISPLAYHOOK); 
     116  mutt_message_hook (cur, M_DISPLAYHOOK); 
     117 
     118  if (DisplayFilter && *DisplayFilter)  
     119  { 
     120    fpfilterout = fpout; 
     121    fpout = NULL; 
     122    endwin (); 
     123    filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL, 
     124                                       -1, fileno(fpfilterout), -1); 
     125    if (filterpid < 0) 
     126    { 
     127      mutt_error (_("Cannot create display filter")); 
     128      fclose (fpfilterout); 
     129      unlink (tempfile); 
     130      return 0; 
     131    } 
     132  } 
    111133 
    112134  if (!Pager || mutt_strcmp (Pager, "builtin") == 0) 
     
    119141  } 
    120142 
    121   if (mutt_copy_message (fpout, Context, cur, cmflags, 
    122                          (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM) == -1) 
    123   { 
    124     fclose (fpout); 
    125     unlink (tempfile); 
     143  res = mutt_copy_message (fpout, Context, cur, cmflags, 
     144        (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM); 
     145  if ((fclose (fpout) != 0 && errno != EPIPE) || res == -1) 
     146  { 
     147    mutt_error (_("Could not copy message")); 
     148    if (fpfilterout != NULL) 
     149      mutt_wait_filter (filterpid); 
     150    mutt_unlink (tempfile); 
    126151    return 0; 
    127152  } 
    128153 
    129   if (fclose (fpout) != 0 && errno != EPIPE) 
    130   { 
    131     mutt_perror ("fclose"); 
    132     mutt_unlink (tempfile); 
    133     return (0); 
    134   } 
     154  if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0) 
     155    mutt_any_key_to_continue (NULL); 
    135156 
    136157#ifdef HAVE_PGP