ares_strcasecmp.c
Go to the documentation of this file.
1 
2 
3 /* Copyright 1998 by the Massachusetts Institute of Technology.
4  *
5  * Permission to use, copy, modify, and distribute this
6  * software and its documentation for any purpose and without
7  * fee is hereby granted, provided that the above copyright
8  * notice appear in all copies and that both that copyright
9  * notice and this permission notice appear in supporting
10  * documentation, and that the name of M.I.T. not be used in
11  * advertising or publicity pertaining to distribution of the
12  * software without specific, written prior permission.
13  * M.I.T. makes no representations about the suitability of
14  * this software for any purpose. It is provided "as is"
15  * without express or implied warranty.
16  */
17 
18 #include "ares_setup.h"
19 #include "ares_strcasecmp.h"
20 
21 #ifndef HAVE_STRCASECMP
22 int ares_strcasecmp(const char *a, const char *b)
23 {
24 #if defined(HAVE_STRCMPI)
25  return strcmpi(a, b);
26 #elif defined(HAVE_STRICMP)
27  return stricmp(a, b);
28 #else
29  size_t i;
30 
31  for (i = 0; i < (size_t)-1; i++) {
32  int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i];
33  int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i];
34  if (c1 != c2)
35  return c1-c2;
36  if (!c1)
37  break;
38  }
39  return 0;
40 #endif
41 }
42 #endif
43 
44 #ifndef HAVE_STRNCASECMP
45 int ares_strncasecmp(const char *a, const char *b, size_t n)
46 {
47 #if defined(HAVE_STRNCMPI)
48  return strncmpi(a, b, n);
49 #elif defined(HAVE_STRNICMP)
50  return strnicmp(a, b, n);
51 #else
52  size_t i;
53 
54  for (i = 0; i < n; i++) {
55  int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i];
56  int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i];
57  if (c1 != c2)
58  return c1-c2;
59  if (!c1)
60  break;
61  }
62  return 0;
63 #endif
64 }
65 #endif
66 
ares_strncasecmp
int ares_strncasecmp(const char *a, const char *b, size_t n)
Definition: ares_strcasecmp.c:45
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
ares_strcasecmp.h
ISUPPER
#define ISUPPER(x)
Definition: setup_once.h:282
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
ares_setup.h
absl::hash_internal::c1
static const uint32_t c1
Definition: abseil-cpp/absl/hash/internal/city.cc:58
ares_strcasecmp
int ares_strcasecmp(const char *a, const char *b)
Definition: ares_strcasecmp.c:22
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
absl::hash_internal::c2
static const uint32_t c2
Definition: abseil-cpp/absl/hash/internal/city.cc:59


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:43