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