0001
0002
0003
0004
0005
0006 #ifndef _H_JFS_UNICODE
0007 #define _H_JFS_UNICODE
0008
0009 #include <linux/slab.h>
0010 #include <asm/byteorder.h>
0011 #include "jfs_types.h"
0012
0013 typedef struct {
0014 wchar_t start;
0015 wchar_t end;
0016 signed char *table;
0017 } UNICASERANGE;
0018
0019 extern signed char UniUpperTable[512];
0020 extern UNICASERANGE UniUpperRange[];
0021 extern int get_UCSname(struct component_name *, struct dentry *);
0022 extern int jfs_strfromUCS_le(char *, const __le16 *, int, struct nls_table *);
0023
0024 #define free_UCSname(COMP) kfree((COMP)->name)
0025
0026
0027
0028
0029 static inline wchar_t *UniStrcpy(wchar_t * ucs1, const wchar_t * ucs2)
0030 {
0031 wchar_t *anchor = ucs1;
0032
0033 while ((*ucs1++ = *ucs2++));
0034 return anchor;
0035 }
0036
0037
0038
0039
0040
0041
0042 static inline __le16 *UniStrncpy_le(__le16 * ucs1, const __le16 * ucs2,
0043 size_t n)
0044 {
0045 __le16 *anchor = ucs1;
0046
0047 while (n-- && *ucs2)
0048 *ucs1++ = *ucs2++;
0049
0050 n++;
0051 while (n--)
0052 *ucs1++ = 0;
0053 return anchor;
0054 }
0055
0056
0057
0058
0059 static inline int UniStrncmp_le(const wchar_t * ucs1, const __le16 * ucs2,
0060 size_t n)
0061 {
0062 if (!n)
0063 return 0;
0064 while ((*ucs1 == __le16_to_cpu(*ucs2)) && *ucs1 && --n) {
0065 ucs1++;
0066 ucs2++;
0067 }
0068 return (int) *ucs1 - (int) __le16_to_cpu(*ucs2);
0069 }
0070
0071
0072
0073
0074 static inline __le16 *UniStrncpy_to_le(__le16 * ucs1, const wchar_t * ucs2,
0075 size_t n)
0076 {
0077 __le16 *anchor = ucs1;
0078
0079 while (n-- && *ucs2)
0080 *ucs1++ = cpu_to_le16(*ucs2++);
0081
0082 n++;
0083 while (n--)
0084 *ucs1++ = 0;
0085 return anchor;
0086 }
0087
0088
0089
0090
0091 static inline wchar_t *UniStrncpy_from_le(wchar_t * ucs1, const __le16 * ucs2,
0092 size_t n)
0093 {
0094 wchar_t *anchor = ucs1;
0095
0096 while (n-- && *ucs2)
0097 *ucs1++ = __le16_to_cpu(*ucs2++);
0098
0099 n++;
0100 while (n--)
0101 *ucs1++ = 0;
0102 return anchor;
0103 }
0104
0105
0106
0107
0108 static inline wchar_t UniToupper(wchar_t uc)
0109 {
0110 UNICASERANGE *rp;
0111
0112 if (uc < sizeof(UniUpperTable)) {
0113 return uc + UniUpperTable[uc];
0114 } else {
0115 rp = UniUpperRange;
0116 while (rp->start) {
0117 if (uc < rp->start)
0118 return uc;
0119 if (uc <= rp->end)
0120 return uc + rp->table[uc - rp->start];
0121 rp++;
0122 }
0123 }
0124 return uc;
0125 }
0126
0127
0128
0129
0130
0131 static inline wchar_t *UniStrupr(wchar_t * upin)
0132 {
0133 wchar_t *up;
0134
0135 up = upin;
0136 while (*up) {
0137 *up = UniToupper(*up);
0138 up++;
0139 }
0140 return upin;
0141 }
0142
0143 #endif