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 i

⟦d11026c4a⟧ TextFile

    Length: 10854 (0x2a66)
    Types: TextFile
    Names: »inter-read.c«

Derivation

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

TextFile

/* inter-read.c: reading side of interface program */

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

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Src/qmgr/RCS/inter-read.c,v 5.0 90/09/20 16:21:10 pp Exp Locker: pp $
 *
 * $Log:	inter-read.c,v $
 * Revision 5.0  90/09/20  16:21:10  pp
 * rcsforce : 5.0 public release
 * 
 */



#include <stdio.h>
#include <ctype.h>
#include "types.h"		/* type definitions */

/* \f

 Routines */

struct type_QmgrP1_MPDUIdentifier *gmpduidentifier ();
struct type_Qmgr_EncodedInformationTypes *geit();
struct type_UNIV_UTCTime *gutctime ();
struct type_UNIV_UTCTime *gutcinterval ();
struct type_Qmgr_PerMessageInfo *gpermessageinfo ();
struct type_Qmgr_User *guser ();
struct type_Qmgr_RecipientList *grecipientlist ();
struct type_Qmgr_RecipientInfo *grecipientinfo ();
struct type_Qmgr_MtaControl *gmtacontrol ();
struct type_Qmgr_RecipientList *grecipient ();
struct type_QmgrP1_GlobalDomainIdentifier *ggldmdid ();
struct type_QmgrP1_CountryName *gcountry ();
struct type_QmgrP1_AdministrationDomainName *gadmd ();
struct type_QmgrP1_PrivateDomainIdentifier *gprmd ();
struct type_Qmgr_Filter *gfilter ();
struct type_Qmgr_FilterList *gfilterlist ();
struct type_Qmgr_Control *gcontrol ();
struct type_Qmgr_Priority *gpriority ();
struct type_Qmgr_ChannelList *gchanlist ();
struct qbuf *gqbuf ();
char	*gline ();

static FILE	*input = stdin;
int	level;
#define DISP_INDENT 2

setinput(file)
char	*file;
{
	if ((input = fopen(file, "r")) == NULL) {
		advise (file, "Can't read");
		input = stdin;
	}
}

resetinput ()
{
	if (input != stdin)
		(void) fclose (input);
	input = stdin;
}

struct type_Qmgr_MsgStruct *gmsgstruct ()
{
	struct type_Qmgr_MsgStruct *msg;

	display ("MsgStruct");
	level ++;
	msg = (struct type_Qmgr_MsgStruct *) malloc (sizeof (*msg));
	msg -> messageinfo = gpermessageinfo();
	msg -> recipientlist = grecipientlist ();
	level --;

	return msg;
}

struct type_Qmgr_ReadMessageArgument *greadmessageargument ()
{
	struct type_Qmgr_ReadMessageArgument *rma;

	display ("ReadMessageArgument");
	level ++;

	rma = (struct type_Qmgr_ReadMessageArgument *) malloc (sizeof *rma);

	rma -> filters = gfilterlist ();
	rma -> interval = gutcinterval ("read message");

	level --;
	return rma;
}

struct type_Qmgr_MtaRead *gmtaread ()
{
	struct type_Qmgr_MtaRead *mr;

	display ("MtaRead");
	level ++;

	mr = (struct type_Qmgr_MtaRead *) malloc (sizeof *mr);

	mr -> channel = gqbuf ("Channel");
	mr -> time = gutcinterval ("mta read");

	level --;
	return mr;
}

struct type_Qmgr_ChannelControl	*gchannelcontrol ()
{
	struct type_Qmgr_ChannelControl *cc;

	display ("ChannelControl");
	level ++;

	cc = (struct type_Qmgr_ChannelControl *) malloc (sizeof *cc);

	cc -> channel = gqbuf ("Channel");
	cc -> control = gcontrol ();

	level --;
	return cc;
}

static struct type_Qmgr_PerMessageInfo *gpermessageinfo ()
{
	struct type_Qmgr_PerMessageInfo *pmi;

	display ("PerMessageInfo");
	level ++;
	pmi = (struct type_Qmgr_PerMessageInfo *) malloc (sizeof(*pmi));

	pmi -> queueid = gqbuf ("Queue Id");
	pmi -> mpduiden = gmpduidentifier ();
	pmi -> originator = guser ();
	pmi -> contenttype = gqbuf ("ContentType");
	pmi -> eit = geit ();
	pmi -> priority = gpriority ();
	pmi -> size = gint ("size");
	pmi -> age = gutctime ();
	pmi -> warnInterval = gint ("warninterval");
	pmi -> expiryTime = gutctime ();
	pmi -> deferredTime = gutctime ();
	pmi -> uaContentId = gqbuf ("uaContentId");

	level --;
	return pmi;
}

