xref: /minix3/lib/libc/string/strstr.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
12fe8fb19SBen Gras.\" Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
22fe8fb19SBen Gras.\" Copyright (c) 1990, 1991, 1993
32fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
42fe8fb19SBen Gras.\"
52fe8fb19SBen Gras.\" This code is derived from software contributed to Berkeley by
62fe8fb19SBen Gras.\" Chris Torek and the American National Standards Committee X3,
72fe8fb19SBen Gras.\" on Information Processing Systems.
82fe8fb19SBen Gras.\"
92fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
102fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
112fe8fb19SBen Gras.\" are met:
122fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
132fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
142fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
152fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
162fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
172fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
182fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
192fe8fb19SBen Gras.\"    without specific prior written permission.
202fe8fb19SBen Gras.\"
212fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
222fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
232fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
242fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
252fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
262fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
272fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
282fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
292fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
302fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
312fe8fb19SBen Gras.\" SUCH DAMAGE.
322fe8fb19SBen Gras.\"
332fe8fb19SBen Gras.\"     from: @(#)strstr.3	8.1 (Berkeley) 6/4/93
34*0a6a1f1dSLionel Sambuc.\"	$NetBSD: strstr.3,v 1.12 2014/09/24 18:43:21 wiz Exp $
352fe8fb19SBen Gras.\"
36*0a6a1f1dSLionel Sambuc.Dd September 24, 2014
372fe8fb19SBen Gras.Dt STRSTR 3
382fe8fb19SBen Gras.Os
392fe8fb19SBen Gras.Sh NAME
40*0a6a1f1dSLionel Sambuc.Nm strstr , strcasestr , strnstr
412fe8fb19SBen Gras.Nd locate a substring in a string
422fe8fb19SBen Gras.Sh LIBRARY
432fe8fb19SBen Gras.Lb libc
442fe8fb19SBen Gras.Sh SYNOPSIS
452fe8fb19SBen Gras.In string.h
462fe8fb19SBen Gras.Ft char *
472fe8fb19SBen Gras.Fn strstr "const char *big" "const char *little"
482fe8fb19SBen Gras.Ft char *
492fe8fb19SBen Gras.Fn strcasestr "const char *big" "const char *little"
50*0a6a1f1dSLionel Sambuc.Ft char *
51*0a6a1f1dSLionel Sambuc.Fn strnstr "const char *big" "const char *little" "size_t len"
522fe8fb19SBen Gras.Sh DESCRIPTION
532fe8fb19SBen GrasThe
542fe8fb19SBen Gras.Fn strstr
552fe8fb19SBen Grasfunction
562fe8fb19SBen Graslocates the first occurrence of the nul-terminated string
572fe8fb19SBen Gras.Fa little
582fe8fb19SBen Grasin the nul-terminated string
592fe8fb19SBen Gras.Fa big .
602fe8fb19SBen Gras.Pp
612fe8fb19SBen GrasThe
622fe8fb19SBen Gras.Fn strcasestr
632fe8fb19SBen Grasfunction is similar to
642fe8fb19SBen Gras.Fn strstr ,
652fe8fb19SBen Grasbut ignores the case of both strings.
66*0a6a1f1dSLionel SambucThe
67*0a6a1f1dSLionel Sambuc.Fn strnstr
68*0a6a1f1dSLionel Sambucfunction
69*0a6a1f1dSLionel Sambuclocates the first occurrence of the NUL-terminated string
70*0a6a1f1dSLionel Sambuc.Fa little
71*0a6a1f1dSLionel Sambucin the string
72*0a6a1f1dSLionel Sambuc.Fa big ,
73*0a6a1f1dSLionel Sambucwhere not more than
74*0a6a1f1dSLionel Sambuc.Fa len
75*0a6a1f1dSLionel Sambuccharacters are searched.
76*0a6a1f1dSLionel SambucCharacters that appear after a
77*0a6a1f1dSLionel Sambuc.Ql \e0
78*0a6a1f1dSLionel Sambuccharacter are not searched.
79*0a6a1f1dSLionel SambucSince the
80*0a6a1f1dSLionel Sambuc.Fn strnstr
81*0a6a1f1dSLionel Sambucfunction is a
82*0a6a1f1dSLionel Sambuc.Nx
83*0a6a1f1dSLionel Sambucspecific API, it should only be used when portability is not a concern.
842fe8fb19SBen Gras.Sh RETURN VALUES
852fe8fb19SBen GrasIf
862fe8fb19SBen Gras.Fa little
872fe8fb19SBen Grasis an empty string,
882fe8fb19SBen Gras.Fa big
892fe8fb19SBen Grasis returned;
902fe8fb19SBen Grasif
912fe8fb19SBen Gras.Fa little
922fe8fb19SBen Grasoccurs nowhere in
932fe8fb19SBen Gras.Fa big ,
942fe8fb19SBen Gras.Dv NULL
952fe8fb19SBen Grasis returned;
962fe8fb19SBen Grasotherwise a pointer to the first character of the first occurrence of
972fe8fb19SBen Gras.Fa little
982fe8fb19SBen Grasis returned.
992fe8fb19SBen Gras.Sh EXAMPLES
1002fe8fb19SBen GrasThe following sets the pointer
1012fe8fb19SBen Gras.Va ptr
1022fe8fb19SBen Grasto the
1032fe8fb19SBen Gras.Qq Li Bar Baz
1042fe8fb19SBen Grasportion of
1052fe8fb19SBen Gras.Va largestring :
1062fe8fb19SBen Gras.Bd -literal -offset indent
1072fe8fb19SBen Grasconst char *largestring = "Foo Bar Baz";
1082fe8fb19SBen Grasconst char *smallstring = "Bar";
1092fe8fb19SBen Graschar *ptr;
1102fe8fb19SBen Gras
1112fe8fb19SBen Grasptr = strstr(largestring, smallstring);
1122fe8fb19SBen Gras.Ed
1132fe8fb19SBen Gras.Sh SEE ALSO
1142fe8fb19SBen Gras.Xr index 3 ,
1152fe8fb19SBen Gras.Xr memchr 3 ,
1162fe8fb19SBen Gras.Xr rindex 3 ,
1172fe8fb19SBen Gras.Xr strchr 3 ,
1182fe8fb19SBen Gras.Xr strcspn 3 ,
1192fe8fb19SBen Gras.Xr strpbrk 3 ,
1202fe8fb19SBen Gras.Xr strrchr 3 ,
1212fe8fb19SBen Gras.Xr strsep 3 ,
1222fe8fb19SBen Gras.Xr strspn 3 ,
1232fe8fb19SBen Gras.Xr strtok 3
1242fe8fb19SBen Gras.Sh STANDARDS
1252fe8fb19SBen GrasThe
1262fe8fb19SBen Gras.Fn strstr
1272fe8fb19SBen Grasfunction
1282fe8fb19SBen Grasconforms to
1292fe8fb19SBen Gras.St -isoC .
130*0a6a1f1dSLionel Sambuc.Sh HISTORY
131*0a6a1f1dSLionel SambucThe
132*0a6a1f1dSLionel Sambuc.Fn strnstr
133*0a6a1f1dSLionel Sambucfunction originated in
134*0a6a1f1dSLionel Sambuc.Fx .
135