DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T a

⟦6a49c44c9⟧ TextFile

    Length: 4145 (0x1031)
    Types: TextFile
    Names: »ad_getlocal.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« 
        └─⟦e5a54fb17⟧ 
            └─⟦this⟧ »pp-5.0/Lib/parse/ad_getlocal.c« 

TextFile

/* ad_getlocal.c: get the local part of the address */

# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/parse/RCS/ad_getlocal.c,v 5.0 90/09/20 16:09:16 pp Exp Locker: pp $";
# endif

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Lib/parse/RCS/ad_getlocal.c,v 5.0 90/09/20 16:09:16 pp Exp Locker: pp $
 *
 * $Log:	ad_getlocal.c,v $
 * Revision 5.0  90/09/20  16:09:16  pp
 * rcsforce : 5.0 public release
 * 
 */



#include "head.h"
#include "adr.h"
#include "alias.h"
#include "ap.h"
#include "or.h"
#include "chan.h"
#include "list_rchan.h"

static char     *x440_getlocal(),
		*rfc822_getlocal(),
		*local_getlocal(),
		*local_alias_check(),
		*local_user_check();

extern char     *loc_dom_site,
		*loc_dom_mta,
		*locsubdom;
extern int	topParse;

char *ad_getlocal(addr, type)
char    *addr;
int     type;
{
	if (type == AD_X400_TYPE)
		return x440_getlocal(addr);
	else
		return rfc822_getlocal(addr);
}

/* \f

 */

static char     *rfc822_getlocal(addr)
char    *addr;
{
	AP_ptr  tree,
		local,
		domain;
	char	official[LINESIZE], mta_key[LINESIZE];
	char	*ltablepref;
	char    *retstr = NULLCP;
	int	weareTopParse = FALSE;

	if (topParse == TRUE) {
		weareTopParse = TRUE;
		topParse = FALSE;
	}

	tree = ap_s2t(addr);
	tree = ap_normalize(tree, 0);

	if (tree == NULLAP
	    || tree == (AP_ptr) NOTOK)
		return NULLCP;

	(void) ap_t2p (tree, (AP_ptr *)0, (AP_ptr*)0, &local, &domain,
					(AP_ptr*)0);

	if (domain == NULLAP ||
		(lexequ(domain->ap_obvalue, loc_dom_site) == 0
		 || lexequ(domain->ap_obvalue, loc_dom_mta) == 0))
		/* local */
		retstr = local_getlocal(local->ap_obvalue, NULLCP);
	else {
		if (tb_getdomain (domain -> ap_obvalue, mta_key, official,
				  CH_USA_PREF, &ltablepref) == OK &&
		    ltablepref) {
			retstr = local_getlocal (local -> ap_obvalue,
						 ltablepref);
			free (ltablepref);
		}
	}
	if (weareTopParse == TRUE) {
		freeAliasList();
		topParse = TRUE;
	}
	ap_sqdelete(tree, NULLAP);
	return retstr;
}

/* \f

 */

static char    *x440_getlocal(addr)
char    *addr;
{
	OR_ptr  or;
	char    tbuf[LINESIZE],
		*retstr = NULLCP;
	int     type;
	char	*ltablepref;
	int	weareTopParse = FALSE;
	if (topParse == TRUE) {
		weareTopParse = TRUE;
		topParse = FALSE;
	}

	if ((or = or_std2or(addr)) == NULLOR)
		return NULLCP;

	if (or_check(&or, tbuf, &type, &ltablepref) != NOTOK
	    && type == OR_ISLOCAL)
		retstr = local_getlocal(tbuf, ltablepref);

	if (ltablepref) free (ltablepref);
	or_free(or);
	if (weareTopParse == TRUE) {
		freeAliasList();
		topParse = TRUE;
	}
	return retstr;
}

/* \f

 */

static char     *local_getlocal(loc, ltablepref)
char    *loc, *ltablepref;
{
	ALIAS                   alias_struct,
				*alp = &alias_struct;

	switch (tb_getalias (loc, alp, ltablepref)) {
	case NOTOK:
		/* -- routine or table error -- */
		return NULLCP;
	case OK:
		/* -- found, do alias check -- */
		return local_alias_check (loc, alp, ltablepref);
	default:
		/* -- otherwise do the user checks -- */
		return local_user_check (loc, ltablepref);
	}
}

static char     *local_alias_check(loc, alp, ltablepref)
char            *loc;
ALIAS           *alp;
char		*ltablepref;
{
	char *new_loc;
	if (inAliasList(alp->alias_user) == OK)
		return NULLCP;
	else
		addToAliasList(alp->alias_user);

	switch (alp->alias_type) {
	    case ALIAS_PROPER:
		if ((new_loc = local_getlocal(alp->alias_user,
					      ltablepref)) != NULLCP) {
			/* proper alias don't unwind */
			free(new_loc);
			return (loc);
		} else
			return NULLCP;

	    case ALIAS_822_SYNONYM:
		return rfc822_getlocal (alp -> alias_user);

	    case ALIAS_X400_SYNONYM:
		return x440_getlocal (alp -> alias_user);
		
	    case ALIAS_SYNONYM:
		return local_getlocal(alp->alias_user, ltablepref);

	    case ALIAS_X400:
	    case ALIAS_822:
		return strdup(alp->alias_user);
	    default:
		break;
	}
	return NULLCP;
}

static char     *local_user_check(loc, ltablepref)
char            *loc;
char		*ltablepref;
{
	LIST_RCHAN	*temp;
	extern LIST_RCHAN	*tb_getuser();

	if ((temp = tb_getuser (loc, ltablepref)) == NULLIST_RCHAN)
		return NULLCP;
	else
		list_rchan_free(temp);
	return strdup(loc);
}