mount_namespaces.7: SEE ALSO: add mount_setattr(2)
[man-pages.git] / man3 / strnlen.3
blob09e9c19b7f1ed542f417f331def08af919db0599
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  2021-03-22 "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 .PP
20 .BI "size_t strnlen(const char *" s ", size_t " maxlen );
21 .fi
22 .PP
23 .RS -4
24 Feature Test Macro Requirements for glibc (see
25 .BR feature_test_macros (7)):
26 .RE
27 .PP
28 .BR strnlen ():
29 .nf
30     Since glibc 2.10:
31         _POSIX_C_SOURCE >= 200809L
32     Before glibc 2.10:
33         _GNU_SOURCE
34 .fi
35 .SH DESCRIPTION
36 The
37 .BR strnlen ()
38 function returns the number of bytes in the string
39 pointed to by
40 .IR s ,
41 excluding the terminating null byte (\(aq\e0\(aq),
42 but at most
43 .IR maxlen .
44 In doing this,
45 .BR strnlen ()
46 looks only at the first
47 .I maxlen
48 characters in the string pointed to by
49 .I s
50 and never beyond
51 .IR s[maxlen\-1] .
52 .SH RETURN VALUE
53 The
54 .BR strnlen ()
55 function returns
56 .IR strlen(s) ,
57 if that is less than
58 .IR maxlen ,
60 .I maxlen
61 if there is no null terminating (\(aq\e0\(aq) among the first
62 .I maxlen
63 characters pointed to by
64 .IR s .
65 .SH ATTRIBUTES
66 For an explanation of the terms used in this section, see
67 .BR attributes (7).
68 .ad l
69 .nh
70 .TS
71 allbox;
72 lbx lb lb
73 l l l.
74 Interface       Attribute       Value
76 .BR strnlen ()
77 T}      Thread safety   MT-Safe
78 .TE
79 .hy
80 .ad
81 .sp 1
82 .SH CONFORMING TO
83 POSIX.1-2008.
84 .SH SEE ALSO
85 .BR strlen (3)