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 r

⟦cb5bc60f2⟧ TextFile

    Length: 5030 (0x13a6)
    Types: TextFile
    Names: »rfc2x400trace.c«

Derivation

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

TextFile

/* rfc2x400trace.c: converts an RFC string to an x400 trace via rfc 1138 */

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

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



#include "util.h"
#include "mta.h"

extern char	*compress();
static int 	do_md_mta(),
		do_deferred(),
		do_converted(),
		do_attempt_md_mta(),
		do_arrival(),
		do_actions();

int rfc2x400trace (trace, str)
Trace	*trace;
char	*str;
{
	/* see sect 5.3.7 in 1138 */

	char	*start, *end, *tmp = strdup(str);
	int	result = OK;
	PP_DBG (("Lib/rfc2x400trace (%s)", str));
	
	start = tmp;
	
	while (result == OK && start !=  NULLCP && *start != '\0') {
		if ((end = index (start, ';')) != NULLCP) 
			*end++ = '\0';
		(void) compress (start, start);
		if (lexnequ(start, "by", strlen("by")) == 0)
			/* md and mta bit */
			result = do_md_mta(trace, start);
		else if (lexnequ(start, "deferred until", strlen("deferred until")) == 0)
			/* deffered delivery time */
			result = do_deferred (trace, start);
		else if (lexnequ(start, "converted", strlen("converted")) == 0)
			/* converted eits */
			result = do_converted(trace, start);
		else if (lexnequ(start, "attempted", strlen("attempted")) == 0)
			/* attempted md and mta */
			result = do_attempt_md_mta(trace, start);
		else if (end == NULLCP) 
			/* arrival-time */
			result = do_arrival(trace, start);
		else 
			/* action-list */
			result = do_actions (trace, start);
		start = end;
	}
	free(tmp);
	return result;
}

static int do_md_mta (trace, start)
Trace	*trace;
char	*start;
{
	char	*end;
	PP_DBG (("Lib/rfc2x400trace/do_md_mta (%s)", start));
	start += strlen("by");
	
	while (isspace(*start)) start++;
	
	if (lexnequ (start, "mta ", strlen("mta ")) == 0) {
		start += strlen("mta ");
		while (isspace(*start)) start++;
		end = start;
		while (*end != ' ') end++;
		*end = '\0';
		trace -> trace_mta = strdup(start);
		start = end+1;
		while (isspace(*start)) start++;
		if (lexnequ (start, "in ", strlen("in ")) != 0)
			return NOTOK;
		start += strlen("in ");
		while (isspace(*start)) start++;
	}
	
	return rfc2x400globalid (&trace -> trace_DomId, start);
}
	     
static int do_deferred (trace, start)
Trace	*trace;
char	*start;
{
	PP_DBG (("Lib/rfc2x400trace/do_deferred (%s)", start));
	start += strlen("deferred until");
	while (isspace(*start)) start++;
	
	return rfc2UTC (start, &trace->trace_DomSinfo.dsi_deferred);
}

static int do_converted (trace, start)
Trace	*trace;
char	*start;
{
	char	*end;
	PP_DBG (("Lib/rfc2x400trace/do_converted (%s)", start));
	if ((start = index(start, '(')) == NULLCP)
		return NOTOK;

	start++;
	if ((end = index(start, ')')) == NULLCP)
		return NOTOK;
	*end = '\0';

	return rfc2encinfo (&trace -> trace_DomSinfo.dsi_converted, start);
}

static int do_attempt_md_mta(trace, start)
Trace	*trace;
char	*start;
{
	char	*end;

	PP_DBG (("Lib/rfc2x400trace/do_attempt_md_mta (%s)", start));

	start += strlen("attempted");
	
	while (isspace(*start)) start++;
	
	if (lexnequ (start, "mta ", strlen("mta ")) == 0) {
		start += strlen("mta ");
		while (isspace(*start)) start++;
		end = start;
		while (*end != ' ') end++;
		*end = '\0';
		trace -> trace_DomSinfo.dsi_attempted_mta = strdup(start);
		start = end+1;
		while (isspace(*start)) start++;
		if (lexnequ (start, "in ", strlen("in ")) != 0)
			return NOTOK;
		start += strlen("in ");
		while (isspace(*start)) start++;
	}
	
	return rfc2x400globalid (&trace -> trace_DomSinfo.dsi_attempted_md, start);
}
	
static int do_actions (trace, start)
Trace	*trace;
char	*start;
{

	PP_DBG (("Lib/rfc2x400trace/do_actions (%s)", start));

	while (start != NULLCP && *start != '\0') {
		while (isspace(*start)) start++;
		if (lexnequ(start, "relayed", strlen("relayed")) == 0) {
			trace -> trace_DomSinfo.dsi_action = ACTION_RELAYED;
			start += strlen("relayed");
		} else if (lexnequ(start, "rerouted", strlen("rerouted")) == 0) {
			trace -> trace_DomSinfo.dsi_action = ACTION_ROUTED;
			start += strlen("rerouted");
		} else if (lexnequ(start, "redirected", strlen("redirected")) == 0) {
			trace -> trace_DomSinfo.dsi_other_actions 
				= trace -> trace_DomSinfo.dsi_other_actions 
					| ACTION_REDIRECTED;
			start += strlen("redirected");
		} else if (lexnequ (start, "expanded", strlen("expanded")) == 0) {
			trace -> trace_DomSinfo.dsi_other_actions 
				= trace -> trace_DomSinfo.dsi_other_actions
					| ACTION_EXPANDED;
			start += strlen("expanded");
		} else {
			PP_TRACE(("Unknown action in x400 trace '%s'", start));
			return NOTOK;
		}
		while (isspace(*start)) start++;
	}
	return OK;
}
			
static int do_arrival (trace, start)
Trace	*trace;
char	*start;
{
	PP_DBG (("Lib/rfc2x400trace/do_arrival (%s)", start));

	return rfc2UTC (start, &trace->trace_DomSinfo.dsi_time);
}