ab2e15292da9da04b0d10cf867d976083b7aef34
[oweals/cde.git] / cde / programs / nsgmls / sptchar.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: sptchar.h /main/1 1996/07/29 17:10:09 cde-hp $ */
24 // Copyright (c) 1996 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef sptchar_INCLUDED
28 #define sptchar_INCLUDED 1
29
30 #include <string.h>
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <ctype.h>
34
35 #ifdef SP_NAMESPACE
36 namespace SP_NAMESPACE {
37 #endif
38
39 #ifdef SP_WIDE_SYSTEM
40
41 // typedef wchar_t SP_TCHAR;
42 // typedef wchar_t SP_TUCHAR;
43 #define SP_TCHAR wchar_t
44 #define SP_TUCHAR wchar_t
45
46 #define SP_T(x) L ## x
47
48 inline
49 wchar_t *tgetenv(const wchar_t *s)
50 {
51   return _wgetenv(s);
52 }
53
54 inline
55 int tcscmp(const wchar_t *s1, const wchar_t *s2)
56 {
57   return wcscmp(s1, s2);
58 }
59
60 inline
61 int tcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
62 {
63   return wcsncmp(s1, s2, n);
64 }
65
66 inline
67 unsigned long tcstoul(const wchar_t *s, const wchar_t **sp, int base)
68 {
69   return wcstoul((wchar_t *)s, (wchar_t **)sp, base);
70 }
71
72 inline
73 unsigned long tcstoul(wchar_t *s, wchar_t **sp, int base)
74 {
75   return wcstoul(s, sp, base);
76 }
77
78 inline
79 const wchar_t *tcschr(const wchar_t *s, wint_t c)
80 {
81   return wcschr(s, c);
82 }
83
84 inline
85 wchar_t *tcschr(wchar_t *s, wint_t c)
86 {
87   return wcschr(s, c);
88 }
89
90 inline
91 size_t tcslen(const wchar_t *s)
92 {
93   return wcslen(s);
94 }
95
96 inline
97 int fputts(const wchar_t *s, FILE *fp)
98 {
99   return fputws(s, fp);
100 }
101
102 inline
103 int totupper(wint_t c)
104 {
105   return towupper(c);
106 }
107
108 #else /* not SP_WIDE_SYSTEM */
109
110 // typedef char SP_TCHAR;
111 // typedef unsigned char SP_TUCHAR;
112 #define SP_TCHAR char
113 #define SP_TUCHAR unsigned char
114
115 #define SP_T(x) x
116
117 inline
118 char *tgetenv(const char *s)
119 {
120   return getenv(s);
121 }
122
123 inline
124 int tcscmp(const char *s1, const char *s2)
125 {
126   return strcmp(s1, s2);
127 }
128
129 inline
130 int tcsncmp(const char *s1, const char *s2, size_t n)
131 {
132   return strncmp(s1, s2, n);
133 }
134
135 inline
136 unsigned long tcstoul(const char *s, const char **sp, int base)
137 {
138   return strtoul((char *)s, (char **)sp, base);
139 }
140
141 inline
142 unsigned long tcstoul(char *s, char **sp, int base)
143 {
144   return strtoul(s, sp, base);
145 }
146
147 inline
148 const char *tcschr(const char *s, int c)
149 {
150   return strchr(s, c);
151 }
152
153 inline
154 char *tcschr(char *s, int c)
155 {
156   return strchr(s, c);
157 }
158
159 inline
160 size_t tcslen(const char *s)
161 {
162   return strlen(s);
163 }
164
165 inline
166 int fputts(const char *s, FILE *fp)
167 {
168   return fputs(s, fp);
169 }
170
171 inline
172 int totupper(int c)
173 {
174   return toupper(c);
175 }
176
177 #endif /* not SP_WIDE_SYSTEM */
178
179 #ifdef SP_NAMESPACE
180 }
181 #endif
182
183 #endif /* not sptchar_INCLUDED */