]> granicus.if.org Git - neomutt/commitdiff
standardise the naming of the charset functions
authorRichard Russon <rich@flatcap.org>
Sun, 26 Nov 2017 23:11:52 +0000 (23:11 +0000)
committerRichard Russon <rich@flatcap.org>
Sun, 3 Dec 2017 23:45:02 +0000 (23:45 +0000)
13 files changed:
copy.c
handler.c
init.c
mbyte.c
mutt/charset.c
mutt/charset.h
mutt_charset.c
ncrypt/crypt_gpgme.c
ncrypt/pgp.c
parse.c
rfc2047.c
rfc2231.c
sendlib.c

diff --git a/copy.c b/copy.c
index a6901896c34ab83013cda3ed095624482cdde115..0b3c64baeee7c7951f11ce040d1d35c1c208b6d8 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -394,8 +394,8 @@ int mutt_copy_header(FILE *in, struct Header *h, FILE *out, int flags, const cha
     fputs("MIME-Version: 1.0\n", out);
     fputs("Content-Transfer-Encoding: 8bit\n", out);
     fputs("Content-Type: text/plain; charset=", out);
-    mutt_canonical_charset(chsbuf, sizeof(chsbuf),
-                           Charset ? Charset : "us-ascii");
+    mutt_cs_canonical_charset(chsbuf, sizeof(chsbuf),
+                              Charset ? Charset : "us-ascii");
     mutt_addr_cat(buffer, sizeof(buffer), chsbuf, MimeSpecials);
     fputs(buffer, out);
     fputc('\n', out);
index efda72699b38ef63a34cba040331bc5895fb1118..132a80eda6e84466e47138e781c3f0ed46ea7ed4 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -120,7 +120,7 @@ static void convert_to_state(iconv_t cd, char *bufi, size_t *l, struct State *s)
   while (true)
   {
     ob = bufo, obl = sizeof(bufo);
-    mutt_iconv(cd, &ib, &ibl, &ob, &obl, 0, "?");
+    mutt_cs_iconv(cd, &ib, &ibl, &ob, &obl, 0, "?");
     if (ob == bufo)
       break;
     state_prefix_put(bufo, ob - bufo, s);
@@ -1592,7 +1592,7 @@ void mutt_decode_attachment(struct Body *b, struct State *s)
   {
     char *charset = mutt_param_get("charset", b->parameter);
     if (!charset && AssumedCharset && *AssumedCharset)
-      charset = mutt_get_default_charset();
+      charset = mutt_cs_get_default_charset();
     if (charset && Charset)
       cd = mutt_iconv_open(Charset, charset, MUTT_ICONV_HOOK_FROM);
   }
diff --git a/init.c b/init.c
index e1a942226ee70ae98e758396fa43374d5fb5c090..148199073673608f45cac2dd17881bda805a2d25 100644 (file)
--- a/init.c
+++ b/init.c
@@ -4192,7 +4192,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands)
   if (p)
     From = mutt_addr_parse_list(NULL, p);
 
-  mutt_set_langinfo_charset();
+  mutt_cs_set_langinfo_charset();
   mutt_set_charset(Charset);
 
   Matches = mutt_mem_calloc(Matches_listsize, sizeof(char *));
diff --git a/mbyte.c b/mbyte.c
index 145b16bd9b68a442a00b17b7d2ad5aa920452557..09849b77bae36693fa018519092ce991d09976f5 100644 (file)
--- a/mbyte.c
+++ b/mbyte.c
@@ -43,9 +43,9 @@ void mutt_set_charset(char *charset)
 {
   char buffer[STRING];
 
-  mutt_canonical_charset(buffer, sizeof(buffer), charset);
+  mutt_cs_canonical_charset(buffer, sizeof(buffer), charset);
 
-  if (mutt_is_utf8(buffer))
+  if (mutt_cs_is_utf8(buffer))
   {
     Charset_is_utf8 = true;
     ReplacementChar = 0xfffd;
index a1c27c2eb16666fb8b5763403dd479c46cb45027..edbcf64249ed0ba537ae485720dc90c0f97d4f24 100644 (file)
@@ -201,7 +201,7 @@ const struct MimeNames PreferredMIMENames[] =
 };
 // clang-format on
 
-void fgetconv_close(FGETCONV **_fc)
+void mutt_cs_fgetconv_close(FGETCONV **_fc)
 {
   struct FgetConv *fc = (struct FgetConv *) *_fc;
 
@@ -210,7 +210,7 @@ void fgetconv_close(FGETCONV **_fc)
   FREE(_fc);
 }
 
-int fgetconv(FGETCONV *_fc)
+int mutt_cs_fgetconv(FGETCONV *_fc)
 {
   struct FgetConv *fc = (struct FgetConv *) _fc;
 
@@ -252,7 +252,7 @@ int fgetconv(FGETCONV *_fc)
   if (fc->ibl)
   {
     size_t obl = sizeof(fc->bufo);
-    mutt_iconv(fc->cd, (const char **) &fc->ib, &fc->ibl, &fc->ob, &obl, fc->inrepls, 0);
+    mutt_cs_iconv(fc->cd, (const char **) &fc->ib, &fc->ibl, &fc->ob, &obl, fc->inrepls, 0);
     if (fc->p < fc->ob)
       return (unsigned char) *(fc->p)++;
   }
@@ -262,14 +262,14 @@ int fgetconv(FGETCONV *_fc)
   return EOF;
 }
 
-char *fgetconvs(char *buf, size_t l, FGETCONV *_fc)
+char *mutt_cs_fgetconvs(char *buf, size_t l, FGETCONV *_fc)
 {
   int c;
   size_t r;
 
   for (r = 0; r + 1 < l;)
   {
-    c = fgetconv(_fc);
+    c = mutt_cs_fgetconv(_fc);
     if (c == EOF)
       break;
     buf[r++] = (char) c;
@@ -285,12 +285,12 @@ char *fgetconvs(char *buf, size_t l, FGETCONV *_fc)
 }
 
 /**
- * mutt_canonical_charset - Canonicalise the charset of a string
+ * mutt_cs_canonical_charset - Canonicalise the charset of a string
  *
  * this first ties off any charset extension such as //TRANSLIT,
  * canonicalizes the charset and re-adds the extension
  */
-void mutt_canonical_charset(char *dest, size_t dlen, const char *name)
+void mutt_cs_canonical_charset(char *dest, size_t dlen, const char *name)
 {
   char *p = NULL, *ext = NULL;
   char in[LONG_STRING], scratch[LONG_STRING];
@@ -342,7 +342,7 @@ out:
   }
 }
 
-int mutt_chscmp(const char *s, const char *chs)
+int mutt_cs_chscmp(const char *s, const char *chs)
 {
   char buffer[STRING];
   int a, b;
@@ -350,19 +350,19 @@ int mutt_chscmp(const char *s, const char *chs)
   if (!s)
     return 0;
 
-  /* charsets may have extensions mutt_canonical_charset()
+  /* charsets may have extensions mutt_cs_canonical_charset()
      leaves intact; we expect `chs' to originate from neomutt
      code, not user input (i.e. `chs' does _not_ have any
      extension)
      we simply check if the shorter string is a prefix for
      the longer */
-  mutt_canonical_charset(buffer, sizeof(buffer), s);
+  mutt_cs_canonical_charset(buffer, sizeof(buffer), s);
   a = mutt_str_strlen(buffer);
   b = mutt_str_strlen(chs);
   return (mutt_str_strncasecmp(a > b ? buffer : chs, a > b ? chs : buffer, MIN(a, b)) == 0);
 }
 
-char *mutt_get_default_charset(void)
+char *mutt_cs_get_default_charset(void)
 {
   static char fcharset[SHORT_STRING];
   const char *c = AssumedCharset;
@@ -378,14 +378,14 @@ char *mutt_get_default_charset(void)
 }
 
 /**
- * mutt_iconv - Change the encoding of a string
+ * mutt_cs_iconv - Change the encoding of a string
  *
  * Like iconv, but keeps going even when the input is invalid
  * If you're supplying inrepls, the source charset should be stateless;
  * if you're supplying an outrepl, the target charset should be.
  */
-size_t mutt_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
-                  size_t *outbytesleft, const char **inrepls, const char *outrepl)
+size_t mutt_cs_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
+                     size_t *outbytesleft, const char **inrepls, const char *outrepl)
 {
   size_t rc = 0, ret1;
   const char *ib = *inbuf;
@@ -454,13 +454,13 @@ size_t mutt_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **ou
   }
 }
 
