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 g

⟦b7ddda5bd⟧ TextFile

    Length: 4741 (0x1285)
    Types: TextFile
    Names: »gen_ndr.c«

Derivation

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

TextFile

/* gen_ndr.c: generate the Non Delivery Notifications from submit */

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

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Src/submit/RCS/gen_ndr.c,v 5.0 90/09/20 16:23:02 pp Exp Locker: pp $
 *
 * $Log:	gen_ndr.c,v $
 * Revision 5.0  90/09/20  16:23:02  pp
 * rcsforce : 5.0 public release
 * 
 */



#include "head.h"
#include "q.h"
#include "dr.h"
#include <isode/cmd_srch.h>

extern Q_struct         Qstruct;
extern char             msg_fullpath[];
extern char		*loc_dom_site;
extern CMD_TABLE	rr_tcode[],
			rr_dcode[],
			rr_rcode[];


/* -- local routines -- */
void			gen_ndr();
static void		gen_ndrFORrecip();
static void		gen_ndrFORsender();
static void		set_DRvalues();




/*----------------------  Begin  Routines  -------------------------------- */




void gen_ndr()
{
	register Q_struct       *qp = &Qstruct;


	PP_TRACE (("submit/gen_ndr()"));

	if (qp -> Oaddress -> ad_status == AD_STAT_DRREQUIRED)
		gen_ndrFORsender();
	else 
		gen_ndrFORrecip();
}




static void gen_ndrFORsender()
{
	register Q_struct       *qp = &Qstruct;
	register ADDR           *ad,
				*sender;
	char			errbuf[LINESIZE];


	PP_TRACE (("submit/gen_ndrFORsender()"));

	sender = qp -> Oaddress;
	sender -> ad_status = AD_STAT_DONE;
	(void) sprintf (errbuf,
		"Bad sender address '%s' [%s], all recips are rejected",
		sender -> ad_value, sender -> ad_parse_message);

	if (qp -> queuetime == NULLUTC)
		qp -> queuetime = utcnow();

	for (ad = qp -> Raddress; ad != NULLADDR; ad = ad -> ad_next) {
		if (ad -> ad_status == AD_STAT_DONE)
			continue;

		ad -> ad_status = AD_STAT_DRREQUIRED;
		ad -> ad_reason = DRR_NO_REASON;
		if (ad -> ad_add_info)
			free (ad -> ad_add_info);
		ad -> ad_add_info = NULLCP;
		set_DRvalues (sender, ad, errbuf);
	}

	if (wr_q2drsubmit (qp, msg_fullpath) != RP_OK)
		PP_LOG (LLOG_EXCEPTIONS, ("wr_q2drsubmit failed"));

	return;
}




static void gen_ndrFORrecip()
{
	register Q_struct       *qp = &Qstruct;
	register ADDR           *ad,
				*sender;
	int                     recip_err = FALSE;


	PP_TRACE (("submit/gen_ndrFORrecip()"));

	sender = qp -> Oaddress;
	if (qp -> queuetime == NULLUTC)
		qp -> queuetime = utcnow();

	for (ad = qp -> Raddress; ad != NULLADDR; ad = ad -> ad_next) {
		if (ad -> ad_status != AD_STAT_PEND &&
		    ad -> ad_status != AD_STAT_DRREQUIRED)
			continue;

		if (rp_isbad (ad -> ad_parse_stat) ||
		    ad -> ad_status == AD_STAT_DRREQUIRED)
		{
			recip_err = TRUE;
			set_DRvalues (sender, ad, NULLCP);
		}
	}


	if (recip_err == FALSE) {
		PP_TRACE (("submit/gen_ndrFORrecip (not generated)"));
		return;
	}


	if (wr_q2drsubmit (qp, msg_fullpath) != RP_OK)
		PP_LOG (LLOG_EXCEPTIONS, ("wr_q2drsubmit failed"));

	return;
}


#define gval(x)                 ((x -> ad_type) == AD_X400_TYPE ? \
                                        (x -> ad_r400adr) : (x -> ad_r822adr))

static void set_DRvalues (sender, recip, errstr)
ADDR	*sender;
ADDR	*recip;
char	*errstr;
{
	int	maxl = LINESIZE;
	char	rdl, sdl, boundadd[BUFSIZ];

	register Q_struct       *qp = &Qstruct;

	recip -> ad_type = sender -> ad_type;

	if (recip -> ad_reason == DRR_NO_REASON) {
		recip -> ad_reason = DRR_UNABLE_TO_TRANSFER;
		recip -> ad_diagnostic = DRD_UNRECOGNISED_OR;
	}

	if (recip -> ad_add_info == NULLCP) {
		recip -> ad_add_info = malloc ((unsigned)maxl);
		bzero (recip -> ad_add_info, maxl);

		if (errstr)
			(void) sprintf (recip -> ad_add_info, errstr);
		else 
			(void) sprintf (recip -> ad_add_info,
					"Bad recipient address '%s' [%s]",
					recip -> ad_value,
					rp_valstr (recip -> ad_parse_stat));
	}

	if (index (gval (qp->Oaddress), '"') == NULLCP)
		sdl = '"';
	else if (index (gval (qp->Oaddress), '\'') == NULLCP)
		sdl = '\'';
	else
		sdl = '`';

	if (index (gval (recip), '"') == NULLCP)
		rdl = '"';
	else if (index (gval (recip), '\'') == NULLCP)
		rdl = '\'';
	else
		rdl = '`';

	if (recip->ad_add_info != NULLCP)
		sprintf (boundadd, "reason=\"%s\" ", recip->ad_add_info);

	PP_STAT (("DR chan=\"%s\" sender=%c%s%c \"%s\" recip=%c%s%c on %s \"%s\" channel=%s %s reason-code=\"%s (%d)\", diag-code=\"%s (%d)\"",
		  qp->inbound->li_chan->ch_name,
		  sdl, gval(qp->Oaddress), sdl,
		  qp->inbound->li_mta,
		  rdl, gval(recip), rdl,
		  (recip->ad_outchan && recip->ad_outchan->li_chan) ? recip->ad_outchan->li_chan->ch_name : "submission",
		  (recip->ad_outchan) ? recip->ad_outchan->li_mta : loc_dom_site,
		  "submit",
		  (recip->ad_add_info != NULLCP) ? boundadd : "",
		  rcmd_srch(recip->ad_reason, rr_rcode), recip->ad_reason,
		  rcmd_srch(recip->ad_diagnostic, rr_dcode), recip->ad_diagnostic));
}