patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / fs / ntfs / unistr.c
index 36bee49..507f836 100644 (file)
@@ -8,13 +8,13 @@
  * by the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
- * This program/include file is distributed in the hope that it will be 
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
+ * This program/include file is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program (in the main directory of the Linux-NTFS 
+ * along with this program (in the main directory of the Linux-NTFS
  * distribution in the file COPYING); if not, write to the Free Software
  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
@@ -61,10 +61,9 @@ static const u8 legal_ansi_char_array[0x40] = {
  * identical, or FALSE (0) if they are not identical. If @ic is IGNORE_CASE,
  * the @upcase table is used to performa a case insensitive comparison.
  */
-BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
-                    const uchar_t *s2, size_t s2_len,
-                    const IGNORE_CASE_BOOL ic,
-                    const uchar_t *upcase, const u32 upcase_size)
+BOOL ntfs_are_names_equal(const ntfschar *s1, size_t s1_len,
+               const ntfschar *s2, size_t s2_len, const IGNORE_CASE_BOOL ic,
+               const ntfschar *upcase, const u32 upcase_size)
 {
        if (s1_len != s2_len)
                return FALSE;
@@ -78,12 +77,12 @@ BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
  * @name1:     first Unicode name to compare
  * @name2:     second Unicode name to compare
  * @err_val:   if @name1 contains an invalid character return this value
- * @ic:         either CASE_SENSITIVE or IGNORE_CASE
+ * @ic:                either CASE_SENSITIVE or IGNORE_CASE
  * @upcase:    upcase table (ignored if @ic is CASE_SENSITIVE)
  * @upcase_len:        upcase table size (ignored if @ic is CASE_SENSITIVE)
  *
  * ntfs_collate_names collates two Unicode names and returns:
- * 
+ *
  *  -1 if the first name collates before the second one,
  *   0 if the names match,
  *   1 if the second name collates before the first one, or
@@ -91,13 +90,13 @@ BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
  *
  * The following characters are considered invalid: '"', '*', '<', '>' and '?'.
  */
-int ntfs_collate_names(const uchar_t *name1, const u32 name1_len,
-               const uchar_t *name2, const u32 name2_len,
+int ntfs_collate_names(const ntfschar *name1, const u32 name1_len,
+               const ntfschar *name2, const u32 name2_len,
                const int err_val, const IGNORE_CASE_BOOL ic,
-               const uchar_t *upcase, const u32 upcase_len)
+               const ntfschar *upcase, const u32 upcase_len)
 {
        u32 cnt, min_len;
-       uchar_t c1, c2;
+       ntfschar c1, c2;
 
        min_len = name1_len;
        if (name1_len > name2_len)
@@ -138,14 +137,14 @@ int ntfs_collate_names(const uchar_t *name1, const u32 name1_len,
  * Compare the first @n characters of the Unicode strings @s1 and @s2,
  * The strings in little endian format and appropriate le16_to_cpu()
  * conversion is performed on non-little endian machines.
- * 
+ *
  * The function returns an integer less than, equal to, or greater than zero
  * if @s1 (or the first @n Unicode characters thereof) is found, respectively,
  * to be less than, to match, or be greater than @s2.
  */
-int ntfs_ucsncmp(const uchar_t *s1, const uchar_t *s2, size_t n)
+int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n)
 {
-       uchar_t c1, c2;
+       ntfschar c1, c2;
        size_t i;
 
        for (i = 0; i < n; ++i) {
@@ -172,17 +171,17 @@ int ntfs_ucsncmp(const uchar_t *s1, const uchar_t *s2, size_t n)
  * Compare the first @n characters of the Unicode strings @s1 and @s2,
  * ignoring case. The strings in little endian format and appropriate
  * le16_to_cpu() conversion is performed on non-little endian machines.
- * 
+ *
  * Each character is uppercased using the @upcase table before the comparison.
  *
  * The function returns an integer less than, equal to, or greater than zero
  * if @s1 (or the first @n Unicode characters thereof) is found, respectively,
  * to be less than, to match, or be greater than @s2.
  */
-int ntfs_ucsncasecmp(const uchar_t *s1, const uchar_t *s2, size_t n,
-                    const uchar_t *upcase, const u32 upcase_size)
+int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n,
+               const ntfschar *upcase, const u32 upcase_size)
 {
-       uchar_t c1, c2;
+       ntfschar c1, c2;
        size_t i;
 
        for (i = 0; i < n; ++i) {
@@ -200,11 +199,11 @@ int ntfs_ucsncasecmp(const uchar_t *s1, const uchar_t *s2, size_t n,
        return 0;
 }
 
-void ntfs_upcase_name(uchar_t *name, u32 name_len, const uchar_t *upcase,
+void ntfs_upcase_name(ntfschar *name, u32 name_len, const ntfschar *upcase,
                const u32 upcase_len)
 {
        u32 i;
-       uchar_t u;
+       ntfschar u;
 
        for (i = 0; i < name_len; i++)
                if ((u = le16_to_cpu(name[i])) < upcase_len)
@@ -212,20 +211,20 @@ void ntfs_upcase_name(uchar_t *name, u32 name_len, const uchar_t *upcase,
 }
 
 void ntfs_file_upcase_value(FILE_NAME_ATTR *file_name_attr,
-               const uchar_t *upcase, const u32 upcase_len)
+               const ntfschar *upcase, const u32 upcase_len)
 {
-       ntfs_upcase_name((uchar_t*)&file_name_attr->file_name,
+       ntfs_upcase_name((ntfschar*)&file_name_attr->file_name,
                        file_name_attr->file_name_length, upcase, upcase_len);
 }
 
 int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1,
                FILE_NAME_ATTR *file_name_attr2,
                const int err_val, const IGNORE_CASE_BOOL ic,
-               const uchar_t *upcase, const u32 upcase_len)
+               const ntfschar *upcase, const u32 upcase_len)
 {
-       return ntfs_collate_names((uchar_t*)&file_name_attr1->file_name,
+       return ntfs_collate_names((ntfschar*)&file_name_attr1->file_name,
                        file_name_attr1->file_name_length,
-                       (uchar_t*)&file_name_attr2->file_name,
+                       (ntfschar*)&file_name_attr2->file_name,
                        file_name_attr2->file_name_length,
                        err_val, ic, upcase, upcase_len);
 }
@@ -254,16 +253,16 @@ int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1,
  * This might look a bit odd due to fast path optimization...
  */
 int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
-               const int ins_len, uchar_t **outs)
+               const int ins_len, ntfschar **outs)
 {
        struct nls_table *nls = vol->nls_map;
-       uchar_t *ucs;
+       ntfschar *ucs;
        wchar_t wc;
        int i, o, wc_len;
 
        /* We don't trust outside sources. */
        if (ins) {
-               ucs = (uchar_t*)kmem_cache_alloc(ntfs_name_cache, SLAB_NOFS);
+               ucs = (ntfschar*)kmem_cache_alloc(ntfs_name_cache, SLAB_NOFS);
                if (ucs) {
                        for (i = o = 0; i < ins_len; i += wc_len) {
                                wc_len = nls->char2uni(ins + i, ins_len - i,
@@ -319,7 +318,7 @@ conversion_err:
  *
  * This might look a bit odd due to fast path optimization...
  */
-int ntfs_ucstonls(const ntfs_volume *vol, const uchar_t *ins,
+int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins,
                const int ins_len, unsigned char **outs, int outs_len)
 {
        struct nls_table *nls = vol->nls_map;
@@ -381,4 +380,3 @@ mem_err_out:
        ntfs_error(vol->sb, "Failed to allocate name!");
        return -ENOMEM;
 }
-