const char *p;
int i = 0;
+ if (!name) {
+ m_strcpy(dest, dlen, "us-ascii");
+ return;
+ }
+
// canonize name: only keep a-z0-9 and dots, put into lowercase
for (p = name; *p && *p != ':' && i < ssizeof(scratch) - 1; p++) {
if (isalnum(*p) || *p== '.') {
return fcharset;
}
-static int mutt_chscmp(const char *s, const char *chs)
-{
- char buffer[SHORT_STRING];
-
- if (!s)
- return 0;
-
- charset_canonicalize(buffer, sizeof(buffer), s);
- return !strcmp(buffer, chs);
-}
-
int charset_is_utf8(const char *s)
{
- return mutt_chscmp(s, "utf-8");
+ char buf[SHORT_STRING];
+ charset_canonicalize(buf, sizeof(buf), s);
+ return !strcmp(buf, "utf-8");
}
int charset_is_us_ascii(const char *s)
{
- return mutt_chscmp(s, "us-ascii");
+ char buf[SHORT_STRING];
+ charset_canonicalize(buf, sizeof(buf), s);
+ return !strcmp(buf, "us-ascii");
}
fputs ("MIME-Version: 1.0\n", out);
fputs ("Content-Transfer-Encoding: 8bit\n", out);
fputs ("Content-Type: text/plain; charset=", out);
- charset_canonicalize (chsbuf, sizeof (chsbuf),
- Charset ? Charset : "us-ascii");
+ charset_canonicalize(chsbuf, sizeof (chsbuf), Charset);
rfc822_strcpy(buffer, sizeof(buffer), chsbuf, MimeSpecials);
fputs (buffer, out);
fputc ('\n', out);
void mutt_to_base64 (unsigned char *, const unsigned char *, ssize_t, ssize_t);
int mutt_from_base64 (char *, const char *);
-/* utf8.c */
-int mutt_wctoutf8 (char *s, unsigned int c);
-
#define IsPrint(c) (isprint((unsigned char)(c)) || \
(option (OPTLOCALES) ? 0 : \
((unsigned char)(c) >= 0xa0)))
return (ferror (f) ? -1 : 0);
}
-# define write_as_text_part(a) (mutt_is_text_part(a) || mutt_is_application_pgp(a))
-
int mutt_write_mime_body (BODY * a, FILE * f)
{
const char *p;
else
fc = fgetconv_open (fpin, 0, 0, 0);
+#define write_as_text_part(a) (mutt_is_text_part(a) || mutt_is_application_pgp(a))
if (a->encoding == ENCQUOTEDPRINTABLE)
encode_quoted (fc, f, write_as_text_part (a));
else if (a->encoding == ENCBASE64)
encode_8bit (fc, f, write_as_text_part (a));
else
mutt_copy_stream (fpin, f);
+#undef write_as_text_part
fgetconv_close (&fc);
fclose (fpin);
return (ferror (f) ? -1 : 0);
}
-#undef write_as_text_part
-
typedef struct {
int from;
int whitespace;
/* Get a body's character set */
-char *mutt_get_body_charset (char *d, ssize_t dlen, BODY * b)
+char *mutt_get_body_charset(char *d, ssize_t dlen, BODY * b)
{
- const char *p = NULL;
-
- if (b && b->type != TYPETEXT)
- return NULL;
-
- if (b)
- p = parameter_getval(b->parameter, "charset");
+ const char *p;
- if (p)
- charset_canonicalize (d, dlen, p);
- else
- m_strcpy(d, dlen, "us-ascii");
+ if (b && b->type != TYPETEXT)
+ return NULL;
- return d;
+ p = b ? parameter_getval(b->parameter, "charset") : NULL;
+ charset_canonicalize(d, dlen, p);
+ return d;
}
/* Attempt to determine the appropriate content-type based on the filename
* suffix.
*/
-
-#if 0
-
- if ((n =
- mutt_lookup_mime_type (buf, sizeof (buf), xbuf, sizeof (xbuf),
- path)) != TYPEOTHER || *xbuf != '\0') {
- att->type = n;
- att->subtype = m_strdup(buf);
- att->xtype = m_strdup(xbuf);
- }
-
-#else
-
mutt_lookup_mime_type (att, path);
-#endif
-
if ((info = mutt_get_content_info (path, att)) == NULL) {
body_list_wipe(&att);
return NULL;
*/
att->type = TYPETEXT;
att->subtype = m_strdup("plain");
- }
- else {
+ } else {
att->type = TYPEAPPLICATION;
att->subtype = m_strdup("octet-stream");
}
}
mutt_update_encoding (att);
- return (att);
+ return att;
}
static int get_toplevel_encoding (BODY * a)