1*8fd2f243SFrançois Tigeot /*- 2*8fd2f243SFrançois Tigeot * Copyright (c) 2013 Niclas Zeising 3*8fd2f243SFrançois Tigeot * All rights reserved. 4*8fd2f243SFrançois Tigeot * 5*8fd2f243SFrançois Tigeot * Redistribution and use in source and binary forms, with or without 6*8fd2f243SFrançois Tigeot * modification, are permitted provided that the following conditions 7*8fd2f243SFrançois Tigeot * are met: 8*8fd2f243SFrançois Tigeot * 1. Redistributions of source code must retain the above copyright 9*8fd2f243SFrançois Tigeot * notice, this list of conditions and the following disclaimer. 10*8fd2f243SFrançois Tigeot * 2. Redistributions in binary form must reproduce the above copyright 11*8fd2f243SFrançois Tigeot * notice, this list of conditions and the following disclaimer in the 12*8fd2f243SFrançois Tigeot * documentation and/or other materials provided with the distribution. 13*8fd2f243SFrançois Tigeot * 14*8fd2f243SFrançois Tigeot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*8fd2f243SFrançois Tigeot * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*8fd2f243SFrançois Tigeot * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*8fd2f243SFrançois Tigeot * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*8fd2f243SFrançois Tigeot * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*8fd2f243SFrançois Tigeot * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*8fd2f243SFrançois Tigeot * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*8fd2f243SFrançois Tigeot * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*8fd2f243SFrançois Tigeot * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*8fd2f243SFrançois Tigeot * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*8fd2f243SFrançois Tigeot * SUCH DAMAGE. 25*8fd2f243SFrançois Tigeot * 26*8fd2f243SFrançois Tigeot * $FreeBSD: src/lib/libc/string/strchrnul.c,v 1.1 2013/02/14 01:18:03 svnexp Exp $ 27*8fd2f243SFrançois Tigeot */ 28*8fd2f243SFrançois Tigeot 29*8fd2f243SFrançois Tigeot #include <string.h> 30*8fd2f243SFrançois Tigeot 31*8fd2f243SFrançois Tigeot char * 32*8fd2f243SFrançois Tigeot strchrnul(const char *p, int ch) 33*8fd2f243SFrançois Tigeot { 34*8fd2f243SFrançois Tigeot char c; 35*8fd2f243SFrançois Tigeot 36*8fd2f243SFrançois Tigeot c = ch; 37*8fd2f243SFrançois Tigeot for (;; ++p) { 38*8fd2f243SFrançois Tigeot if (*p == c || *p == '\0') 39*8fd2f243SFrançois Tigeot return ((char *)p); 40*8fd2f243SFrançois Tigeot } 41*8fd2f243SFrançois Tigeot /* NOTREACHED */ 42*8fd2f243SFrançois Tigeot } 43