13153Sdg199075 /* 23153Sdg199075 * CDDL HEADER START 33153Sdg199075 * 43153Sdg199075 * The contents of this file are subject to the terms of the 53153Sdg199075 * Common Development and Distribution License (the "License"). 63153Sdg199075 * You may not use this file except in compliance with the License. 73153Sdg199075 * 83153Sdg199075 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93153Sdg199075 * or http://www.opensolaris.org/os/licensing. 103153Sdg199075 * See the License for the specific language governing permissions 113153Sdg199075 * and limitations under the License. 123153Sdg199075 * 133153Sdg199075 * When distributing Covered Code, include this CDDL HEADER in each 143153Sdg199075 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153153Sdg199075 * If applicable, add the following below this CDDL HEADER, with the 163153Sdg199075 * fields enclosed by brackets "[]" replaced with your own identifying 173153Sdg199075 * information: Portions Copyright [yyyy] [name of copyright owner] 183153Sdg199075 * 193153Sdg199075 * CDDL HEADER END 203153Sdg199075 */ 213153Sdg199075 223153Sdg199075 /* 23*6812Sraf * Copyright 2008 Sun Microsystems, Inc. 243153Sdg199075 * All rights reserved. Use is subject to license terms. 253153Sdg199075 */ 263153Sdg199075 273153Sdg199075 #pragma ident "%Z%%M% %I% %E% SMI" 283153Sdg199075 29*6812Sraf #include "lint.h" 303153Sdg199075 #include <string.h> 313153Sdg199075 #include <sys/types.h> 323153Sdg199075 333153Sdg199075 /* 343153Sdg199075 * Returns the number of non-NULL bytes in string argument, 353153Sdg199075 * but not more than maxlen. Does not look past str + maxlen. 363153Sdg199075 */ 373153Sdg199075 size_t strnlen(const char * str,size_t maxlen)383153Sdg199075strnlen(const char *str, size_t maxlen) 393153Sdg199075 { 403153Sdg199075 const char *ptr; 413153Sdg199075 423153Sdg199075 ptr = memchr(str, 0, maxlen); 433153Sdg199075 if (ptr == NULL) 443153Sdg199075 return (maxlen); 453153Sdg199075 463153Sdg199075 return (ptr - str); 473153Sdg199075 } 48