1 
2  /***************************************************************************/
3 
4 /*
5  * Portions Copyright (c) 1999 GMRS Software GmbH
6  * Carl-von-Linde-Str. 38, D-85716 Unterschleissheim, http://www.gmrs.de
7  * All rights reserved.
8  *
9  * Author: Arno Unkrig <arno@unkrig.de>
10  *
11  * All advertising materials mentioning features or use of this software
12  * must display the following acknowledgement:
13  * "This product includes software developed by GMRS Software GmbH."
14  * The name of GMRS Software GmbH may not be used to endorse or promote
15  * products derived from this software without specific prior written
16  * permission.
17  */
18 
19 /* This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 2 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License in the file COPYING for more details.
28  */
29 
30  /***************************************************************************/
31 
32 /*
33  * Changes to version 1.2.2 were made by Martin Bayer <mbayer@zedat.fu-berlin.de>
34  * Dates and reasons of modifications:
35  * Thu Oct  4 21:31:58 CEST 2001: ported to g++ 3.0
36  */
37 
38  /***************************************************************************/
39 
40 
41 #ifndef __cmp_nocase_h_INCLUDED__ /* { */
42 #define __cmp_nocase_h_INCLUDED__
43 
44 /* ------------------------------------------------------------------------- */
45 
46 #include <string.h>
47 #include <string>
48 
49 using std::string;
50 
51 /* ------------------------------------------------------------------------- */
52 
53 /*
54  * The Standard C++ library is lacking a case-insensitive string comparison
55  * function... so I define my own, adapting Stroustrup's ("The C++ Programming
56  * Language", 3rd edition).
57  */
58 
59 // Helper
60 extern int _cmp_nocase(const char *s1, size_t l1, const char *s2, size_t l2);
61 
62 // -1: s1 < s2; 0: s1 == s2, 1: s1 > s2
cmp_nocase(const string & s1,const string & s2)63 inline int cmp_nocase(const string &s1, const string &s2)
64       { return _cmp_nocase(s1.data(), s1.length(), s2.data(), s2.length()); }
cmp_nocase(const char * s1,const string & s2)65 inline int cmp_nocase(const char   *s1, const string &s2)
66       { return _cmp_nocase(s1, strlen(s1), s2.data(), s2.length()); }
cmp_nocase(const string & s1,const char * s2)67 inline int cmp_nocase(const string &s1, const char   *s2)
68       { return _cmp_nocase(s1.data(), s1.length(), s2, strlen(s2)); }
cmp_nocase(const char * s1,const char * s2)69 inline int cmp_nocase(const char   *s1, const char   *s2)
70       { return _cmp_nocase(s1, strlen(s1), s2, strlen(s2)); }
71 
72 /* ------------------------------------------------------------------------- */
73 
74 #endif /* } */
75 
76 /* ------------------------------------------------------------------------- */
77 
78