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