1*f359758cSJung-uk Kim /*- 2*f359758cSJung-uk Kim * Copyright (c) 2009 David Schultz <das@FreeBSD.org> 3*f359758cSJung-uk Kim * All rights reserved. 4*f359758cSJung-uk Kim * 5*f359758cSJung-uk Kim * Redistribution and use in source and binary forms, with or without 6*f359758cSJung-uk Kim * modification, are permitted provided that the following conditions 7*f359758cSJung-uk Kim * are met: 8*f359758cSJung-uk Kim * 1. Redistributions of source code must retain the above copyright 9*f359758cSJung-uk Kim * notice, this list of conditions and the following disclaimer. 10*f359758cSJung-uk Kim * 2. Redistributions in binary form must reproduce the above copyright 11*f359758cSJung-uk Kim * notice, this list of conditions and the following disclaimer in the 12*f359758cSJung-uk Kim * documentation and/or other materials provided with the distribution. 13*f359758cSJung-uk Kim * 14*f359758cSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*f359758cSJung-uk Kim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*f359758cSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*f359758cSJung-uk Kim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*f359758cSJung-uk Kim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*f359758cSJung-uk Kim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*f359758cSJung-uk Kim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*f359758cSJung-uk Kim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*f359758cSJung-uk Kim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*f359758cSJung-uk Kim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*f359758cSJung-uk Kim * SUCH DAMAGE. 25*f359758cSJung-uk Kim */ 26*f359758cSJung-uk Kim 27*f359758cSJung-uk Kim #include <sys/cdefs.h> 28*f359758cSJung-uk Kim __FBSDID("$FreeBSD$"); 29*f359758cSJung-uk Kim 30*f359758cSJung-uk Kim #include <sys/libkern.h> 31*f359758cSJung-uk Kim 32*f359758cSJung-uk Kim size_t 33*f359758cSJung-uk Kim strnlen(const char *s, size_t maxlen) 34*f359758cSJung-uk Kim { 35*f359758cSJung-uk Kim size_t len; 36*f359758cSJung-uk Kim 37*f359758cSJung-uk Kim for (len = 0; len < maxlen; len++, s++) { 38*f359758cSJung-uk Kim if (!*s) 39*f359758cSJung-uk Kim break; 40*f359758cSJung-uk Kim } 41*f359758cSJung-uk Kim return (len); 42*f359758cSJung-uk Kim } 43