1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
34 int curl_strequal(const char *first, const char *second)
36 #if defined(HAVE_STRCASECMP)
37 return !(strcasecmp)(first, second);
38 #elif defined(HAVE_STRCMPI)
39 return !(strcmpi)(first, second);
40 #elif defined(HAVE_STRICMP)
41 return !(stricmp)(first, second);
43 while(*first && *second) {
44 if(toupper(*first) != toupper(*second)) {
50 return toupper(*first) == toupper(*second);
57 int curl_strnequal(const char *first, const char *second, size_t max)
59 #if defined(HAVE_STRNCASECMP)
60 return !strncasecmp(first, second, max);
61 #elif defined(HAVE_STRNCMPI)
62 return !strncmpi(first, second, max);
63 #elif defined(HAVE_STRNICMP)
64 return !strnicmp(first, second, max);
66 while(*first && *second && max) {
67 if(toupper(*first) != toupper(*second)) {
75 return 1; /* they are equal this far */
77 return toupper(*first) == toupper(*second);