-void mutt_set_langinfo_charset(void)
+void mutt_cs_set_langinfo_charset(void)
 {
   char buf[LONG_STRING];
   char buf2[LONG_STRING];
 
   mutt_str_strfcpy(buf, nl_langinfo(CODESET), sizeof(buf));
-  mutt_canonical_charset(buf2, sizeof(buf2), buf);
+  mutt_cs_canonical_charset(buf2, sizeof(buf2), buf);
 
   /* finally, set $charset */
   Charset = mutt_str_strdup(buf2);
index 816258880dae85917e6b99307e8142edf1711365..27ab5e9c28e6fe478985d63e180f9c34c4ba23ab 100644 (file)
@@ -56,6 +56,9 @@ struct FgetConvNot
   iconv_t cd;
 };
 
+/**
+ * struct MimeNames - MIME name lookup entry
+ */
 struct MimeNames
 {
   const char *key;
@@ -64,16 +67,16 @@ struct MimeNames
 
 extern const struct MimeNames PreferredMIMENames[];
 
-char * fgetconvs(char *buf, size_t l, FGETCONV *_fc);
-char * mutt_get_default_charset(void);
-int    fgetconv(FGETCONV *_fc);
-int    mutt_chscmp(const char *s, const char *chs);
-size_t mutt_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft, const char **inrepls, const char *outrepl);
-void   fgetconv_close(FGETCONV **_fc);
-void   mutt_canonical_charset(char *dest, size_t dlen, const char *name);
-void   mutt_set_langinfo_charset(void);
+void   mutt_cs_canonical_charset(char *dest, size_t dlen, const char *name);
+int    mutt_cs_chscmp(const char *s, const char *chs);
+void   mutt_cs_fgetconv_close(FGETCONV **fc);
+int    mutt_cs_fgetconv(FGETCONV *fc);
+char * mutt_cs_fgetconvs(char *buf, size_t l, FGETCONV *fc);
+char * mutt_cs_get_default_charset(void);
+size_t mutt_cs_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft, const char **inrepls, const char *outrepl);
+void   mutt_cs_set_langinfo_charset(void);
 
