home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d1xx
/
d197
/
stevie.lha
/
Stevie
/
bsd.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-03-28
|
2KB
|
113 lines
/*
* System-dependent routines for BSD 4.3 UNIX
*/
#include "stevie.h"
#include <sgtty.h>
/*
* inchar() - get a character from the keyboard
*/
int
inchar()
{
int c;
fflush(stdout); /* flush any pending output */
c = getchar();
return c;
}
void
outstr(s)
char *s;
{
while (*s)
outchar(*s++);
}
void
beep()
{
if (RedrawingDisabled)
return;
outchar('\007');
}
void
delay()
{
sleep(1);
}
static struct sgttyb ostate;
void
windinit()
{
char *getenv();
char *term;
struct sgttyb nstate;
term = getenv("TERM");
if (!term) {
fprintf(stderr, "Invalid terminal type '%s'\n", term);
exit(1);
}
if ((strncmp(term, "vt", 2) != 0) && (strncmp(term, "kd", 2) != 0)) {
fprintf(stderr, "Invalid terminal type '%s'\n", term);
exit(1);
}
Columns = 80;
P(P_LI) = Rows = 24;
/*
* Go into cbreak mode
*/
ioctl(1, (long) TIOCGETP, (char *) &ostate);
nstate = ostate;
nstate.sg_flags = nstate.sg_flags & ~(ECHO | CRMOD) | CBREAK;
ioctl(1, (long) TIOCSETP, (char *) &nstate);
}
void
windexit(r)
int r;
{
fflush(stdout);
ioctl(0, (long) TIOCSETP, (char *) &ostate);
exit(r);
}
void
windgoto(r, c)
int c;
int r;
{
r++;
c++;
outstr("\033[");
if (r >= 10)
outchar((char) (r / 10 + '0'));
outchar((char) (r % 10 + '0'));
outchar(';');
if (c >= 10)
outchar((char) (c / 10 + '0'));
outchar((char) (c % 10 + '0'));
outchar('H');
}
FILE *
fopenb(fname, mode)
char *fname;
char *mode;
{
return fopen(fname, mode);
}