]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/strnlen.3
9f922f6cacdc0a898ee82d4d054687640b51fc5f
[thirdparty/man-pages.git] / man3 / strnlen.3
1 '\" t
2 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3 .\"
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
5 .\"
6 .\" References consulted:
7 .\" GNU glibc-2 source code and manual
8 .\"
9 .TH strnlen 3 (date) "Linux man-pages (unreleased)"
10 .SH NAME
11 strnlen \- determine the length of a fixed-size string
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ", " \-lc )
15 .SH SYNOPSIS
16 .nf
17 .B #include <string.h>
18 .PP
19 .BI "size_t strnlen(const char " s [. maxlen "], size_t " maxlen );
20 .fi
21 .PP
22 .RS -4
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
25 .RE
26 .PP
27 .BR strnlen ():
28 .nf
29 Since glibc 2.10:
30 _POSIX_C_SOURCE >= 200809L
31 Before glibc 2.10:
32 _GNU_SOURCE
33 .fi
34 .SH DESCRIPTION
35 The
36 .BR strnlen ()
37 function returns the number of bytes in the string
38 pointed to by
39 .IR s ,
40 excluding the terminating null byte (\[aq]\e0\[aq]),
41 but at most
42 .IR maxlen .
43 In doing this,
44 .BR strnlen ()
45 looks only at the first
46 .I maxlen
47 characters in the string pointed to by
48 .I s
49 and never beyond
50 .IR s[maxlen\-1] .
51 .SH RETURN VALUE
52 The
53 .BR strnlen ()
54 function returns
55 .IR strlen(s) ,
56 if that is less than
57 .IR maxlen ,
58 or
59 .I maxlen
60 if there is no null terminating (\[aq]\e0\[aq]) among the first
61 .I maxlen
62 characters pointed to by
63 .IR s .
64 .SH ATTRIBUTES
65 For an explanation of the terms used in this section, see
66 .BR attributes (7).
67 .ad l
68 .nh
69 .TS
70 allbox;
71 lbx lb lb
72 l l l.
73 Interface Attribute Value
74 T{
75 .BR strnlen ()
76 T} Thread safety MT-Safe
77 .TE
78 .hy
79 .ad
80 .sp 1
81 .SH STANDARDS
82 POSIX.1-2008.
83 .SH HISTORY
84 POSIX.1-2008.
85 .SH SEE ALSO
86 .BR strlen (3)