OSDN Git Service

7971ecb89b13ef0326a6c005eb189a7c84f07a8c
[linuxjm/LDP_man-pages.git] / original / man3 / strnlen.3
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\" %%%LICENSE_END
9 .\"
10 .\" References consulted:
11 .\"   GNU glibc-2 source code and manual
12 .\"
13 .TH STRNLEN 3  2014-02-25 "GNU" "Linux Programmer's Manual"
14 .SH NAME
15 strnlen \- determine the length of a fixed-size string
16 .SH SYNOPSIS
17 .nf
18 .B #include <string.h>
19 .sp
20 .BI "size_t strnlen(const char *" s ", size_t " maxlen );
21 .fi
22 .sp
23 .in -4n
24 Feature Test Macro Requirements for glibc (see
25 .BR feature_test_macros (7)):
26 .in
27 .sp
28 .BR strnlen ():
29 .PD 0
30 .ad l
31 .RS 4
32 .TP 4
33 Since glibc 2.10:
34 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
35 .TP
36 Before glibc 2.10:
37 _GNU_SOURCE
38 .RE
39 .ad
40 .PD
41 .SH DESCRIPTION
42 The
43 .BR strnlen ()
44 function returns the number of bytes in the string
45 pointed to by
46 .IR s ,
47 excluding the terminating null byte (\(aq\\0\(aq),
48 but at most
49 .IR maxlen .
50 In doing this,
51 .BR strnlen ()
52 looks only at the first
53 .I maxlen
54 bytes at
55 .I s
56 and never beyond
57 .IR s+maxlen .
58 .SH RETURN VALUE
59 The
60 .BR strnlen ()
61 function returns
62 .IR strlen(s) ,
63 if that is less than
64 .IR maxlen ,
65 or
66 .I maxlen
67 if there is no null byte (\(aq\\0\(aq) among the first
68 .I maxlen
69 bytes pointed to by
70 .IR s .
71 .SH ATTRIBUTES
72 .SS Multithreading (see pthreads(7))
73 The
74 .BR strnlen ()
75 function is thread-safe.
76 .SH CONFORMING TO
77 POSIX.1-2008.
78 .SH SEE ALSO
79 .BR strlen (3)
80 .SH COLOPHON
81 This page is part of release 3.64 of the Linux
82 .I man-pages
83 project.
84 A description of the project,
85 and information about reporting bugs,
86 can be found at
87 \%http://www.kernel.org/doc/man\-pages/.