/**** Upper HALF driver routines ****/
int sgetc(struct stty* tty)
{
char c;
/*(1). wait for chars in inbuf[]*/
P(&tty->inRoom);
/*(2). get a char from inbuf[]; NOTE: MUST HANDLE POSSIBLE INTERFERENCE FROM shandler()!*/
lock();
c = tty->inbuf[tty->inhead++];
tty->inhead %= BUFLEN;
unlock();
/*(3). return the char;*/
return c;
}/*end sgetc*/
int sgetline(struct stty* tty, char* line)
{
/*(1). one process at a time!
tty = &stty[0];*/
/*(2). call sgetc() repeatedly until a line is copied to line[];*/
while (*line)
{
sgetc(tty, *line++);
}/*end while line exists*/
/*(3). allow another process.*/
return 1;
}/*end sgetline*/