Subversion Repositories Kolibri OS

Rev

Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
/*
2
FUNCTION
3
	<>---character string length
4
 
5
INDEX
6
	strnlen
7
 
8
ANSI_SYNOPSIS
9
	#include 
10
	size_t strnlen(const char *<[str]>, size_t <[n]>);
11
 
12
TRAD_SYNOPSIS
13
	#include 
14
	size_t strnlen(<[str]>, <[n]>)
15
	char *<[src]>;
16
	size_t <[n]>;
17
 
18
DESCRIPTION
19
	The <> function works out the length of the string
20
	starting at <<*<[str]>>> by counting chararacters until it
21
	reaches a NUL character or the maximum: <[n]> number of
22
        characters have been inspected.
23
 
24
RETURNS
25
	<> returns the character count or <[n]>.
26
 
27
PORTABILITY
28
<> is a GNU extension.
29
 
30
<> requires no supporting OS subroutines.
31
 
32
*/
33
 
34
#undef __STRICT_ANSI__
35
#include <_ansi.h>
36
#include 
37
 
38
size_t
39
_DEFUN (strnlen, (str, n),
40
	_CONST char *str _AND
41
	size_t n)
42
{
43
  _CONST char *start = str;
44
 
45
  while (n-- > 0 && *str)
46
    str++;
47
 
48
  return str - start;
49
}