-#define mutt_is_utf8(a)     mutt_chscmp(a, "utf-8")
-#define mutt_is_us_ascii(a) mutt_chscmp(a, "us-ascii")
+#define mutt_cs_is_utf8(a)     mutt_cs_chscmp(a, "utf-8")
+#define mutt_cs_is_us_ascii(a) mutt_cs_chscmp(a, "us-ascii")
 
 #endif 
index 3af22d2f638432cd48163d678450d49e06261ac4..e706336f363ed00fab2f557cce2780093fe0ef22 100644 (file)
@@ -57,14 +57,14 @@ iconv_t mutt_iconv_open(const char *tocode, const char *fromcode, int flags)
   iconv_t cd;
 
   /* transform to MIME preferred charset names */
-  mutt_canonical_charset(tocode1, sizeof(tocode1), tocode);
-  mutt_canonical_charset(fromcode1, sizeof(fromcode1), fromcode);
+  mutt_cs_canonical_charset(tocode1, sizeof(tocode1), tocode);
+  mutt_cs_canonical_charset(fromcode1, sizeof(fromcode1), fromcode);
 
   /* maybe apply charset-hooks and recanonicalise fromcode,
    * but only when caller asked us to sanitize a potentially wrong
    * charset name incoming from the wild exterior. */
   if ((flags & MUTT_ICONV_HOOK_FROM) && (tmp = mutt_charset_hook(fromcode1)))
-    mutt_canonical_charset(fromcode1, sizeof(fromcode1), tmp);
+    mutt_cs_canonical_charset(fromcode1, sizeof(fromcode1), tmp);
 
   /* always apply iconv-hooks to suit system's iconv tastes */
   tocode2 = mutt_iconv_hook(tocode1);
