Пример #1
0
char *
mcall(char *mac)
{
	register char	c;
	register char	*p;
	static char	buf[100];
	FUNC_EXTERN i4	macsget();

	/* set up a new environment to process macro */
	macnewev(macsget, &mac);

	/* process it -- save result */

	for (p = buf; (c = macgetch()) > 0; )
	{
		if (p < &buf[sizeof buf])
			*p++ = c;
	}

	*p = 0;

	/* restore the old environment */
	macpopev();

	return (buf);
}
Пример #2
0
/*
**  EXPRGCH -- expression character get
**
**	Gets the next character from the expression input.  Takes
**	a character out of ExprPeek first.  Also maps spaces, tabs,
**	and newlines into zero bytes.
**
**	Parameters:
**		none
**
**	Returns:
**		Next character.
**
**	Side Effects:
**		Gobbles input.
**		Clears ExprPeek if set.
**
**	Requires:
**		ExprPeek -- the peek character.
**		macgetch -- to get the next character if ExprPeek
**			is not set.
*/
int
exprgch(void)
{
	register int	c;

	c = ExprPeek;
	if (c < 0)
		c = macgetch();
	ExprPeek = -1;
	if (isspace(c)) {
		c = 0;
	}
	return (c);
}
Пример #3
0
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);
}