]>
diplodocus.org Git - nmh/blob - uip/mhshowsbr.c
3 * mhshowsbr.c -- routines to display the contents of MIME messages
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
12 #include <h/signals.h>
18 #include <h/mhparse.h>
22 #endif /* ! HAVE_ICONV */
32 /* flags for moreproc/header display */
38 static sigjmp_buf intrenv
;
42 int part_ok (CT
, int);
43 int type_ok (CT
, int);
44 void content_error (char *, CT
, char *, ...);
45 void flush_errors (void);
48 int list_switch (CT
, int, int, int, int);
49 int list_content (CT
, int, int, int, int);
54 void show_all_messages (CT
*);
55 int show_content_aux (CT
, int, int, char *, char *);
60 static void show_single_message (CT
, char *);
61 static void DisplayMsgHeader (CT
, char *);
62 static int show_switch (CT
, int, int);
63 static int show_content (CT
, int, int);
64 static int show_content_aux2 (CT
, int, int, char *, char *, int, int, int, int, int);
65 static int show_text (CT
, int, int);
66 static int show_multi (CT
, int, int);
67 static int show_multi_internal (CT
, int, int);
68 static int show_multi_aux (CT
, int, int, char *);
69 static int show_message_rfc822 (CT
, int, int);
70 static int show_partial (CT
, int, int);
71 static int show_external (CT
, int, int);
72 static int convert_content_charset (CT
, char **);
73 static void intrser (int);
77 * Top level entry point to show/display a group of messages
81 show_all_messages (CT
*cts
)
86 * If form is not specified, then get default form
87 * for showing headers of MIME messages.
90 formsw
= getcpy (etcpath ("mhl.headers"));
93 * If form is "mhl.null", suppress display of header.
95 if (!strcmp (formsw
, "mhl.null"))
98 for (ctp
= cts
; *ctp
; ctp
++) {
101 /* if top-level type is ok, then display message */
103 show_single_message (ct
, formsw
);
109 * Entry point to show/display a single message
113 show_single_message (CT ct
, char *form
)
119 /* Allow user executable bit so that temporary directories created by
120 * the viewer (e.g., lynx) are going to be accessible */
121 umask (ct
->c_umask
& ~(0100));
124 * If you have a format file, then display
125 * the message headers.
128 DisplayMsgHeader(ct
, form
);
132 /* Show the body of the message */
133 show_switch (ct
, 1, 0);
139 if (ct
->c_ceclosefnx
)
140 (*ct
->c_ceclosefnx
) (ct
);
142 /* block a few signals */
144 sigaddset (&set
, SIGHUP
);
145 sigaddset (&set
, SIGINT
);
146 sigaddset (&set
, SIGQUIT
);
147 sigaddset (&set
, SIGTERM
);
148 sigprocmask (SIG_BLOCK
, &set
, &oset
);
150 while (wait (&status
) != NOTOK
) {
155 /* reset the signal mask */
156 sigprocmask (SIG_SETMASK
, &oset
, &set
);
164 * Use the mhlproc to show the header fields
168 DisplayMsgHeader (CT ct
, char *form
)
175 vec
= argsplit(mhlproc
, &file
, &vecp
);
176 vec
[vecp
++] = getcpy("-form");
177 vec
[vecp
++] = getcpy(form
);
178 vec
[vecp
++] = getcpy("-nobody");
179 vec
[vecp
++] = getcpy(ct
->c_file
);
182 * If we've specified -(no)moreproc,
183 * then just pass that along.
186 vec
[vecp
++] = getcpy("-nomoreproc");
188 vec
[vecp
++] = getcpy("-moreproc");
189 vec
[vecp
++] = getcpy(progsw
);
195 for (i
= 0; (child_id
= fork()) == NOTOK
&& i
< 5; i
++)
200 adios ("fork", "unable to");
205 fprintf (stderr
, "unable to exec ");
215 arglist_free(file
, vec
);
220 * Switching routine. Call the correct routine
221 * based on content type.
225 show_switch (CT ct
, int serial
, int alternate
)
227 switch (ct
->c_type
) {
229 return show_multi (ct
, serial
, alternate
);
232 switch (ct
->c_subtype
) {
233 case MESSAGE_PARTIAL
:
234 return show_partial (ct
, serial
, alternate
);
236 case MESSAGE_EXTERNAL
:
237 return show_external (ct
, serial
, alternate
);
241 return show_message_rfc822 (ct
, serial
, alternate
);
245 return show_text (ct
, serial
, alternate
);
251 return show_content (ct
, serial
, alternate
);
254 adios (NULL
, "unknown content type %d", ct
->c_type
);
257 return 0; /* NOT REACHED */
262 * Generic method for displaying content
266 show_content (CT ct
, int serial
, int alternate
)
268 char *cp
, buffer
[BUFSIZ
];
269 CI ci
= &ct
->c_ctinfo
;
271 /* Check for invo_name-show-type/subtype */
272 snprintf (buffer
, sizeof(buffer
), "%s-show-%s/%s",
273 invo_name
, ci
->ci_type
, ci
->ci_subtype
);
274 if ((cp
= context_find (buffer
)) && *cp
!= '\0')
275 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
277 /* Check for invo_name-show-type */
278 snprintf (buffer
, sizeof(buffer
), "%s-show-%s", invo_name
, ci
->ci_type
);
279 if ((cp
= context_find (buffer
)) && *cp
!= '\0')
280 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
282 if ((cp
= ct
->c_showproc
))
283 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
285 /* complain if we are not a part of a multipart/alternative */
287 content_error (NULL
, ct
, "don't know how to display content");
294 * Parse the display string for displaying generic content
298 show_content_aux (CT ct
, int serial
, int alternate
, char *cp
, char *cracked
)
300 int fd
, len
, buflen
, quoted
;
301 int xstdin
, xlist
, xpause
, xtty
;
302 char *bp
, *pp
, *file
, buffer
[BUFSIZ
];
303 CI ci
= &ct
->c_ctinfo
;
305 if (!ct
->c_ceopenfnx
) {
307 content_error (NULL
, ct
, "don't know how to decode content");
313 if ((fd
= (*ct
->c_ceopenfnx
) (ct
, &file
)) == NOTOK
)
315 if (ct
->c_showproc
&& !strcmp (ct
->c_showproc
, "true"))
316 return (alternate
? DONE
: OK
);
318 if (! strcmp(invo_name
, "mhshow") &&
319 ct
->c_type
== CT_TEXT
&& ct
->c_subtype
== TEXT_PLAIN
) {
320 /* This has to be done after calling c_ceopenfnx, so
321 unfortunately the type checks are necessary without
322 some code rearrangement. And to make this really ugly,
323 only do it in mhshow, not mhfixmsg, mhn, or mhstore. */
324 if (convert_content_charset (ct
, &file
) != OK
) {
325 admonish (NULL
, "unable to convert character set%s to %s",
326 ct
->c_partno
? "of part " : "",
327 ct
->c_partno
? ct
->c_partno
: "",
328 content_charset (ct
));
338 strncpy (buffer
, cp
, sizeof(buffer
));
342 /* get buffer ready to go */
344 buflen
= sizeof(buffer
) - 1;
345 bp
[0] = bp
[buflen
] = '\0';
348 /* Now parse display string */
349 for ( ; *cp
&& buflen
> 0; cp
++) {
355 /* insert parameters from Content-Type field */
360 for (ap
= ci
->ci_attrs
, ep
= ci
->ci_values
; *ap
; ap
++, ep
++) {
361 snprintf (bp
, buflen
, "%s%s=\"%s\"", s
, *ap
, *ep
);
371 /* insert content description */
375 s
= trimcpy (ct
->c_descr
);
376 strncpy (bp
, s
, buflen
);
382 /* exclusive execution */
387 /* %e, %f, and stdin is terminal not content */
393 /* insert filename containing content */
394 snprintf (bp
, buflen
, "'%s'", file
);
395 /* since we've quoted the file argument, set things up
396 * to look past it, to avoid problems with the quoting
397 * logic below. (I know, I should figure out what's
398 * broken with the quoting logic, but..)
407 /* %l, and pause prior to displaying content */
412 /* display listing prior to displaying content */
417 /* insert subtype of content */
418 strncpy (bp
, ci
->ci_subtype
, buflen
);
422 /* insert character % */
435 /* Did we actually insert something? */
437 /* Insert single quote if not inside quotes already */
438 if (!quoted
&& buflen
) {
440 memmove (pp
+ 1, pp
, len
);
445 /* Escape existing quotes */
446 while ((pp
= strchr (pp
, '\'')) && buflen
> 3) {
448 memmove (pp
+ 3, pp
, len
);
455 /* If pp is still set, that means we ran out of space. */
458 if (!quoted
&& buflen
) {
476 (ct
->c_termproc
&& (size_t) buflen
<= strlen(ct
->c_termproc
))) {
477 /* content_error would provide a more useful error message
478 * here, except that if we got overrun, it probably would
481 fprintf(stderr
, "Buffer overflow constructing show command!\n");
485 /* use charset string to modify display method */
486 if (ct
->c_termproc
) {
489 strncpy (term
, buffer
, sizeof(term
));
490 snprintf (buffer
, sizeof(buffer
), ct
->c_termproc
, term
);
494 return show_content_aux2 (ct
, serial
, alternate
, cracked
, buffer
,
495 fd
, xlist
, xpause
, xstdin
, xtty
);
500 * Routine to actually display the content
504 show_content_aux2 (CT ct
, int serial
, int alternate
, char *cracked
, char *buffer
,
505 int fd
, int xlist
, int xpause
, int xstdin
, int xtty
)
509 char *vec
[4], exec
[BUFSIZ
+ sizeof "exec "];
511 if (debugsw
|| cracked
) {
514 fprintf (stderr
, "%s msg %s", cracked
? "storing" : "show",
517 fprintf (stderr
, " part %s", ct
->c_partno
);
519 fprintf (stderr
, " using command (cd %s; %s)\n", cracked
, buffer
);
521 fprintf (stderr
, " using command %s\n", buffer
);
524 if (xpid
< 0 || (xtty
&& xpid
)) {
527 pidcheck(pidwait (xpid
, NOTOK
));
534 if (ct
->c_type
== CT_MULTIPART
)
535 list_content (ct
, -1, 1, 0, 0);
537 list_switch (ct
, -1, 1, 0, 0);
539 if (xpause
&& isatty (fileno (stdout
))) {
541 SIGNAL_HANDLER istat
;
543 if (SOprintf ("Press <return> to show content..."))
544 printf ("Press <return> to show content...");
546 istat
= SIGNAL (SIGINT
, intrser
);
547 if ((intr
= sigsetjmp (intrenv
, 1)) == OK
) {
550 read (fileno (stdout
), prompt
, sizeof(prompt
));
552 SIGNAL (SIGINT
, istat
);
553 if (intr
!= OK
|| prompt
[0] == 'n') {
554 (*ct
->c_ceclosefnx
) (ct
);
555 return (alternate
? DONE
: NOTOK
);
557 if (prompt
[0] == 'q') done(OK
);
561 snprintf (exec
, sizeof(exec
), "exec %s", buffer
);
570 for (i
= 0; (child_id
= fork()) == NOTOK
&& i
< 5; i
++)
574 advise ("fork", "unable to");
575 (*ct
->c_ceclosefnx
) (ct
);
584 execvp ("/bin/sh", vec
);
585 fprintf (stderr
, "unable to exec ");
592 ct
->c_pid
= child_id
;
596 pidcheck (pidXwait (child_id
, NULL
));
600 (*ct
->c_ceclosefnx
) (ct
);
601 return (alternate
? DONE
: OK
);
607 * show content of type "text"
611 show_text (CT ct
, int serial
, int alternate
)
613 char *cp
, buffer
[BUFSIZ
];
614 CI ci
= &ct
->c_ctinfo
;
616 /* Check for invo_name-show-type/subtype */
617 snprintf (buffer
, sizeof(buffer
), "%s-show-%s/%s",
618 invo_name
, ci
->ci_type
, ci
->ci_subtype
);
619 if ((cp
= context_find (buffer
)) && *cp
!= '\0')
620 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
622 /* Check for invo_name-show-type */
623 snprintf (buffer
, sizeof(buffer
), "%s-show-%s", invo_name
, ci
->ci_type
);
624 if ((cp
= context_find (buffer
)) && *cp
!= '\0')
625 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
628 * Use default method if content is text/plain, or if
629 * if it is not a text part of a multipart/alternative
631 if (!alternate
|| ct
->c_subtype
== TEXT_PLAIN
) {
632 snprintf (buffer
, sizeof(buffer
), "%%p%s '%%F'", progsw
? progsw
:
633 moreproc
&& *moreproc
? moreproc
: DEFAULT_PAGER
);
634 cp
= (ct
->c_showproc
= add (buffer
, NULL
));
635 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
643 * show message body of type "multipart"
647 show_multi (CT ct
, int serial
, int alternate
)
649 char *cp
, buffer
[BUFSIZ
];
650 CI ci
= &ct
->c_ctinfo
;
652 /* Check for invo_name-show-type/subtype */
653 snprintf (buffer
, sizeof(buffer
), "%s-show-%s/%s",
654 invo_name
, ci
->ci_type
, ci
->ci_subtype
);
655 if ((cp
= context_find (buffer
)) && *cp
!= '\0')
656 return show_multi_aux (ct
, serial
, alternate
, cp
);
658 /* Check for invo_name-show-type */
659 snprintf (buffer
, sizeof(buffer
), "%s-show-%s", invo_name
, ci
->ci_type
);
660 if ((cp
= context_find (buffer
)) && *cp
!= '\0')
661 return show_multi_aux (ct
, serial
, alternate
, cp
);
663 if ((cp
= ct
->c_showproc
))
664 return show_multi_aux (ct
, serial
, alternate
, cp
);
667 * Use default method to display this multipart content. Even
668 * unknown types are displayable, since they're treated as mixed
671 return show_multi_internal (ct
, serial
, alternate
);
676 * show message body of subtypes of multipart that
677 * we understand directly (mixed, alternate, etc...)
681 show_multi_internal (CT ct
, int serial
, int alternate
)
683 int alternating
, nowalternate
, nowserial
, result
;
684 struct multipart
*m
= (struct multipart
*) ct
->c_ctparams
;
690 nowalternate
= alternate
;
692 if (ct
->c_subtype
== MULTI_PARALLEL
) {
693 nowserial
= serialsw
;
694 } else if (ct
->c_subtype
== MULTI_ALTERNATE
) {
702 * unknown subtypes of multipart (treat as mixed per rfc2046)
707 /* block a few signals */
710 sigaddset (&set
, SIGHUP
);
711 sigaddset (&set
, SIGINT
);
712 sigaddset (&set
, SIGQUIT
);
713 sigaddset (&set
, SIGTERM
);
714 sigprocmask (SIG_BLOCK
, &set
, &oset
);
718 * alternate -> we are a part inside an multipart/alternative
719 * alternating -> we are a multipart/alternative
722 result
= alternate
? NOTOK
: OK
;
724 for (part
= m
->mp_parts
; part
; part
= part
->mp_next
) {
727 if (part_ok (p
, 1) && type_ok (p
, 1)) {
730 inneresult
= show_switch (p
, nowserial
, nowalternate
);
731 switch (inneresult
) {
733 if (alternate
&& !alternating
) {
746 alternate
= nowalternate
= 0;
756 if (alternating
&& !part
) {
758 content_error (NULL
, ct
, "don't know how to display any of the contents");
763 if (serial
&& !nowserial
) {
769 for (part
= m
->mp_parts
; part
; part
= part
->mp_next
) {
773 if (kill (p
->c_pid
, 0) == NOTOK
)
780 while (kids
> 0 && (pid
= wait (&status
)) != NOTOK
) {
783 for (part
= m
->mp_parts
; part
; part
= part
->mp_next
) {
788 if (p
->c_pid
== pid
) {
799 /* reset the signal mask */
800 sigprocmask (SIG_SETMASK
, &oset
, &set
);
808 * Parse display string for multipart content
809 * and use external program to display it.
813 show_multi_aux (CT ct
, int serial
, int alternate
, char *cp
)
815 int len
, buflen
, quoted
;
816 int xlist
, xpause
, xtty
;
817 char *bp
, *pp
, *file
, buffer
[BUFSIZ
];
818 struct multipart
*m
= (struct multipart
*) ct
->c_ctparams
;
820 CI ci
= &ct
->c_ctinfo
;
823 for (part
= m
->mp_parts
; part
; part
= part
->mp_next
) {
826 if (!p
->c_ceopenfnx
) {
828 content_error (NULL
, p
, "don't know how to decode content");
832 if (p
->c_storage
== NULL
) {
834 if ((*p
->c_ceopenfnx
) (p
, &file
) == NOTOK
)
837 /* I'm not sure if this is necessary? */
838 p
->c_storage
= add (file
, NULL
);
840 if (p
->c_showproc
&& !strcmp (p
->c_showproc
, "true"))
841 return (alternate
? DONE
: OK
);
842 (*p
->c_ceclosefnx
) (p
);
850 /* get buffer ready to go */
852 buflen
= sizeof(buffer
) - 1;
853 bp
[0] = bp
[buflen
] = '\0';
856 /* Now parse display string */
857 for ( ; *cp
&& buflen
> 0; cp
++) {
862 /* insert parameters from Content-Type field */
867 for (ap
= ci
->ci_attrs
, ep
= ci
->ci_values
; *ap
; ap
++, ep
++) {
868 snprintf (bp
, buflen
, "%s%s=\"%s\"", s
, *ap
, *ep
);
878 /* insert content description */
882 s
= trimcpy (ct
->c_descr
);
883 strncpy (bp
, s
, buflen
);
889 /* exclusive execution */
899 /* insert filename(s) containing content */
903 for (part
= m
->mp_parts
; part
; part
= part
->mp_next
) {
906 snprintf (bp
, buflen
, "%s'%s'", s
, p
->c_storage
);
912 /* set our starting pointer back to bp, to avoid
913 * requoting the filenames we just added
920 /* %l, and pause prior to displaying content */
925 /* display listing prior to displaying content */
930 /* insert subtype of content */
931 strncpy (bp
, ci
->ci_subtype
, buflen
);
935 /* insert character % */
948 /* Did we actually insert something? */
950 /* Insert single quote if not inside quotes already */
951 if (!quoted
&& buflen
) {
953 memmove (pp
+ 1, pp
, len
);
958 /* Escape existing quotes */
959 while ((pp
= strchr (pp
, '\'')) && buflen
> 3) {
961 memmove (pp
+ 3, pp
, len
);
968 /* If pp is still set, that means we ran out of space. */
971 if (!quoted
&& buflen
) {
989 (ct
->c_termproc
&& buflen
<= (ssize_t
) strlen(ct
->c_termproc
))) {
990 /* content_error would provide a more useful error message
991 * here, except that if we got overrun, it probably would
994 fprintf(stderr
, "Buffer overflow constructing show command!\n");
998 /* use charset string to modify display method */
999 if (ct
->c_termproc
) {
1002 strncpy (term
, buffer
, sizeof(term
));
1003 snprintf (buffer
, sizeof(buffer
), ct
->c_termproc
, term
);
1006 return show_content_aux2 (ct
, serial
, alternate
, NULL
, buffer
,
1007 NOTOK
, xlist
, xpause
, 0, xtty
);
1012 * show content of type "message/rfc822"
1016 show_message_rfc822 (CT ct
, int serial
, int alternate
)
1018 char *cp
, buffer
[BUFSIZ
];
1019 CI ci
= &ct
->c_ctinfo
;
1021 /* Check for invo_name-show-type/subtype */
1022 snprintf (buffer
, sizeof(buffer
), "%s-show-%s/%s",
1023 invo_name
, ci
->ci_type
, ci
->ci_subtype
);
1024 if ((cp
= context_find (buffer
)) && *cp
!= '\0')
1025 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
1027 /* Check for invo_name-show-type */
1028 snprintf (buffer
, sizeof(buffer
), "%s-show-%s", invo_name
, ci
->ci_type
);
1029 if ((cp
= context_find (buffer
)) && *cp
!= '\0')
1030 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
1032 if ((cp
= ct
->c_showproc
))
1033 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
1035 /* default method for message/rfc822 */
1036 if (ct
->c_subtype
== MESSAGE_RFC822
) {
1037 cp
= (ct
->c_showproc
= add ("%pshow -file '%F'", NULL
));
1038 return show_content_aux (ct
, serial
, alternate
, cp
, NULL
);
1041 /* complain if we are not a part of a multipart/alternative */
1043 content_error (NULL
, ct
, "don't know how to display content");
1050 * Show content of type "message/partial".
1054 show_partial (CT ct
, int serial
, int alternate
)
1056 NMH_UNUSED (serial
);
1057 NMH_UNUSED (alternate
);
1059 content_error (NULL
, ct
,
1060 "in order to display this message, you must reassemble it");
1066 * Show content of type "message/external".
1068 * THE ERROR CHECKING IN THIS ONE IS NOT DONE YET.
1072 show_external (CT ct
, int serial
, int alternate
)
1074 struct exbody
*e
= (struct exbody
*) ct
->c_ctparams
;
1075 CT p
= e
->eb_content
;
1077 if (!type_ok (p
, 0))
1080 return show_switch (p
, serial
, alternate
);
1085 convert_charset (CT ct
, char *dest_charset
, int *message_mods
) {
1086 char *src_charset
= content_charset (ct
);
1089 /* norm_charmap() is case sensitive. */
1090 char *src_charset_u
= upcase (src_charset
);
1091 char *dest_charset_u
= upcase (dest_charset
);
1092 int different_charsets
=
1093 strcmp (norm_charmap (src_charset
), norm_charmap (dest_charset
));
1095 free (dest_charset_u
);
1096 free (src_charset_u
);
1098 if (different_charsets
) {
1100 iconv_t conv_desc
= NULL
;
1107 int opened_input_file
= 0;
1108 char src_buffer
[BUFSIZ
];
1112 if ((conv_desc
= iconv_open (dest_charset
, src_charset
)) ==
1114 advise (NULL
, "Can't convert %s to %s", src_charset
, dest_charset
);
1118 if ((tempfile
= m_mktemp2 (NULL
, invo_name
, &fd
, NULL
)) == NULL
) {
1119 adios (NULL
, "unable to create temporary file in %s",
1122 dest
= add (tempfile
, NULL
);
1124 if (ct
->c_cefile
.ce_file
) {
1125 file
= &ct
->c_cefile
.ce_file
;
1126 fp
= &ct
->c_cefile
.ce_fp
;
1128 } else if (ct
->c_file
) {
1131 begin
= (size_t) ct
->c_begin
;
1132 end
= (size_t) ct
->c_end
;
1133 } /* else no input file: shouldn't happen */
1135 if (file
&& *file
&& fp
) {
1137 if ((*fp
= fopen (*file
, "r")) == NULL
) {
1138 advise (*file
, "unable to open for reading");
1141 opened_input_file
= 1;
1148 size_t bytes_to_read
=
1149 end
> 0 && end
> begin
? end
- begin
: sizeof src_buffer
;
1151 fseeko (*fp
, begin
, SEEK_SET
);
1152 while ((inbytes
= fread (src_buffer
, 1,
1153 min (bytes_to_read
, sizeof src_buffer
),
1155 char dest_buffer
[BUFSIZ
];
1156 ICONV_CONST
char *ib
= src_buffer
;
1157 char *ob
= dest_buffer
;
1158 size_t outbytes
= sizeof dest_buffer
;
1159 size_t outbytes_before
= outbytes
;
1161 if (end
> 0) bytes_to_read
-= inbytes
;
1163 if (iconv (conv_desc
, &ib
, &inbytes
, &ob
, &outbytes
) ==
1168 write (fd
, dest_buffer
, outbytes_before
- outbytes
);
1172 if (opened_input_file
) {
1178 iconv_close (conv_desc
);
1182 /* Replace the decoded file with the converted one. */
1183 if (ct
->c_cefile
.ce_file
) {
1184 if (ct
->c_cefile
.ce_unlink
) {
1185 (void) m_unlink (ct
->c_cefile
.ce_file
);
1187 free (ct
->c_cefile
.ce_file
);
1189 ct
->c_cefile
.ce_file
= dest
;
1190 ct
->c_cefile
.ce_unlink
= 1;
1194 /* Update ci_attrs. */
1195 src_charset
= dest_charset
;
1197 /* Update ct->c_ctline. */
1200 update_attr (ct
->c_ctline
, "charset=", dest_charset
);
1202 free (ct
->c_ctline
);
1203 ct
->c_ctline
= ctline
;
1204 } /* else no CT line, which is odd */
1206 /* Update Content-Type header field. */
1207 for (hf
= ct
->c_first_hf
; hf
; hf
= hf
->next
) {
1208 if (! strcasecmp (TYPE_FIELD
, hf
->name
)) {
1209 char *ctline_less_newline
=
1210 update_attr (hf
->value
, "charset=", dest_charset
);
1211 char *ctline
= concat (ctline_less_newline
, "\n", NULL
);
1212 free (ctline_less_newline
);
1220 (void) m_unlink (dest
);
1222 #else /* ! HAVE_ICONV */
1223 NMH_UNUSED (message_mods
);
1225 advise (NULL
, "Can't convert %s to %s without iconv", src_charset
,
1228 #endif /* ! HAVE_ICONV */
1236 convert_content_charset (CT ct
, char **file
) {
1238 /* Using current locale, see if the content needs to be converted. */
1240 /* content_charset() cannot return NULL. */
1241 char *charset
= content_charset (ct
);
1243 if (! check_charset (charset
, strlen (charset
))) {
1246 if (convert_charset (ct
, get_charset (), &unused
) == 0) {
1247 *file
= ct
->c_cefile
.ce_file
;
1252 #endif /* ! HAVE_ICONV */
1264 siglongjmp (intrenv
, DONE
);