X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fmf.c;h=8130fbfb6b0aa2877ab9a5ea2fe6539f80055b54;hp=45bbecd4c82b5d30981ed57c057d62350806cab9;hb=641a9d953e86685f9ca2f3da72e9a94e5bcfd69e;hpb=5b792c4424571f05bc2008e3109797d18d7d00d1 diff --git a/sbr/mf.c b/sbr/mf.c index 45bbecd..8130fbf 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -10,12 +10,14 @@ #include #include #include +#include +#include +#include /* ** static prototypes */ static char *getcpy(char *); -static int isat(char *); static int parse_address(void); static int phrase(char *); static int route_addr(char *); @@ -28,7 +30,7 @@ static int my_lex(char *); static char * getcpy(char *s) { - register char *p; + char *p; if (!s) { /* @@ -40,33 +42,19 @@ getcpy(char *s) for(;;) pause(); } - p = mh_xmalloc((size_t) (strlen(s) + 2)); + p = mh_xcalloc(strlen(s) + 2, sizeof(char)); strcpy(p, s); return p; } -#define CHKADR 0 /* undertermined address style */ -#define UNIXDR 1 /* UNIX-style address */ -#define ARPADR 2 /* ARPAnet-style address */ - - -static int -isat(char *p) -{ - return (strncmp(p, " AT ", 4) - && strncmp(p, " At ", 4) - && strncmp(p, " aT ", 4) - && strncmp(p, " at ", 4) ? FALSE : TRUE); -} - - /* ** ** getadrx() implements a partial 822-style address parser. The parser ** is neither complete nor correct. It does however recognize nearly all -** of the 822 address syntax. In addition it handles the majority of the -** 733 syntax as well. Most problems arise from trying to accomodate both. +** of the 822 address syntax. +** Historically, it handled the majority (and still handles parts) of the +** 733 syntax as well. Most problems arise from trying to accommodate both. ** ** In terms of 822, the route-specification in ** @@ -76,8 +64,6 @@ isat(char *p) ** via source-routing. Recursive groups are not allowed as per the ** standard. ** -** In terms of 733, " at " is recognized as equivalent to "@". -** ** In terms of both the parser will not complain about missing hosts. ** ** ----- @@ -178,37 +164,35 @@ static struct adrx adrxs2; struct adrx * getadrx(char *addrs) { - register char *bp; - register struct adrx *adrxp = &adrxs2; + char *bp; + struct adrx *adrxp = &adrxs2; if (pers) - free(pers); + mh_free0(&pers); if (mbox) - free(mbox); + mh_free0(&mbox); if (host) - free(host); + mh_free0(&host); if (path) - free(path); + mh_free0(&path); if (grp) - free(grp); + mh_free0(&grp); if (note) - free(note); - pers = mbox = host = path = grp = note = NULL; + mh_free0(¬e); err[0] = 0; if (dp == NULL) { dp = cp = getcpy(addrs ? addrs : ""); glevel = 0; } else if (cp == NULL) { - free(dp); - dp = NULL; + mh_free0(&dp); return NULL; } switch (parse_address()) { case DONE: - free(dp); - dp = cp = NULL; + mh_free0(&dp); + cp = NULL; return NULL; case OK: @@ -286,8 +270,7 @@ again: ; } case LX_COMA: if (note) { - free(note); - note = NULL; + mh_free0(¬e); } goto again; @@ -435,7 +418,7 @@ phrase(char *buffer) static int route_addr(char *buffer) { - register char *pp = cp; + char *pp = cp; if (my_lex(buffer) == LX_AT) { if (route(buffer) == NOTOK) @@ -515,8 +498,7 @@ domain(char *buffer) case LX_AT: /* sigh (0) */ mbox = add(host, add("%", mbox)); - free(host); - host = NULL; + mh_free0(&host); continue; default: @@ -556,7 +538,7 @@ route(char *buffer) default: sprintf(err, "no at-sign found for next domain in route (%s)", - buffer); + buffer); } break; } @@ -583,9 +565,9 @@ static int my_lex(char *buffer) { /* buffer should be at least BUFSIZ bytes long */ - int i, gotat = 0; - register unsigned char c; - register char *bp; + int i; + unsigned char c; + char *bp; /* ** Add C to the buffer bp. After use of this macro *bp is guaranteed @@ -603,7 +585,6 @@ my_lex(char *buffer) if (!cp) return (last_lex = LX_END); - gotat = isat(cp); c = *cp++; while (isspace(c)) c = *cp++; @@ -713,9 +694,7 @@ got_atom: ; else cp--; *bp = 0; - last_lex = !gotat || cp == NULL || strchr(cp, '<') != NULL - ? LX_ATOM : LX_AT; - return last_lex; + return LX_ATOM; my_lex_buffull: /* Out of buffer space. *bp is the last byte in the buffer */ @@ -728,7 +707,7 @@ char * legal_person(char *p) { int i; - register char *cp; + char *cp; static char buffer[BUFSIZ]; if (*p == '"')