]>
Commit | Line | Data |
---|---|---|
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 |
15 | strnlen \- determine the length of a fixed-size string | |
16 | .SH SYNOPSIS | |
17 | .nf | |
18 | .B #include <string.h> | |
68e4db0a | 19 | .PP |
fea681da MK |
20 | .BI "size_t strnlen(const char *" s ", size_t " maxlen ); |
21 | .fi | |
68e4db0a | 22 | .PP |
69fdc7ee MK |
23 | .in -4n |
24 | Feature Test Macro Requirements for glibc (see | |
25 | .BR feature_test_macros (7)): | |
26 | .in | |
68e4db0a | 27 | .PP |
69fdc7ee | 28 | .BR strnlen (): |
ea91c3fd MK |
29 | .PD 0 |
30 | .ad l | |
31 | .RS 4 | |
32 | .TP 4 | |
33 | Since glibc 2.10: | |
b0da7b8b | 34 | _POSIX_C_SOURCE\ >=\ 200809L |
ea91c3fd | 35 | .TP |
69fdc7ee MK |
36 | Before glibc 2.10: |
37 | _GNU_SOURCE | |
ea91c3fd MK |
38 | .RE |
39 | .ad | |
40 | .PD | |
fea681da | 41 | .SH DESCRIPTION |
60a90ecd MK |
42 | The |
43 | .BR strnlen () | |
51d8bd57 | 44 | function returns the number of bytes in the string |
46d8df8e MK |
45 | pointed to by |
46 | .IR s , | |
47 | excluding the terminating null byte (\(aq\\0\(aq), | |
48 | but at most | |
49 | .IR maxlen . | |
60a90ecd MK |
50 | In doing this, |
51 | .BR strnlen () | |
52 | looks only at the first | |
46d8df8e | 53 | .I maxlen |
5c6de1fc | 54 | characters in the string pointed to by |
46d8df8e MK |
55 | .I s |
56 | and never beyond | |
57 | .IR s+maxlen . | |
47297adb | 58 | .SH RETURN VALUE |
60a90ecd MK |
59 | The |
60 | .BR strnlen () | |
46d8df8e MK |
61 | function returns |
62 | .IR strlen(s) , | |
63 | if that is less than | |
64 | .IR maxlen , | |
65 | or | |
66 | .I maxlen | |
5c6de1fc | 67 | if there is no null terminating (\(aq\\0\(aq) among the first |
46d8df8e | 68 | .I maxlen |
5c6de1fc | 69 | characters pointed to by |
46d8df8e | 70 | .IR s . |
0f5df2aa | 71 | .SH ATTRIBUTES |
24d06319 PH |
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{ | |
0f5df2aa | 80 | .BR strnlen () |
24d06319 PH |
81 | T} Thread safety MT-Safe |
82 | .TE | |
47297adb | 83 | .SH CONFORMING TO |
b8f7487d | 84 | POSIX.1-2008. |
47297adb | 85 | .SH SEE ALSO |
0a4f8b7b | 86 | .BR strlen (3) |