1
/***************************************************************************
3
* Project ___| | | | _ \| |
5
* | (__| |_| | _ <| |___
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2009, 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 http://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
* $Id: rawstr.c,v 1.3 2009-02-07 22:53:37 bagder Exp $
22
***************************************************************************/
28
/* Portable, consistent toupper (remember EBCDIC). Do not use toupper() because
29
its behavior is altered by the current locale. */
30
char Curl_raw_toupper(char in)
90
* Curl_raw_equal() is for doing "raw" case insensitive strings. This is meant
91
* to be locale independent and only compare strings we know are safe for
92
* this. See http://daniel.haxx.se/blog/2008/10/15/strcasecmp-in-turkish/ for
93
* some further explanation to why this function is necessary.
95
* The function is capable of comparing a-z case insensitively even for
99
int Curl_raw_equal(const char *first, const char *second)
101
while(*first && *second) {
102
if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second))
103
/* get out of the loop as soon as they don't match */
108
/* we do the comparison here (possibly again), just to make sure that if the
109
loop above is skipped because one of the strings reached zero, we must not
110
return this as a successful match */
111
return (Curl_raw_toupper(*first) == Curl_raw_toupper(*second));
114
int Curl_raw_nequal(const char *first, const char *second, size_t max)
116
while(*first && *second && max) {
117
if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second)) {
125
return 1; /* they are equal this far */
127
return Curl_raw_toupper(*first) == Curl_raw_toupper(*second);
130
/* Copy an upper case version of the string from src to dest. The
131
* strings may overlap. No more than n characters of the string are copied
132
* (including any NUL) and the destination string will NOT be
133
* NUL-terminated if that limit is reached.
135
void Curl_strntoupper(char *dest, const char *src, size_t n)
141
*dest++ = Curl_raw_toupper(*src);
142
} while (*src++ && --n);