sbr/snprintb.c sbr/ssequal.c \
sbr/strindex.c sbr/trimcpy.c sbr/unquote.c \
sbr/uprf.c sbr/vfgets.c \
- sbr/fmt_def.c sbr/mf.c sbr/utils.c sbr/ctype-checked.c \
+ sbr/mf.c sbr/utils.c sbr/ctype-checked.c \
sbr/m_mktemp.c sbr/getansreadline.c sbr/vector.c \
config/config.c config/version.c
* addrsbr.h -- definitions for the address parsing system
*/
-#define AD_HOST 1 /* getm(): lookup official hostname */
-#define AD_NHST 0 /* getm(): do not lookup official name */
-#define AD_NAME AD_NHST /* AD_HOST is TOO slow */
-
#define UUCPHOST (-1)
#define LOCALHOST 0
#define NETHOST 1
* localhost().
* dftype - If dfhost is given, use dftype as the email address type
* if no host is in the email address.
- * wanthost - One of AD_HOST or AD_NHST. If AD_HOST, look up the
- * "official name" of the host. Well, that's what the
- * documentation says, at least ... support for that
- * functionality was removed when hostable support was
- * removed and the address parser was converted by default
- * to always being in DUMB mode. So nowadays this only
- * affects where error messages are put if there is no
- * host part (set it to AD_HOST if you want error messages
- * to appear on standard error).
- * eresult - Any error string returned by the address parser. String
- * must contain sufficient room for the error message.
- * (BUFSIZ is used in general by the code). Can be NULL.
+ * eresult - A buffer containing an error message returned by the
+ * address parser. May be NULL.
+ * eresultsize - The size of the buffer passed in eresult.
*
* A pointer to an allocated struct mailname corresponding to the email
* address is returned.
+ *
+ * This function used to have an argument called 'wanthost' which would
+ * control whether or not it would canonicalize hostnames in email
+ * addresses. This functionalit was removed for nmh 1.5, and eventually
+ * all of the code that used this argument was garbage collected.
*/
-struct mailname *getm(char *str, char *dfhost, int dftype,
- int wanthost, char *eresult);
+struct mailname *getm(char *str, char *dfhost, int dftype, char *eresult,
+ size_t eresultsize);
#define CF_BITS "\020\01TRUE\02PARSED\03CF_DATEFAB\04TRIMMED"
-extern int fmt_norm;
-
/*
* This structure defines one formatting instruction.
*/
.RB [ \-alias
.IR aliasfile ]
.RB [ \-list " | " \-nolist ]
-.RB [ \-normalize " | " \-nonormalize ]
.RB [ \-user " | " \-nouser ]
.RB [ \-version ]
.RB [ \-help ]
alias expands to,
.B ali
will list the aliases that expand to each
-given address. If the
-.B \-normalize
-switch is given,
-.B ali
-will
-try to track down the official hostname of the address.
+given address.
.PP
The files specified by the profile entry
.RI \*(lq Aliasfile \*(rq
.TP
\-nolist
.TP
-\-nonormalize
-.TP
\-nouser
.PD
.SH CONTEXT
.IR formatfile ]
.RB [ \-format
.IR string ]
-.RB [ \-normalize " | " \-nonormalize ]
.RB [ \-width
.IR columns ]
.RB [ \-version ]
.RE
.fi
.PP
-If the
-.B \-normalize
-switch is given,
-.B ap
-will try to track down
-the official hostname of the address.
-.PP
Here is the default format string used by
.BR ap :
.PP
-format
As described above.
.TP
-\-normalize
-.TP
\-width
The width of the terminal.
.PD
.IR component-text ]
.RB [ \-dupaddrs " | " \-nodupaddrs ]
.RB [ \-ccme " | " \-noccme ]
-.RB [ \-normalize " | " \-nonormalize ]
.RB [ \-outsize
.IR size-in-characters ]
.RB [ \-bufsize
is in effect.
.PP
The
-.B \-normalize
-and
-.B \-nonormalize
-switches control whether or not email addresses are normalized by the
-address parsing routines. This is only functional when in address
-mode and is designed to replicate the switch of the same name to
-.IR ap (8).
-.PP
-The
.B \-outsize
switch controls the maximum number of printable characters that the format
engine will produce. Characters marked as non-printing by the format
struct mailname *
-getm (char *str, char *dfhost, int dftype, int wanthost, char *eresult)
+getm (char *str, char *dfhost, int dftype, char *eresult, size_t eresultsize)
{
char *pp;
struct mailname *mp;
if (err[0]) {
- if (eresult)
- strcpy (eresult, err);
- else
- if (wanthost == AD_HOST)
- admonish (NULL, "bad address '%s' - %s", str, err);
+ if (eresult) {
+ strncpy (eresult, err, eresultsize);
+ eresult[eresultsize - 1] = '\0';
+ }
return NULL;
}
if (pers == NULL
&& mbox == NULL && host == NULL && route == NULL
&& grp == NULL) {
- if (eresult)
- strcpy (eresult, "null address");
- else
- if (wanthost == AD_HOST)
- admonish (NULL, "null address '%s'", str);
+ if (eresult) {
+ strncpy (eresult, "null address", eresultsize);
+ eresult[eresultsize - 1] = '\0';
+ }
return NULL;
}
if (mbox == NULL && grp == NULL) {
- if (eresult)
- strcpy (eresult, "no mailbox in address");
- else
- if (wanthost == AD_HOST)
- admonish (NULL, "no mailbox in address '%s'", str);
+ if (eresult) {
+ strncpy (eresult, "no mailbox in address", eresultsize);
+ eresult[eresultsize - 1] = '\0';
+ }
return NULL;
}
mp = (struct mailname *) calloc ((size_t) 1, sizeof(*mp));
if (mp == NULL) {
- if (eresult)
- strcpy (eresult, "insufficient memory to represent address");
- else
- if (wanthost == AD_HOST)
- adios (NULL, "insufficient memory to represent address");
+ if (eresult) {
+ strncpy (eresult, "insufficient memory to represent address",
+ eresultsize);
+ eresult[eresultsize - 1] = '\0';
+ }
return NULL;
}
return 0;
}
- if ((mq.m_next = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) {
+ if ((mq.m_next = getm (cp, NULL, 0, NULL, 0)) == NULL) {
admonish (NULL, "invalid entry in local-mailbox: %s", cp);
return 0;
}
mp = mq.m_next ? mq.m_next : &mq;
oops = 0;
while ((cp = getname (am))) {
- if ((mp->m_next = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) {
+ if ((mp->m_next = getm (cp, NULL, 0, NULL, 0)) == NULL) {
admonish (NULL, "illegal address: %s", cp);
oops++;
} else {
char *tmpbuf = NULL;
size_t tmpbufsize = 0;
struct mailname *mn;
+ char errbuf[BUFSIZ];
/*
* Because these are addresses, we need to handle them individually.
output = add(" ", output);
for (groupflag = 0; (mp = getname(*value)); ) {
- if ((mn = getm(mp, NULL, 0, AD_HOST, NULL)) == NULL) {
+ if ((mn = getm(mp, NULL, 0, errbuf, sizeof(errbuf))) == NULL) {
+ advise(mp, "%s", errbuf);
errflag++;
continue;
}
/* concatenate all the new addresses onto 'buf' */
for (isgroup = 0; (cp = getname (str)); ) {
- if ((mp = getm (cp, NULL, 0, fmt_norm, NULL)) == NULL)
+ if ((mp = getm (cp, NULL, 0, NULL, 0)) == NULL)
continue;
if (isgroup && (mp->m_gname || !mp->m_ingrp)) {
+++ /dev/null
-
-/*
- * fmt_def.c -- some defines for sbr/fmt_scan.c
- *
- * 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/addrsbr.h>
-
-int fmt_norm = AD_NAME;
# include <wchar.h>
#endif
-extern int fmt_norm; /* defined in sbr/fmt_def.c = AD_NAME */
struct mailname fmt_mnull = { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0,
NULL, NULL };
if (comp->c_mn != &fmt_mnull)
mnfree (comp->c_mn);
if ((sp = comp->c_text) && (sp = getname(sp)) &&
- (mn = getm (sp, NULL, 0, fmt_norm, NULL))) {
+ (mn = getm (sp, NULL, 0, NULL, 0))) {
comp->c_mn = mn;
while (getname(""))
;
if (comp->c_mn != &fmt_mnull)
mnfree (comp->c_mn);
if ((sp = comp->c_text) && (sp = getname(sp)) &&
- (mn = getm (sp, NULL, 0, AD_NAME, NULL))) {
+ (mn = getm (sp, NULL, 0, NULL, 0))) {
comp->c_mn = mn;
if (ismymbox(mn))
comp->c_flags |= CF_TRUE;
comp->c_flags &= ~CF_TRUE;
while ((sp = getname(sp)))
if ((comp->c_flags & CF_TRUE) == 0 &&
- (mn = getm (sp, NULL, 0, AD_NAME, NULL)))
+ (mn = getm (sp, NULL, 0, NULL, 0)))
if (ismymbox(mn))
comp->c_flags |= CF_TRUE;
} else {
switches are:
-alias aliasfile
-[no]list
- -[no]normalize
-[no]user
-version
-help
X("noalias", -7, NALIASW) \
X("list", 0, LISTSW) \
X("nolist", 0, NLISTSW) \
- X("normalize", 0, NORMSW) \
- X("nonormalize", 0, NNORMSW) \
X("user", 0, USERSW) \
X("nouser", 0, NUSERSW) \
X("version", 0, VERSIONSW) \
* prototypes
*/
static void print_aka (char *, int, int);
-static void print_usr (char *, int, int);
+static void print_usr (char *, int);
int
main (int argc, char **argv)
{
int i, vecp = 0, inverted = 0, list = 0;
- int noalias = 0, normalize = AD_NHST;
+ int noalias = 0;
char *cp, **ap, **argp, buf[BUFSIZ];
/* Really only need to allocate for argc-1, but must allocate at least 1,
so go ahead and allocate for argc char pointers. */
list = 0;
continue;
- case NORMSW:
- normalize = AD_HOST;
- continue;
- case NNORMSW:
- normalize = AD_NHST;
- continue;
-
case USERSW:
inverted++;
continue;
invo_name);
for (i = 0; i < vecp; i++)
- print_usr (vec[i], list, normalize);
+ print_usr (vec[i], list);
} else {
if (vecp) {
/* print specified aliases */
}
static void
-print_usr (char *s, int list, int norm)
+print_usr (char *s, int list)
{
register char *cp, *pp, *vp;
register struct aka *ak;
if ((pp = getname (s)) == NULL)
adios (NULL, "no address in \"%s\"", s);
- if ((mp = getm (pp, NULL, 0, norm, NULL)) == NULL)
+ if ((mp = getm (pp, NULL, 0, NULL, 0)) == NULL)
adios (NULL, "bad address \"%s\"", s);
while (getname (""))
continue;
for (ak = akahead; ak; ak = ak->ak_next) {
pp = akresult (ak);
while ((cp = getname (pp))) {
- if ((np = getm (cp, NULL, 0, norm, NULL)) == NULL)
+ if ((np = getm (cp, NULL, 0, NULL, 0)) == NULL)
continue;
if (!strcasecmp (mp->m_host ? mp->m_host : "",
np->m_host ? np->m_host : "") &&
if (name) {
/* s is of the form "Blind list: address". If address
is an alias, expand it. */
- struct mailname *mp = getm (name, NULL, 0, AD_NAME, NULL);
+ struct mailname *mp = getm (name, NULL, 0, NULL, 0);
if (mp && mp->m_ingrp) {
char *gname = add (mp->m_gname, NULL);
#define AP_SWITCHES \
X("form formatfile", 0, FORMSW) \
X("format string", 5, FMTSW) \
- X("normalize", 0, NORMSW) \
- X("nonormalize", 0, NNORMSW) \
X("width columns", 0, WIDTHSW) \
X("version", 0, VERSIONSW) \
X("help", 0, HELPSW) \
/*
* static prototypes
*/
-static int process (char *, int, int);
+static int process (char *, int);
int
main (int argc, char **argv)
{
- int addrp = 0, normalize = AD_HOST;
+ int addrp = 0;
int width = 0, status = 0;
char *cp, *form = NULL, *format = NULL, *nfs;
char buf[BUFSIZ], **argp;
adios (NULL, "missing argument to %s", argp[-2]);
width = atoi (cp);
continue;
-
- case NORMSW:
- normalize = AD_HOST;
- continue;
- case NNORMSW:
- normalize = AD_NHST;
- continue;
}
}
if (addrp > NADDRS)
}
if (width > WBUFSIZ)
width = WBUFSIZ;
- fmt_norm = normalize;
fmt_compile (nfs, &fmt, 1);
dat[0] = 0;
dat[4] = 0;
for (addrp = 0; addrs[addrp]; addrp++)
- status += process (addrs[addrp], width, normalize);
+ status += process (addrs[addrp], width);
fmt_free (fmt, 1);
done (status);
static int
-process (char *arg, int length, int norm)
+process (char *arg, int length)
{
int status = 0;
register char *cp;
while ((cp = getname (arg))) {
if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
adios (NULL, "unable to allocate pqpair memory");
- if ((mp = getm (cp, NULL, 0, norm, error)) == NULL) {
+ if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
p->pq_text = getcpy (cp);
p->pq_error = getcpy (error);
status++;
X("nodupaddrs", 0, NDUPADDRSW) \
X("ccme", 0, CCMESW) \
X("noccme", 0, NCCMESW) \
- X("normalize", 0, NORMSW) \
- X("nonormalize", 0, NNORMSW) \
X("outsize size-in-characters", 0, OUTSIZESW) \
X("bufsize size-in-bytes", 0, BUFSZSW) \
X("width column-width", 0, WIDTHSW) \
static void litputs(char *);
static void litputc(char);
static void process_addresses(struct format *, struct msgs_array *, char *,
- int, int, int *, int, struct fmt_callbacks *);
+ int, int, int *, struct fmt_callbacks *);
static void process_raw(struct format *, struct msgs_array *, char *,
int, int, int *, struct fmt_callbacks *);
static void process_messages(struct format *, struct msgs_array *,
int dump = 0, i;
int outputsize = 0, bufsize = 0, dupaddrs = 1, trace = 0, files = 0;
int colwidth = -1, msgnum = -1, msgcur = -1, msgsize = -1, msgunseen = -1;
- int normalize = AD_HOST;
enum mode_t mode = MESSAGE;
int dat[5];
struct fmt_callbacks cb, *cbp = NULL;
form = NULL;
continue;
- case NORMSW:
- normalize = AD_HOST;
- continue;
- case NNORMSW:
- normalize = AD_NHST;
- continue;
-
case TRACESW:
trace++;
continue;
}
if (mode == ADDRESS) {
- fmt_norm = normalize;
process_addresses(fmt, &msgs, buffer, bufsize, outputsize,
- dat, normalize, cbp);
+ dat, cbp);
} else /* Fall-through for RAW or DATE */
process_raw(fmt, &msgs, buffer, bufsize, outputsize, dat, cbp);
}
static void
process_addresses(struct format *fmt, struct msgs_array *addrs, char *buffer,
- int bufsize, int outwidth, int *dat, int norm,
- struct fmt_callbacks *cb)
+ int bufsize, int outwidth, int *dat, struct fmt_callbacks *cb)
{
int i;
char *cp, error[BUFSIZ];
while ((cp = getname(addrs->msgs[i]))) {
if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
adios (NULL, "unable to allocate pqpair memory");
- if ((mp = getm(cp, NULL, 0, norm, error)) == NULL) {
+ if ((mp = getm(cp, NULL, 0, error, sizeof(error))) == NULL) {
p->pq_text = getcpy(cp);
p->pq_error = getcpy(error);
} else {
/* concatenate all the new addresses onto 'buf' */
for (isgroup = 0; (cp = getname (str)); ) {
- if ((mp = getm (cp, NULL, 0, AD_NAME, error)) == NULL) {
+ if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
fprintf(stderr, "bad address \"%s\" -- %s\n", cp, error);
continue;
}
if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
adios (NULL, "unable to allocate pqpair memory");
- if ((mp = getm (cp, NULL, 0, AD_NAME, error)) == NULL) {
+ if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
p->pq_text = getcpy (cp);
p->pq_error = getcpy (error);
} else {
{
int count, grp, i, keep;
char *cp, *pp, *qp;
- char namep[BUFSIZ];
+ char namep[BUFSIZ], error[BUFSIZ];
struct mailname *mp = NULL, *np = NULL;
struct headers *hdr;
tmpaddrs.m_next = NULL;
for (count = 0; (cp = getname (str)); count++)
- if ((mp = getm (cp, NULL, 0, AD_HOST, NULL))) {
+ if ((mp = getm (cp, NULL, 0, error, sizeof(error)))) {
if (tmpaddrs.m_next)
np->m_next = mp;
else
tmpaddrs.m_next = mp;
np = mp;
}
- else
+ else {
+ admonish(cp, "%s", error);
if (hdr->flags & HTRY)
badadr++;
else
badmsg++;
+ }
if (count < 1) {
if (hdr->flags & HNIL)
if (np->m_gname)
putgrp (namep, np->m_gname, out, hdr->flags);
while ((cp = getname (pp))) {
- if (!(mp = getm (cp, NULL, 0, AD_HOST, NULL))) {
+ if (!(mp = getm (cp, NULL, 0, error, sizeof(error)))) {
+ admonish(cp, "%s", error);
badadr++;
continue;
}
/* concatenate all the new addresses onto 'buf' */
for (isgroup = 0; (cp = getname (fixed_str)); ) {
- if ((mp = getm (cp, dfhost, dftype, AD_NAME, error)) == NULL) {
+ if ((mp = getm (cp, dfhost, dftype, error, sizeof(error))) == NULL) {
snprintf (baddr, sizeof(baddr), "\t%s -- %s\n", cp, error);
badaddrs = add (baddr, badaddrs);
continue;
adr_nodep->next = NULL;
/* With AD_NAME, errors are not reported to user. */
- if ((mp = getm (cp, dfhost, dftype, AD_NAME, error)) == NULL) {
+ if ((mp = getm (cp, dfhost, dftype, error,
+ sizeof(error))) == NULL) {
const char *no_at_sign = "no at-sign after local-part";
adr_nodep->escape_local_part =
new_adr = concat (display_name, " ", angle_addr, NULL);
adr = getname (new_adr);
if (adr != NULL &&
- (mp = getm (adr, dfhost, dftype, AD_NAME, NULL)) != NULL) {
+ (mp = getm (adr, dfhost, dftype, NULL, 0)) != NULL) {
fixed_address = 1;
mnfree (mp);
}