XINU
Macros | Functions
stdio.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define scanf(fmt, args)   fscanf(CONSOLE, fmt, args)
 
#define stderr   ((proctab[currpid]).prdesc[2])
 
#define stdin   ((proctab[currpid]).prdesc[0])
 
#define stdout   ((proctab[currpid]).prdesc[1])
 

Functions

int32 _doscan (char *, int32 *, int32(*)(void), int32(*)(char), int32, int32)
 
int32 fgetc (int)
 デバイス(ファイル)から文字を読み込む。 More...
 
char * fgets (char *, int32, int32)
 デバイス(ファイル)から文字列を読み込む。 More...
 
int32 fprintf (int, char *,...)
 
int32 fputc (int32, int32)
 文字をデバイス(ファイル)に書き込む。 More...
 
int32 fputs (char *, int32)
 文字列をデバイス(ファイル)に書き込む。 More...
 
int32 fscanf (int32, char *, int32)
 
int32 getchar (void)
 STDIN(標準入力)から文字を読み込む。 More...
 
int32 printf (const char *,...)
 
int32 putchar (int32 c)
 
int32 sprintf (char *, char *,...)
 
int32 sscanf (char *, char *, int32)
 

Macro Definition Documentation

◆ scanf

#define scanf (   fmt,
  args 
)    fscanf(CONSOLE, fmt, args)

Definition at line 10 of file stdio.h.

◆ stderr

#define stderr   ((proctab[currpid]).prdesc[2])

◆ stdin

#define stdin   ((proctab[currpid]).prdesc[0])

Definition at line 15 of file stdio.h.

Referenced by getchar(), if(), main(), and xsh_cat().

◆ stdout

#define stdout   ((proctab[currpid]).prdesc[1])

Definition at line 16 of file stdio.h.

Referenced by hexdump(), hexdump_print(), if(), printf(), putchar(), and xsh_cat().

Function Documentation

◆ _doscan()

int32 _doscan ( char *  ,
int32 ,
int32(*)(void)  ,
int32(*)(char)  ,
int32  ,
int32   
)

◆ fgetc()

int32 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:

◆ fgets()

char* fgets ( char *  s,
int  n,
int  dev 
)

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

以下のいずれかの場合に、文字列の読み込みを停止する
 ・最大読み込みByteに達した
 ・行の最後(改行コード)まで達した(Linux形式=LFか、Mac形式=CRのどちらか)
 ・EOFまで達した
文字列(改行コード含む)の最後にはNULL終端を付与する。

Parameters
[in,out]s読み込んだ文字列
[in]n最大読み込みByte
[in]devデバイスディスクリプタ
Returns
成功時は読み込んだ文字列(改行コードとNULL終端含む)、EOFや空文字の場合はNULLを返す。

Definition at line 25 of file fgets.c.

References getc(), and NULL.

26 {
27  int c = 0;
28  char *cs;
29 
30  cs = s;
31 
32  /* Read characters until maximum read length, */
33  /* end of line, or end of file */
34  while ((--n > 0) && ((c = getc(dev)) >= 0))
35  {
36  *cs++ = c;
37  if (('\n' == c) || ('\r' == c))
38  {
39  break;
40  }
41  }
42 
43  /* Check for EOF or empty string */
44  if ((c < 0) && (cs == s))
45  {
46  return NULL;
47  }
48 
49  /* Terminate string and return */
50  *cs++ = '\0';
51  return s;
52 }
#define NULL
NULLを示す値
Definition: fgets.c:7
int getc(int)
デバイスから1Byte読み込むgetc()のextern宣言
Definition: getc.c:9
Here is the call graph for this function:

◆ fprintf()

int32 fprintf ( int  ,
char *  ,
  ... 
)

Definition at line 14 of file fprintf.c.

References _fdoprnt(), putc(), va_end, and va_start.

Referenced by addattr(), addton(), devisid(), devonid(), getattrid(), getutime(), hexdump(), hexdump_print(), if(), main(), newdev(), newtype(), shell(), xsh_cat(), xsh_clear(), xsh_date(), xsh_devdump(), xsh_help(), xsh_kill(), xsh_ls(), xsh_memdump(), xsh_memstat(), xsh_netinfo(), xsh_ping(), xsh_ps(), xsh_sleep(), xsh_udpdump(), xsh_udpecho(), xsh_udpeserver(), xsh_uptime(), and yyerror().

19 {
20  va_list ap;
21  int putc(did32, char);
22 
23  va_start(ap, fmt);
24  _fdoprnt(fmt, ap, putc, dev);
25  va_end(ap);
26 
27  return 0;
28 }
void _fdoprnt(char *, va_list, int(*)(did32, char), int)
#define va_start(last, va)
va_list型を初期化し、可変長引数の使用を開始する。
Definition: stdarg.h:25
syscall putc(did32, char)
デバイスへ文字1Byteを送信する。
Definition: putc.c:18
#define va_end(va)
可変長引数の処理を終了する。
Definition: stdarg.h:42
int32 did32
デバイスID
Definition: kernel.h:28
__builtin_va_list va_list
可変個の実引数を扱うための情報を保持するための型(__builtin_va_listはGCCに定義された型) ...
Definition: stdarg.h:7
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fputc()

int32 fputc ( int  c,
int  dev 
)

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

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

Definition at line 24 of file fputc.c.

References EOF, putc(), and SYSERR.

Referenced by putchar().

