]> granicus.if.org Git - neomutt/commitdiff
mutt_get_body_charset
authorRichard Russon <rich@flatcap.org>
Sat, 23 Jun 2018 00:23:52 +0000 (01:23 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 23 Jun 2018 15:24:59 +0000 (16:24 +0100)
ncrypt/crypt_gpgme.c
ncrypt/pgp.c
protos.h
recvattach.c
sendlib.c

index e0bd561a939778b40d46399c90cc3c1e1dcff6a2..1435f18cb0474dc39f91fe3628f8aba996ac32e4 100644 (file)
@@ -2460,7 +2460,7 @@ int pgp_gpgme_application_handler(struct Body *m, struct State *s)
   /* For clearsigned messages we won't be able to get a character set
      but we know that this may only be text thus we assume Latin-1
      here. */
-  if (!mutt_get_body_charset(body_charset, sizeof(body_charset), m))
+  if (!mutt_body_get_charset(m, body_charset, sizeof(body_charset)))
     mutt_str_strfcpy(body_charset, "iso-8859-1", sizeof(body_charset));
 
   fseeko(s->fpin, m->offset, SEEK_SET);
index 01850f7750ed86ab1499d3d586c7ff71cc1abc2b..487818f13ec51104e5838897624fbdefc84091e8 100644 (file)
@@ -417,7 +417,7 @@ int pgp_class_application_handler(struct Body *m, struct State *s)
 
   char *gpgcharset = NULL;
   char body_charset[STRING];
-  mutt_get_body_charset(body_charset, sizeof(body_charset), m);
+  mutt_body_get_charset(m, body_charset, sizeof(body_charset));
 
   rc = 0; /* silence false compiler warning if (s->flags & MUTT_DISPLAY) */
 
@@ -1609,7 +1609,7 @@ struct Body *pgp_class_traditional_encryptsign(struct Body *a, int flags, char *
    * we have to convert from $charset to utf-8.
    */
 
-  mutt_get_body_charset(body_charset, sizeof(body_charset), a);
+  mutt_body_get_charset(a, body_charset, sizeof(body_charset));
   if (a->noconv)
     from_charset = body_charset;
   else
index 53b0c127bda95a351027af3cc42b185a81182516..a6f9e0bd058212835d45f57f7a57deb733ba87be 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -129,7 +129,7 @@ char *mutt_expand_path(char *s, size_t slen);
 char *mutt_expand_path_regex(char *s, size_t slen, bool regex);
 char *mutt_find_hook(int type, const char *pat);
 char *mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw);
-char *mutt_get_body_charset(char *d, size_t dlen, struct Body *b);
+char *mutt_body_get_charset(struct Body *b, char *buf, size_t buflen);
 void mutt_crypt_hook(struct ListHead *list, struct Address *addr);
 void mutt_timeout_hook(void);
 void mutt_startup_shutdown_hook(int type);
index 795d6dead72576a76d89630e8ecf9a55eebec6ed..717eee85b69a167da4fe96fd45f82438a99729c7 100644 (file)
@@ -211,7 +211,7 @@ const char *attach_format_str(char *buf, size_t buflen, size_t col, int cols,
       if (!optional)
       {
         if (mutt_is_text_part(aptr->content) &&
-            mutt_get_body_charset(charset, sizeof(charset), aptr->content))
+            mutt_body_get_charset(aptr->content, charset, sizeof(charset)))
         {
           mutt_format_s(buf, buflen, prec, charset);
         }
@@ -219,7 +219,7 @@ const char *attach_format_str(char *buf, size_t buflen, size_t col, int cols,
           mutt_format_s(buf, buflen, prec, "");
       }
       else if (!mutt_is_text_part(aptr->content) ||
-               !mutt_get_body_charset(charset, sizeof(charset), aptr->content))
+               !mutt_body_get_charset(aptr->content, charset, sizeof(charset)))
       {
         optional = 0;
       }
index 6171c5d73c7e96878deea4a88f2963209358af5b..afa5f037b09ddb74942fcb1946712e68f9e461a6 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -507,7 +507,7 @@ int mutt_write_mime_body(struct Body *a, FILE *f)
   {
     char send_charset[SHORT_STRING];
     fc = mutt_ch_fgetconv_open(
-        fpin, a->charset, mutt_get_body_charset(send_charset, sizeof(send_charset), a), 0);
+        fpin, a->charset, mutt_body_get_charset(a, send_charset, sizeof(send_charset)), 0);
   }
   else
     fc = mutt_ch_fgetconv_open(fpin, 0, 0, 0);
@@ -1291,7 +1291,7 @@ static void set_encoding(struct Body *b, struct Content *info)
   if (b->type == TYPETEXT)
   {
     char send_charset[SHORT_STRING];
-    char *chsname = mutt_get_body_charset(send_charset, sizeof(send_charset), b);
+    char *chsname = mutt_body_get_charset(b, send_charset, sizeof(send_charset));
     if ((info->lobin && (mutt_str_strncasecmp(chsname, "iso-2022", 8) != 0)) ||
         info->linemax > 990 || (info->from && EncodeFrom))
     {
@@ -1348,29 +1348,29 @@ void mutt_stamp_attachment(struct Body *a)
 }
 
 /**
- * mutt_get_body_charset - Get a body's character set
- * @param d    Buffer for the result
- * @param dlen Length of the buffer
- * @param b    Body to examine
+ * mutt_body_get_charset - Get a body's character set
+ * @param b      Body to examine
+ * @param buf    Buffer for the result
+ * @param buflen Length of the buffer
  * @retval ptr  Buffer containing character set
  * @retval NULL On error, or if not a text type
  */
-char *mutt_get_body_charset(char *d, size_t dlen, struct Body *b)
+char *mutt_body_get_charset(struct Body *b, char *buf, size_t buflen)
 {
   char *p = NULL;
 
-  if (b && b->type != TYPETEXT)
+  if (b && (b->type != TYPETEXT))
     return NULL;
 
   if (b)
     p = mutt_param_get(&b->parameter, "charset");
 
   if (p)
-    mutt_ch_canonical_charset(d, dlen, p);
+    mutt_ch_canonical_charset(buf, buflen, p);
   else
-    mutt_str_strfcpy(d, "us-ascii", dlen);
+    mutt_str_strfcpy(buf, "us-ascii", buflen);
 
-  return d;
+  return buf;
 }
 
 /**
@@ -1385,7 +1385,7 @@ void mutt_update_encoding(struct Body *a)
   char chsbuf[STRING];
 
   /* override noconv when it's us-ascii */
-  if (mutt_ch_is_us_ascii(mutt_get_body_charset(chsbuf, sizeof(chsbuf), a)))
+  if (mutt_ch_is_us_ascii(mutt_body_get_charset(a, chsbuf, sizeof(chsbuf))))
     a->noconv = false;
 
   if (!a->force_charset && !a->noconv)