]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/strnlen.3
strnlen.3: wfix
[thirdparty/man-pages.git] / 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 2015-03-02 "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 characters 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 characters in the string pointed to by
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 terminating (\(aq\\0\(aq) among the first
68 .I maxlen
69 characters pointed to by
70 .IR s .
71 .SH ATTRIBUTES
72 For an explanation of the terms used in this section, see
73 .BR attributes (7).
74 .TS
75 allbox;
76 lb lb lb
77 l l l.
78 Interface Attribute Value
79 T{
80 .BR strnlen ()
81 T} Thread safety MT-Safe
82 .TE
83 .SH CONFORMING TO
84 POSIX.1-2008.
85 .SH SEE ALSO
86 .BR strlen (3)