YAZ  5.23.1
cclstr.c
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12 #include <yaz/yaz-iconv.h>
13 #include <stdio.h>
14 #include <stdlib.h>
15 
16 #include <yaz/ccl.h>
17 
18 static int ccli_toupper (int c)
19 {
20  if (yaz_islower(c))
21  return yaz_toupper(c);
22  else
23  return c;
24 }
25 
26 int (*ccl_toupper)(int c) = NULL;
27 
28 int ccl_stricmp (const char *s1, const char *s2)
29 {
30  if (!ccl_toupper)
32  while (*s1 && *s2)
33  {
34  int c1, c2;
35  c1 = (*ccl_toupper)(*s1);
36  c2 = (*ccl_toupper)(*s2);
37  if (c1 != c2)
38  return c1 - c2;
39  s1++;
40  s2++;
41  }
42  return (*ccl_toupper)(*s1) - (*ccl_toupper)(*s2);
43 }
44 
45 int ccl_memicmp (const char *s1, const char *s2, size_t n)
46 {
47  if (!ccl_toupper)
49  while (1)
50  {
51  int c1, c2;
52 
53  c1 = (*ccl_toupper)(*s1);
54  c2 = (*ccl_toupper)(*s2);
55  if (n <= 1 || c1 != c2)
56  return c1 - c2;
57  s1++;
58  s2++;
59  --n;
60  }
61 }
62 
63 /*
64  * Local variables:
65  * c-basic-offset: 4
66  * c-file-style: "Stroustrup"
67  * indent-tabs-mode: nil
68  * End:
69  * vim: shiftwidth=4 tabstop=8 expandtab
70  */
71 
static int ccli_toupper(int c)
Definition: cclstr.c:18
#define yaz_toupper(x)
Definition: yaz-iconv.h:88
int(* ccl_toupper)(int c)
Definition: cclstr.c:26
#define yaz_islower(x)
Definition: yaz-iconv.h:91
int ccl_stricmp(const char *s1, const char *s2)
Definition: cclstr.c:28
Header for YAZ iconv interface.
int ccl_memicmp(const char *s1, const char *s2, size_t n)
Definition: cclstr.c:45
Header with public definitions for CCL.