XINU
Functions
ttygetc.c File Reference
#include <xinu.h>
Include dependency graph for ttygetc.c:

Go to the source code of this file.

Functions

devcall ttygetc (struct dentry *devptr)
 

Function Documentation

◆ ttygetc()

devcall ttygetc ( struct dentry devptr)

Definition at line 9 of file ttygetc.c.

References dentry::dvminor, EOF, ttytab, TY_IBUFLEN, TY_IMCOOKED, ttycblk::tyeof, ttycblk::tyeofch, ttycblk::tyibuff, ttycblk::tyihead, ttycblk::tyimode, ttycblk::tyisem, and wait().

Referenced by ttyread().

12 {
13  char ch; /* Character to return */
14  struct ttycblk *typtr; /* Pointer to ttytab entry */
15 
16  typtr = &ttytab[devptr->dvminor];
17 
18  /* Wait for a character in the buffer and extract one character */
19 
20  wait(typtr->tyisem);
21  ch = *typtr->tyihead++;
22 
23  /* Wrap around to beginning of buffer, if needed */
24 
25  if (typtr->tyihead >= &typtr->tyibuff[TY_IBUFLEN]) {
26  typtr->tyihead = typtr->tyibuff;
27  }
28 
29  /* In cooked mode, check for the EOF character */
30 
31  if ( (typtr->tyimode == TY_IMCOOKED) && (typtr->tyeof) &&
32  (ch == typtr->tyeofch) ) {
33  return (devcall)EOF;
34  }
35 
36  return (devcall)ch;
37 }
char tyeofch
Definition: tty.h:48
int32 dvminor
Definition: conf.h:8
char tyibuff[TY_IBUFLEN]
Definition: tty.h:29
#define EOF
ファイルの終端(End of File)に達した場合(読み込み処理に用いる)
Definition: kernel.h:81
Definition: tty.h:26
char * tyihead
Definition: tty.h:27
struct ttycblk ttytab[]
Definition: ttyinit.c:11
char tyimode
Definition: tty.h:38
#define TY_IMCOOKED
Definition: tty.h:22
syscall wait(sid32)
Definition: wait.c:9
#define TY_IBUFLEN
Definition: tty.h:13
bool8 tyeof
Definition: tty.h:47
int32 devcall
デバイスコール関数 返り値の型
Definition: kernel.h:49
sid32 tyisem
Definition: tty.h:30
Here is the call graph for this function:
Here is the caller graph for this function: