Replace extern inline with static inline.
[linux-2.6/linux-mips.git] / fs / jfs / jfs_unicode.h
blob27c9b32f7b16381a24a08cb38e6de617975c69b1
1 /*
2 * Copyright (c) International Business Machines Corp., 2000-2002
3 * Portions Copyright (c) Christoph Hellwig, 2001-2002
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef _H_JFS_UNICODE
20 #define _H_JFS_UNICODE
22 #include <asm/byteorder.h>
23 #include "jfs_types.h"
25 typedef struct {
26 wchar_t start;
27 wchar_t end;
28 signed char *table;
29 } UNICASERANGE;
31 extern signed char UniUpperTable[512];
32 extern UNICASERANGE UniUpperRange[];
33 extern int get_UCSname(struct component_name *, struct dentry *,
34 struct nls_table *);
35 extern int jfs_strfromUCS_le(char *, const wchar_t *, int, struct nls_table *);
37 #define free_UCSname(COMP) kfree((COMP)->name)
40 * UniStrcpy: Copy a string
42 static inline wchar_t *UniStrcpy(wchar_t * ucs1, const wchar_t * ucs2)
44 wchar_t *anchor = ucs1; /* save the start of result string */
46 while ((*ucs1++ = *ucs2++));
47 return anchor;
53 * UniStrncpy: Copy length limited string with pad
55 static inline wchar_t *UniStrncpy(wchar_t * ucs1, const wchar_t * ucs2,
56 size_t n)
58 wchar_t *anchor = ucs1;
60 while (n-- && *ucs2) /* Copy the strings */
61 *ucs1++ = *ucs2++;
63 n++;
64 while (n--) /* Pad with nulls */
65 *ucs1++ = 0;
66 return anchor;
70 * UniStrncmp_le: Compare length limited string - native to little-endian
72 static inline int UniStrncmp_le(const wchar_t * ucs1, const wchar_t * ucs2,
73 size_t n)
75 if (!n)
76 return 0; /* Null strings are equal */
77 while ((*ucs1 == __le16_to_cpu(*ucs2)) && *ucs1 && --n) {
78 ucs1++;
79 ucs2++;
81 return (int) *ucs1 - (int) __le16_to_cpu(*ucs2);
85 * UniStrncpy_le: Copy length limited string with pad to little-endian
87 static inline wchar_t *UniStrncpy_le(wchar_t * ucs1, const wchar_t * ucs2,
88 size_t n)
90 wchar_t *anchor = ucs1;
92 while (n-- && *ucs2) /* Copy the strings */
93 *ucs1++ = __le16_to_cpu(*ucs2++);
95 n++;
96 while (n--) /* Pad with nulls */
97 *ucs1++ = 0;
98 return anchor;
103 * UniToupper: Convert a unicode character to upper case
105 static inline wchar_t UniToupper(wchar_t uc)
107 UNICASERANGE *rp;
109 if (uc < sizeof(UniUpperTable)) { /* Latin characters */
110 return uc + UniUpperTable[uc]; /* Use base tables */
111 } else {
112 rp = UniUpperRange; /* Use range tables */
113 while (rp->start) {
114 if (uc < rp->start) /* Before start of range */
115 return uc; /* Uppercase = input */
116 if (uc <= rp->end) /* In range */
117 return uc + rp->table[uc - rp->start];
118 rp++; /* Try next range */
121 return uc; /* Past last range */
126 * UniStrupr: Upper case a unicode string
128 static inline wchar_t *UniStrupr(wchar_t * upin)
130 wchar_t *up;
132 up = upin;
133 while (*up) { /* For all characters */
134 *up = UniToupper(*up);
135 up++;
137 return upin; /* Return input pointer */
140 #endif /* !_H_JFS_UNICODE */