a110a22cdc478489cb647e8048c6b9b3ce603ad7
[public/netxms.git] / include / unicode.h
1 /*
2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003, 2004 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** $module: unicode.h
20 **
21 **/
22
23 #ifndef _unicode_h_
24 #define _unicode_h_
25
26 #ifdef _WIN32
27
28 // Ensure that both UNICODE and _UNICODE are defined
29 #ifdef _UNICODE
30 #ifndef UNICODE
31 #define UNICODE
32 #endif
33 #endif
34
35 #ifdef UNICODE
36 #ifndef _UNICODE
37 #define _UNICODE
38 #endif
39 #endif
40
41 #include <tchar.h>
42
43 #ifdef UNICODE
44
45 #define _tcstoll wcstoll
46 #define _tcstoull wcstoull
47
48 #else
49
50 #define _tcstoll strtoll
51 #define _tcstoull strtoull
52
53 #endif
54
55 #else /* not _WIN32 */
56
57 #if HAVE_WCHAR_H
58 #include <wchar.h>
59 #endif
60
61 #if HAVE_STRING_H
62 #include <string.h>
63 #endif
64
65 #ifdef _NETWARE
66 #define WCHAR wchar_t
67 #else
68 #define WCHAR unsigned short
69 #endif
70
71 // Redefine wide character functions if system's wchar_t is not 2 bytes long
72 #if !HAVE_USEABLE_WCHAR
73
74 #define wcslen nx_wcslen
75
76 #endif
77
78 #ifdef UNICODE
79
80 #error UNICODE is not supported on non-Windows platforms
81
82 #else
83
84 // On some old systems, ctype.h defines _T macro, so we include it
85 // before our definition and do an undef
86 #include <ctype.h>
87
88 #undef _T
89 #define _T(x) x
90 #define TCHAR char
91 #define _TINT int
92
93 #define _tcscpy strcpy
94 #define _tcsncpy strncpy
95 #define _tcslen strlen
96 #define _tcschr strchr
97 #define _tcsrchr strrchr
98 #define _tcscmp strcmp
99 #define _tcsicmp stricmp
100 #define _tcsncmp strncmp
101 #define _tprintf printf
102 #define _stprintf sprintf
103 #define _ftprintf fprintf
104 #define _sntprintf snprintf
105 #define _vtprintf vprintf
106 #define _vstprintf vsprintf
107 #define _vsntprintf vsnprintf
108 #define _tfopen fopen
109 #define _fgetts fgets
110 #define _fputts fputs
111 #define _tcstol strtol
112 #define _tcstoul strtoul
113 #define _tcstoll strtoll
114 #define _tcstoull strtoull
115 #define _tcstod strtod
116 #define _tcsdup strdup
117 #define _tcsupr strupr
118 #define _tcsspn strspn
119 #define _tcsstr strstr
120 #define _tcscat strcat
121 #define _topen open
122 #define _taccess access
123 #define _tunlink unlink
124 #define _tcsftime strftime
125 #define _tctime ctime
126 #define _istspace isspace
127 #define _istdigit isdigit
128 #define _istalpha isalpha
129 #define _istupper isupper
130
131 #endif
132
133 #define CP_ACP 0
134 #define CP_UTF8 65001
135 #define MB_PRECOMPOSED 0x00000001
136 #define WC_COMPOSITECHECK 0x00000002
137 #define WC_DEFAULTCHAR 0x00000004
138
139 #endif /* _WIN32 */
140
141
142 #ifdef UNICODE
143 #define _t_inet_addr inet_addr_w
144 #else
145 #define _t_inet_addr inet_addr
146 #endif
147
148
149 #endif /* _unicode_h_ */