XINU
Functions
fputs.c File Reference

文字列をデバイス(ファイル)に書き込む。 More...

Go to the source code of this file.

Functions

int fputs (char *s, int dev)
 文字列をデバイス(ファイル)に書き込む。 More...
 
int putc (int, char)
 文字を書き込むputc()のextern宣言 More...
 

Detailed Description

文字列をデバイス(ファイル)に書き込む。

Definition in file fputs.c.

Function Documentation

◆ fputs()

int fputs ( char *  s,
int  dev 
)

文字列をデバイス(ファイル)に書き込む。

Parameters
[in]s書き込む文字列(NULL終端されている事)
[in]devデバイスディスクリプタ
Returns
最後にputc()で書き込んだ結果を返す(詳細は、 putc()を参照する事)

Definition at line 15 of file fputs.c.

References putc().

16 {
17  int r = 0, c;
18 
19  while ((c = (*s++)))
20  {
21  r = putc(dev, c);
22  }
23  return r;
24 }
int putc(int, char)
文字を書き込むputc()のextern宣言
Definition: putc.c:18
Here is the call graph for this function:

◆ putc()

int putc ( did32  descrp,
char  ch 
)

文字を書き込むputc()のextern宣言

文字を書き込むputc()のextern宣言

Step1. 割り込みを禁止する。
Step2. デバイスディスクリプタが不正値の場合は、割り込み状態を復元し、処理を終了する。
Step3. デバイスに応じたputc()処理を行う。
Step4. 割り込み状態を復元する。

Parameters
[in]descrpデバイスディスクリプタ
[in]ch送信したい文字
Returns
成功時はデバイスに応じた返り値、デバイスディスクリプタが不正値の場合はSYSERRを返す。

Definition at line 18 of file putc.c.

References devtab, disable(), dentry::dvputc, isbaddev, restore(), and SYSERR.

Referenced by fputs().

19 {
20  intmask mask; /* Saved interrupt mask */
21  struct dentry *devptr; /* Entry in device switch table */
22  int32 retval; /* Value to return to caller */
23 
24  mask = disable();
25  if (isbaddev(descrp))
26  {
27  restore(mask);
28  return SYSERR;
29  }
30  devptr = (struct dentry *)&devtab[descrp];
31  retval = (*devptr->dvputc)(devptr, ch);
32  restore(mask);
33  return retval;
34 }
void restore(intmask)
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
devcall(* dvputc)(struct dentry *, char)
Definition: conf.h:17
Definition: conf.h:6
struct dentry devtab[]
Definition: conf.c:11
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 call graph for this function:
Here is the caller graph for this function: