1 /*------------------------------------------------------------------------------
2 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
3 *
4 * Distributable under the terms of either the Apache License (Version 2.0) or
5 * the GNU Lesser General Public License, as specified in the COPYING file.
6 ------------------------------------------------------------------------------*/
7 #ifndef _lucene_repl_wchar_h
8 #define _lucene_repl_wchar_h
9 
10 #ifdef _UCS2
11 
12 #ifndef _CL_HAVE_WCSCPY
13 	//copy a string to another string
14 	#error wcscpy is not defined, and a licensed replacement has not been written yet
15 #endif
16 
17 #ifndef _CL_HAVE_WCSNCPY
18 	//copy a specified amount of one string to another string.
19 	#error wcsncpy is not defined, and a licensed replacement has not been written yet
20 #endif
21 
22 #ifndef _CL_HAVE_WCSCAT
23 	//copy a string onto the end of the other string
24 	#error wcscat is not defined, and a licensed replacement has not been written yet
25 #endif
26 
27 #ifndef _CL_HAVE_WCSCHR
28 	//find location of one character
29 	#error wcschr is not defined, and a licensed replacement has not been written yet
30 #endif
31 
32 #ifndef _CL_HAVE_WCSSTR
33 	//find location of a string
34 	#error wcspy is not defined, and a licensed replacement has not been written yet
35 #endif
36 
37 #ifndef _CL_HAVE_WCSLEN
38 	//get length of a string
39 	#error wcslen is not defined, and a licensed replacement has not been written yet
40 #endif
41 
42 #ifndef _CL_HAVE_WCSCMP
43 	//case sensitive compare two strings
44 	#error wcscmp is not defined, and a licensed replacement has not been written yet
45 #endif
46 
47 #ifndef _CL_HAVE_WCSNCMP
48 	//case sensitive compare two strings of a specified length
49 	#error wcsncmp is not defined, and a licensed replacement has not been written yet
50 #endif
51 
52 #ifndef _CL_HAVE_WCSCSPN
53 	//Return the length of the maximum initial segment
54 	//of WCS which contains only wide-characters not in REJECT.
55 	#error wcscspn is not defined, and a licensed replacement has not been written yet
56 #endif
57 
58 #endif //_UCS2
59 
60 //string function replacements
61 #if defined(LUCENE_USE_INTERNAL_CHAR_FUNCTIONS) || (defined(_UCS2) && !defined(_CL_HAVE_WCSCASECMP)) || (defined(_ASCII) && !defined(_CL_HAVE_STRCASECMP))
62     int lucene_tcscasecmp(const TCHAR *, const TCHAR *);
63     #undef _tcsicmp
64     #define _tcsicmp lucene_tcscasecmp
65 #endif
66 #if defined(LUCENE_USE_INTERNAL_CHAR_FUNCTIONS) || (defined(_UCS2) && !defined(_CL_HAVE_WCSLWR)) || (defined(_ASCII) && !defined(_CL_HAVE_STRLWR))
67     TCHAR* lucene_tcslwr( TCHAR* str );
68     #undef _tcslwr
69     #define _tcslwr lucene_tcslwr
70 #endif
71 
72 //conversion functions
73 #if (defined(_ASCII) && !defined(_CL_HAVE_LLTOA)) || (defined(_UCS2) && !defined(_CL_HAVE_LLTOW))
74     TCHAR* lucene_i64tot( int64_t value, TCHAR* str, int radix);
75     #undef _i64tot
76     #define _i64tot lucene_i64tot
77 #endif
78 #if (defined(_UCS2) && !defined(_CL_HAVE_WCSTOLL)) || (defined(_ASCII) && !defined(_CL_HAVE_STRTOLL))
79 	int64_t lucene_tcstoi64(const TCHAR* str, TCHAR**end, int radix);
80     #undef _tcstoi64
81     #define _tcstoi64 lucene_tcstoi64
82 #endif
83 #if defined(_UCS2) && !defined(_CL_HAVE_WCSTOD)
84     double lucene_tcstod(const TCHAR *value, TCHAR **end);
85     #undef _tcstod
86     #define _tcstod lucene_tcstod
87 #endif
88 
89 //printf functions
90 #if defined(_UCS2) && (!defined(_CL_HAVE_SNWPRINTF) || defined(_CL_HAVE_SWPRINTF_BUG) )
91     #undef _sntprintf
92     #define _sntprintf lucene_snwprintf
93     int lucene_snwprintf(wchar_t* strbuf, size_t count, const wchar_t * format, ...);
94 
95     #ifndef __CL_INCLUDE_TPRINTF
96     	#define __CL_INCLUDE_TPRINTF
97     #endif
98 #endif
99 #if defined(_UCS2) && !defined(_CL_HAVE_WPRINTF)
100     #undef _tprintf
101     #define _tprintf lucene_wprintf
102     void lucene_wprintf(const wchar_t * format, ...);
103 
104     #ifndef __CL_INCLUDE_TPRINTF
105     	#define __CL_INCLUDE_TPRINTF
106     #endif
107 #endif
108 #if defined(_UCS2) && (!defined(_CL_HAVE_VSNWPRINTF) || defined(_CL_HAVE_SWPRINTF_BUG) )
109     #undef _vsntprintf
110     #define _vsntprintf lucene_vsnwprintf
111     int lucene_vsnwprintf(wchar_t * strbuf, size_t count, const wchar_t * format, va_list& ap);
112 
113     #ifndef __CL_INCLUDE_TPRINTF
114     	#define __CL_INCLUDE_TPRINTF
115     #endif
116 #endif
117 
118 //todo: if _CL_HAVE_SNPRINTF_BUG fails(snprintf overflow),we should use our own
119 //function. but we don't have it currently, and our functions are dubious anyway...
120 
121 #endif //end of _lucene_repl_wchar_h
122