static int Curl_raw_equal(const char *first, const char *second) { while(*first && *second) { if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second)) /* get out of the loop as soon as they don't match */ break; first++; second++; } /* we do the comparison here (possibly again), just to make sure that if the loop above is skipped because one of the strings reached zero, we must not return this as a successful match */ return (Curl_raw_toupper(*first) == Curl_raw_toupper(*second)); }
static int Curl_raw_nequal(const char *first, const char *second, size_t max) { while(*first && *second && max) { if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second)) { break; } max--; first++; second++; } if(0 == max) return 1; /* they are equal this far */ return Curl_raw_toupper(*first) == Curl_raw_toupper(*second); }
/* Copy an upper case version of the string from src to dest. The * strings may overlap. No more than n characters of the string are copied * (including any NUL) and the destination string will NOT be * NUL-terminated if that limit is reached. */ void Curl_strntoupper(char *dest, const char *src, size_t n) { if(n < 1) return; do { *dest++ = Curl_raw_toupper(*src); } while(*src++ && --n); }
/* * A case-insensitive hash for the cookie domains. */ static size_t cookie_hash_domain(const char *domain, const size_t len) { const char *end = domain + len; size_t h = 5381; while(domain < end) { h += h << 5; h ^= Curl_raw_toupper(*domain++); } return (h % COOKIE_HASH_SIZE); }
static unsigned char hex_to_uint(const char *s) { int v[2]; int i; for(i = 0; i < 2; ++i) { v[i] = Curl_raw_toupper(s[i]); if('0' <= v[i] && v[i] <= '9') { v[i] -= '0'; } else if('A' <= v[i] && v[i] <= 'Z') { v[i] -= 'A'-10; } } return (unsigned char)((v[0] << 4) | v[1]); }