TIVI-153: Add as dependency for iputils
[profile/ivi/opensp.git] / include / sptchar.h
1 // Copyright (c) 1996 James Clark
2 // See the file COPYING for copying permission.
3
4 #ifndef sptchar_INCLUDED
5 #define sptchar_INCLUDED 1
6
7 #include <string.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <ctype.h>
11
12 #ifdef SP_NAMESPACE
13 namespace SP_NAMESPACE {
14 #endif
15
16 #ifdef SP_WIDE_SYSTEM
17
18 typedef wchar_t SP_TCHAR;
19 typedef wchar_t SP_TUCHAR;
20
21 #define SP_T(x) L ## x
22
23 inline
24 wchar_t *tgetenv(const wchar_t *s)
25 {
26   return _wgetenv(s);
27 }
28
29 inline
30 int tcscmp(const wchar_t *s1, const wchar_t *s2)
31 {
32   return wcscmp(s1, s2);
33 }
34
35 inline
36 int tcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
37 {
38   return wcsncmp(s1, s2, n);
39 }
40
41 inline
42 unsigned long tcstoul(const wchar_t *s, const wchar_t **sp, int base)
43 {
44   return wcstoul((wchar_t *)s, (wchar_t **)sp, base);
45 }
46
47 inline
48 unsigned long tcstoul(wchar_t *s, wchar_t **sp, int base)
49 {
50   return wcstoul(s, sp, base);
51 }
52
53 inline
54 const wchar_t *tcschr(const wchar_t *s, wint_t c)
55 {
56   return wcschr(s, c);
57 }
58
59 inline
60 wchar_t *tcschr(wchar_t *s, wint_t c)
61 {
62   return wcschr(s, c);
63 }
64
65 inline
66 size_t tcslen(const wchar_t *s)
67 {
68   return wcslen(s);
69 }
70
71 inline
72 int fputts(const wchar_t *s, FILE *fp)
73 {
74   return fputws(s, fp);
75 }
76
77 inline
78 int totupper(wint_t c)
79 {
80   return towupper(c);
81 }
82
83 inline
84 bool istalnum(wint_t c)
85 {
86   return iswalnum(c);
87 }
88  
89 #else /* not SP_WIDE_SYSTEM */
90
91 typedef char SP_TCHAR;
92 typedef unsigned char SP_TUCHAR;
93
94 #define SP_T(x) x
95
96 inline
97 char *tgetenv(const char *s)
98 {
99   return getenv(s);
100 }
101
102 inline
103 int tcscmp(const char *s1, const char *s2)
104 {
105   return strcmp(s1, s2);
106 }
107
108 inline
109 int tcsncmp(const char *s1, const char *s2, size_t n)
110 {
111   return strncmp(s1, s2, n);
112 }
113
114 inline
115 unsigned long tcstoul(const char *s, const char **sp, int base)
116 {
117   return strtoul((char *)s, (char **)sp, base);
118 }
119
120 inline
121 unsigned long tcstoul(char *s, char **sp, int base)
122 {
123   return strtoul(s, sp, base);
124 }
125
126 inline
127 const char *tcschr(const char *s, int c)
128 {
129   return strchr(s, c);
130 }
131
132 inline
133 char *tcschr(char *s, int c)
134 {
135   return strchr(s, c);
136 }
137
138 inline
139 size_t tcslen(const char *s)
140 {
141   return strlen(s);
142 }
143
144 inline
145 int fputts(const char *s, FILE *fp)
146 {
147   return fputs(s, fp);
148 }
149
150 inline
151 int totupper(int c)
152 {
153   return toupper(c);
154 }
155
156 inline
157 bool istalnum(int c)
158 {
159   return isalnum(c);
160 }
161
162 #endif /* not SP_WIDE_SYSTEM */
163
164 #ifdef SP_NAMESPACE
165 }
166 #endif
167
168 #endif /* not sptchar_INCLUDED */