strnlen.c revision 302408
1217309Snwhitehorn/* 2255852Sdteske * Copyright (c) 1995 - 1999 Kungliga Tekniska H��gskolan 3217309Snwhitehorn * (Royal Institute of Technology, Stockholm, Sweden). 4220749Snwhitehorn * All rights reserved. 5217309Snwhitehorn * 6251843Sbapt * Redistribution and use in source and binary forms, with or without 7217309Snwhitehorn * modification, are permitted provided that the following conditions 8217309Snwhitehorn * are met: 9217309Snwhitehorn * 10217309Snwhitehorn * 1. Redistributions of source code must retain the above copyright 11217309Snwhitehorn * notice, this list of conditions and the following disclaimer. 12217309Snwhitehorn * 13217309Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright 14217309Snwhitehorn * notice, this list of conditions and the following disclaimer in the 15217309Snwhitehorn * documentation and/or other materials provided with the distribution. 16217309Snwhitehorn * 17217309Snwhitehorn * 3. Neither the name of the Institute nor the names of its contributors 18217309Snwhitehorn * may be used to endorse or promote products derived from this software 19217309Snwhitehorn * without specific prior written permission. 20217309Snwhitehorn * 21217309Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22217309Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23217309Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24217309Snwhitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25217309Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26217309Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27217309Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28217309Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29220749Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30217309Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31217309Snwhitehorn * SUCH DAMAGE. 32217309Snwhitehorn */ 33217309Snwhitehorn 34217309Snwhitehorn#include <config.h> 35217309Snwhitehorn 36217309Snwhitehorn#include "roken.h" 37217309Snwhitehorn 38217309SnwhitehornROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL 39217309Snwhitehornstrnlen(const char *s, size_t len) 40217309Snwhitehorn{ 41217309Snwhitehorn size_t i; 42217309Snwhitehorn 43217309Snwhitehorn for(i = 0; i < len && s[i]; i++) 44217309Snwhitehorn ; 45217309Snwhitehorn return i; 46217309Snwhitehorn} 47223289Sjh