Exemple #1
0
/* main - the main routine */
int main(int argc,char *argv[])
{
    char *fname,*lname;
    int rows,cols,i;

#ifdef MAC
    char name[50];
    macinit(name);
    fname = name;
    lname = NULL;
    rows = 20;
    cols = 80;
#else
    printf("ADVINT v1.2 - Copyright (c) 1986, by David Betz\n");
    fname = NULL;
    lname = NULL;
    rows = 24;
    cols = 80;

    /* parse the command line */
    for (i = 1; i < argc; i++)
	if (argv[i][0] == '-')
	    switch (argv[i][1]) {
	    case 'r':
	    case 'R':
		    rows = atoi(&argv[i][2]);
		    break;
	    case 'c':
	    case 'C':
		    cols = atoi(&argv[i][2]);
		    break;
	    case 'l':
	    case 'L':
		    lname = &argv[i][2];
	    	    break;
	    }
	else
	    fname = argv[i];
    if (fname == NULL) {
	printf("usage: advint [-r<rows>] [-c<columns>] [-l<log-file>] <file>\n");
	exit(EXIT_FAILURE);
    }
#endif

    /* initialize terminal i/o */
    trm_init(rows,cols,lname);

    /* initialize the database */
    db_init(fname);

    /* play the game */
    play();
    return 0;
}
Exemple #2
0
branch()
{
	register char	c;
	register int	i;
	extern char	getch();

#	ifdef xMTR2
	if (tTf(16, -1))
		printf(">>branch: ");
#	endif

	/* see if conditional */
	while ((c = getch()) > 0)
		if (c != ' ' && c != '\t')
			break;
	if (c == '?')
	{
		/* got a conditional; evaluate it */
		Oneline = TRUE;
		macinit(&getch, 0, 0);
		i = expr();

		if (i <= 0)
		{
			/* no branch */
#			ifdef xMTR2
			if (tTf(16, 0))
				printf("no branch\n");
#			endif
			getfilename();
			return;
		}
	}
	else
	{
		Peekch = c;
	}

	/* get the target label */
	if (branchto(getfilename()) == 0)
		if (branchto(macro("{default}")) == 0)
		{
			Peekch = -1;
			printf("Cannot branch\n");
		}
	return;
}
void
trapquery(struct resp *resp, char *name)
{
	register FILE	*iop;
	static int	first;
	register char	*sp, c;
	time_t		timevec;

	if (first < 0)
		return;
	if (Trapfile == NULL) {
		if ((Trapfile = fopen(name, "a")) == NULL) {
			printf("can't trap query in %s\n", name);
			first = -1;
			return;
		}
	}
	if (first == 0) {
		(void) time(&timevec);
		sp = ctime(&timevec);
		while (*sp)
			putc(*sp++, Trapfile);
		first++;
	}

	if ((iop = fopen(Qbname, "r")) == NULL)
		syserr("go: open 1");
	macinit(fgetc, iop, 1);

	while ((c = macgetch()) > 0)
		putc(c, Trapfile);

	if (resp->resp_resp == 0) {
		sp = (char *) locv(resp->resp_tups);
		while (*sp)
			putc(*sp++, Trapfile);
		putc('\n', Trapfile);
	}

	fclose(iop);
}