OSDN Git Service

(split) LDP: Change Makefile to stamp-based compilation
[linuxjm/LDP_man-pages.git] / original / 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  2012-05-10 "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 bytes in the string
45 pointed to by \fIs\fP, excluding the terminating null bye (\(aq\\0\(aq),
46 but at most \fImaxlen\fP.
47 In doing this,
48 .BR strnlen ()
49 looks only at the first
50 \fImaxlen\fP bytes at \fIs\fP and never beyond \fIs+maxlen\fP.
51 .SH RETURN VALUE
52 The
53 .BR strnlen ()
54 function returns \fIstrlen(s)\fP, if that is less than
55 \fImaxlen\fP, or \fImaxlen\fP
56 if there is no null byte (\(aq\\0\(aq) among the first
57 \fImaxlen\fP bytes pointed to by \fIs\fP.
58 .SH CONFORMING TO
59 POSIX.1-2008.
60 .SH SEE ALSO
61 .BR strlen (3)