XINU
ttygetc.c
Go to the documentation of this file.
1 /* ttygetc.c - ttygetc */
2 
3 #include <xinu.h>
4 
5 /*------------------------------------------------------------------------
6  * ttygetc - Read one character from a tty device (interrupts disabled)
7  *------------------------------------------------------------------------
8  */
10  struct dentry *devptr /* Entry in device switch table */
11  )
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
devcall ttygetc(struct dentry *devptr)
Definition: ttygetc.c:9
#define EOF
ファイルの終端(End of File)に達した場合(読み込み処理に用いる)
Definition: kernel.h:81
Definition: conf.h:6
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