14642e01fSmrg/*- 24642e01fSmrg * Copyright (c) 1990, 1993 34642e01fSmrg * The Regents of the University of California. All rights reserved. 44642e01fSmrg * 54642e01fSmrg * This code is derived from software contributed to Berkeley by 64642e01fSmrg * Chris Torek. 74642e01fSmrg * 84642e01fSmrg * Redistribution and use in source and binary forms, with or without 94642e01fSmrg * modification, are permitted provided that the following conditions 104642e01fSmrg * are met: 114642e01fSmrg * 1. Redistributions of source code must retain the above copyright 124642e01fSmrg * notice, this list of conditions and the following disclaimer. 134642e01fSmrg * 2. Redistributions in binary form must reproduce the above copyright 144642e01fSmrg * notice, this list of conditions and the following disclaimer in the 154642e01fSmrg * documentation and/or other materials provided with the distribution. 164642e01fSmrg * 4. Neither the name of the University nor the names of its contributors 174642e01fSmrg * may be used to endorse or promote products derived from this software 184642e01fSmrg * without specific prior written permission. 194642e01fSmrg * 204642e01fSmrg * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 214642e01fSmrg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224642e01fSmrg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234642e01fSmrg * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 244642e01fSmrg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254642e01fSmrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264642e01fSmrg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274642e01fSmrg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284642e01fSmrg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294642e01fSmrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304642e01fSmrg * SUCH DAMAGE. 314642e01fSmrg */ 324642e01fSmrg 334642e01fSmrg#ifdef HAVE_DIX_CONFIG_H 344642e01fSmrg#include <dix-config.h> 354642e01fSmrg#endif 364642e01fSmrg 374642e01fSmrg#include <ctype.h> 384642e01fSmrg#include <string.h> 394642e01fSmrg 404642e01fSmrg/* 414642e01fSmrg * Find the first occurrence of find in s, ignore case. 424642e01fSmrg */ 4335c4bbdfSmrg#ifndef HAVE_STRCASESTR 444642e01fSmrgchar * 454642e01fSmrgxstrcasestr(const char *s, const char *find) 464642e01fSmrg{ 4735c4bbdfSmrg char c, sc; 4835c4bbdfSmrg size_t len; 494642e01fSmrg 5035c4bbdfSmrg if ((c = *find++) != 0) { 5135c4bbdfSmrg c = tolower((unsigned char) c); 5235c4bbdfSmrg len = strlen(find); 5335c4bbdfSmrg do { 5435c4bbdfSmrg do { 5535c4bbdfSmrg if ((sc = *s++) == 0) 5635c4bbdfSmrg return NULL; 5735c4bbdfSmrg } while ((char) tolower((unsigned char) sc) != c); 5835c4bbdfSmrg } while (strncasecmp(s, find, len) != 0); 5935c4bbdfSmrg s--; 6035c4bbdfSmrg } 6135c4bbdfSmrg return ((char *) s); 624642e01fSmrg} 634642e01fSmrg#endif 64