1706f2543Smrg/* 2706f2543Smrg * Copyright (c) 1987, 1993 3706f2543Smrg * The Regents of the University of California. All rights reserved. 4706f2543Smrg * 5706f2543Smrg * Redistribution and use in source and binary forms, with or without 6706f2543Smrg * modification, are permitted provided that the following conditions 7706f2543Smrg * are met: 8706f2543Smrg * 1. Redistributions of source code must retain the above copyright 9706f2543Smrg * notice, this list of conditions and the following disclaimer. 10706f2543Smrg * 2. Redistributions in binary form must reproduce the above copyright 11706f2543Smrg * notice, this list of conditions and the following disclaimer in the 12706f2543Smrg * documentation and/or other materials provided with the distribution. 13706f2543Smrg * 4. Neither the name of the University nor the names of its contributors 14706f2543Smrg * may be used to endorse or promote products derived from this software 15706f2543Smrg * without specific prior written permission. 16706f2543Smrg * 17706f2543Smrg * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18706f2543Smrg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19706f2543Smrg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20706f2543Smrg * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21706f2543Smrg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22706f2543Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23706f2543Smrg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24706f2543Smrg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25706f2543Smrg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26706f2543Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27706f2543Smrg * SUCH DAMAGE. 28706f2543Smrg */ 29706f2543Smrg 30706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 31706f2543Smrg#include <dix-config.h> 32706f2543Smrg#endif 33706f2543Smrg 34706f2543Smrg#include <ctype.h> 35706f2543Smrg#include "dix.h" 36706f2543Smrg 37706f2543Smrg#ifdef NEED_STRCASECMP 38706f2543Smrgint 39706f2543Smrgxstrcasecmp(const char *str1, const char *str2) 40706f2543Smrg{ 41706f2543Smrg const u_char *us1 = (const u_char *)str1, *us2 = (const u_char *)str2; 42706f2543Smrg 43706f2543Smrg while (tolower(*us1) == tolower(*us2)) { 44706f2543Smrg if (*us1++ == '\0') 45706f2543Smrg return 0; 46706f2543Smrg us2++; 47706f2543Smrg } 48706f2543Smrg 49706f2543Smrg return (tolower(*us1) - tolower(*us2)); 50706f2543Smrg} 51706f2543Smrg#endif 52706f2543Smrg 53706f2543Smrg#ifdef NEED_STRNCASECMP 54706f2543Smrgint 55706f2543Smrgxstrncasecmp(const char *s1, const char *s2, size_t n) 56706f2543Smrg{ 57706f2543Smrg if (n != 0) { 58706f2543Smrg const u_char *us1 = (const u_char *)s1, *us2 = (const u_char *)s2; 59706f2543Smrg 60706f2543Smrg do { 61706f2543Smrg if (tolower(*us1) != tolower(*us2++)) 62706f2543Smrg return (tolower(*us1) - tolower(*--us2)); 63706f2543Smrg if (*us1++ == '\0') 64706f2543Smrg break; 65706f2543Smrg } while (--n != 0); 66706f2543Smrg } 67706f2543Smrg 68706f2543Smrg return 0; 69706f2543Smrg} 70706f2543Smrg#endif 71