static int parse_display_string (CT, char *, int *, int *, char *, char *,
size_t, int multipart);
static int convert_content_charset (CT, char **);
-static struct format *compile_marker(char *, char *);
+static struct format *compile_marker(char *);
static void output_marker (CT, struct format *);
static void free_markercomps (void);
static int pidcheck(int);
*/
void
-show_all_messages (CT *cts, int concat, int textonly, int inlineonly,
- char *markerform, char *markerformat)
+show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly,
+ char *markerform)
{
CT ct, *ctp;
struct format *fmt;
/*
* Compile the content marker format line
*/
- fmt = compile_marker(markerform, markerformat);
+ fmt = compile_marker(markerform);
/*
* If form is "mhl.null", suppress display of header.
/* if top-level type is ok, then display message */
if (type_ok (ct, 1))
- show_single_message (ct, formsw, concat, textonly, inlineonly, fmt);
+ show_single_message (ct, formsw, concatsw, textonly, inlineonly,
+ fmt);
}
free_markercomps();
*/
static void
-show_single_message (CT ct, char *form, int concat, int textonly,
+show_single_message (CT ct, char *form, int concatsw, int textonly,
int inlineonly, struct format *fmt)
{
sigset_t set, oset;
* the message headers.
*/
if (form)
- DisplayMsgHeader(ct, form, concat);
+ DisplayMsgHeader(ct, form, concatsw);
/* Show the body of the message */
- show_switch (ct, 0, concat, textonly, inlineonly, fmt);
+ show_switch (ct, 0, concatsw, textonly, inlineonly, fmt);
if (ct->c_fp) {
fclose (ct->c_fp);
sigaddset (&set, SIGTERM);
sigprocmask (SIG_BLOCK, &set, &oset);
- while (!concat && wait (&status) != NOTOK) {
+ while (!concatsw && wait (&status) != NOTOK) {
pidcheck (status);
continue;
}
*/
static void
-DisplayMsgHeader (CT ct, char *form, int concat)
+DisplayMsgHeader (CT ct, char *form, int concatsw)
{
pid_t child_id;
int i, vecp;
* If we've specified -(no)moreproc,
* then just pass that along.
*/
- if (nomore || concat) {
+ if (nomore || concatsw) {
vec[vecp++] = getcpy("-nomoreproc");
} else if (progsw) {
vec[vecp++] = getcpy("-moreproc");
*/
static int
-show_switch (CT ct, int alternate, int concat, int textonly, int inlineonly,
+show_switch (CT ct, int alternate, int concatsw, int textonly, int inlineonly,
struct format *fmt)
{
switch (ct->c_type) {
case CT_MULTIPART:
- return show_multi (ct, alternate, concat, textonly,
+ return show_multi (ct, alternate, concatsw, textonly,
inlineonly, fmt);
case CT_MESSAGE:
return show_partial (ct, alternate);
case MESSAGE_EXTERNAL:
- return show_external (ct, alternate, concat, textonly,
+ return show_external (ct, alternate, concatsw, textonly,
inlineonly, fmt);
case MESSAGE_RFC822:
}
case CT_TEXT:
- return show_text (ct, alternate, concat);
+ return show_text (ct, alternate, concatsw);
case CT_AUDIO:
case CT_IMAGE:
* the content-type.
*/
- if (textonly || (inlineonly && is_inline(ct))) {
+ if (textonly || (inlineonly && !is_inline(ct))) {
output_marker(ct, fmt);
return OK;
}
some code rearrangement. And to make this really ugly,
only do it in mhshow, not mhfixmsg, mhn, or mhstore. */
if (convert_content_charset (ct, &file) == OK) {
- close_encoding (ct);
+ (*ct->c_ceclosefnx) (ct);
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
} else {
- admonish (NULL, "unable to convert character set%s to %s",
- ct->c_partno ? "of part " : "",
+ admonish (NULL, "unable to convert character set%s%s to %s",
+ ct->c_partno ? " of part " : "",
ct->c_partno ? ct->c_partno : "",
content_charset (ct));
}
close (fd);
execvp (file, vec);
fprintf (stderr, "unable to exec ");
- perror ("/bin/sh");
+ perror (buffer);
_exit (-1);
/* NOTREACHED */
*/
static int
-show_text (CT ct, int alternate, int concat)
+show_text (CT ct, int alternate, int concatsw)
{
char *cp, buffer[BUFSIZ];
CI ci = &ct->c_ctinfo;
* if it is not a text part of a multipart/alternative
*/
if (!alternate || ct->c_subtype == TEXT_PLAIN) {
- if (concat)
- snprintf(buffer, sizeof(buffer), "%%l");
- else
+ if (concatsw) {
+ if (ct->c_termproc)
+ snprintf(buffer, sizeof(buffer), "%%lcat");
+ else
+ snprintf(buffer, sizeof(buffer), "%%l");
+ } else
snprintf (buffer, sizeof(buffer), "%%l%s %%F", progsw ? progsw :
moreproc && *moreproc ? moreproc : DEFAULT_PAGER);
cp = (ct->c_showproc = add (buffer, NULL));
*/
static int
-show_multi (CT ct, int alternate, int concat, int textonly, int inlineonly,
+show_multi (CT ct, int alternate, int concatsw, int textonly, int inlineonly,
struct format *fmt)
{
char *cp, buffer[BUFSIZ];
* unknown types are displayable, since they're treated as mixed
* per RFC 2046.
*/
- return show_multi_internal (ct, alternate, concat, textonly,
+ return show_multi_internal (ct, alternate, concatsw, textonly,
inlineonly, fmt);
}
*/
static int
-show_multi_internal (CT ct, int alternate, int concat, int textonly,
+show_multi_internal (CT ct, int alternate, int concatsw, int textonly,
int inlineonly, struct format *fmt)
{
int alternating, nowalternate, result;
if (part_ok (p, 1) && type_ok (p, 1)) {
int inneresult;
- inneresult = show_switch (p, nowalternate, concat, textonly,
+ inneresult = show_switch (p, nowalternate, concatsw, textonly,
inlineonly, fmt);
switch (inneresult) {
case NOTOK:
/* default method for message/rfc822 */
if (ct->c_subtype == MESSAGE_RFC822) {
- cp = (ct->c_showproc = add ("%pecho -file %F", NULL));
+ cp = (ct->c_showproc = add ("%pshow -file %F", NULL));
return show_content_aux (ct, alternate, cp, NULL);
}
*/
static int
-show_external (CT ct, int alternate, int concat, int textonly, int inlineonly,
+show_external (CT ct, int alternate, int concatsw, int textonly, int inlineonly,
struct format *fmt)
{
struct exbody *e = (struct exbody *) ct->c_ctparams;
if (!type_ok (p, 0))
return OK;
- return show_switch (p, alternate, concat, textonly, inlineonly, fmt);
+ return show_switch (p, alternate, concatsw, textonly, inlineonly, fmt);
}
size_t end;
int opened_input_file = 0;
char src_buffer[BUFSIZ];
+ size_t dest_buffer_size = BUFSIZ;
+ char *dest_buffer = mh_xmalloc(dest_buffer_size);
HF hf;
char *tempfile;
while ((inbytes = fread (src_buffer, 1,
min (bytes_to_read, sizeof src_buffer),
*fp)) > 0) {
- char dest_buffer[BUFSIZ];
ICONV_CONST char *ib = src_buffer;
char *ob = dest_buffer;
- size_t outbytes = sizeof dest_buffer;
+ size_t outbytes = dest_buffer_size;
size_t outbytes_before = outbytes;
if (end > 0) bytes_to_read -= inbytes;
+iconv_start:
if (iconv (conv_desc, &ib, &inbytes, &ob, &outbytes) ==
(size_t) -1) {
+ if (errno == E2BIG) {
+ /*
+ * Bump up the buffer by at least a factor of 2
+ * over what we need.
+ */
+ size_t bumpup = inbytes * 2, ob_off = ob - dest_buffer;
+ dest_buffer_size += bumpup;
+ dest_buffer = mh_xrealloc(dest_buffer,
+ dest_buffer_size);
+ ob = dest_buffer + ob_off;
+ outbytes += bumpup;
+ outbytes_before += bumpup;
+ goto iconv_start;
+ }
status = NOTOK;
break;
} else {
} else {
(void) m_unlink (dest);
}
+ free(dest_buffer);
#else /* ! HAVE_ICONV */
NMH_UNUSED (message_mods);
advise (NULL, "Can't convert %s to %s without iconv", src_charset,
dest_charset);
+ errno = ENOSYS;
status = NOTOK;
#endif /* ! HAVE_ICONV */
}
"%|%{ctype-name}%> ]"
static struct format *
-compile_marker(char *markerform, char *markerformat)
+compile_marker(char *markerform)
{
struct format *fmt;
char *fmtstring;
unsigned int bucket;
struct param_comp_list *pc_entry;
- fmtstring = new_fs(markerform, markerformat, DEFAULT_MARKER);
+ fmtstring = new_fs(markerform, NULL, DEFAULT_MARKER);
(void) fmt_compile(fmtstring, &fmt, 1);
free(fmtstring);