XINU
Macros | Functions
fgetc.c File Reference

デバイス(ファイル)から文字を読み込む。 More...

Go to the source code of this file.

Macros

#define EOF   (-2)
 End Of Fileを示す値 More...
 

Functions

int fgetc (int dev)
 デバイス(ファイル)から文字を読み込む。 More...
 
int getc (int)
 デバイスから1Byte読み込むgetc()のextern宣言 More...
 

Detailed Description

デバイス(ファイル)から文字を読み込む。

Definition in file fgetc.c.

Macro Definition Documentation

◆ EOF

#define EOF   (-2)

End Of Fileを示す値

Definition at line 11 of file fgetc.c.

Referenced by fgetc().

Function Documentation

◆ fgetc()

int fgetc ( int  dev)

デバイス(ファイル)から文字を読み込む。

Parameters
[in]devデバイスディスクリプタ
Returns
成功時は読み込んだ文字、異常時はEOFを返す。

Definition at line 19 of file fgetc.c.

References EOF, and getc().

Referenced by getchar().

21 {
22  int result = (int)getc(dev);
23 
24  if (0 > result)
25  {
26  return EOF;
27  }
28  else
29  {
30  return result;
31  }
32 }
#define EOF
End Of Fileを示す値
Definition: fgetc.c:11
int getc(int)
デバイスから1Byte読み込むgetc()のextern宣言
Definition: getc.c:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getc()

int getc ( int  )

デバイスから1Byte読み込むgetc()のextern宣言

Definition at line 9 of file getc.c.

Referenced by fgetc().

12 {
13  intmask mask; /* Saved interrupt mask */
14  struct dentry *devptr; /* Entry in device switch table */
15  int32 retval; /* Value to return to caller */
16 
17  mask = disable();
18  if (isbaddev(descrp)) {
19  restore(mask);
20  return SYSERR;
21  }
22  devptr = (struct dentry *) &devtab[descrp];
23  retval = (*devptr->dvgetc) (devptr);
24  restore(mask);
25  return retval;
26 }
void restore(intmask)
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
Definition: conf.h:6
struct dentry devtab[]
Definition: conf.c:11
devcall(* dvgetc)(struct dentry *)
Definition: conf.h:16
uint32 intmask
保存された割り込みマスク
Definition: kernel.h:38
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
#define isbaddev(f)
デバイスIDを検証するマクロ。
Definition: device.h:15
intmask disable(void)
割り込み禁止(intr.Sに定義がある)
Here is the caller graph for this function: