xref: /freebsd/lib/libc/string/memmem.3 (revision 88521634e964e3da78a0ce54109cddb59bf3f099)
16050c8feSAndre Oppermann.\" Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com>
26050c8feSAndre Oppermann.\"
36050c8feSAndre Oppermann.\" Redistribution and use in source and binary forms, with or without
46050c8feSAndre Oppermann.\" modification, are permitted provided that the following conditions
56050c8feSAndre Oppermann.\" are met:
66050c8feSAndre Oppermann.\" 1. Redistributions of source code must retain the above copyright
76050c8feSAndre Oppermann.\"    notice, this list of conditions and the following disclaimer.
86050c8feSAndre Oppermann.\" 2. Redistributions in binary form must reproduce the above copyright
96050c8feSAndre Oppermann.\"    notice, this list of conditions and the following disclaimer in the
106050c8feSAndre Oppermann.\"    documentation and/or other materials provided with the distribution.
116050c8feSAndre Oppermann.\" 3. The name of the author may not be used to endorse or promote
126050c8feSAndre Oppermann.\"    products derived from this software without specific prior written
136050c8feSAndre Oppermann.\"    permission.
146050c8feSAndre Oppermann.\"
156050c8feSAndre Oppermann.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
166050c8feSAndre Oppermann.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
176050c8feSAndre Oppermann.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
186050c8feSAndre Oppermann.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
196050c8feSAndre Oppermann.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
206050c8feSAndre Oppermann.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
216050c8feSAndre Oppermann.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
226050c8feSAndre Oppermann.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
236050c8feSAndre Oppermann.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
246050c8feSAndre Oppermann.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
256050c8feSAndre Oppermann.\" SUCH DAMAGE.
266050c8feSAndre Oppermann.\"
27ca513774SRuslan Ermilov.\" $FreeBSD$
286050c8feSAndre Oppermann.\"
29*88521634SEd Maste.Dd March 17, 2017
306050c8feSAndre Oppermann.Dt MEMMEM 3
316050c8feSAndre Oppermann.Os
326050c8feSAndre Oppermann.Sh NAME
336050c8feSAndre Oppermann.Nm memmem
34ca513774SRuslan Ermilov.Nd "locate a byte substring in a byte string"
356050c8feSAndre Oppermann.Sh LIBRARY
366050c8feSAndre Oppermann.Lb libc
376050c8feSAndre Oppermann.Sh SYNOPSIS
386050c8feSAndre Oppermann.In string.h
39ca513774SRuslan Ermilov.Ft "void *"
40ca513774SRuslan Ermilov.Fo memmem
4136c71f6aSRuslan Ermilov.Fa "const void *big" "size_t big_len"
4236c71f6aSRuslan Ermilov.Fa "const void *little" "size_t little_len"
43ca513774SRuslan Ermilov.Fc
446050c8feSAndre Oppermann.Sh DESCRIPTION
456050c8feSAndre OppermannThe
466050c8feSAndre Oppermann.Fn memmem
476050c8feSAndre Oppermannfunction
486050c8feSAndre Oppermannlocates the first occurrence of the byte string
496050c8feSAndre Oppermann.Fa little
506050c8feSAndre Oppermannin the byte string
516050c8feSAndre Oppermann.Fa big .
526050c8feSAndre Oppermann.Sh RETURN VALUES
536050c8feSAndre OppermannIf
546050c8feSAndre Oppermann.Fa little_len
5516150352SEd Masteis zero
5616150352SEd Maste.Fa big
5716150352SEd Masteis returned (that is, an empty little is deemed to match at the beginning of
5816150352SEd Mastebig);
5916150352SEd Masteif
606050c8feSAndre Oppermann.Fa little
616050c8feSAndre Oppermannoccurs nowhere in
626050c8feSAndre Oppermann.Fa big ,
636050c8feSAndre Oppermann.Dv NULL
646050c8feSAndre Oppermannis returned;
656050c8feSAndre Oppermannotherwise a pointer to the first character of the first occurrence of
666050c8feSAndre Oppermann.Fa little
676050c8feSAndre Oppermannis returned.
686050c8feSAndre Oppermann.Sh SEE ALSO
696050c8feSAndre Oppermann.Xr memchr 3 ,
706050c8feSAndre Oppermann.Xr strchr 3 ,
716050c8feSAndre Oppermann.Xr strstr 3
726050c8feSAndre Oppermann.Sh CONFORMING TO
736050c8feSAndre Oppermann.Fn memmem
746050c8feSAndre Oppermannis a GNU extension.
756050c8feSAndre Oppermann.Sh HISTORY
766050c8feSAndre OppermannThe
776050c8feSAndre Oppermann.Fn memmem
786050c8feSAndre Oppermannfunction first appeared in
796050c8feSAndre Oppermann.Fx 6.0 .
80*88521634SEd MasteIt was replaced with an optimized O(n) implementation from the musl libc
81*88521634SEd Masteproject in
82*88521634SEd Maste.Fx 12.0 .
838fbf3d50SBaptiste Daroussin.An Pascal Gloor Aq Mt pascal.gloor@spale.com
84*88521634SEd Masteprovided this man page along with the previous implementation.
856050c8feSAndre Oppermann.Sh BUGS
866050c8feSAndre OppermannThis function was broken in Linux libc up to and including version 5.0.9
876050c8feSAndre Oppermannand in GNU libc prior to version 2.1.
8816150352SEd MastePrior to
8916150352SEd Maste.Fx 11.0
9016150352SEd Maste.Nm
9116150352SEd Mastereturned
9216150352SEd Maste.Dv NULL
9316150352SEd Mastewhen
9416150352SEd Maste.Fa little_len
9516150352SEd Masteequals 0.
96