@@ -104,9 +104,9 @@ int mutt_convert_string(char **ps, const char *from, const char *to, int flags)
     const char **inrepls = NULL;
     char *outrepl = NULL;
 
-    if (mutt_is_utf8(to))
+    if (mutt_cs_is_utf8(to))
       outrepl = "\357\277\275";
-    else if (mutt_is_utf8(from))
+    else if (mutt_cs_is_utf8(from))
       inrepls = repls;
     else
       outrepl = "?";
@@ -117,7 +117,7 @@ int mutt_convert_string(char **ps, const char *from, const char *to, int flags)
     obl = MB_LEN_MAX * ibl;
     ob = buf = mutt_mem_malloc(obl + 1);
 
-    mutt_iconv(cd, &ib, &ibl, &ob, &obl, inrepls, outrepl);
+    mutt_cs_iconv(cd, &ib, &ibl, &ob, &obl, inrepls, outrepl);
     iconv_close(cd);
 
     *ob = '\0';
@@ -153,7 +153,7 @@ FGETCONV *fgetconv_open(FILE *file, const char *from, const char *to, int flags)
     fc->p = fc->ob = fc->bufo;
     fc->ib = fc->bufi;
     fc->ibl = 0;
-    fc->inrepls = mutt_is_utf8(to) ? repls : repls + 1;
+    fc->inrepls = mutt_cs_is_utf8(to) ? repls : repls + 1;
   }
   else
     fc = mutt_mem_malloc(sizeof(struct FgetConvNot));
@@ -166,7 +166,7 @@ bool mutt_check_charset(const char *s, bool strict)
 {
   iconv_t cd;
 
-  if (mutt_is_utf8(s))
+  if (mutt_cs_is_utf8(s))
     return true;
 
   if (!strict)
index 04ea35d421a5915fa483c93c6336dd169f12afe8..6a1f2a4d4d56479068f370f338469ff9b08aa63d 100644 (file)
@@ -2453,7 +2453,7 @@ static void copy_clearsigned(gpgme_data_t data, struct State *s, char *charset)
    */
   fc = fgetconv_open(fp, charset, Charset, MUTT_ICONV_HOOK_FROM);
 
-  for (complete = true, armor_header = true; fgetconvs(buf, sizeof(buf), fc) != NULL;
+  for (complete = true, armor_header = true; mutt_cs_fgetconvs(buf, sizeof(buf), fc) != NULL;
        complete = (strchr(buf, '\n') != NULL))
   {
     if (!complete)
@@ -2482,7 +2482,7 @@ static void copy_clearsigned(gpgme_data_t data, struct State *s, char *charset)
       state_puts(buf, s);
   }
 
-  fgetconv_close(&fc);
+  mutt_cs_fgetconv_close(&fc);
   mutt_file_fclose(&fp);
 }
 
@@ -2677,13 +2677,13 @@ int pgp_gpgme_application_handler(struct Body *m, struct State *s)
         int c;
         rewind(pgpout);
         fc = fgetconv_open(pgpout, "utf-8", Charset, 0);
-        while ((c = fgetconv(fc)) != EOF)
+        while ((c = mutt_cs_fgetconv(fc)) != EOF)
         {
           state_putc(c, s);
           if (c == '\n' && s->prefix)
             state_puts(s->prefix, s);
         }
-        fgetconv_close(&fc);
+        mutt_cs_fgetconv_close(&fc);
       }
 
       if (s->flags & MUTT_DISPLAY)
index dd68f2b7e2f1605944bb5205be4e79a01268155f..53be76194b58209af9eac17078738c12966eff7e 100644 (file)
@@ -288,7 +288,7 @@ static void pgp_copy_clearsigned(FILE *fpin, struct State *s, char *charset)
    */
   fc = fgetconv_open(fpin, charset, Charset, MUTT_ICONV_HOOK_FROM);
 
