projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow a user to enable setgid of inc when running distcheck with:
[mmh]
/
uip
/
mhlsbr.c
diff --git
a/uip/mhlsbr.c
b/uip/mhlsbr.c
index
ae1fb5d
..
be63c25
100644
(file)
--- a/
uip/mhlsbr.c
+++ b/
uip/mhlsbr.c
@@
-13,7
+13,7
@@
#include <h/fmt_scan.h>
#include <h/tws.h>
#include <h/utils.h>
#include <h/fmt_scan.h>
#include <h/tws.h>
#include <h/utils.h>
-#include <h/m_setjmp.h>
+#include <setjmp.h>
#include <signal.h>
#include <errno.h>
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>
#include <sys/wait.h>
@@
-156,11
+156,13
@@
static struct mcomp *fmthd = NULL;
static struct mcomp *fmttl = NULL;
static struct mcomp global = {
static struct mcomp *fmttl = NULL;
static struct mcomp global = {
- NULL, NULL, NULL, NULL, NULL, NULL, 0, -1, 80, -1, 40, BELL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, 0, -1, 80, -1, 40, BELL, NULL, NULL,
+ 0, NULL
};
static struct mcomp holder = {
};
static struct mcomp holder = {
- NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NOCOMPONENT, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NOCOMPONENT, NULL, NULL,
+ 0, NULL
};
struct pair {
};
struct pair {
@@
-221,6
+223,22
@@
static struct triple triples[] = {
{ NULL, 0, 0 }
};
{ NULL, 0, 0 }
};
+static char *addrcomps[] = {
+ "from",
+ "sender",
+ "reply-to",
+ "to",
+ "cc",
+ "bcc",
+ "resent-from",
+ "resent-sender",
+ "resent-reply-to",
+ "resent-to",
+ "resent-cc",
+ "resent-bcc",
+ NULL
+};
+
static int bellflg = 0;
static int clearflg = 0;
static int bellflg = 0;
static int clearflg = 0;
@@
-238,6
+256,8
@@
static int issue = 0;
static int exitstat = 0;
static int mhldebug = 0;
static int exitstat = 0;
static int mhldebug = 0;
+static int filesize = 0;
+
#define PITTY (-1)
#define NOTTY 0
#define ISTTY 1
#define PITTY (-1)
#define NOTTY 0
#define ISTTY 1
@@
-318,7
+338,8
@@
int
mhl (int argc, char **argv)
{
int length = 0, nomore = 0;
mhl (int argc, char **argv)
{
int length = 0, nomore = 0;
- int i, width = 0, vecp = 0;
+ unsigned int i, vecp = 0;;
+ int width = 0;
char *cp, *folder = NULL, *form = NULL;
char buf[BUFSIZ], *files[MAXARGS];
char **argp, **arguments;
char *cp, *folder = NULL, *form = NULL;
char buf[BUFSIZ], *files[MAXARGS];
char **argp, **arguments;
@@
-845,8
+866,9
@@
process (char *folder, char *fname, int ofilen, int ofilec)
char *cp = NULL;
FILE *fp = NULL;
struct mcomp *c1;
char *cp = NULL;
FILE *fp = NULL;
struct mcomp *c1;
+ struct stat st;
- switch (m_setjmp (env)) {
+ switch (setjmp (env)) {
case OK:
if (fname) {
fp = mhl_action ? (*mhl_action) (fname) : fopen (fname, "r");
case OK:
if (fname) {
fp = mhl_action ? (*mhl_action) (fname) : fopen (fname, "r");
@@
-859,6
+881,11
@@
process (char *folder, char *fname, int ofilen, int ofilec)
fname = "(stdin)";
fp = stdin;
}
fname = "(stdin)";
fp = stdin;
}
+ if (fstat(fileno(fp), &st) == 0) {
+ filesize = st.st_size;
+ } else {
+ filesize = 0;
+ }
cp = folder ? concat (folder, ":", fname, NULL) : getcpy (fname);
if (ontty != PITTY)
SIGNAL (SIGINT, intrser);
cp = folder ? concat (folder, ":", fname, NULL) : getcpy (fname);
if (ontty != PITTY)
SIGNAL (SIGINT, intrser);
@@
-1109,7
+1136,7
@@
mcomp_format (struct mcomp *c1, struct mcomp *c2)
c2->c_text = NULL;
dat[0] = 0;
dat[1] = 0;
c2->c_text = NULL;
dat[0] = 0;
dat[1] = 0;
- dat[2] = 0;
+ dat[2] = filesize;
dat[3] = sizeof(buffer) - 1;
dat[4] = 0;
fmt_compile (c1->c_nfs, &c1->c_fmt);
dat[3] = sizeof(buffer) - 1;
dat[4] = 0;
fmt_compile (c1->c_nfs, &c1->c_fmt);
@@
-1140,13
+1167,8
@@
mcomp_format (struct mcomp *c1, struct mcomp *c2)
p->pq_error = getcpy (error);
} else {
if ((c1->c_flags & FACEDFLT) && c2->c_face == NULL) {
p->pq_error = getcpy (error);
} else {
if ((c1->c_flags & FACEDFLT) && c2->c_face == NULL) {
- char *h, *o;
- if ((h = mp->m_host) == NULL)
- h = LocalName (0);
- if ((o = OfficialName (h)))
- h = o;
- c2->c_face = concat ("address ", h, " ", mp->m_mbox,
- NULL);
+ char *h = mp->m_host ? mp->m_host : LocalName (0);
+ c2->c_face = concat ("address ", h, " ", mp->m_mbox, NULL);
}
p->pq_text = getcpy (mp->m_text);
mnfree (mp);
}
p->pq_text = getcpy (mp->m_text);
mnfree (mp);
@@
-1558,11
+1580,7
@@
face_format (struct mcomp *c1)
if ((cp = getname (cp))) {
if ((mp = getm (cp, NULL, 0, AD_NAME, NULL))) {
if ((cp = getname (cp))) {
if ((mp = getm (cp, NULL, 0, AD_NAME, NULL))) {
- char *h, *o;
- if ((h = mp->m_host) == NULL)
- h = LocalName (0);
- if ((o = OfficialName (h)))
- h = o;
+ char *h = mp->m_host ? mp->m_host : LocalName (0);
c1->c_face = concat ("address ", h, " ", mp->m_mbox, NULL);
}
c1->c_face = concat ("address ", h, " ", mp->m_mbox, NULL);
}
@@
-1754,7
+1772,7
@@
mhlsbr (int argc, char **argv, FILE *(*action)())
char *cp = NULL;
struct mcomp *c1;
char *cp = NULL;
struct mcomp *c1;
- switch (m_setjmp (mhlenv)) {
+ switch (setjmp (mhlenv)) {
case OK:
cp = invo_name;
sleepsw = 0; /* XXX */
case OK:
cp = invo_name;
sleepsw = 0; /* XXX */
@@
-1905,10
+1923,22
@@
compileargs (struct mcomp *c1, char *nfs)
{
struct format *fmt;
struct arglist *args;
{
struct format *fmt;
struct arglist *args;
- int i;
+ char **ap;
+ struct comp *cptr;
+ unsigned int i;
i = fmt_compile(nfs, &fmt);
i = fmt_compile(nfs, &fmt);
+ /*
+ * Search through and mark any components that are address components
+ */
+
+ for (ap = addrcomps; *ap; ap++) {
+ FINDCOMP (cptr, *ap);
+ if (cptr)
+ cptr->c_type |= CT_ADDR;
+ }
+
args = (struct arglist *) mh_xmalloc(sizeof(struct arglist));
if (! args)
args = (struct arglist *) mh_xmalloc(sizeof(struct arglist));
if (! args)
@@
-1969,9
+1999,7
@@
checkcomp(char *name, char *buf)
if (mh_strcasecmp(name, c->c_name) == 0) {
found++;
if (! c->c_text) {
if (mh_strcasecmp(name, c->c_name) == 0) {
found++;
if (! c->c_text) {
- i = strlen(c->c_text = strdup(buf)) - 1;
- if (c->c_text[i] == '\n')
- c->c_text[i] = '\0';
+ c->c_text = strdup(buf);
} else {
i = strlen(cp = c->c_text) - 1;
if (cp[i] == '\n') {
} else {
i = strlen(cp = c->c_text) - 1;
if (cp[i] == '\n') {
@@
-2017,7
+2045,7
@@
static void
freecomps(void)
{
struct comp *c1, *c2;
freecomps(void)
{
struct comp *c1, *c2;
- int i;
+ unsigned int i;
for (i = 0; i < sizeof(mhlcomp)/sizeof(mhlcomp[0]); i++) {
if ((c1 = mhlcomp[i]))
for (i = 0; i < sizeof(mhlcomp)/sizeof(mhlcomp[0]); i++) {
if ((c1 = mhlcomp[i]))
@@
-2038,7
+2066,7
@@
static void
freecomptext(void)
{
struct comp *c1;
freecomptext(void)
{
struct comp *c1;
- int i;
+ unsigned int i;
for (i = 0; i < sizeof(mhlcomp)/sizeof(mhlcomp[0]); i++) {
if ((c1 = mhlcomp[i]))
for (i = 0; i < sizeof(mhlcomp)/sizeof(mhlcomp[0]); i++) {
if ((c1 = mhlcomp[i]))
@@
-2119,7
+2147,11
@@
filterbody (struct mcomp *c1, char *buf, int bufsz, int state, FILE *fp)
*/
close(fdinput[1]);
*/
close(fdinput[1]);
- exit(0);
+ /*
+ * Make sure we call _exit(), otherwise we may flush out the stdio
+ * buffers that we have duplicated from the parent.
+ */
+ _exit(0);
break;
case -1:
adios(NULL, "Unable to fork for filter writer process");
break;
case -1:
adios(NULL, "Unable to fork for filter writer process");