XINU
Functions
strnlen.c File Reference

NULL終端された文字列の長さを返す。 More...

Go to the source code of this file.

Functions

int strnlen (const char *s, unsigned int len)
 NULL終端された文字列の長さを返す。NULL終端は長さに含まない。 More...
 

Detailed Description

NULL終端された文字列の長さを返す。

文字列を読み取る長さは、ユーザが指定したN Byteを最大長とする。
文字列の長さにNULL終端を含まない。

Definition in file strnlen.c.

Function Documentation

◆ strnlen()

int strnlen ( const char *  s,
unsigned int  len 
)

NULL終端された文字列の長さを返す。NULL終端は長さに含まない。

Parameters
[in]s長さを調べる対象の文字列
[in]len読み取る長さの最大長(Byte)
Returns
文字列の長さを返す。NULL終端は長さに含まず、ユーザが指定したN Byteを最大長とする。

Definition at line 14 of file strnlen.c.

Referenced by tftpget_mb(), xsh_help(), and xsh_udpecho().

15 {
16  int n;
17 
18  n = 0;
19  while (*s++ && n < len)
20  n++;
21 
22  return (n);
23 }
Here is the caller graph for this function: