#ifndef lint
static char *RCSid = "$Header: /usr/brule/guest/empire/empire/emprcs/client/termlib.c,v 2.1 1995/10/11 03:07:43 empire Exp $";
#endif /* not lint */

/*
 * termlib.c
 *
 * Dave Pare, 1986
 */

#include <stdio.h>
#include <ctype.h>
#include "misc.h"

s_char	*SO;
s_char	*SE;

parsedelay(r)
	s_char *r;
{
	s_char *s, *t;

	s = r;
	while (isdigit(*s) || (*s == '*') || (*s == '.')) {
		s++;
	}
	for (t = r; *s != 0; (s++, t++)) {
		*t = *s;
	}
	*t = 0;
}

int
getsose()
{
	extern	s_char *getenv();
	extern	s_char *tgetstr();
	static	s_char tbuf[1024];
	static	s_char cbuf[20];
	s_char	*cp;
	s_char	*term;

	term = getenv("TERM");
	if (term == 0) {
		fprintf(stderr, "warning: no TERM environment variable\n");
		return 0;
	}
	tgetent(tbuf, term);
	cp = cbuf;
	SO = tgetstr("so", &cp);
	SE = tgetstr("se", &cp);
	if (SO == 0) {
		SO = tgetstr("us", &cp);
		SE = tgetstr("ue", &cp);
	}
	if (SO != 0) {
		parsedelay(SO);
		parsedelay(SE);
	}
}
