OSDN Git Service

a7243aad8af7724085642a8405b229c4113ed749
[linuxjm/LDP_man-pages.git] / original / man3 / strnlen.3
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" References consulted:
9 .\"   GNU glibc-2 source code and manual
10 .\"
11 .TH STRNLEN 3  2010-10-31 "GNU" "Linux Programmer's Manual"
12 .SH NAME
13 strnlen \- determine the length of a fixed-size string
14 .SH SYNOPSIS
15 .nf
16 .B #include <string.h>
17 .sp
18 .BI "size_t strnlen(const char *" s ", size_t " maxlen );
19 .fi
20 .sp
21 .in -4n
22 Feature Test Macro Requirements for glibc (see
23 .BR feature_test_macros (7)):
24 .in
25 .sp
26 .BR strnlen ():
27 .PD 0
28 .ad l
29 .RS 4
30 .TP 4
31 Since glibc 2.10:
32 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
33 .TP
34 Before glibc 2.10:
35 _GNU_SOURCE
36 .RE
37 .ad
38 .PD
39 .SH DESCRIPTION
40 The
41 .BR strnlen ()
42 function returns the number of characters in the string
43 pointed to by \fIs\fP, not including the terminating \(aq\\0\(aq character,
44 but at most \fImaxlen\fP.
45 In doing this,
46 .BR strnlen ()
47 looks only at the first
48 \fImaxlen\fP characters at \fIs\fP and never beyond \fIs+maxlen\fP.
49 .SH "RETURN VALUE"
50 The
51 .BR strnlen ()
52 function returns \fIstrlen(s)\fP, if that is less than
53 \fImaxlen\fP, or \fImaxlen\fP
54 if there is no \(aq\\0\(aq character among the first
55 \fImaxlen\fP characters pointed to by \fIs\fP.
56 .SH "CONFORMING TO"
57 This function is a GNU extension.
58 .SH "SEE ALSO"
59 .BR strlen (3)