/[mailutils]/mailutils/mh/comp.c
ViewVC logotype

Diff of /mailutils/mh/comp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by gray, Thu Feb 20 14:00:34 2003 UTC revision 1.10 by gray, Fri Mar 14 14:42:01 2003 UTC
# Line 71  struct mh_option mh_option[] = { Line 71  struct mh_option mh_option[] = {
71    { 0 }    { 0 }
72  };  };
73    
 static char *format_str =  
 "To:\n"  
 "cc:\n"  
 "Subject:\n"  
 "--------\n";  
   
74  struct mh_whatnow_env wh_env = { 0 };  struct mh_whatnow_env wh_env = { 0 };
75  const char *formfile;  const char *formfile;
76  static int initial_edit = 1;  static int initial_edit = 1;
# Line 139  opt_handler (int key, char *arg, void *u Line 133  opt_handler (int key, char *arg, void *u
133      }      }
134    return 0;    return 0;
135  }  }
   
 int  
 check_draft_disposition (struct mh_whatnow_env *wh)  
 {  
   struct stat st;  
   int disp = DISP_REPLACE;  
   
   /* First check if the draft exists */  
   if (stat (wh->draftfile, &st) == 0)  
     {  
       if (use_draft)  
         disp = DISP_USE;  
       else  
         {  
           printf (_("Draft \"%s\" exists (%lu bytes).\n"),  
                   wh->draftfile, (unsigned long) st.st_size);  
           disp = mh_disposition (wh->draftfile);  
         }  
     }  
   
   return disp;  
 }  
136        
137  int  int
138  copy_message (mailbox_t mbox, size_t n, const char *file)  copy_message (mailbox_t mbox, size_t n, const char *file)
# Line 233  main (int argc, char **argv) Line 205  main (int argc, char **argv)
205    if (!wh_env.draftfile)    if (!wh_env.draftfile)
206      wh_env.draftfile = mh_expand_name (wh_env.draftfolder, "draft", 0);      wh_env.draftfile = mh_expand_name (wh_env.draftfolder, "draft", 0);
207    
208    switch (check_draft_disposition (&wh_env))    switch (check_draft_disposition (&wh_env, use_draft))
209      {      {
210      case DISP_QUIT:      case DISP_QUIT:
211        exit (0);        exit (0);
# Line 260  main (int argc, char **argv) Line 232  main (int argc, char **argv)
232              }              }
233            copy_message (mbox, msgset.list[0], wh_env.file);            copy_message (mbox, msgset.list[0], wh_env.file);
234          }          }
       else if (formfile)  
         {  
           if (mh_file_copy (formfile, wh_env.file) == 0)  
             exit (1);  
         }  
235        else        else
236          {          mh_comp_draft (formfile, "components", wh_env.file);
           int rc;  
           stream_t stream;  
             
           if ((rc = file_stream_create (&stream,  
                                         wh_env.file,  
                                         MU_STREAM_WRITE|MU_STREAM_CREAT)) != 0  
               || (rc = stream_open (stream)))  
             {  
               mh_error (_("cannot open output file \"%s\": %s"),  
                         wh_env.file, mu_strerror (rc));  
               exit (1);  
             }  
             
           rc = stream_sequential_write (stream,  
                                         format_str, strlen (format_str));  
           stream_close (stream);  
           stream_destroy (&stream, stream_get_owner (stream));  
   
           if (rc)  
             {  
               mh_error (_("error writing to \"%s\": %s"),  
                         wh_env.file, mu_strerror (rc));  
               exit (1);  
             }  
         }  
237      }      }
238        
239    /* Exit immediately if --build is given */    /* Exit immediately if --build is given */

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26