static int gint (prompt)
char	*prompt;
{
	char	*p;
	int	val = 0;

	p = gline (prompt);
	sscanf (p, "%d", &val);
	return val;
}

static char *gline (prompt)
char	*prompt;
{
	static char buffer[BUFSIZ];
	char	*p;

	printf ("%*s%s : ", level * DISP_INDENT, "", prompt);
	fflush (stdout);
	do {
		fgets (buffer, sizeof buffer, input);
	} while (buffer[0] == '\n' || buffer[0] == '#');
	if (p = index (buffer, '\n'))
		*p = '\0';
	if (input != stdin )
		printf ("%s\n", buffer);

	return buffer;
}


struct type_QmgrP1_MPDUIdentifier *gmpduidentifier ()
{
	struct type_QmgrP1_MPDUIdentifier *mpdu;

	display ("MPDUIdentifier");
	level ++;
	mpdu = (struct type_QmgrP1_MPDUIdentifier *) malloc (sizeof (*mpdu));

	mpdu -> global = ggldmdid ();
	mpdu -> local = gqbuf ("domain id string");
	level --;
	return mpdu;
}

struct type_Qmgr_EncodedInformationTypes *geit()
{
	struct type_Qmgr_EncodedInformationTypes *eit;

	display ("EncodedInformationTypes");
	level ++;
	eit = (struct type_Qmgr_EncodedInformationTypes *)malloc (sizeof (*eit));
	eit -> PrintableString = gqbuf ("PrintableString");
	eit -> next = NULL;

	level --;
	return eit;
}

struct type_Qmgr_Priority *gpriority ()
{
	struct type_Qmgr_Priority *prio;

	display ("Priority");
	level ++;
	prio = (struct type_Qmgr_Priority *)malloc (sizeof (*prio));
	prio -> parm = gint ("priority");
	level --;
	return prio;
}

struct type_UNIV_UTCTime *gutctime ()
{
	struct type_UNIV_UTCTime *ti;
	UTCtime uu;
	UTC	utc = &uu;
	struct tm *tm;
	time_t t;
	char	*cp;
	char	buf[BUFSIZ];

	display ("gtime");
	level ++;
	time (&t);
	tm = localtime (&t);
	tm2ut (tm, utc);
	cp = time2str (utc, 0);
	sprintf (buf, "gutctime: %s", cp);
	display (buf);
	ti = str2qb (cp, strlen (cp), 1);
	level --;
	return ti;
}

struct type_UNIV_UTCTime *gutcinterval (str)
char *str;
{
	struct type_UNIV_UTCTime *ti;
	UTCtime uu;
	UTC	utc = &uu;
	struct tm *tm;
	time_t t;
	char	*cp, *prompt, *p;
	char	buf[BUFSIZ];

	display ("gutcinterval");
	level ++;

	utc = (UTC) calloc (1, sizeof(struct UTCtime));

	utc->ut_flags = UT_SEC;
	prompt = malloc (strlen("Input number of seconds between  operations :" )
			 + strlen(str));
	sprintf(prompt,"Input number of seconds between %s operations :",str);
	p = gline (prompt);
	sscanf(p,"%d",&(utc->ut_sec));
	cp = utct2str(utc);
	ti = str2qb (cp, strlen (cp), 1);
	if (prompt != NULL) free(prompt);
	level --;
	return ti;
}

struct type_Qmgr_User *guser ()
{
	struct type_Qmgr_User *user;

	display ("User");
	level ++;
	user =  gqbuf ("rfc822");
	level --;
	return user;
}

struct type_Qmgr_RecipientList *grecipientlist ()
{
	struct type_Qmgr_RecipientList *rl;

	display ("RecipientList");
	level ++;
	rl = (struct type_Qmgr_RecipientList *) malloc (sizeof *rl);
	rl -> RecipientInfo = grecipientinfo ();
	rl -> next = 0;
	level--;
	return rl;
}
		


static struct type_Qmgr_RecipientInfo *grecipientinfo ()
{
	struct type_Qmgr_RecipientInfo *ri;

	display ("RecipientInfo");
	level ++;
	ri = (struct type_Qmgr_RecipientInfo *) malloc (sizeof(*ri));
	ri -> user = guser ();
	ri -> id = gint ("id");
	ri -> mta = gqbuf ("Mta");
	ri -> channelList = gchanlist ();
	ri -> channelsDone = gint ("channelsDone");
	
	level --;
	return ri;
}

struct type_Qmgr_ChannelList *gchanlist ()
{
	struct type_Qmgr_ChannelList *cl;

	display ("ChannelList");
	level ++;

	cl = (struct type_Qmgr_ChannelList *) malloc (sizeof *cl);

	cl -> Channel = gqbuf ("Channel");
	cl -> next = 0;

	level --;
	return cl;
}

struct type_QmgrP1_GlobalDomainIdentifier *ggldmdid ()
{
	struct type_QmgrP1_GlobalDomainIdentifier *glid;