-  for (complete = true, armor_header = true; fgetconvs(buf, sizeof(buf), fc) != NULL;
+  for (complete = true, armor_header = true; mutt_cs_fgetconvs(buf, sizeof(buf), fc) != NULL;
        complete = (strchr(buf, '\n') != NULL))
   {
     if (!complete)
@@ -318,7 +318,7 @@ static void pgp_copy_clearsigned(FILE *fpin, struct State *s, char *charset)
       state_puts(buf, s);
   }
 
-  fgetconv_close(&fc);
+  mutt_cs_fgetconv_close(&fc);
 }
 
 /**
@@ -549,9 +549,9 @@ int pgp_application_pgp_handler(struct Body *m, struct State *s)
         rewind(pgpout);
         state_set_prefix(s);
         fc = fgetconv_open(pgpout, expected_charset, Charset, MUTT_ICONV_HOOK_FROM);
-        while ((ch = fgetconv(fc)) != EOF)
+        while ((ch = mutt_cs_fgetconv(fc)) != EOF)
           state_prefix_putc(ch, s);
-        fgetconv_close(&fc);
+        mutt_cs_fgetconv_close(&fc);
       }
 
       /*
@@ -1539,7 +1539,7 @@ struct Body *pgp_traditional_encryptsign(struct Body *a, int flags, char *keylis
   else
     from_charset = Charset;
 
-  if (!mutt_is_us_ascii(body_charset))
+  if (!mutt_cs_is_us_ascii(body_charset))
   {
     int c;
     FGETCONV *fc = NULL;
@@ -1551,10 +1551,10 @@ struct Body *pgp_traditional_encryptsign(struct Body *a, int flags, char *keylis
 
     /* fromcode is assumed to be correct: we set flags to 0 */
     fc = fgetconv_open(fp, from_charset, "utf-8", 0);
-    while ((c = fgetconv(fc)) != EOF)
+    while ((c = mutt_cs_fgetconv(fc)) != EOF)
       fputc(c, pgpin);
 
-    fgetconv_close(&fc);
+    mutt_cs_fgetconv_close(&fc);
   }
   else
   {
diff --git a/parse.c b/parse.c
index f7d747107ea3978bb3d9139a535aee3d18656732..e856ef0ca841fbd7a063aaa438ad7ed9910ea4f2 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -387,10 +387,10 @@ void mutt_parse_content_type(char *s, struct Body *ct)
     pc = mutt_param_get("charset", ct->parameter);
     if (!pc)
       mutt_param_set("charset",
-                     (AssumedCharset && *AssumedCharset) ?
-                         (const char *) mutt_get_default_charset() :
-                         "us-ascii",
-                     &ct->parameter);
+                         (AssumedCharset && *AssumedCharset) ?
+                             (const char *) mutt_cs_get_default_charset() :
+                             "us-ascii",
+                         &ct->parameter);
   }
 }
 
index 5c4db41dbdb9321bebb7a03796490086703b2a32..cd0727dac5f18898fdff7c3485975242fa2ca647 100644 (file)
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -117,7 +117,7 @@ int convert_nonmime_string(char **ps)
       return 0;
     }
   }
-  mutt_convert_string(ps, (const char *) mutt_get_default_charset(), Charset,
+  mutt_convert_string(ps, (const char *) mutt_cs_get_default_charset(), Charset,
                       MUTT_ICONV_HOOK_FROM);
   return -1;
 }
@@ -181,7 +181,7 @@ char *mutt_choose_charset(const char *fromcode, const char *charsets, char *u,
     if (dlen)
       *dlen = elen;
 
-    mutt_canonical_charset(canonical_buf, sizeof(canonical_buf), tocode);
+    mutt_cs_canonical_charset(canonical_buf, sizeof(canonical_buf), tocode);
     mutt_str_replace(&tocode, canonical_buf);
   }
   return tocode;
@@ -493,7 +493,7 @@ static int rfc2047_encode(const char *d, size_t dlen, int col, const char *fromc
   }
 
   /* Hack to avoid labelling 8-bit data as us-ascii. */
-  if (!icode && mutt_is_us_ascii(tocode))
+  if (!icode && mutt_cs_is_us_ascii(tocode))
     tocode = "unknown-8bit";
 
   /* Adjust t0 for maximum length of line. */
