1:
2:
3:
4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28:
29:
30: #include <sys/cdefs.h>
31: #include <sys/types.h>
32:
33: #include <errno.h>
34: #include <string.h>
35: #include <stdio.h>
36: #include <stdlib.h>
37: #include <stddef.h>
38: #include <wchar.h>
39:
40: #include "citrus_ctype.h"
41: #include "citrus_none.h"
42:
43: _CITRUS_CTYPE_DEF_OPS(none);
44:
45: size_t
46:
47: _citrus_none_ctype_mbrtowc(wchar_t * __restrict pwc,
48: const char * __restrict s, size_t n,
49: void * __restrict pspriv)
50: {
51:
52:
53:
54:
55: if (s == NULL)
56: return 0;
57: if (n == 0)
58: return (size_t)-2;
59: if (pwc)
60: *pwc = (wchar_t)(unsigned char)*s;
61: return (*s != '\0');
62: }
63:
64: int
65:
66: _citrus_none_ctype_mbsinit(const void * __restrict pspriv)
67: {
68: return (1);
69: }
70:
71: size_t
72:
73: _citrus_none_ctype_mbsrtowcs(wchar_t * __restrict pwcs,
74: const char ** __restrict s, size_t n,
75: void * __restrict pspriv)
76: {
77: int count = 0;
78:
79:
80:
81:
82:
83: if (!s || !*s)
84: return 0;
85:
86: if (pwcs == NULL)
87: return strlen(*s);
88:
89: while (n > 0) {
90: if ((*pwcs++ = (wchar_t)(unsigned char)*(*s)++) == 0)
91: break;
92: count++;
93: n--;
94: }
95:
96: return count;
97: }
98:
99: size_t
100:
101: _citrus_none_ctype_wcrtomb(char * __restrict s,
102: wchar_t wc, void * __restrict pspriv)
103: {
104:
105:
106:
107: if (s == NULL)
108: return 0;
109:
110: *s = (char) wc;
111: return 1;
112: }
113:
114: size_t
115:
116: _citrus_none_ctype_wcsrtombs(char * __restrict s,
117: const wchar_t ** __restrict pwcs, size_t n,
118: void * __restrict pspriv)
119: {
120: int count = 0;
121:
122:
123:
124:
125:
126: if (pwcs == NULL || *pwcs == NULL)
127: return (0);
128:
129: if (s == NULL) {
130: while (*(*pwcs)++ != 0)
131: count++;
132: return(count);
133: }
134:
135: if (n != 0) {
136: do {
137: if ((*s++ = (char) *(*pwcs)++) == 0)
138: break;
139: count++;
140: } while (--n != 0);
141: }
142:
143: return count;
144: }