25 {
26  if (SYSERR == (int)putc(dev, c))
27  {
28  return EOF;
29  }
30  else
31  {
32  return c;
33  }
34 }
int putc(int, char)
文字を書き込むputc()のextern宣言
Definition: putc.c:18
#define EOF
End Of Fileを示す値
Definition: fputc.c:15
#define SYSERR
システムエラーを示す値
Definition: fputc.c:11
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fputs()

int32 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:

◆ fscanf()

int32 fscanf ( int32  ,
char *  ,
int32   
)

Definition at line 23 of file fscanf.c.

References _doscan(), EMPTY, getch(), and ungetch().

28 {
29  int buf;
30 
31  buf = EMPTY;
32  return (_doscan
33  (fmt, (int **)&args, getch, ungetch, dev, (int)(int)&buf));
34 }
static int ungetch(int, int)
Definition: fscanf.c:60
#define EMPTY
Definition: fscanf.c:4
int _doscan(register char *, register int **, int(*getc)(int, int), int(*ungetc)(int, int), int, int)
Definition: doscan.c:38
static int getch(int, int)
Definition: fscanf.c:40
Here is the call graph for this function:

◆ getchar()

int32 getchar ( void  )

STDIN(標準入力)から文字を読み込む。

Returns
成功時は読み込んだ文字、異常時はEOFを返す。

Definition at line 12 of file getchar.c.

References fgetc(), and stdin.

13 {
14  return fgetc(stdin);
15 }
int32 fgetc(int)
デバイス(ファイル)から文字を読み込む。
Definition: fgetc.c:19
#define stdin
Definition: stdio.h:15
Here is the call graph for this function:

◆ printf()

int32 printf ( const char *  ,
  ... 
)

Definition at line 13 of file printf.c.

References _fdoprnt(), putc(), stdout, va_end, and va_start.

Referenced by arp_dmp(), arp_dump(), main(), printFreeList(), printMemUse(), xsh_argecho(), xsh_arp(), xsh_cat(), xsh_clear(), xsh_date(), xsh_devdump(), xsh_echo(), xsh_help(), xsh_kill(), xsh_ls(), xsh_memdump(), xsh_memstat(), xsh_netinfo(), xsh_ping(), xsh_ps(), xsh_sleep(), xsh_udpdump(), xsh_udpecho(), xsh_udpeserver(), and xsh_uptime().

17 {
18  va_list ap;
19  syscall putc(did32, char);
20 
21  va_start(ap, fmt);
22  _fdoprnt((char *)fmt, ap, putc, stdout);
23  va_end(ap);
24 
25  return 0;
26 }
#define stdout
Definition: stdio.h:16
#define va_start(last, va)
va_list型を初期化し、可変長引数の使用を開始する。
Definition: stdarg.h:25
void _fdoprnt(char *, va_list, int(*)(did32, char), int)
syscall putc(did32, char)
デバイスへ文字1Byteを送信する。
Definition: putc.c:18
#define va_end(va)
可変長引数の処理を終了する。
Definition: stdarg.h:42
int32 did32
デバイスID
Definition: kernel.h:28
__builtin_va_list va_list
可変個の実引数を扱うための情報を保持するための型(__builtin_va_listはGCCに定義された型) ...
Definition: stdarg.h:7
int32 syscall
システムコール関数 返り値の型
Definition: kernel.h:47
Here is the call graph for this function:
Here is the caller graph for this function:

◆ putchar()

int32 putchar ( int32  c)

Definition at line 10 of file putchar.c.

References fputc(), and stdout.

13 {
14  return fputc(c, stdout);
15 }
#define stdout
Definition: stdio.h:16
int32 fputc(int32, int32)
文字をデバイス(ファイル)に書き込む。
Definition: fputc.c:24
Here is the call graph for this function:

◆ sprintf()

int32 sprintf ( char *  ,
char *  ,
  ... 
)

Definition at line 12 of file sprintf.c.

References _fdoprnt(), sprntf(), va_end, and va_start.

Referenced by ascdate(), startup(), and xsh_netinfo().

17 {
18  va_list ap;
19  char *s;
20 
21  s = str;
22  va_start(ap, fmt);
23  _fdoprnt(fmt, ap, sprntf, (int)&s);
24  va_end(ap);
25  *s++ = '\0';
26 
27  return ((int)str);
28 }
void _fdoprnt(char *, va_list, int(*func)(int, int), int)
Definition: fdoprnt.c:20
#define va_start(last, va)
va_list型を初期化し、可変長引数の使用を開始する。
Definition: stdarg.h:25
#define va_end(va)
可変長引数の処理を終了する。
Definition: stdarg.h:42
__builtin_va_list va_list
可変個の実引数を扱うための情報を保持するための型(__builtin_va_listはGCCに定義された型) ...
Definition: stdarg.h:7
static int sprntf(int, int)
Definition: sprintf.c:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sscanf()

int32 sscanf ( char *  ,
char *  ,
int32   
)

Definition at line 20 of file sscanf.c.

References _doscan(), sgetch(), and sungetch().

25 {
26  char *s;
27 
28  s = str;
29  return (_doscan(fmt, (int **)&args, sgetch, sungetch, 0, (int)&s));
30 }
int _doscan(register char *, register int **, int(*getc)(int, char **), int(*ungetc)(int, char **), int, int)
static int sungetch(int, char **)
Definition: sscanf.c:48
static int sgetch(int, char **)
Definition: sscanf.c:36
Here is the call graph for this function: