1123256Sscottl/*- 2123256Sscottl * Copyright (c) 2009 David Schultz <das@FreeBSD.org> 3123256Sscottl * All rights reserved. 4123256Sscottl * 5123256Sscottl * Redistribution and use in source and binary forms, with or without 6123256Sscottl * modification, are permitted provided that the following conditions 7123256Sscottl * are met: 8123256Sscottl * 1. Redistributions of source code must retain the above copyright 9123256Sscottl * notice, this list of conditions and the following disclaimer. 10123256Sscottl * 2. Redistributions in binary form must reproduce the above copyright 11123256Sscottl * notice, this list of conditions and the following disclaimer in the 12123256Sscottl * documentation and/or other materials provided with the distribution. 13123256Sscottl * 14123256Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15123256Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16123256Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17123256Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18123256Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19123256Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20123256Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21123256Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22123256Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23123256Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24123256Sscottl * SUCH DAMAGE. 25123256Sscottl */ 26123256Sscottl 27123256Sscottl#include <sys/cdefs.h> 28123256Sscottl__FBSDID("$FreeBSD$"); 29123256Sscottl 30123256Sscottl#include <sys/libkern.h> 31284435Sken 32206622Suqssize_t 33123256Sscottlstrnlen(const char *s, size_t maxlen) 34123256Sscottl{ 35123256Sscottl size_t len; 36180161Sjhb 37123256Sscottl for (len = 0; len < maxlen; len++, s++) { 38180161Sjhb if (!*s) 39284435Sken break; 40123256Sscottl } 41123256Sscottl return (len); 42284435Sken} 43284435Sken