]> granicus.if.org Git - mutt/commitdiff
Introduce a state_printf() function.
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 12 Nov 1998 21:23:33 +0000 (21:23 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 12 Nov 1998 21:23:33 +0000 (21:23 +0000)
handler.c
lib.c
mutt.h

index 23a1de5dfcf162a718b7cb3caab4e883b8cf8f0a..a115c69d4f3872230fda0f89ba6aec513840b6a2 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1047,7 +1047,6 @@ int mutt_can_decode (BODY *a)
 void multipart_handler (BODY *a, STATE *s)
 {
   BODY *b, *p;
-  char buffer[STRING];
   char length[5];
   struct stat st;
   int count;
@@ -1069,8 +1068,7 @@ void multipart_handler (BODY *a, STATE *s)
   {
     if (s->flags & M_DISPLAY)
     {
-      snprintf (buffer, sizeof (buffer), _("[-- Attachment #%d"), count);
-      state_puts (buffer, s);
+      state_printf (s, _("[-- Attachment #%d"), count);
       if (p->description || p->filename || p->form_name)
       {
        state_puts (": ", s);
@@ -1080,11 +1078,9 @@ void multipart_handler (BODY *a, STATE *s)
       state_puts (" --]\n", s);
 
       mutt_pretty_size (length, sizeof (length), p->length);
-
-      snprintf (buffer, sizeof (buffer),
-               _("[-- Type: %s/%s, Encoding: %s, Size: %s --]\n"),
-              TYPE (p), p->subtype, ENCODING (p->encoding), length);
-      state_puts (buffer, s);
+      
+      state_printf (s, _("[-- Type: %s/%s, Encoding: %s, Size: %s --]\n"),
+                   TYPE (p), p->subtype, ENCODING (p->encoding), length);
       if (!option (OPTWEED))
       {
        fseek (s->fpin, p->hdr_offset, 0);
@@ -1096,16 +1092,11 @@ void multipart_handler (BODY *a, STATE *s)
     else
     {
       if (p->description && mutt_can_decode (p))
-      {
-       state_puts ("Content-Description: ", s);
-       state_puts (p->description, s);
-       state_putc ('\n', s);
-      }
+       state_printf (s, "Content-Description: %s\n", p->description);
+
       if (p->form_name)
-      {
-       state_puts (p->form_name, s);
-       state_puts (": \n", s);
-      }
+       state_printf(s, "%s: \n", p->form_name);
+
     }
     mutt_body_handler (p, s);
     state_putc ('\n', s);
@@ -1147,10 +1138,7 @@ void autoview_handler (BODY *a, STATE *s)
 
     if (s->flags & M_DISPLAY)
     {
-      char mesg[STRING];
-
-      snprintf (mesg, sizeof (buffer), _("[-- Autoview using %s --]\n"), command);
-      state_puts (mesg, s);
+      state_printf (s, _("[-- Autoview using %s --]\n"), command);
       mutt_message(_("Invoking autoview command: %s"),command);
     }
 
@@ -1188,13 +1176,8 @@ void autoview_handler (BODY *a, STATE *s)
       if (fgets (buffer, sizeof(buffer), fperr)) 
       {
        if (s->flags & M_DISPLAY) 
-       {
-         char mesg[STRING];
+         state_printf (s, _("[-- Autoview stderr of %s --]\n"), command);
 
-         snprintf (mesg, sizeof (buffer), _("[-- Autoview stderr of %s --]\n"), 
-             command);
-         state_puts (mesg, s);
-       }
        state_puts (s->prefix, s);
        state_puts (buffer, s);
        while (fgets (buffer, sizeof(buffer), fperr) != NULL)
@@ -1211,13 +1194,9 @@ void autoview_handler (BODY *a, STATE *s)
       if (fgets (buffer, sizeof(buffer), fperr))
       {
        if (s->flags & M_DISPLAY)
-       {
-         char mesg[STRING];
-
-         snprintf (mesg, sizeof (buffer), _("[-- Autoview stderr of %s --]\n"), 
-             command);
-         state_puts (mesg, s);
-       }
+         state_printf (s, _("[-- Autoview stderr of %s --]\n"), 
+                       command);
+       
        state_puts (buffer, s);
        mutt_copy_stream (fperr, s->fpout);
       }
@@ -1491,7 +1470,7 @@ void mutt_body_handler (BODY *b, STATE *s)
   }
   else if (s->flags & M_DISPLAY)
   {
-    fprintf (s->fpout, _("[-- %s/%s is unsupported "), TYPE (b), b->subtype);
+    state_printf (s, _("[-- %s/%s is unsupported "), TYPE (b), b->subtype);
     if (!option (OPTVIEWATTACH))
     {
       if (km_expand_key (type, sizeof(type),
diff --git a/lib.c b/lib.c
index da97222c9f836e75f69c83f7787ad36ea6cab894..f5f01ea693bb2f92a26d4e23b813192bf4d59371 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -1224,6 +1224,18 @@ void state_prefix_putc(char c, STATE *s)
     state_set_prefix(s);
 }
 
+int state_printf(STATE *s, const char *fmt, ...)
+{
+  int rv;
+  va_list ap;
+
+  va_start (ap, fmt);
+  rv = vfprintf(s->fpout, fmt, ap);
+  va_end(ap);
+  
+  return rv;
+}
+
 /* NULL-pointer aware string comparison functions */
 
 int mutt_strcmp(const char *a, const char *b)
diff --git a/mutt.h b/mutt.h
index 7147468f1988fe5051d514721a24b91309f279d9..49c4787b9ca81a1cb4abaca6b611c72f97c5048e 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -671,6 +671,7 @@ typedef struct
 #define state_putc(x,y) fputc(x,(y)->fpout)
 
 void state_prefix_putc(char, STATE *);
+int  state_printf(STATE *, const char *, ...);
 
 #include "protos.h"
 #include "globals.h"