	display ("GlobalDomainIdentifier");
	level ++;
	glid = (struct type_QmgrP1_GlobalDomainIdentifier *) malloc (sizeof(*glid));

	glid -> country = gcountry();
	glid -> admd = gadmd ();
	glid -> prmd = gprmd ();
	level --;
	return glid;
}

struct type_QmgrP1_CountryName *gcountry ()
{
	struct type_QmgrP1_CountryName *country;

	display ("CountryName");
	level ++;
	country = (struct type_QmgrP1_CountryName *)malloc (sizeof(*country));
	country -> offset = type_QmgrP1_CountryName_printable;
	country -> un.printable = gqbuf("country");
	level --;
	return country;
}

struct type_QmgrP1_AdministrationDomainName *gadmd ()
{
	struct type_QmgrP1_AdministrationDomainName *admd;

	display ("AdministrationDomainName");
	level ++;
	admd = (struct type_QmgrP1_AdministrationDomainName *)malloc (sizeof(*admd));
	admd -> offset = type_QmgrP1_AdministrationDomainName_printable;
	admd -> un.printable = gqbuf("admd");
	level --;
	return admd;
}

struct type_QmgrP1_PrivateDomainIdentifier *gprmd ()
{
	struct type_QmgrP1_PrivateDomainIdentifier *prmd;

	display ("PrivateDomainIdentifier");
	level ++;
	prmd = (struct type_QmgrP1_PrivateDomainIdentifier *)malloc (sizeof(*prmd));
	prmd -> offset = type_QmgrP1_PrivateDomainIdentifier_printable;
	prmd -> un.printable = gqbuf("prmd");
	level --;
	return prmd;
}


struct qbuf *gqbuf (p)
char	*p;
{
	char	*s = gline (p);

	return str2qb (s, strlen(s), 1);
}

static char first_non_white (str)
char	*str;
{
	char *ix = str;
	while ((ix != NULL) && isspace(*ix))
		ix++;
	if (ix == NULL)
		return ' ';
	else
		return *ix;
}

struct type_Qmgr_FilterList *gfilterlist ()
{
	struct type_Qmgr_FilterList *head = NULL,
	                            *tail = NULL,
	                            *temp;
	int			    cont;
	char			    ans, *p;

	display ("readmsginfo");
	level ++;
	
	p = gline ("Do you want to input a filter (y/n) ? ");
	ans = first_non_white (p);
	while (index("yn",ans) == NULL) {
		p = gline(" (y/n) ? ");
		ans = first_non_white (p);
	}
	cont = (ans == 'y') ? 0 : 1;
	
	while (cont == 0) {
		temp = (struct type_Qmgr_FilterList *) calloc (1,sizeof (*temp));
		temp -> Filter = gfilter ();
		if (head == NULL)
			head = tail = temp;
		else {
			tail->next = temp;
			tail = temp;
		}

		p = gline ("Do you want to input another filter (y/n) ? ");
		ans = first_non_white (p);
		while (index("yn",ans) == NULL) {
			p = gline(" (y/n) ? ");
			ans = first_non_white (p);
		}
		cont = (ans == 'y') ? 0 : 1;

	}
	level --;
	return head;
}

struct type_Qmgr_Filter *gfilter ()
{
	struct type_Qmgr_Filter *filt;

	display ("Filter");
	level ++;

	filt = (struct type_Qmgr_Filter *) malloc (sizeof (*filt));

	filt -> contenttype = gqbuf ("ContentType");
	filt -> eit = geit ();
	filt -> priority = gpriority ();
	filt -> moreRecentThan = gutctime ();
	filt -> earlierThan = gutctime ();
	filt -> maxSize = gint ("maxSize");
	filt -> originator = guser ();
	filt -> recipient = guser ();
	filt -> channel = gqbuf ("Channel");
	filt -> mta = gqbuf("DMtahost");
	filt -> queueid = gqbuf ("Queue Id");
	filt -> mpduiden = gmpduidentifier ();
	filt -> uaContentId = gqbuf ("UAContentId");
	level --;
	return filt;
}

struct type_Qmgr_MtaControl *gmtacontrol ()
{
	struct type_Qmgr_MtaControl *mc;

	display ("MtaControl");
	level ++;
	mc = (struct type_Qmgr_MtaControl *)calloc (1, sizeof (*mc));
	mc -> channel = gqbuf ("Channel");
	mc -> mta = gqbuf ("mta");
	mc -> control = gcontrol ();
	level --;
	return mc;
}

struct type_Qmgr_Control *gcontrol ()
{
	struct type_Qmgr_Control *co;

	display ("Control");
	level ++;

	co = (struct type_Qmgr_Control *) malloc (sizeof *co);

	co -> offset = gint ("1/stop 2/start 3/cacheClear");

	level --;
	return co;
}