1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: mimedesc.c 1142 2008-08-13 17:22:21Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2006-2008 University of Washington
8 * Copyright 2013-2014 Eduardo Chappa
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
19 #include "../pith/headers.h"
20 #include "../pith/mimedesc.h"
21 #include "../pith/mimetype.h"
22 #include "../pith/state.h"
23 #include "../pith/conf.h"
24 #include "../pith/mailview.h"
25 #include "../pith/rfc2231.h"
26 #include "../pith/editorial.h"
27 #include "../pith/mailpart.h"
28 #include "../pith/mailcap.h"
29 #include "../pith/smime.h"
32 /* internal prototypes */
33 int mime_known_text_subtype(char *);
34 ATTACH_S
*next_attachment(void);
35 void format_mime_size(char *, size_t, BODY
*, int);
36 int mime_show(BODY
*);
40 * Def's to help in sorting out multipart/alternative
44 #define SHOW_ALL_EXT 2
48 * Def's to control format_mime_size output
51 #define FMS_SPACE 0x01
54 /*----------------------------------------------------------------------
55 Add lines to the attachments structure
57 Args: body -- body of the part being described
58 prefix -- The prefix for numbering the parts
59 num -- The number of this specific part
60 should_show -- Flag indicating which of alternate parts should be shown
61 multalt -- Flag indicating the part is one of the multipart
62 alternative parts (so suppress editorial comment)
64 Result: The ps_global->attachments data structure is filled in. This
65 is called recursively to descend through all the parts of a message.
66 The description strings filled in are malloced and should be freed.
70 describe_mime(struct mail_bodystruct
*body
, char *prefix
, int num
,
71 int should_show
, int multalt
, int flags
)
74 char numx
[512], string
[800], *description
;
75 int n
, named
= 0, can_display_ext
;
81 if(body
->type
== TYPEMULTIPART
){
84 if(strucmp(body
->subtype
, "alternative") == 0){
85 int effort
, best_effort
= SHOW_NONE
;
87 /*---- Figure out which alternative part to display ---*/
89 * This is kind of complicated because some TEXT types
90 * are more displayable than others. We don't want to
91 * commit to displaying a text-part alternative that we
92 * don't directly recognize unless that's all there is.
94 for(part
=body
->nested
.part
, n
=1; part
; part
=part
->next
, n
++)
95 if(flags
& FM_FORCEPREFPLN
96 || (!(flags
& FM_FORCENOPREFPLN
)
97 && F_ON(F_PREFER_PLAIN_TEXT
, ps_global
)
98 && part
->body
.type
== TYPETEXT
99 && (!part
->body
.subtype
100 || !strucmp(part
->body
.subtype
, "PLAIN")))){
101 if((effort
= mime_show(&part
->body
)) != SHOW_ALL_EXT
){
102 best_effort
= effort
;
107 else if((effort
= mime_show(&part
->body
)) >= best_effort
108 && (part
->body
.type
!= TYPETEXT
|| mime_known_text_subtype(part
->body
.subtype
))
109 && effort
!= SHOW_ALL_EXT
){
110 best_effort
= effort
;
113 else if(part
->body
.type
== TYPETEXT
&& alt_to_show
== 0){
114 best_effort
= effort
;
118 else if(!strucmp(body
->subtype
, "digest")){
119 memset(a
= next_attachment(), 0, sizeof(ATTACH_S
));
121 prefix
[n
= strlen(prefix
) - 1] = '\0';
122 a
->number
= cpystr(prefix
);
126 a
->number
= cpystr("");
128 a
->description
= cpystr("Multipart/Digest");
130 a
->can_display
= MCD_INTERNAL
;
131 (a
+1)->description
= NULL
;
134 else if(!strucmp(body
->subtype
, OUR_PKCS7_ENCLOSURE_SUBTYPE
)){
135 memset(a
= next_attachment(), 0, sizeof(ATTACH_S
));
137 prefix
[n
= strlen(prefix
) - 1] = '\0';
138 a
->number
= cpystr(prefix
);
142 a
->number
= cpystr("");
144 a
->description
= body
->description
? cpystr(body
->description
)
147 a
->can_display
= MCD_INTERNAL
;
148 (a
+1)->description
= NULL
;
151 else if(mailcap_can_display(body
->type
, body
->subtype
, body
, 0)
153 = mailcap_can_display(body
->type
, body
->subtype
, body
, 1))){
154 memset(a
= next_attachment(), 0, sizeof(ATTACH_S
));
156 prefix
[n
= strlen(prefix
) - 1] = '\0';
157 a
->number
= cpystr(prefix
);
161 a
->number
= cpystr("");
163 snprintf(string
, sizeof(string
), "%s/%s", body_type_names(body
->type
),
165 string
[sizeof(string
)-1] = '\0';
166 a
->description
= cpystr(string
);
168 a
->can_display
= MCD_EXTERNAL
;
170 a
->can_display
|= MCD_EXT_PROMPT
;
171 (a
+1)->description
= NULL
;
174 for(part
=body
->nested
.part
, n
=1; part
; part
=part
->next
, n
++){
175 snprintf(numx
, sizeof(numx
), "%s%d.", prefix
, n
);
176 numx
[sizeof(numx
)-1] = '\0';
178 * Last arg to describe_mime here. If we have chosen one part
179 * of a multipart/alternative to display then we suppress
180 * the editorial messages on the other parts.
182 describe_mime(&(part
->body
),
183 (part
->body
.type
== TYPEMULTIPART
) ? numx
: prefix
,
184 n
, should_show
&& (n
== alt_to_show
|| !alt_to_show
),
185 alt_to_show
!= 0, flags
);
189 char tmp1
[MAILTMPLEN
], tmp2
[MAILTMPLEN
];
192 a
= next_attachment();
193 format_mime_size(a
->size
, sizeof(a
->size
), body
, FMS_SPACE
);
195 a
->suppress_editorial
= (multalt
!= 0);
197 snprintf(tmp1
, sizeof(tmp1
), "%s", body
->description
? body
->description
: "");
198 tmp1
[sizeof(tmp1
)-1] = '\0';
199 snprintf(tmp2
, sizeof(tmp2
), "%s", (!body
->description
&& body
->type
== TYPEMESSAGE
&& body
->encoding
<= ENCBINARY
&& body
->subtype
&& strucmp(body
->subtype
, "rfc822") == 0 && body
->nested
.msg
->env
&& body
->nested
.msg
->env
->subject
) ? body
->nested
.msg
->env
->subject
: "");
200 tmp2
[sizeof(tmp2
)-1] = '\0';
202 description
= (body
->description
)
203 ? (char *) rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf
,
205 : (body
->type
== TYPEMESSAGE
206 && body
->encoding
<= ENCBINARY
208 && strucmp(body
->subtype
, "rfc822") == 0
209 && body
->nested
.msg
->env
210 && body
->nested
.msg
->env
->subject
)
211 ? (char *) rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf
, SIZEOF_20KBUF
, tmp2
)
212 : (body
->type
== TYPEMESSAGE
214 && !strucmp(body
->subtype
, "delivery-status"))
218 description
= iutf8ncpy((char *)(tmp_20k_buf
+1000), description
, 1000);
219 snprintf(string
, sizeof(string
), "%s%s%s%s",
220 type_desc(body
->type
,body
->subtype
,body
->parameter
,
221 body
->disposition
.type
? body
->disposition
.parameter
: NULL
, 0),
222 (description
&& description
[0]) ? ", \"" : "",
223 (description
&& description
[0]) ? description
: "",
224 (description
&& description
[0]) ? "\"": "");
225 string
[sizeof(string
)-1] =- '\0';
226 a
->description
= cpystr(string
);
229 if(body
->disposition
.type
){
230 named
= strucmp(body
->disposition
.type
, "inline");
237 * This test remains for backward compatibility
239 if(body
&& (value
= parameter_val(body
->parameter
, "name")) != NULL
){
240 named
= strucmp(value
, "Message Body");
241 fs_give((void **) &value
);
246 * Make sure we have the tools available to display the
247 * type/subtype, *AND* that we can decode it if needed.
248 * Of course, if it's text, we display it anyway in the
249 * mail_view_screen so put off testing mailcap until we're
250 * explicitly asked to display that segment 'cause it could
251 * be expensive to test...
253 if((body
->type
== TYPETEXT
&& !named
)
254 || MIME_VCARD(body
->type
,body
->subtype
)){
255 a
->test_deferred
= 1;
256 a
->can_display
= MCD_INTERNAL
;
259 a
->test_deferred
= 0;
260 a
->can_display
= mime_can_display(body
->type
, body
->subtype
, body
);
264 * Deferred means we can display it
266 a
->shown
= ((a
->can_display
& MCD_INTERNAL
)
267 && !MIME_VCARD(body
->type
,body
->subtype
)
268 && (!named
|| multalt
269 || (body
->type
== TYPETEXT
&& num
== 1
270 && !(*prefix
&& strcmp(prefix
,"1."))))
271 && (body
->type
!= TYPEMESSAGE
272 || (body
->type
== TYPEMESSAGE
273 && body
->encoding
<= ENCBINARY
))
275 ll
= (strlen(prefix
) + 16) * sizeof(char);
276 a
->number
= (char *) fs_get(ll
);
277 snprintf(a
->number
, ll
, "%s%d",prefix
, num
);
278 a
->number
[ll
-1] = '\0';
279 (a
+1)->description
= NULL
;
280 if(body
->type
== TYPEMESSAGE
&& body
->encoding
<= ENCBINARY
281 && body
->subtype
&& strucmp(body
->subtype
, "rfc822") == 0){
282 body
= body
->nested
.msg
->body
;
283 snprintf(numx
, sizeof(numx
), "%.*s%d.", sizeof(numx
)-20, prefix
, num
);
284 numx
[sizeof(numx
)-1] = '\0';
285 describe_mime(body
, numx
, 1, should_show
, 0, flags
);
292 mime_known_text_subtype(char *subtype
)
295 static char *known_types
[] = {
303 if(!(subtype
&& *subtype
))
306 for(p
= known_types
; *p
; p
++)
307 if(!strucmp(subtype
, *p
))
314 * Returns attribute value or NULL.
315 * Value returned needs to be freed by caller
318 parameter_val(PARAMETER
*param
, char *attribute
)
320 if(!(param
&& attribute
&& attribute
[0]))
323 return(rfc2231_get_param(param
, attribute
, NULL
, NULL
));
328 * Get sender_filename, the filename set by the sender in the attachment.
329 * If a sender_filename buffer is passed in, the answer is copied to it
330 * and a pointer to it is returned. If sender_filename is passed in as NULL
331 * then an allocated copy of the sender filename is returned instead.
332 * If ext_ptr is non-NULL then it is set to point to the extension name.
333 * It is not a separate copy, it points into the string sender_filename.
336 get_filename_parameter(char *sender_filename
, size_t sfsize
, BODY
*body
, char **ext_ptr
)
339 char *decoded_name
= NULL
;
340 char *filename
= NULL
;
350 sender_filename
[0] = '\0';
354 * First check for Content-Disposition's "filename" parameter and
355 * if that isn't found for the deprecated Content-Type "name" parameter.
357 if((p
= parameter_val(body
->disposition
.parameter
, "filename"))
358 || (p
= parameter_val(body
->parameter
, "name"))){
361 * If somebody sent us and incorrectly rfc2047 encoded
362 * parameter value instead of what rfc2231 suggest we
363 * grudglingly try to fix it.
365 if(p
[0] == '=' && p
[1] == '?')
366 decoded_name
= (char *) rfc1522_decode_to_utf8((unsigned char *) tmp
,
372 filename
= last_cmpnt(decoded_name
);
375 filename
= decoded_name
;
380 strncpy(sender_filename
, filename
, sfsize
-1);
381 sender_filename
[sfsize
-1] = '\0';
384 sender_filename
= cpystr(filename
);
388 fs_give((void **) &p
);
390 /* ext_ptr will end up pointing into sender_filename string */
391 if(ext_ptr
&& sender_filename
)
392 mt_get_file_ext(sender_filename
, ext_ptr
);
394 return(sender_filename
);
398 /*----------------------------------------------------------------------
399 Return a pointer to the next attachment struct
405 next_attachment(void)
410 for(a
= ps_global
->atmts
; a
->description
; a
++)
413 if((n
= a
- ps_global
->atmts
) + 1 >= ps_global
->atmts_allocated
){
414 ps_global
->atmts_allocated
*= 2;
415 fs_resize((void **)&ps_global
->atmts
,
416 ps_global
->atmts_allocated
* sizeof(ATTACH_S
));
417 a
= &ps_global
->atmts
[n
];
425 /*----------------------------------------------------------------------
426 Zero out the attachments structure and free up storage
429 zero_atmts(ATTACH_S
*atmts
)
433 for(a
= atmts
; a
->description
!= NULL
; a
++){
434 fs_give((void **)&(a
->description
));
435 fs_give((void **)&(a
->number
));
438 atmts
->description
= NULL
;
443 body_type_names(int t
)
446 static char body_type
[TLEN
+ 1];
450 strncpy(body_type
, /* copy the given type */
451 (t
> -1 && t
< TYPEMAX
&& body_types
[t
])
452 ? body_types
[t
] : "Other", TLEN
);
453 body_type
[sizeof(body_type
)-1] = '\0';
455 for(p
= body_type
+ 1; *p
; p
++) /* make it presentable */
456 if(isascii((unsigned char) (*p
)) && isupper((unsigned char) (*p
)))
457 *p
= tolower((unsigned char)(*p
));
459 return(body_type
); /* present it */
463 /*----------------------------------------------------------------------
464 Mapping table use to neatly display charset parameters
467 static struct set_names
{
470 } charset_names
[] = {
471 {"US-ASCII", "Plain Text"},
472 {"ISO-8859-1", "Latin 1 (Western Europe)"},
473 {"ISO-8859-2", "Latin 2 (Eastern Europe)"},
474 {"ISO-8859-3", "Latin 3 (Southern Europe)"},
475 {"ISO-8859-4", "Latin 4 (Northern Europe)"},
476 {"ISO-8859-5", "Latin & Cyrillic"},
477 {"ISO-8859-6", "Latin & Arabic"},
478 {"ISO-8859-7", "Latin & Greek"},
479 {"ISO-8859-8", "Latin & Hebrew"},
480 {"ISO-8859-9", "Latin 5 (Turkish)"},
481 {"ISO-8859-10", "Latin 6 (Nordic)"},
482 {"ISO-8859-11", "Latin & Thai"},
483 {"ISO-8859-13", "Latin 7 (Baltic)"},
484 {"ISO-8859-14", "Latin 8 (Celtic)"},
485 {"ISO-8859-15", "Latin 9 (Euro)"},
486 {"KOI8-R", "Latin & Russian"},
487 {"KOI8-U", "Latin & Ukranian"},
488 {"VISCII", "Latin & Vietnamese"},
489 {"GB2312", "Latin & Simplified Chinese"},
490 {"BIG5", "Latin & Traditional Chinese"},
491 {"EUC-JP", "Latin & Japanese"},
492 {"Shift-JIS", "Latin & Japanese"},
493 {"Shift_JIS", "Latin & Japanese"},
494 {"EUC-KR", "Latin & Korean"},
495 {"ISO-2022-CN", "Latin & Chinese"},
496 {"ISO-2022-JP", "Latin & Japanese"},
497 {"ISO-2022-KR", "Latin & Korean"},
498 {"UTF-7", "7-bit encoded Unicode"},
499 {"UTF-8", "Internet-standard Unicode"},
500 {"ISO-2022-JP-2", "Multilingual"},
505 /*----------------------------------------------------------------------
506 Return a nicely formatted discription of the type of the part
510 type_desc(int type
, char *subtype
, PARAMETER
*params
, PARAMETER
*disp_params
, int full
)
512 static char type_d
[200];
517 sstrncpy(&p
, body_type_names(type
), sizeof(type_d
)-(p
-type_d
));
520 sstrncpy(&p
, subtype
, sizeof(type_d
)-(p
-type_d
));
523 type_d
[sizeof(type_d
)-1] = '\0';
527 parmval
= parameter_val(params
, "charset");
530 for(i
= 0; charset_names
[i
].rfcname
; i
++)
531 if(!strucmp(parmval
, charset_names
[i
].rfcname
)){
532 if(!strucmp(parmval
, ps_global
->display_charmap
533 ? ps_global
->display_charmap
: "us-ascii")
534 || !strucmp(parmval
, "us-ascii"))
540 if(i
>= 0){ /* charset to write */
541 if(charset_names
[i
].rfcname
){
542 sstrncpy(&p
, " (charset: ", sizeof(type_d
)-(p
-type_d
));
543 sstrncpy(&p
, charset_names
[i
].rfcname
544 ? charset_names
[i
].rfcname
: "Unknown", sizeof(type_d
)-(p
-type_d
));
546 sstrncpy(&p
, " \"", sizeof(type_d
)-(p
-type_d
));
547 sstrncpy(&p
, charset_names
[i
].humanname
548 ? charset_names
[i
].humanname
549 : parmval
, sizeof(type_d
)-(p
-type_d
));
550 if(sizeof(type_d
)-(p
-type_d
) > 0)
554 sstrncpy(&p
, ")", sizeof(type_d
)-(p
-type_d
));
557 sstrncpy(&p
, " (charset: ", sizeof(type_d
)-(p
-type_d
));
558 sstrncpy(&p
, parmval
, sizeof(type_d
)-(p
-type_d
));
559 sstrncpy(&p
, ")", sizeof(type_d
)-(p
-type_d
));
563 fs_give((void **) &parmval
);
569 if(full
&& subtype
&& strucmp(subtype
, "external-body") == 0)
570 if((parmval
= parameter_val(params
, "access-type")) != NULL
){
571 snprintf(p
, sizeof(type_d
)-(p
-type_d
), " (%s%s)", full
? "Access: " : "", parmval
);
572 fs_give((void **) &parmval
);
581 if(full
&& type
!= TYPEMULTIPART
&& type
!= TYPEMESSAGE
){
582 if((parmval
= parameter_val(params
, "name")) != NULL
){
583 snprintf(p
, sizeof(type_d
)-(p
-type_d
), " (Name: \"%s\")", parmval
);
584 fs_give((void **) &parmval
);
586 else if((parmval
= parameter_val(disp_params
, "filename")) != NULL
){
587 snprintf(p
, sizeof(type_d
)-(p
-type_d
), " (Filename: \"%s\")", parmval
);
588 fs_give((void **) &parmval
);
592 type_d
[sizeof(type_d
)-1] = '\0';
601 format_mime_size(char *string
, size_t stringlen
, struct mail_bodystruct
*b
, int flags
)
603 char tmp
[10], *p
= NULL
;
612 if(flags
& FMS_SPACE
)
617 if(b
->type
== TYPETEXT
){
618 if(flags
& FMS_SPACE
)
624 strncpy(p
= string
, byte_string((3 * b
->size
.bytes
) / 4), stringlen
-(string
-origstring
));
628 case ENCQUOTEDPRINTABLE
:
629 if(flags
& FMS_SPACE
)
636 if(b
->type
== TYPETEXT
)
637 /* lines with no CRLF aren't counted, just add one so it makes more sense */
638 snprintf(string
, stringlen
-(string
-origstring
), "%s lines", comatose(b
->size
.lines
+1));
640 strncpy(p
= string
, byte_string(b
->size
.bytes
), stringlen
-(string
-origstring
));
645 origstring
[stringlen
-1] = '\0';
648 for(; *p
&& (isascii((unsigned char) *p
) && (isdigit((unsigned char) *p
)
649 || ispunct((unsigned char) *p
))); p
++)
652 snprintf(tmp
, sizeof(tmp
), (flags
& FMS_SPACE
) ? " %-5.5s" : " %s", p
);
653 tmp
[sizeof(tmp
)-1] = '\0';
654 strncpy(p
, tmp
, stringlen
-(p
-origstring
));
657 origstring
[stringlen
-1] = '\0';
662 /*----------------------------------------------------------------------
663 Determine if we can show all, some or none of the parts of a body
665 Args: body --- The message body to check
667 Returns: SHOW_ALL, SHOW_ALL_EXT, SHOW_PART or SHOW_NONE depending on
668 how much of the body can be shown and who can show it.
671 mime_show(struct mail_bodystruct
*body
)
673 int effort
, best_effort
;
681 if(!strucmp(body
->subtype
, "rfc822"))
682 return(mime_show(body
->nested
.msg
->body
) == SHOW_ALL
683 ? SHOW_ALL
: SHOW_PARTS
);
684 /* else fall thru to default case... */
688 * Since we're testing for internal displayability, give the
689 * internal result over an external viewer
691 effort
= mime_can_display(body
->type
, body
->subtype
, body
);
692 if(effort
== MCD_NONE
)
694 else if(effort
& MCD_INTERNAL
)
697 return(SHOW_ALL_EXT
);
700 best_effort
= SHOW_NONE
;
701 for(p
= body
->nested
.part
; p
; p
= p
->next
)
702 if((effort
= mime_show(&p
->body
)) > best_effort
)
703 best_effort
= effort
;
714 fcc_size_guess(struct mail_bodystruct
*body
)
719 if(body
->type
== TYPEMULTIPART
){
722 for(part
= body
->nested
.part
; part
; part
= part
->next
)
723 size
+= fcc_size_guess(&part
->body
);
726 size
= body
->size
.bytes
;
728 * If it is ENCBINARY we will be base64 encoding it. This
729 * ideally increases the size by a factor of 4/3, but there
730 * is a per-line increase in that because of the CRLFs and
731 * because the number of characters in the line might not
732 * be a factor of 3. So push it up by 3/2 instead. This still
733 * won't catch all the cases. In particular, attachements with
734 * lots of short lines (< 10) will expand by more than that,
735 * but that's ok since this is an optimization. That's why
736 * so_cs_puts uses the 3/2 factor when it does a resize, so
737 * that it won't have to resize linearly until it gets there.
739 if(body
->encoding
== ENCBINARY
)
749 /*----------------------------------------------------------------------
750 Format a strings describing one unshown part of a Mime message
752 Args: number -- A string with the part number i.e. "3.2.1"
753 body -- The body part
754 type -- 1 - Not shown, but can be
755 2 - Not shown, cannot be shown
757 width -- allowed width per line of editorial comment
758 pc -- function used to write the description comment
760 Result: formatted description written to object ref'd by "pc"
763 part_desc(char *number
, BODY
*body
, int type
, int width
, int flags
, gf_io_t pc
)
766 char buftmp
[MAILTMPLEN
], sizebuf
[256];
768 if(!gf_puts(NEWLINE
, pc
))
769 return("No space for description");
771 format_mime_size(sizebuf
, 256, body
, FMS_NONE
);
773 snprintf(buftmp
, sizeof(buftmp
), "%s", body
->description
? body
->description
: "");
774 buftmp
[sizeof(buftmp
)-1] = '\0';
775 snprintf(tmp_20k_buf
+10000, SIZEOF_20KBUF
-10000, "Part %s, %s%.2048s%s%s %s.",
777 body
->description
== NULL
? "" : "\"",
778 body
->description
== NULL
? ""
779 : (char *)rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf
, 10000, buftmp
),
780 body
->description
== NULL
? "" : "\" ",
781 type_desc(body
->type
, body
->subtype
, body
->parameter
, NULL
, 1),
783 tmp_20k_buf
[SIZEOF_20KBUF
-1] = '\0';
785 iutf8ncpy((char *)tmp_20k_buf
, (char *)(tmp_20k_buf
+10000), 10000);
786 tmp_20k_buf
[10000] = '\0';
788 t
= &tmp_20k_buf
[strlen(tmp_20k_buf
)];
791 /* if smime and not attempting print */
792 if(F_OFF(F_DONT_DO_SMIME
, ps_global
) && is_pkcs7_body(body
) && type
!= 3){
794 sstrncpy(&t
, "\015\012", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
796 if(ps_global
->smime
&& ps_global
->smime
->need_passphrase
){
798 "This part is a PKCS7 S/MIME enclosure. "
799 "You may be able to view it by entering the correct passphrase "
800 "with the \"Decrypt\" command.",
801 SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
805 "This part is a PKCS7 S/MIME enclosure. "
806 "Press \"^E\" for more information.",
807 SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
814 sstrncpy(&t
, "\015\012", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
817 if(MIME_VCARD(body
->type
,body
->subtype
))
819 /* TRANSLATORS: This is the description of an attachment that isn't being
820 shown but that can be viewed or saved. */
821 _("Not Shown. Use the \"V\" command to view or save to address book."), SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
824 /* TRANSLATORS: This is the description of an attachment that isn't being
825 shown but that can be viewed or saved. */
826 _("Not Shown. Use the \"V\" command to view or save this part."), SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
831 sstrncpy(&t
, "Cannot ", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
832 if(body
->type
!= TYPEAUDIO
&& body
->type
!= TYPEVIDEO
)
833 sstrncpy(&t
, "dis", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
836 "play this part. Press \"V\" then \"S\" to save in a file.", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
840 sstrncpy(&t
, _("Unable to print this part."), SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
845 if(!(t
= format_editorial(tmp_20k_buf
, width
, flags
, NULL
, pc
))){
846 if(!gf_puts(NEWLINE
, pc
))
847 t
= "No space for description";
854 /*----------------------------------------------------------------------
855 Can we display this type/subtype?
857 Args: type -- the MIME type to check
858 subtype -- the MIME subtype
860 use_viewer -- tell caller he should run external viewer cmd to view
864 MCD_NONE if we can't display this type at all
865 MCD_INTERNAL if we can display it internally
866 MCD_EXTERNAL if it can be displayed via an external viewer
870 mime_can_display(int type
, char *subtype
, BODY
*body
)
872 return((mailcap_can_display(type
, subtype
, body
, 0)
874 : (mailcap_can_display(type
, subtype
, body
, 1)
875 ? (MCD_EXT_PROMPT
| MCD_EXTERNAL
) : MCD_NONE
))
876 | ((type
== TYPETEXT
|| type
== TYPEMESSAGE
877 || MIME_VCARD(type
,subtype
))
878 ? MCD_INTERNAL
: MCD_NONE
));