/*
- * mhshowsbr.c -- routines to display the contents of MIME messages
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** mhshowsbr.c -- routines to display the contents of MIME messages
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
#endif
/*
- * Just use sigjmp/longjmp on older machines that
- * don't have sigsetjmp/siglongjmp.
- */
+** Just use sigjmp/longjmp on older machines that
+** don't have sigsetjmp/siglongjmp.
+*/
#ifndef HAVE_SIGSETJMP
# define sigjmp_buf jmp_buf
# define sigsetjmp(env,mask) setjmp(env)
int list_content (CT, int, int, int, int);
/*
- * prototypes
- */
+** prototypes
+*/
void show_all_messages (CT *);
int show_content_aux (CT, int, int, char *, char *);
/*
- * static prototypes
- */
+** static prototypes
+*/
static void show_single_message (CT, char *);
static void DisplayMsgHeader (CT, char *);
static int show_switch (CT, int, int);
static int show_content (CT, int, int);
-static int show_content_aux2 (CT, int, int, char *, char *, int, int, int, int, int);
+static int show_content_aux2 (CT, int, int, char *, char *,
+ int, int, int, int, int);
static int show_text (CT, int, int);
static int show_multi (CT, int, int);
static int show_multi_internal (CT, int, int);
/*
- * Top level entry point to show/display a group of messages
- */
+** Top level entry point to show/display a group of messages
+*/
void
show_all_messages (CT *cts)
CT ct, *ctp;
/*
- * If form is not specified, then get default form
- * for showing headers of MIME messages.
- */
+ ** If form is not specified, then get default form
+ ** for showing headers of MIME messages.
+ */
if (!formsw)
formsw = getcpy (etcpath ("mhl.headers"));
/*
- * If form is "mhl.null", suppress display of header.
- */
+ ** If form is "mhl.null", suppress display of header.
+ */
if (!strcmp (formsw, "mhl.null"))
formsw = NULL;
/*
- * Entry point to show/display a single message
- */
+** Entry point to show/display a single message
+*/
static void
show_single_message (CT ct, char *form)
int status;
#endif
- /* Allow user executable bit so that temporary directories created by
- * the viewer (e.g., lynx) are going to be accessible */
+ /*
+ ** Allow user executable bit so that temporary directories created by
+ ** the viewer (e.g., lynx) are going to be accessible
+ */
umask (ct->c_umask & ~(0100));
/*
- * If you have a format file, then display
- * the message headers.
- */
+ ** If you have a format file, then display
+ ** the message headers.
+ */
if (form)
DisplayMsgHeader(ct, form);
else
/*
- * Use the mhlproc to show the header fields
- */
+** Use the mhlproc to show the header fields
+*/
static void
DisplayMsgHeader (CT ct, char *form)
vec[vecp++] = ct->c_file;
/*
- * If we've specified -(no)moreproc,
- * then just pass that along.
- */
+ ** If we've specified -(no)moreproc,
+ ** then just pass that along.
+ */
if (nomore) {
vec[vecp++] = "-nomoreproc";
} else if (progsw) {
/*
- * Switching routine. Call the correct routine
- * based on content type.
- */
+** Switching routine. Call the correct routine
+** based on content type.
+*/
static int
show_switch (CT ct, int serial, int alternate)
/*
- * Generic method for displaying content
- */
+** Generic method for displaying content
+*/
static int
show_content (CT ct, int serial, int alternate)
/*
- * Parse the display string for displaying generic content
- */
+** Parse the display string for displaying generic content
+*/
int
show_content_aux (CT ct, int serial, int alternate, char *cp, char *cracked)
if (!ct->c_ceopenfnx) {
if (!alternate)
- content_error (NULL, ct, "don't know how to decode content");
+ content_error (NULL, ct,
+ "don't know how to decode content");
return NOTOK;
}
char **ap, **ep;
char *s = "";
- for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
+ for (ap = ci->ci_attrs, ep = ci->ci_values;
+ *ap; ap++, ep++) {
+ snprintf (bp, buflen, "%s%s=\"%s\"",
+ s, *ap, *ep);
len = strlen (bp);
bp += len;
buflen -= len;
case 'f':
/* insert filename containing content */
snprintf (bp, buflen, "'%s'", file);
- /* since we've quoted the file argument, set things up
- * to look past it, to avoid problems with the quoting
- * logic below. (I know, I should figure out what's
- * broken with the quoting logic, but..)
- */
+ /*
+ ** since we've quoted the file argument,
+ ** set things up to look past it, to avoid
+ ** problems with the quoting logic below.
+ ** (I know, I should figure out what's
+ ** broken with the quoting logic, but..)
+ */
len = strlen(bp);
buflen -= len;
bp += len;
/* and fall... */
case 'l':
- /* display listing prior to displaying content */
+ /*
+ ** display listing prior to displaying content
+ */
xlist = !nolist;
break;
/* Did we actually insert something? */
if (bp != pp) {
- /* Insert single quote if not inside quotes already */
+ /*
+ ** Insert single quote if not inside quotes
+ ** already
+ */
if (!quoted && buflen) {
len = strlen (pp);
memmove (pp + 1, pp, len);
buflen -= 3;
bp += 3;
}
- /* If pp is still set, that means we ran out of space. */
+ /*
+ ** If pp is still set, that means we ran
+ ** out of space.
+ */
if (pp)
buflen = 0;
if (!quoted && buflen) {
}
if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) {
- /* content_error would provide a more useful error message
- * here, except that if we got overrun, it probably would
- * too.
- */
+ /*
+ ** content_error would provide a more useful error message
+ ** here, except that if we got overrun, it probably would
+ ** too.
+ */
fprintf(stderr, "Buffer overflow constructing show command!\n");
return NOTOK;
}
got_command:
return show_content_aux2 (ct, serial, alternate, cracked, buffer,
- fd, xlist, xpause, xstdin, xtty);
+ fd, xlist, xpause, xstdin, xtty);
}
/*
- * Routine to actually display the content
- */
+** Routine to actually display the content
+*/
static int
show_content_aux2 (CT ct, int serial, int alternate, char *cracked,
if (ct->c_partno)
fprintf (stderr, " part %s", ct->c_partno);
if (cracked)
- fprintf (stderr, " using command (cd %s; %s)\n", cracked, buffer);
+ fprintf (stderr, " using command (cd %s; %s)\n",
+ cracked, buffer);
else
fprintf (stderr, " using command %s\n", buffer);
}
/*
- * show content of type "text"
- */
+** show content of type "text"
+*/
static int
show_text (CT ct, int serial, int alternate)
return show_content_aux (ct, serial, alternate, cp, NULL);
/*
- * Use default method if content is text/plain, or if
- * if it is not a text part of a multipart/alternative
- */
+ ** Use default method if content is text/plain, or if
+ ** if it is not a text part of a multipart/alternative
+ */
if (!alternate || ct->c_subtype == TEXT_PLAIN) {
snprintf (buffer, sizeof(buffer), "%%p%s '%%F'", progsw ? progsw :
moreproc && *moreproc ? moreproc : "more");
/*
- * show message body of type "multipart"
- */
+** show message body of type "multipart"
+*/
static int
show_multi (CT ct, int serial, int alternate)
return show_multi_aux (ct, serial, alternate, cp);
/*
- * Use default method to display this multipart content
- * if it is not a (nested) part of a multipart/alternative,
- * or if it is one of the known subtypes of multipart.
- */
+ ** Use default method to display this multipart content
+ ** if it is not a (nested) part of a multipart/alternative,
+ ** or if it is one of the known subtypes of multipart.
+ */
if (!alternate || ct->c_subtype != MULTI_UNKNOWN)
return show_multi_internal (ct, serial, alternate);
/*
- * show message body of subtypes of multipart that
- * we understand directly (mixed, alternate, etc...)
- */
+** show message body of subtypes of multipart that
+** we understand directly (mixed, alternate, etc...)
+*/
static int
show_multi_internal (CT ct, int serial, int alternate)
nowserial = serial;
} else {
/*
- * multipart/mixed
- * mutlipart/digest
- * unknown subtypes of multipart (treat as mixed per rfc2046)
- */
+ ** multipart/mixed
+ ** mutlipart/digest
+ ** unknown subtypes of multipart (treat as mixed per rfc2046)
+ */
nowserial = serial;
}
}
/*
- * alternate -> we are a part inside an multipart/alternative
- * alternating -> we are a multipart/alternative
- */
+** alternate -> we are a part inside an multipart/alternative
+** alternating -> we are a multipart/alternative
+*/
result = alternate ? NOTOK : OK;
/*
- * Parse display string for multipart content
- * and use external program to display it.
- */
+** Parse display string for multipart content
+** and use external program to display it.
+*/
static int
show_multi_aux (CT ct, int serial, int alternate, char *cp)
char **ap, **ep;
char *s = "";
- for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
+ for (ap = ci->ci_attrs, ep = ci->ci_values;
+ *ap; ap++, ep++) {
+ snprintf (bp, buflen, "%s%s=\"%s\"",
+ s, *ap, *ep);
len = strlen (bp);
bp += len;
buflen -= len;
{
char *s = "";
- for (part = m->mp_parts; part; part = part->mp_next) {
+ for (part = m->mp_parts; part;
+ part = part->mp_next) {
p = part->mp_part;
snprintf (bp, buflen, "%s'%s'", s, p->c_storage);
buflen -= len;
s = " ";
}
- /* set our starting pointer back to bp, to avoid
- * requoting the filenames we just added
- */
+ /*
+ ** set our starting pointer back to bp,
+ ** to avoid requoting the filenames we
+ ** just added
+ */
pp = bp;
}
break;
/* and fall... */
case 'l':
- /* display listing prior to displaying content */
+ /*
+ ** display listing prior to displaying content
+ */
xlist = !nolist;
break;
/* Did we actually insert something? */
if (bp != pp) {
- /* Insert single quote if not inside quotes already */
+ /*
+ ** Insert single quote if not inside quotes
+ ** already
+ */
if (!quoted && buflen) {
len = strlen (pp);
memmove (pp + 1, pp, len);
buflen -= 3;
bp += 3;
}
- /* If pp is still set, that means we ran out of space. */
+ /*
+ ** If pp is still set, that means we ran
+ ** out of space.
+ */
if (pp)
buflen = 0;
if (!quoted && buflen) {
}
if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) {
- /* content_error would provide a more useful error message
- * here, except that if we got overrun, it probably would
- * too.
- */
+ /*
+ ** content_error would provide a more useful error message
+ ** here, except that if we got overrun, it probably would
+ ** too.
+ */
fprintf(stderr, "Buffer overflow constructing show command!\n");
return NOTOK;
}
}
return show_content_aux2 (ct, serial, alternate, NULL, buffer,
- NOTOK, xlist, xpause, 0, xtty);
+ NOTOK, xlist, xpause, 0, xtty);
}
/*
- * show content of type "message/rfc822"
- */
+** show content of type "message/rfc822"
+*/
static int
show_message_rfc822 (CT ct, int serial, int alternate)
/*
- * Show content of type "message/partial".
- */
+** Show content of type "message/partial".
+*/
static int
show_partial (CT ct, int serial, int alternate)
/*
- * Show content of type "message/external".
- *
- * THE ERROR CHECKING IN THIS ONE IS NOT DONE YET.
- */
+** Show content of type "message/external".
+**
+** THE ERROR CHECKING IN THIS ONE IS NOT DONE YET.
+*/
static int
show_external (CT ct, int serial, int alternate)