116175Snate/*- 216175Snate * Copyright (c) 1990, 1993 316175Snate * The Regents of the University of California. All rights reserved. 416175Snate * 516175Snate * Redistribution and use in source and binary forms, with or without 616175Snate * modification, are permitted provided that the following conditions 716175Snate * are met: 816175Snate * 1. Redistributions of source code must retain the above copyright 916175Snate * notice, this list of conditions and the following disclaimer. 1016175Snate * 2. Redistributions in binary form must reproduce the above copyright 1116175Snate * notice, this list of conditions and the following disclaimer in the 1216175Snate * documentation and/or other materials provided with the distribution. 1316175Snate * 4. Neither the name of the University nor the names of its contributors 1416175Snate * may be used to endorse or promote products derived from this software 1516175Snate * without specific prior written permission. 1616175Snate * 1716175Snate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1816175Snate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1916175Snate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2016175Snate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2116175Snate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2216175Snate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2316175Snate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2416175Snate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2516175Snate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2616175Snate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2716175Snate * SUCH DAMAGE. 2816175Snate */ 2916175Snate 30116189Sobrien#include <sys/cdefs.h> 31116189Sobrien__FBSDID("$FreeBSD$"); 32116189Sobrien 3353492Speter#include <sys/param.h> 3453492Speter#include <sys/libkern.h> 3516175Snate 36168604Swkoszek/* 37168604Swkoszek * index() is also present as the strchr() in the kernel; it does exactly the 38168604Swkoszek * same thing as it's userland equivalent. 39168604Swkoszek */ 4016175Snatechar * 4116175Snateindex(p, ch) 4254411Speter const char *p; 4353492Speter int ch; 4416175Snate{ 4554411Speter union { 4654411Speter const char *cp; 4754411Speter char *p; 4854411Speter } u; 4953492Speter 5054411Speter u.cp = p; 5154411Speter for (;; ++u.p) { 5254411Speter if (*u.p == ch) 5354411Speter return(u.p); 54127586Srobert if (*u.p == '\0') 5553492Speter return(NULL); 5653492Speter } 5753492Speter /* NOTREACHED */ 5853492Speter} 59