add m_strchrnul that does what GNU strchrnul does: search for 'c' or
[apps/madmutt.git] / send.c
diff --git a/send.c b/send.c
index cf15950..2cf6550 100644 (file)
--- a/send.c
+++ b/send.c
 # include "config.h"
 #endif
 
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <time.h>
+#include <sys/types.h>
+#include <utime.h>
+
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
 #include <lib-lib/ascii.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
+#include <lib-lib/debug.h>
 
 #include <lib-mime/mime.h>
 
+#include <lib-ui/curses.h>
+#include <lib-ui/enter.h>
+
 #include "mutt.h"
-#include "enter.h"
-#include "mutt_curses.h"
 #include "rfc3676.h"
 #include "keymap.h"
 #include "copy.h"
 #include "url.h"
 #include "attach.h"
 
-#include "lib/debug.h"
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <dirent.h>
-#include <time.h>
-#include <sys/types.h>
-#include <utime.h>
-
 #ifdef USE_NNTP
 #include "nntp.h"
 #endif
@@ -1072,7 +1072,7 @@ static void fix_end_of_file (const char *data)
 
 int mutt_resend_message (FILE * fp, CONTEXT * ctx, HEADER * cur)
 {
-  HEADER *msg = mutt_new_header ();
+  HEADER *msg = header_new();
 
   if (mutt_prepare_template (fp, ctx, msg, cur, 1) < 0)
     return -1;
@@ -1135,7 +1135,7 @@ int ci_send_message (int flags, /* send mode */
    */
 
   if (!msg) {
-    msg = mutt_new_header ();
+    msg = header_new();
 
     if (flags == SENDPOSTPONED) {
       if ((flags =
@@ -1165,7 +1165,7 @@ int ci_send_message (int flags, /* send mode */
     }
 
     if (!msg->env)
-      msg->env = mutt_new_envelope ();
+      msg->env = envelope_new();
   }
 
   /* Parse and use an eventual list-post header */
@@ -1261,8 +1261,7 @@ int ci_send_message (int flags, /* send mode */
       msg->env->newsgroups = m_strdup(((NNTP_DATA *) ctx->data)->group);
 #endif
 
-    if (!(flags & SENDMAILX) &&
-        !(option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
+    if (!(option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
         !((flags & SENDREPLY) && option (OPTFASTREPLY))) {
       if (edit_envelope (msg->env, flags) == -1)
         goto cleanup;
@@ -1311,9 +1310,7 @@ int ci_send_message (int flags, /* send mode */
       process_user_header (msg->env);
 
 
-    if (option (OPTSIGONTOP)
-        && (!(flags & (SENDMAILX | SENDKEY)) && Editor
-            && m_strcmp(Editor, "builtin") != 0))
+    if (option (OPTSIGONTOP) && (!(flags & SENDKEY) && Editor))
       append_signature (tempfp);
 
     /* include replies/forwarded messages, unless we are given a template */
@@ -1321,9 +1318,7 @@ int ci_send_message (int flags, /* send mode */
         && generate_body (tempfp, msg, flags, ctx, cur) == -1)
       goto cleanup;
 
-    if (!option (OPTSIGONTOP)
-        && (!(flags & (SENDMAILX | SENDKEY)) && Editor
-            && m_strcmp(Editor, "builtin") != 0))
+    if (!option (OPTSIGONTOP) && (!(flags & SENDKEY) && Editor))
       append_signature (tempfp);
 
     /* 
@@ -1331,24 +1326,22 @@ int ci_send_message (int flags, /* send mode */
      * can take effect.
      */
 
-    if (!(flags & SENDMAILX)) {
-      if (option (OPTCRYPTAUTOSIGN))
-        msg->security |= SIGN;
-      if (option (OPTCRYPTAUTOENCRYPT))
-        msg->security |= ENCRYPT;
-      if (option (OPTCRYPTREPLYENCRYPT) && cur && (cur->security & ENCRYPT))
-        msg->security |= ENCRYPT;
-      if (option (OPTCRYPTREPLYSIGN) && cur && (cur->security & SIGN))
-        msg->security |= SIGN;
-      if (option (OPTCRYPTREPLYSIGNENCRYPTED) && cur
-          && (cur->security & ENCRYPT))
-        msg->security |= SIGN;
-      if (msg->security & (ENCRYPT | SIGN)) {
-        if (option (OPTPGPAUTOINLINE))
-          msg->security |= INLINE;
-        if (option (OPTPGPREPLYINLINE) && cur && (cur->security & INLINE))
-          msg->security |= INLINE;
-      }
+    if (option (OPTCRYPTAUTOSIGN))
+      msg->security |= SIGN;
+    if (option (OPTCRYPTAUTOENCRYPT))
+      msg->security |= ENCRYPT;
+    if (option (OPTCRYPTREPLYENCRYPT) && cur && (cur->security & ENCRYPT))
+      msg->security |= ENCRYPT;
+    if (option (OPTCRYPTREPLYSIGN) && cur && (cur->security & SIGN))
+      msg->security |= SIGN;
+    if (option (OPTCRYPTREPLYSIGNENCRYPTED) && cur
+        && (cur->security & ENCRYPT))
+      msg->security |= SIGN;
+    if (msg->security & (ENCRYPT | SIGN)) {
+      if (option (OPTPGPAUTOINLINE))
+        msg->security |= INLINE;
+      if (option (OPTPGPREPLYINLINE) && cur && (cur->security & INLINE))
+        msg->security |= INLINE;
     }
 
     if (msg->security) {
@@ -1404,11 +1397,7 @@ int ci_send_message (int flags, /* send mode */
   if (!(flags & SENDKEY))
     safe_fclose (&tempfp);
 
-  if (flags & SENDMAILX) {
-    if (mutt_builtin_editor (msg->content->filename, msg, cur) == -1)
-      goto cleanup;
-  }
-  else if (!(flags & SENDBATCH)) {
+  if (!(flags & SENDBATCH)) {
     struct stat st;
     time_t mtime = mutt_decrease_mtime (msg->content->filename, NULL);
 
@@ -1433,9 +1422,7 @@ int ci_send_message (int flags, /* send mode */
       if (mutt_needs_mailcap (msg->content)) {
         if (!mutt_edit_attachment (msg->content))
           goto cleanup;
-      } else if (!Editor || m_strcmp("builtin", Editor) == 0)
-        mutt_builtin_editor (msg->content->filename, msg, cur);
-      else if (option (OPTEDITHDRS)) {
+      } else if (option (OPTEDITHDRS)) {
         mutt_env_to_local (msg->env);
         mutt_edit_headers (Editor, msg->content->filename, msg, fcc,
                            sizeof (fcc));
@@ -1494,7 +1481,7 @@ int ci_send_message (int flags, /* send mode */
 
   mutt_update_encoding (msg->content);
 
-  if (!(flags & (SENDMAILX | SENDBATCH))) {
+  if (!(flags & SENDBATCH)) {
   main_loop:
 
     fcc_error = 0;              /* reset value since we may have failed before */
@@ -1659,7 +1646,7 @@ int ci_send_message (int flags, /* send mode */
       && (msg->content->parts != clear_content))
     free_clear_content = 1;
 
-  if (!option (OPTNOCURSES) && !(flags & SENDMAILX))
+  if (!option (OPTNOCURSES))
     mutt_message _("Sending message...");
 
   mutt_prepare_envelope (msg->env, 1);
@@ -1786,15 +1773,15 @@ int ci_send_message (int flags, /* send mode */
       goto cleanup;
     }
   }
-  else if (!option (OPTNOCURSES) && !(flags & SENDMAILX))
+  else if (!option (OPTNOCURSES))
     mutt_message (i != 0 ? _("Sending in background.") :
 #ifdef USE_NNTP
                   (flags & SENDNEWS) ? _("Article posted.") :
-                  _("Mail sent."));
+                  _("Mail sent.")
 #else
-                  _("Mail sent."));
+                  _("Mail sent.")
 #endif
-
+    );
   if (msg->security & ENCRYPT)
     p_delete(&pgpkeylist);
 
@@ -1824,7 +1811,7 @@ cleanup:
   }
 
   safe_fclose (&tempfp);
-  mutt_free_header (&msg);
+  header_delete(&msg);
 
   return rv;
 }