Re-implemented the element name encoding as Adams suggestion: <e tag="value"> when...
[yaz-moved-to-github.git] / src / cclstr.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 Index Data
3  * See the file LICENSE for details.
4  */
5 /** 
6  * \file cclstr.c
7  * \brief Implements CCL string compare utilities
8  */
9 #include <ctype.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12
13 #include <yaz/ccl.h>
14
15 static int ccli_toupper (int c)
16 {
17     return toupper (c);
18 }
19
20 int (*ccl_toupper)(int c) = NULL;
21
22 int ccl_stricmp (const char *s1, const char *s2)
23 {
24     if (!ccl_toupper)
25         ccl_toupper = ccli_toupper;
26     while (*s1 && *s2)
27     {
28         int c1, c2;
29         c1 = (*ccl_toupper)(*s1);
30         c2 = (*ccl_toupper)(*s2);
31         if (c1 != c2)
32             return c1 - c2;
33         s1++;
34         s2++;
35     }
36     return (*ccl_toupper)(*s1) - (*ccl_toupper)(*s2);
37 }
38
39 int ccl_memicmp (const char *s1, const char *s2, size_t n)
40 {
41     if (!ccl_toupper)
42         ccl_toupper = ccli_toupper;
43     while (1)
44     {
45         int c1, c2;
46
47         c1 = (*ccl_toupper)(*s1);
48         c2 = (*ccl_toupper)(*s2);
49         if (n <= 1 || c1 != c2)
50             return c1 - c2;
51         s1++;
52         s2++;
53         --n;
54     }
55 }
56
57 /*
58  * Local variables:
59  * c-basic-offset: 4
60  * c-file-style: "Stroustrup"
61  * indent-tabs-mode: nil
62  * End:
63  * vim: shiftwidth=4 tabstop=8 expandtab
64  */
65