1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef _H_JFS_UNICODE
20#define _H_JFS_UNICODE
21
22#include <asm/byteorder.h>
23#include "jfs_types.h"
24
25typedef struct {
26 wchar_t start;
27 wchar_t end;
28 signed char *table;
29} UNICASERANGE;
30
31extern signed char UniUpperTable[512];
32extern UNICASERANGE UniUpperRange[];
33extern int get_UCSname(struct component_name *, struct dentry *);
34extern int jfs_strfromUCS_le(char *, const __le16 *, int, struct nls_table *);
35
36#define free_UCSname(COMP) kfree((COMP)->name)
37
38
39
40
41static inline wchar_t *UniStrcpy(wchar_t * ucs1, const wchar_t * ucs2)
42{
43 wchar_t *anchor = ucs1;
44
45 while ((*ucs1++ = *ucs2++));
46 return anchor;
47}
48
49
50
51
52
53
54static inline __le16 *UniStrncpy_le(__le16 * ucs1, const __le16 * ucs2,
55 size_t n)
56{
57 __le16 *anchor = ucs1;
58
59 while (n-- && *ucs2)
60 *ucs1++ = *ucs2++;
61
62 n++;
63 while (n--)
64 *ucs1++ = 0;
65 return anchor;
66}
67
68
69
70
71static inline int UniStrncmp_le(const wchar_t * ucs1, const __le16 * ucs2,
72 size_t n)
73{
74 if (!n)
75 return 0;
76 while ((*ucs1 == __le16_to_cpu(*ucs2)) && *ucs1 && --n) {
77 ucs1++;
78 ucs2++;
79 }
80 return (int) *ucs1 - (int) __le16_to_cpu(*ucs2);
81}
82
83
84
85
86static inline __le16 *UniStrncpy_to_le(__le16 * ucs1, const wchar_t * ucs2,
87 size_t n)
88{
89 __le16 *anchor = ucs1;
90
91 while (n-- && *ucs2)
92 *ucs1++ = cpu_to_le16(*ucs2++);
93
94 n++;
95 while (n--)
96 *ucs1++ = 0;
97 return anchor;
98}
99
100
101
102
103static inline wchar_t *UniStrncpy_from_le(wchar_t * ucs1, const __le16 * ucs2,
104 size_t n)
105{
106 wchar_t *anchor = ucs1;
107
108 while (n-- && *ucs2)
109 *ucs1++ = __le16_to_cpu(*ucs2++);
110
111 n++;
112 while (n--)
113 *ucs1++ = 0;
114 return anchor;
115}
116
117
118
119
120static inline wchar_t UniToupper(wchar_t uc)
121{
122 UNICASERANGE *rp;
123
124 if (uc < sizeof(UniUpperTable)) {
125 return uc + UniUpperTable[uc];
126 } else {
127 rp = UniUpperRange;
128 while (rp->start) {
129 if (uc < rp->start)
130 return uc;
131 if (uc <= rp->end)
132 return uc + rp->table[uc - rp->start];
133 rp++;
134 }
135 }
136 return uc;
137}
138
139
140
141
142
143static inline wchar_t *UniStrupr(wchar_t * upin)
144{
145 wchar_t *up;
146
147 up = upin;
148 while (*up) {
149 *up = UniToupper(*up);
150 up++;
151 }
152 return upin;
153}
154
155#endif
156