]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/strnlen.3
namespaces.7: ffix
[thirdparty/man-pages.git] / man3 / strnlen.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
89e3ffe9 3.\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
fea681da
MK
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.
fe382ebf 8.\" %%%LICENSE_END
fea681da
MK
9.\"
10.\" References consulted:
11.\" GNU glibc-2 source code and manual
12.\"
97986708 13.TH STRNLEN 3 2016-03-15 "GNU" "Linux Programmer's Manual"
fea681da
MK
14.SH NAME
15strnlen \- 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
69fdc7ee
MK
22.sp
23.in -4n
24Feature Test Macro Requirements for glibc (see
25.BR feature_test_macros (7)):
26.in
27.sp
28.BR strnlen ():
ea91c3fd
MK
29.PD 0
30.ad l
31.RS 4
32.TP 4
33Since glibc 2.10:
b0da7b8b 34_POSIX_C_SOURCE\ >=\ 200809L
ea91c3fd 35.TP
69fdc7ee
MK
36Before glibc 2.10:
37_GNU_SOURCE
ea91c3fd
MK
38.RE
39.ad
40.PD
fea681da 41.SH DESCRIPTION
60a90ecd
MK
42The
43.BR strnlen ()
5c6de1fc 44function returns the number of characters in the string
46d8df8e
MK
45pointed to by
46.IR s ,
47excluding the terminating null byte (\(aq\\0\(aq),
48but at most
49.IR maxlen .
60a90ecd
MK
50In doing this,
51.BR strnlen ()
52looks only at the first
46d8df8e 53.I maxlen
5c6de1fc 54characters in the string pointed to by
46d8df8e
MK
55.I s
56and never beyond
57.IR s+maxlen .
47297adb 58.SH RETURN VALUE
60a90ecd
MK
59The
60.BR strnlen ()
46d8df8e
MK
61function returns
62.IR strlen(s) ,
63if that is less than
64.IR maxlen ,
65or
66.I maxlen
5c6de1fc 67if there is no null terminating (\(aq\\0\(aq) among the first
46d8df8e 68.I maxlen
5c6de1fc 69characters pointed to by
46d8df8e 70.IR s .
0f5df2aa 71.SH ATTRIBUTES
24d06319
PH
72For an explanation of the terms used in this section, see
73.BR attributes (7).
74.TS
75allbox;
76lb lb lb
77l l l.
78Interface Attribute Value
79T{
0f5df2aa 80.BR strnlen ()
24d06319
PH
81T} Thread safety MT-Safe
82.TE
47297adb 83.SH CONFORMING TO
b8f7487d 84POSIX.1-2008.
47297adb 85.SH SEE ALSO
0a4f8b7b 86.BR strlen (3)