configure with almost all options set
[apps/madmutt.git] / recvattach.c
index f65c4e1..30bcb49 100644 (file)
 #endif
 
 #include "mutt.h"
+#include "ascii.h"
+#include "enter.h"
+#include "handler.h"
+#include "recvattach.h"
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "rfc1524.h"
@@ -45,6 +49,8 @@ static char LastSaveFolder[_POSIX_PATH_MAX] = "";
     break; \
 }
 
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+
 static struct mapping_t AttachHelp[] = {
   {N_("Exit"), OP_EXIT},
   {N_("Save"), OP_SAVE},
@@ -54,9 +60,9 @@ static struct mapping_t AttachHelp[] = {
   {NULL}
 };
 
-int mutt_extract_path (char *filename, char *path)
+static int mutt_extract_path (char *filename, char *path)
 {
-  char *tmp = safe_malloc (sizeof (char) * _POSIX_PATH_MAX);
+  char *tmp = mem_malloc (sizeof (char) * _POSIX_PATH_MAX);
   char *help_ptr;
 
   help_ptr = tmp;
@@ -70,7 +76,7 @@ int mutt_extract_path (char *filename, char *path)
     }
     *help_ptr++ = *filename++;
   }
-  FREE (&tmp);
+  mem_free (&tmp);
   return 0;
 }
 
@@ -95,11 +101,11 @@ void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
     }
 
     if (idx[x]->tree) {
-      if (mutt_strcmp (idx[x]->tree, buf) != 0)
+      if (str_cmp (idx[x]->tree, buf) != 0)
         str_replace (&idx[x]->tree, buf);
     }
     else
-      idx[x]->tree = safe_strdup (buf);
+      idx[x]->tree = str_dup (buf);
 
     if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
       s = buf + 2 * (idx[x]->level - 1);
@@ -120,7 +126,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m,
 
   for (; m; m = m->next) {
     if (*idxlen == *idxmax) {
-      safe_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
+      mem_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
       for (i = *idxlen; i < *idxmax; i++)
         idx[i] = NULL;
     }
@@ -138,7 +144,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m,
     }
     else {
       if (!idx[*idxlen])
-        idx[*idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
+        idx[*idxlen] = (ATTACHPTR *) mem_calloc (1, sizeof (ATTACHPTR));
 
       new = idx[(*idxlen)++];
       new->content = m;
@@ -298,6 +304,14 @@ const char *mutt_attach_fmt (char *dest,
       snprintf (dest, destlen, fmt, aptr->num + 1);
     }
     break;
+  case 'Q':
+    if (optional)
+      optional = aptr->content->attach_qualifies;
+    else {
+      snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+      mutt_format_s (dest, destlen, fmt, "Q");
+    }
+    break;
   case 's':
     if (flags & M_FORMAT_STAT_FILE) {
       struct stat st;
@@ -334,6 +348,14 @@ const char *mutt_attach_fmt (char *dest,
     else if (!aptr->content->unlink)
       optional = 0;
     break;
+  case 'X':
+    if (optional)
+      optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
+    else {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
+    }
+    break;
   default:
     *dest = 0;
   }
@@ -345,9 +367,10 @@ const char *mutt_attach_fmt (char *dest,
   return (src);
 }
 
-void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
+static void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
 {
-  mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
+  int w=(COLS-SW)>blen?blen:(COLS-SW);
+  mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
                      (unsigned long) (((ATTACHPTR **) menu->data)[num]),
                      M_FORMAT_ARROWCURSOR);
 }
@@ -527,7 +550,7 @@ void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
       break;
   }
 
-  FREE (&directory);
+  mem_free (&directory);
 
   if (tag && menu) {
     menu->oldcurrent = menu->current;
@@ -738,7 +761,7 @@ void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
     print_attachment_list (fp, tag, top, &state);
 }
 
-void
+static void
 mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
                           short *idxlen, short *idxmax, MUTTMENU * menu)
 {
@@ -1077,7 +1100,7 @@ void mutt_view_attachments (HEADER * hdr)
       }
 #endif
 
-      if (WithCrypto && hdr->security) {
+      if (WithCrypto && (hdr->security & (~PGP_TRADITIONAL_CHECKED))) {
         mutt_message
           _
           ("Deletion of attachments from encrypted messages is unsupported.");
@@ -1175,7 +1198,7 @@ void mutt_view_attachments (HEADER * hdr)
       CHECK_ATTACH;
 
       if (!idx[menu->current]->content->hdr->env->followup_to ||
-          safe_strcasecmp (idx[menu->current]->content->hdr->env->followup_to,
+          str_casecmp (idx[menu->current]->content->hdr->env->followup_to,
                            "poster")
           || query_quadoption (OPT_FOLLOWUPTOPOSTER,
                                _("Reply by mail as poster prefers?")) !=
@@ -1218,12 +1241,12 @@ void mutt_view_attachments (HEADER * hdr)
           hdr->attach_del = 1;
         if (idx[idxmax]->content)
           idx[idxmax]->content->aptr = NULL;
-        FREE (&idx[idxmax]->tree);
-        FREE (&idx[idxmax]);
+        mem_free (&idx[idxmax]->tree);
+        mem_free (&idx[idxmax]);
       }
       if (hdr->attach_del)
         hdr->changed = 1;
-      FREE (&idx);
+      mem_free (&idx);
       idxmax = 0;
 
       if (WithCrypto && need_secured && secured) {