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