1adecd3c6Sdg199075 /* 2adecd3c6Sdg199075 * CDDL HEADER START 3adecd3c6Sdg199075 * 4adecd3c6Sdg199075 * The contents of this file are subject to the terms of the 5adecd3c6Sdg199075 * Common Development and Distribution License (the "License"). 6adecd3c6Sdg199075 * You may not use this file except in compliance with the License. 7adecd3c6Sdg199075 * 8adecd3c6Sdg199075 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9adecd3c6Sdg199075 * or http://www.opensolaris.org/os/licensing. 10adecd3c6Sdg199075 * See the License for the specific language governing permissions 11adecd3c6Sdg199075 * and limitations under the License. 12adecd3c6Sdg199075 * 13adecd3c6Sdg199075 * When distributing Covered Code, include this CDDL HEADER in each 14adecd3c6Sdg199075 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15adecd3c6Sdg199075 * If applicable, add the following below this CDDL HEADER, with the 16adecd3c6Sdg199075 * fields enclosed by brackets "[]" replaced with your own identifying 17adecd3c6Sdg199075 * information: Portions Copyright [yyyy] [name of copyright owner] 18adecd3c6Sdg199075 * 19adecd3c6Sdg199075 * CDDL HEADER END 20adecd3c6Sdg199075 */ 21adecd3c6Sdg199075 22adecd3c6Sdg199075 /* 23*7257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. 24adecd3c6Sdg199075 * All rights reserved. Use is subject to license terms. 25adecd3c6Sdg199075 */ 26adecd3c6Sdg199075 27*7257d1b4Sraf #include "lint.h" 28adecd3c6Sdg199075 #include <string.h> 29adecd3c6Sdg199075 #include <sys/types.h> 30adecd3c6Sdg199075 31adecd3c6Sdg199075 /* 32adecd3c6Sdg199075 * Returns the number of non-NULL bytes in string argument, 33adecd3c6Sdg199075 * but not more than maxlen. Does not look past str + maxlen. 34adecd3c6Sdg199075 */ 35adecd3c6Sdg199075 size_t strnlen(const char * str,size_t maxlen)36adecd3c6Sdg199075strnlen(const char *str, size_t maxlen) 37adecd3c6Sdg199075 { 38adecd3c6Sdg199075 const char *ptr; 39adecd3c6Sdg199075 40adecd3c6Sdg199075 ptr = memchr(str, 0, maxlen); 41adecd3c6Sdg199075 if (ptr == NULL) 42adecd3c6Sdg199075 return (maxlen); 43adecd3c6Sdg199075 44adecd3c6Sdg199075 return (ptr - str); 45adecd3c6Sdg199075 } 46