1189136Sdas/*-
2189136Sdas * Copyright (c) 2009 David Schultz <das@FreeBSD.org>
3189136Sdas * All rights reserved.
4189136Sdas *
5189136Sdas * Redistribution and use in source and binary forms, with or without
6189136Sdas * modification, are permitted provided that the following conditions
7189136Sdas * are met:
8189136Sdas * 1. Redistributions of source code must retain the above copyright
9189136Sdas *    notice, this list of conditions and the following disclaimer.
10189136Sdas * 2. Redistributions in binary form must reproduce the above copyright
11189136Sdas *    notice, this list of conditions and the following disclaimer in the
12189136Sdas *    documentation and/or other materials provided with the distribution.
13189136Sdas *
14189136Sdas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15189136Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16189136Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17189136Sdas * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18189136Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19189136Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20189136Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21189136Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22189136Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23189136Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24189136Sdas * SUCH DAMAGE.
25189136Sdas */
26189136Sdas
27189136Sdas#include <sys/cdefs.h>
28189136Sdas__FBSDID("$FreeBSD$");
29189136Sdas
30226029Sjkim#include <sys/libkern.h>
31189136Sdas
32189136Sdassize_t
33189136Sdasstrnlen(const char *s, size_t maxlen)
34189136Sdas{
35189136Sdas	size_t len;
36189136Sdas
37189136Sdas	for (len = 0; len < maxlen; len++, s++) {
38189136Sdas		if (!*s)
39189136Sdas			break;
40189136Sdas	}
41189136Sdas	return (len);
42189136Sdas}
43