00001 /* 00002 * strcasecmp.c -- provides strcasecmp() and strncasecmp if necessary. 00003 * 00004 * $Id: strcasecmp.c,v 1.11 2011/02/13 14:19:33 simple Exp $ 00005 */ 00006 /* 00007 * Copyright (C) 1997 Robey Pointer 00008 * Copyright (C) 1999 - 2011 Eggheads Development Team 00009 * 00010 * This program is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU General Public License 00012 * as published by the Free Software Foundation; either version 2 00013 * of the License, or (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00023 */ 00024 00025 #include "main.h" 00026 #include "memcpy.h" 00027 00028 #ifndef HAVE_STRCASECMP 00029 int egg_strcasecmp(const char *s1, const char *s2) 00030 { 00031 while ((*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) { 00032 s1++; 00033 s2++; 00034 } 00035 return toupper(*s1) - toupper(*s2); 00036 } 00037 #endif /* !HAVE_STRCASECMP */ 00038 00039 #ifndef HAVE_STRNCASECMP 00040 int egg_strncasecmp(const char *s1, const char *s2, size_t n) 00041 { 00042 if (!n) 00043 return 0; 00044 while (--n && (*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) { 00045 s1++; 00046 s2++; 00047 } 00048 return toupper(*s1) - toupper(*s2); 00049 } 00050 #endif /* !HAVE_STRNCASECMP */