|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T r
Length: 3721 (0xe89)
Types: TextFile
Names: »rfc822_parse.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z«
└─⟦e5a54fb17⟧
└─⟦this⟧ »pp-5.0/Lib/parse/rfc822_parse.c«
/* rfc822_parse.c: 822 address parsing & handling */
# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/parse/RCS/rfc822_parse.c,v 5.0 90/09/20 16:09:37 pp Exp Locker: pp $";
# endif
/*
* $Header: /cs/research/pp/hubris/pp-beta/Lib/parse/RCS/rfc822_parse.c,v 5.0 90/09/20 16:09:37 pp Exp Locker: pp $
*
* $Log: rfc822_parse.c,v $
* Revision 5.0 90/09/20 16:09:37 pp
* rcsforce : 5.0 public release
*
*/
#include "head.h"
#include "adr.h"
#include "ap.h"
/* --------------------- Begin Routines -------------------------------- */
/* --- *** ---
Parse an rfc822 address and convert the value into a list of address parts
E.g user%xxx.yyy.zzz%aaa.sss.ddd@qqq.www.eee
--- *** --- */
static void strip_excess_domains_from_route();
rfc822_parse (ad, order_pref, full,
pgroup, pname, plocal, pdomain, proute)
ADDR *ad;
int order_pref;
int full;
AP_ptr *pgroup,
*pname,
*plocal,
*pdomain,
*proute;
{
AP_ptr tree;
char *cp;
PP_DBG (("Lib/parse/rfc822_parse/ad_rfc822='%s', ad_value='%s'",
ad->ad_r822adr, ad->ad_value));
tree = ap_s2t (ad->ad_r822adr ? ad->ad_r822adr : ad->ad_value);
switch ((int)tree) {
case 0:
/* -- could parse it and found it to be duff -- */
ad->ad_parse_message = strdup("Bad address");
return RP_NO;
case NOTOK:
/* -- couldn't parse it (x400 ??) -- */
ad->ad_parse_message = strdup("822 parse error");
return RP_PARSE;
default:
break;
}
/* -- set order pref set from inound channel -- */
tree = ap_normalize (tree, order_pref);
/* -- split into parts for ad_check. -- */
(void) ap_t2p (tree, pgroup, pname, plocal, pdomain,
proute);
strip_excess_domains_from_route(tree, pgroup, pname, plocal, pdomain,
proute);
/* -- parsed okay so fill in ad->rfc822 to pass this up */
/* -- convert back to a string -- */
if (full == OK)
cp = ap_p2s (*pgroup, *pname, *plocal, *pdomain, *proute);
else
cp = ap_p2s_nc (NULLAP, NULLAP, *plocal, *pdomain, *proute);
/* -- Put the address into the ad structure -- */
ad->ad_r822adr = cp;
return RP_OK;
}
extern char *loc_dom_site, *loc_dom_mta;
extern int all_domain_norm;
static int isLocal(ap)
AP_ptr ap;
{
return (lexequ (ap->ap_obvalue, loc_dom_site) == 0
|| lexequ (ap->ap_obvalue, loc_dom_mta) == 0);
}
static void strip_excess_domains_from_route (tree, group, name, local, domain, route)
register AP_ptr tree; /* -- the parse tree -- */
AP_ptr *group, /* -- start of group name -- */
*name, /* -- start of person name -- */
*local, /* -- start of local-part -- */
*domain, /* -- basic domain reference -- */
*route; /* -- start of 822 reverse route -- */
{
if (*route == NULLAP)
return;
while (*route != NULLAP
&& *route != *domain
&& *route != *local
&& *route != *name
&& *route != *group) {
if (isLocal(*route)
|| (all_domain_norm == TRUE && (*route)->ap_next
&& (*route)->ap_next->ap_obvalue
&& (lexequ ((*route)->ap_obvalue, (*route)->ap_next->ap_obvalue) == 0)))
*route = (*route)->ap_next;
else
break;
}
if (all_domain_norm == TRUE && *route != NULLAP
&& ((*route) -> ap_next == *local
|| (*route) -> ap_next == *name
|| (*route) -> ap_next == *group
|| (*route) -> ap_next == NULLAP)) {
/* only one in route test to see if matches with domain */
if (*domain && (*domain) -> ap_obvalue
&& lexequ ((*route) -> ap_obvalue, (*domain) -> ap_obvalue) == 0)
*route = (*route) -> ap_next;
}
if (*route == *domain
|| *route == *local
|| *route == *name
|| *route == *group)
*route = NULLAP;
}