1161243Spjd/*-
2161243Spjd * Copyright (c) 1990, 1993
3161243Spjd *	The Regents of the University of California.  All rights reserved.
4161243Spjd *
5161243Spjd * This code is derived from software contributed to Berkeley by
6161243Spjd * Chris Torek.
7161243Spjd *
8161243Spjd * Redistribution and use in source and binary forms, with or without
9161243Spjd * modification, are permitted provided that the following conditions
10161243Spjd * are met:
11161243Spjd * 1. Redistributions of source code must retain the above copyright
12161243Spjd *    notice, this list of conditions and the following disclaimer.
13161243Spjd * 2. Redistributions in binary form must reproduce the above copyright
14161243Spjd *    notice, this list of conditions and the following disclaimer in the
15161243Spjd *    documentation and/or other materials provided with the distribution.
16161243Spjd * 3. All advertising materials mentioning features or use of this software
17161243Spjd *    must display the following acknowledgement:
18161243Spjd *	This product includes software developed by the University of
19161243Spjd *	California, Berkeley and its contributors.
20161243Spjd * 4. Neither the name of the University nor the names of its contributors
21161243Spjd *    may be used to endorse or promote products derived from this software
22161243Spjd *    without specific prior written permission.
23161243Spjd *
24161243Spjd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25161243Spjd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26161243Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27161243Spjd * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28161243Spjd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29161243Spjd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30161243Spjd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31161243Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32161243Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33161243Spjd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34161243Spjd * SUCH DAMAGE.
35161243Spjd */
36161243Spjd
37161243Spjd#include <sys/cdefs.h>
38161243Spjd__FBSDID("$FreeBSD$");
39161243Spjd
40161243Spjd#include <sys/param.h>
41161243Spjd#include <sys/libkern.h>
42161243Spjd
43161243Spjd/*
44161243Spjd * Find the first occurrence of find in s.
45161243Spjd */
46161243Spjdchar *
47161243Spjdstrstr(const char *s, const char *find)
48161243Spjd{
49161243Spjd	char c, sc;
50161243Spjd	size_t len;
51161243Spjd
52161243Spjd	if ((c = *find++) != 0) {
53161243Spjd		len = strlen(find);
54161243Spjd		do {
55161243Spjd			do {
56161243Spjd				if ((sc = *s++) == 0)
57161243Spjd					return (NULL);
58161243Spjd			} while (sc != c);
59161243Spjd		} while (strncmp(s, find, len) != 0);
60161243Spjd		s--;
61161243Spjd	}
62161243Spjd	return (__DECONST(char *, s));
63161243Spjd}
64