index 378fa548926922a0bd502e5150ef92dacec80a05..eec51c71499a15c03045cb6aa77369b770050d4c 100644 (file)
--- a/rfc2231.c
+++ b/rfc2231.c
@@ -333,7 +333,7 @@ int rfc2231_encode_string(char **pd)
     dlen = strlen(d);
   }
 
-  if (!mutt_is_us_ascii(charset))
+  if (!mutt_cs_is_us_ascii(charset))
     encode = 1;
 
   for (s = d, slen = dlen; slen; s++, slen--)
index c13ac7db4f47c91605475e0177aee262a4937c2d..a55f1b0379903d524aa841191c9444a10a5cf88d 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -90,7 +90,7 @@ static void encode_quoted(FGETCONV *fc, FILE *fout, int istext)
   int c, linelen = 0;
   char line[77], savechar;
 
-  while ((c = fgetconv(fc)) != EOF)
+  while ((c = mutt_cs_fgetconv(fc)) != EOF)
   {
     /* Wrap the line if needed. */
     if (linelen == 76 && ((istext && c != '\n') || !istext))
@@ -279,7 +279,7 @@ static void encode_base64(FGETCONV *fc, FILE *fout, int istext)
 
   b64_init(&ctx);
 
-  while ((ch = fgetconv(fc)) != EOF)
+  while ((ch = mutt_cs_fgetconv(fc)) != EOF)
   {
     if (SigInt == 1)
     {
@@ -299,7 +299,7 @@ static void encode_8bit(FGETCONV *fc, FILE *fout)
 {
   int ch;
 
-  while ((ch = fgetconv(fc)) != EOF)
+  while ((ch = mutt_cs_fgetconv(fc)) != EOF)
   {
     if (SigInt == 1)
     {
@@ -490,7 +490,7 @@ int mutt_write_mime_body(struct Body *a, FILE *f)
     mutt_file_copy_stream(fpin, f);
   mutt_sig_allow_interrupt(0);
 
-  fgetconv_close(&fc);
+  mutt_cs_fgetconv_close(&fc);
   mutt_file_fclose(&fpin);
 
   if (SigInt == 1)
@@ -949,7 +949,7 @@ struct Content *mutt_get_content_info(const char *fname, struct Body *b)
     {
       if (!chs)
       {
-        mutt_canonical_charset(chsbuf, sizeof(chsbuf), tocode);
+        mutt_cs_canonical_charset(chsbuf, sizeof(chsbuf), tocode);
         mutt_param_set("charset", chsbuf, &b->parameter);
       }
       FREE(&b->charset);
@@ -968,10 +968,10 @@ struct Content *mutt_get_content_info(const char *fname, struct Body *b)
   mutt_file_fclose(&fp);
 
   if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
-    mutt_param_set("charset",
-                   (!info->hibin ? "us-ascii" :
-                                   Charset && !mutt_is_us_ascii(Charset) ? Charset : "unknown-8bit"),
-                   &b->parameter);
+    mutt_param_set(
+        "charset",
+        (!info->hibin ? "us-ascii" : Charset && !mutt_cs_is_us_ascii(Charset) ? Charset : "unknown-8bit"),
+        &b->parameter);
 
   return info;
 }
@@ -1318,7 +1318,7 @@ char *mutt_get_body_charset(char *d, size_t dlen, struct Body *b)
     p = mutt_param_get("charset", b->parameter);
 
   if (p)
-    mutt_canonical_charset(d, dlen, NONULL(p));
+    mutt_cs_canonical_charset(d, dlen, NONULL(p));
   else
     mutt_str_strfcpy(d, "us-ascii", dlen);
 
@@ -1336,7 +1336,7 @@ void mutt_update_encoding(struct Body *a)
   char chsbuf[STRING];
 
   /* override noconv when it's us-ascii */
-  if (mutt_is_us_ascii(mutt_get_body_charset(chsbuf, sizeof(chsbuf), a)))
+  if (mutt_cs_is_us_ascii(mutt_get_body_charset(chsbuf, sizeof(chsbuf), a)))
     a->noconv = false;
 
   if (!a->force_charset && !a->noconv)