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-2016 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
)
75 char numx
[NUMXLEN
], string
[800], *description
;
76 int n
, named
= 0, can_display_ext
;
82 if(body
->type
== TYPEMULTIPART
){
85 if(strucmp(body
->subtype
, "alternative") == 0){
86 int effort
, best_effort
= SHOW_NONE
;
88 /*---- Figure out which alternative part to display ---*/
90 * This is kind of complicated because some TEXT types
91 * are more displayable than others. We don't want to
92 * commit to displaying a text-part alternative that we
93 * don't directly recognize unless that's all there is.
95 for(part
=body
->nested
.part
, n
=1; part
; part
=part
->next
, n
++)
96 if(flags
& FM_FORCEPREFPLN
97 || (!(flags
& FM_FORCENOPREFPLN
)
98 && F_ON(F_PREFER_PLAIN_TEXT
, ps_global
)
99 && part
->body
.type
== TYPETEXT
100 && (!part
->body
.subtype
101 || !strucmp(part
->body
.subtype
, "PLAIN")))){
102 if((effort
= mime_show(&part
->body
)) != SHOW_ALL_EXT
){
103 best_effort
= effort
;
108 else if((effort
= mime_show(&part
->body
)) >= best_effort
109 && (part
->body
.type
!= TYPETEXT
|| mime_known_text_subtype(part
->body
.subtype
))
110 && effort
!= SHOW_ALL_EXT
){
111 best_effort
= effort
;
114 else if(part
->body
.type
== TYPETEXT
&& alt_to_show
== 0){
115 best_effort
= effort
;
119 else if(!strucmp(body
->subtype
, "digest")){
120 memset(a
= next_attachment(), 0, sizeof(ATTACH_S
));
122 prefix
[n
= strlen(prefix
) - 1] = '\0';
123 a
->number
= cpystr(prefix
);
127 a
->number
= cpystr("");
129 a
->description
= cpystr("Multipart/Digest");
131 a
->can_display
= MCD_INTERNAL
;
132 (a
+1)->description
= NULL
;
135 else if(!strucmp(body
->subtype
, OUR_PKCS7_ENCLOSURE_SUBTYPE
)){
136 memset(a
= next_attachment(), 0, sizeof(ATTACH_S
));
138 prefix
[n
= strlen(prefix
) - 1] = '\0';
139 a
->number
= cpystr(prefix
);
143 a
->number
= cpystr("");
145 a
->description
= body
->description
? cpystr(body
->description
)
148 a
->can_display
= MCD_INTERNAL
;
149 (a
+1)->description
= NULL
;
152 else if(mailcap_can_display(body
->type
, body
->subtype
, body
, 0)
154 = mailcap_can_display(body
->type
, body
->subtype
, body
, 1))){
155 memset(a
= next_attachment(), 0, sizeof(ATTACH_S
));
157 prefix
[n
= strlen(prefix
) - 1] = '\0';
158 a
->number
= cpystr(prefix
);
162 a
->number
= cpystr("");
164 snprintf(string
, sizeof(string
), "%s/%s", body_type_names(body
->type
),
166 string
[sizeof(string
)-1] = '\0';
167 a
->description
= cpystr(string
);
169 a
->can_display
= MCD_EXTERNAL
;
171 a
->can_display
|= MCD_EXT_PROMPT
;
172 (a
+1)->description
= NULL
;
175 for(part
=body
->nested
.part
, n
=1; part
; part
=part
->next
, n
++){
176 snprintf(numx
, sizeof(numx
), "%s%d.", prefix
, n
);
177 numx
[sizeof(numx
)-1] = '\0';
179 * Last arg to describe_mime here. If we have chosen one part
180 * of a multipart/alternative to display then we suppress
181 * the editorial messages on the other parts.
183 describe_mime(&(part
->body
),
184 (part
->body
.type
== TYPEMULTIPART
) ? numx
: prefix
,
185 n
, should_show
&& (n
== alt_to_show
|| !alt_to_show
),
186 alt_to_show
!= 0, flags
);
190 char tmp1
[MAILTMPLEN
], tmp2
[MAILTMPLEN
];
193 a
= next_attachment();
194 format_mime_size(a
->size
, sizeof(a
->size
), body
, FMS_SPACE
);
196 a
->suppress_editorial
= (multalt
!= 0);
198 snprintf(tmp1
, sizeof(tmp1
), "%s", body
->description
? body
->description
: "");
199 tmp1
[sizeof(tmp1
)-1] = '\0';
200 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
: "");
201 tmp2
[sizeof(tmp2
)-1] = '\0';
203 description
= (body
->description
)
204 ? (char *) rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf
,
206 : (body
->type
== TYPEMESSAGE
207 && body
->encoding
<= ENCBINARY
209 && strucmp(body
->subtype
, "rfc822") == 0
210 && body
->nested
.msg
->env
211 && body
->nested
.msg
->env
->subject
)
212 ? (char *) rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf
, SIZEOF_20KBUF
, tmp2
)
213 : (body
->type
== TYPEMESSAGE
215 && !strucmp(body
->subtype
, "delivery-status"))
219 description
= iutf8ncpy((char *)(tmp_20k_buf
+1000), description
, 1000);
220 snprintf(string
, sizeof(string
), "%s%s%s%s",
221 type_desc(body
->type
,body
->subtype
,body
->parameter
,
222 body
->disposition
.type
? body
->disposition
.parameter
: NULL
, 0),
223 (description
&& description
[0]) ? ", \"" : "",
224 (description
&& description
[0]) ? description
: "",
225 (description
&& description
[0]) ? "\"": "");
226 string
[sizeof(string
)-1] = '\0';
227 a
->description
= cpystr(string
);
230 if(body
->disposition
.type
){
231 named
= strucmp(body
->disposition
.type
, "inline");
238 * This test remains for backward compatibility
240 if(body
&& (value
= parameter_val(body
->parameter
, "name")) != NULL
){
241 named
= strucmp(value
, "Message Body");
242 fs_give((void **) &value
);
247 * Make sure we have the tools available to display the
248 * type/subtype, *AND* that we can decode it if needed.
249 * Of course, if it's text, we display it anyway in the
250 * mail_view_screen so put off testing mailcap until we're
251 * explicitly asked to display that segment 'cause it could
252 * be expensive to test...
254 if((body
->type
== TYPETEXT
&& !named
)
255 || MIME_VCARD(body
->type
,body
->subtype
)){
256 a
->test_deferred
= 1;
257 a
->can_display
= MCD_INTERNAL
;
260 a
->test_deferred
= 0;
261 a
->can_display
= mime_can_display(body
->type
, body
->subtype
, body
);
265 * Deferred means we can display it
267 a
->shown
= ((a
->can_display
& MCD_INTERNAL
)
268 && !MIME_VCARD(body
->type
,body
->subtype
)
269 && (!named
|| multalt
270 || (body
->type
== TYPETEXT
&& num
== 1
271 && !(*prefix
&& strcmp(prefix
,"1."))))
272 && (body
->type
!= TYPEMESSAGE
273 || (body
->type
== TYPEMESSAGE
274 && body
->encoding
<= ENCBINARY
))
276 ll
= (strlen(prefix
) + 16) * sizeof(char);
277 a
->number
= (char *) fs_get(ll
);
278 snprintf(a
->number
, ll
, "%s%d",prefix
, num
);
279 a
->number
[ll
-1] = '\0';
280 (a
+1)->description
= NULL
;
281 if(body
->type
== TYPEMESSAGE
&& body
->encoding
<= ENCBASE64
282 && body
->subtype
&& strucmp(body
->subtype
, "rfc822") == 0){
283 body
= body
->nested
.msg
->body
; /* NUMXLEN = sizeof(numx) */
284 snprintf(numx
, sizeof(numx
), "%.*s%d.", NUMXLEN
-20, prefix
, num
);
285 numx
[sizeof(numx
)-1] = '\0';
286 describe_mime(body
, numx
, 1, should_show
, 0, flags
);
293 mime_known_text_subtype(char *subtype
)
296 static char *known_types
[] = {
304 if(!(subtype
&& *subtype
))
307 for(p
= known_types
; *p
; p
++)
308 if(!strucmp(subtype
, *p
))
315 * Returns attribute value or NULL.
316 * Value returned needs to be freed by caller
319 parameter_val(PARAMETER
*param
, char *attribute
)
321 if(!(param
&& attribute
&& attribute
[0]))
324 return(rfc2231_get_param(param
, attribute
, NULL
, NULL
));
329 * Get sender_filename, the filename set by the sender in the attachment.
330 * If a sender_filename buffer is passed in, the answer is copied to it
331 * and a pointer to it is returned. If sender_filename is passed in as NULL
332 * then an allocated copy of the sender filename is returned instead.
333 * If ext_ptr is non-NULL then it is set to point to the extension name.
334 * It is not a separate copy, it points into the string sender_filename.
337 get_filename_parameter(char *sender_filename
, size_t sfsize
, BODY
*body
, char **ext_ptr
)
340 char *decoded_name
= NULL
;
341 char *filename
= NULL
;
351 sender_filename
[0] = '\0';
355 * First check for Content-Disposition's "filename" parameter and
356 * if that isn't found for the deprecated Content-Type "name" parameter.
358 if((p
= parameter_val(body
->disposition
.parameter
, "filename"))
359 || (p
= parameter_val(body
->parameter
, "name"))){
362 * If somebody sent us and incorrectly rfc2047 encoded
363 * parameter value instead of what rfc2231 suggest we
364 * grudglingly try to fix it.
366 if(p
[0] == '=' && p
[1] == '?')
367 decoded_name
= (char *) rfc1522_decode_to_utf8((unsigned char *) tmp
,
373 filename
= last_cmpnt(decoded_name
);
376 filename
= decoded_name
;
381 strncpy(sender_filename
, filename
, sfsize
-1);
382 sender_filename
[sfsize
-1] = '\0';
385 sender_filename
= cpystr(filename
);
389 fs_give((void **) &p
);
391 /* ext_ptr will end up pointing into sender_filename string */
392 if(ext_ptr
&& sender_filename
)
393 mt_get_file_ext(sender_filename
, ext_ptr
);
395 return(sender_filename
);
399 /*----------------------------------------------------------------------
400 Return a pointer to the next attachment struct
406 next_attachment(void)
411 for(a
= ps_global
->atmts
; a
->description
; a
++)
414 if((n
= a
- ps_global
->atmts
) + 1 >= ps_global
->atmts_allocated
){
415 ps_global
->atmts_allocated
*= 2;
416 fs_resize((void **)&ps_global
->atmts
,
417 ps_global
->atmts_allocated
* sizeof(ATTACH_S
));
418 a
= &ps_global
->atmts
[n
];
426 /*----------------------------------------------------------------------
427 Zero out the attachments structure and free up storage
430 zero_atmts(ATTACH_S
*atmts
)
434 for(a
= atmts
; a
->description
!= NULL
; a
++){
435 fs_give((void **)&(a
->description
));
436 fs_give((void **)&(a
->number
));
439 atmts
->description
= NULL
;
444 body_type_names(int t
)
447 static char body_type
[TLEN
+ 1];
451 strncpy(body_type
, /* copy the given type */
452 (t
> -1 && t
< TYPEMAX
&& body_types
[t
])
453 ? body_types
[t
] : "Other", TLEN
);
454 body_type
[sizeof(body_type
)-1] = '\0';
456 for(p
= body_type
+ 1; *p
; p
++) /* make it presentable */
457 if(isascii((unsigned char) (*p
)) && isupper((unsigned char) (*p
)))
458 *p
= tolower((unsigned char)(*p
));
460 return(body_type
); /* present it */
464 /*----------------------------------------------------------------------
465 Mapping table use to neatly display charset parameters
468 static struct set_names
{
471 } charset_names
[] = {
472 {"US-ASCII", "Plain Text"},
473 {"ISO-8859-1", "Latin 1 (Western Europe)"},
474 {"ISO-8859-2", "Latin 2 (Eastern Europe)"},
475 {"ISO-8859-3", "Latin 3 (Southern Europe)"},
476 {"ISO-8859-4", "Latin 4 (Northern Europe)"},
477 {"ISO-8859-5", "Latin & Cyrillic"},
478 {"ISO-8859-6", "Latin & Arabic"},
479 {"ISO-8859-7", "Latin & Greek"},
480 {"ISO-8859-8", "Latin & Hebrew"},
481 {"ISO-8859-9", "Latin 5 (Turkish)"},
482 {"ISO-8859-10", "Latin 6 (Nordic)"},
483 {"ISO-8859-11", "Latin & Thai"},
484 {"ISO-8859-13", "Latin 7 (Baltic)"},
485 {"ISO-8859-14", "Latin 8 (Celtic)"},
486 {"ISO-8859-15", "Latin 9 (Euro)"},
487 {"KOI8-R", "Latin & Russian"},
488 {"KOI8-U", "Latin & Ukranian"},
489 {"VISCII", "Latin & Vietnamese"},
490 {"GB2312", "Latin & Simplified Chinese"},
491 {"BIG5", "Latin & Traditional Chinese"},
492 {"EUC-JP", "Latin & Japanese"},
493 {"Shift-JIS", "Latin & Japanese"},
494 {"Shift_JIS", "Latin & Japanese"},
495 {"EUC-KR", "Latin & Korean"},
496 {"ISO-2022-CN", "Latin & Chinese"},
497 {"ISO-2022-JP", "Latin & Japanese"},
498 {"ISO-2022-KR", "Latin & Korean"},
499 {"UTF-7", "7-bit encoded Unicode"},
500 {"UTF-8", "Internet-standard Unicode"},
501 {"ISO-2022-JP-2", "Multilingual"},
506 /*----------------------------------------------------------------------
507 Return a nicely formatted discription of the type of the part
511 type_desc(int type
, char *subtype
, PARAMETER
*params
, PARAMETER
*disp_params
, int full
)
513 static char type_d
[200];
518 sstrncpy(&p
, body_type_names(type
), sizeof(type_d
)-(p
-type_d
));
521 sstrncpy(&p
, subtype
, sizeof(type_d
)-(p
-type_d
));
524 type_d
[sizeof(type_d
)-1] = '\0';
528 parmval
= parameter_val(params
, "charset");
531 for(i
= 0; charset_names
[i
].rfcname
; i
++)
532 if(!strucmp(parmval
, charset_names
[i
].rfcname
)){
533 if(!strucmp(parmval
, ps_global
->display_charmap
534 ? ps_global
->display_charmap
: "us-ascii")
535 || !strucmp(parmval
, "us-ascii"))
541 if(i
>= 0){ /* charset to write */
542 if(charset_names
[i
].rfcname
){
543 sstrncpy(&p
, " (charset: ", sizeof(type_d
)-(p
-type_d
));
544 sstrncpy(&p
, charset_names
[i
].rfcname
545 ? charset_names
[i
].rfcname
: "Unknown", sizeof(type_d
)-(p
-type_d
));
547 sstrncpy(&p
, " \"", sizeof(type_d
)-(p
-type_d
));
548 sstrncpy(&p
, charset_names
[i
].humanname
549 ? charset_names
[i
].humanname
550 : parmval
, sizeof(type_d
)-(p
-type_d
));
551 if(sizeof(type_d
)-(p
-type_d
) > 0)
555 sstrncpy(&p
, ")", sizeof(type_d
)-(p
-type_d
));
558 sstrncpy(&p
, " (charset: ", sizeof(type_d
)-(p
-type_d
));
559 sstrncpy(&p
, parmval
, sizeof(type_d
)-(p
-type_d
));
560 sstrncpy(&p
, ")", sizeof(type_d
)-(p
-type_d
));
564 fs_give((void **) &parmval
);
570 if(full
&& subtype
&& strucmp(subtype
, "external-body") == 0)
571 if((parmval
= parameter_val(params
, "access-type")) != NULL
){
572 snprintf(p
, sizeof(type_d
)-(p
-type_d
), " (%s%s)", full
? "Access: " : "", parmval
);
573 fs_give((void **) &parmval
);
582 if(full
&& type
!= TYPEMULTIPART
&& type
!= TYPEMESSAGE
){
583 unsigned char decodebuf
[10000];
584 if((parmval
= parameter_val(params
, "name")) != NULL
){
585 rfc1522_decode_to_utf8(decodebuf
, sizeof(decodebuf
), parmval
);
586 snprintf(p
, sizeof(type_d
)-(p
-type_d
), " (Name: \"%s\")", decodebuf
);
587 fs_give((void **) &parmval
);
589 else if((parmval
= parameter_val(disp_params
, "filename")) != NULL
){
590 rfc1522_decode_to_utf8(decodebuf
, sizeof(decodebuf
), parmval
);
591 snprintf(p
, sizeof(type_d
)-(p
-type_d
), " (Filename: \"%s\")", decodebuf
);
592 fs_give((void **) &parmval
);
596 type_d
[sizeof(type_d
)-1] = '\0';
605 format_mime_size(char *string
, size_t stringlen
, struct mail_bodystruct
*b
, int flags
)
607 char tmp
[10], *p
= NULL
;
616 if(flags
& FMS_SPACE
)
621 if(b
->type
== TYPETEXT
){
622 if(flags
& FMS_SPACE
)
628 strncpy(p
= string
, byte_string((3 * b
->size
.bytes
) / 4), stringlen
-(string
-origstring
));
632 case ENCQUOTEDPRINTABLE
:
633 if(flags
& FMS_SPACE
)
640 if(b
->type
== TYPETEXT
)
641 /* lines with no CRLF aren't counted, just add one so it makes more sense */
642 snprintf(string
, stringlen
-(string
-origstring
), "%s lines", comatose(b
->size
.lines
+1));
644 strncpy(p
= string
, byte_string(b
->size
.bytes
), stringlen
-(string
-origstring
));
649 origstring
[stringlen
-1] = '\0';
652 for(; *p
&& (isascii((unsigned char) *p
) && (isdigit((unsigned char) *p
)
653 || ispunct((unsigned char) *p
))); p
++)
656 snprintf(tmp
, sizeof(tmp
), (flags
& FMS_SPACE
) ? " %-5.5s" : " %s", p
);
657 tmp
[sizeof(tmp
)-1] = '\0';
658 strncpy(p
, tmp
, stringlen
-(p
-origstring
));
661 origstring
[stringlen
-1] = '\0';
666 /*----------------------------------------------------------------------
667 Determine if we can show all, some or none of the parts of a body
669 Args: body --- The message body to check
671 Returns: SHOW_ALL, SHOW_ALL_EXT, SHOW_PART or SHOW_NONE depending on
672 how much of the body can be shown and who can show it.
675 mime_show(struct mail_bodystruct
*body
)
677 int effort
, best_effort
;
685 if(!strucmp(body
->subtype
, "rfc822"))
686 return(mime_show(body
->nested
.msg
->body
) == SHOW_ALL
687 ? SHOW_ALL
: SHOW_PARTS
);
688 /* else fall thru to default case... */
692 * Since we're testing for internal displayability, give the
693 * internal result over an external viewer
695 effort
= mime_can_display(body
->type
, body
->subtype
, body
);
696 if(effort
== MCD_NONE
)
698 else if(effort
& MCD_INTERNAL
)
701 return(SHOW_ALL_EXT
);
704 best_effort
= SHOW_NONE
;
705 for(p
= body
->nested
.part
; p
; p
= p
->next
)
706 if((effort
= mime_show(&p
->body
)) > best_effort
)
707 best_effort
= effort
;
718 fcc_size_guess(struct mail_bodystruct
*body
)
723 if(body
->type
== TYPEMULTIPART
){
726 for(part
= body
->nested
.part
; part
; part
= part
->next
)
727 size
+= fcc_size_guess(&part
->body
);
730 size
= body
->size
.bytes
;
732 * If it is ENCBINARY we will be base64 encoding it. This
733 * ideally increases the size by a factor of 4/3, but there
734 * is a per-line increase in that because of the CRLFs and
735 * because the number of characters in the line might not
736 * be a factor of 3. So push it up by 3/2 instead. This still
737 * won't catch all the cases. In particular, attachements with
738 * lots of short lines (< 10) will expand by more than that,
739 * but that's ok since this is an optimization. That's why
740 * so_cs_puts uses the 3/2 factor when it does a resize, so
741 * that it won't have to resize linearly until it gets there.
743 if(body
->encoding
== ENCBINARY
)
753 /*----------------------------------------------------------------------
754 Format a strings describing one unshown part of a Mime message
756 Args: number -- A string with the part number i.e. "3.2.1"
757 body -- The body part
758 type -- 1 - Not shown, but can be
759 2 - Not shown, cannot be shown
761 width -- allowed width per line of editorial comment
762 pc -- function used to write the description comment
764 Result: formatted description written to object ref'd by "pc"
767 part_desc(char *number
, BODY
*body
, int type
, int width
, int flags
, gf_io_t pc
)
770 char buftmp
[MAILTMPLEN
], sizebuf
[256];
772 if(!gf_puts(NEWLINE
, pc
))
773 return("No space for description");
775 format_mime_size(sizebuf
, 256, body
, FMS_NONE
);
777 snprintf(buftmp
, sizeof(buftmp
), "%s", body
->description
? body
->description
: "");
778 buftmp
[sizeof(buftmp
)-1] = '\0';
779 snprintf(tmp_20k_buf
+10000, SIZEOF_20KBUF
-10000, "Part %s, %s%.2048s%s%s %s.",
781 body
->description
== NULL
? "" : "\"",
782 body
->description
== NULL
? ""
783 : (char *)rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf
, 10000, buftmp
),
784 body
->description
== NULL
? "" : "\" ",
785 type_desc(body
->type
, body
->subtype
, body
->parameter
, NULL
, 1),
787 tmp_20k_buf
[SIZEOF_20KBUF
-1] = '\0';
789 iutf8ncpy((char *)tmp_20k_buf
, (char *)(tmp_20k_buf
+10000), 10000);
790 tmp_20k_buf
[10000] = '\0';
792 t
= &tmp_20k_buf
[strlen(tmp_20k_buf
)];
795 /* if smime and not attempting print */
796 if(F_OFF(F_DONT_DO_SMIME
, ps_global
) && is_pkcs7_body(body
) && type
!= 3){
798 sstrncpy(&t
, "\015\012", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
800 if(ps_global
->smime
&& ps_global
->smime
->need_passphrase
){
802 "This part is a PKCS7 S/MIME enclosure. "
803 "You may be able to view it by entering the correct passphrase "
804 "with the \"Decrypt\" command.",
805 SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
809 "This part is a PKCS7 S/MIME enclosure. "
810 "Press \"^E\" for more information.",
811 SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
818 sstrncpy(&t
, "\015\012", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
821 if(MIME_VCARD(body
->type
,body
->subtype
))
823 /* TRANSLATORS: This is the description of an attachment that isn't being
824 shown but that can be viewed or saved. */
825 _("Not Shown. Use the \"V\" command to view or save to address book."), SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
828 /* TRANSLATORS: This is the description of an attachment that isn't being
829 shown but that can be viewed or saved. */
830 _("Not Shown. Use the \"V\" command to view or save this part."), SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
835 sstrncpy(&t
, "Cannot ", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
836 if(body
->type
!= TYPEAUDIO
&& body
->type
!= TYPEVIDEO
)
837 sstrncpy(&t
, "dis", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
840 "play this part. Press \"V\" then \"S\" to save in a file.", SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
844 sstrncpy(&t
, _("Unable to print this part."), SIZEOF_20KBUF
-(t
-tmp_20k_buf
));
849 if(!(t
= format_editorial(tmp_20k_buf
, width
, flags
, NULL
, pc
))){
850 if(!gf_puts(NEWLINE
, pc
))
851 t
= "No space for description";
858 /*----------------------------------------------------------------------
859 Can we display this type/subtype?
861 Args: type -- the MIME type to check
862 subtype -- the MIME subtype
864 use_viewer -- tell caller he should run external viewer cmd to view
868 MCD_NONE if we can't display this type at all
869 MCD_INTERNAL if we can display it internally
870 MCD_EXTERNAL if it can be displayed via an external viewer
874 mime_can_display(int type
, char *subtype
, BODY
*body
)
876 return((mailcap_can_display(type
, subtype
, body
, 0)
878 : (mailcap_can_display(type
, subtype
, body
, 1)
879 ? (MCD_EXT_PROMPT
| MCD_EXTERNAL
) : MCD_NONE
))
880 | ((type
== TYPETEXT
|| type
== TYPEMESSAGE
881 || MIME_VCARD(type
,subtype
))
882 ? MCD_INTERNAL
: MCD_NONE
));