~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/jfs/jfs_unicode.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 /*
  3  *   Copyright (C) International Business Machines Corp., 2000-2002
  4  *   Portions Copyright (C) Christoph Hellwig, 2001-2002
  5  */
  6 #ifndef _H_JFS_UNICODE
  7 #define _H_JFS_UNICODE
  8 
  9 #include <linux/slab.h>
 10 #include <asm/byteorder.h>
 11 #include "../nls/nls_ucs2_data.h"
 12 #include "jfs_types.h"
 13 
 14 extern int get_UCSname(struct component_name *, struct dentry *);
 15 extern int jfs_strfromUCS_le(char *, const __le16 *, int, struct nls_table *);
 16 
 17 #define free_UCSname(COMP) kfree((COMP)->name)
 18 
 19 /*
 20  * UniStrcpy:  Copy a string
 21  */
 22 static inline wchar_t *UniStrcpy(wchar_t * ucs1, const wchar_t * ucs2)
 23 {
 24         wchar_t *anchor = ucs1; /* save the start of result string */
 25 
 26         while ((*ucs1++ = *ucs2++));
 27         return anchor;
 28 }
 29 
 30 
 31 
 32 /*
 33  * UniStrncpy:  Copy length limited string with pad
 34  */
 35 static inline __le16 *UniStrncpy_le(__le16 * ucs1, const __le16 * ucs2,
 36                                   size_t n)
 37 {
 38         __le16 *anchor = ucs1;
 39 
 40         while (n-- && *ucs2)    /* Copy the strings */
 41                 *ucs1++ = *ucs2++;
 42 
 43         n++;
 44         while (n--)             /* Pad with nulls */
 45                 *ucs1++ = 0;
 46         return anchor;
 47 }
 48 
 49 /*
 50  * UniStrncmp_le:  Compare length limited string - native to little-endian
 51  */
 52 static inline int UniStrncmp_le(const wchar_t * ucs1, const __le16 * ucs2,
 53                                 size_t n)
 54 {
 55         if (!n)
 56                 return 0;       /* Null strings are equal */
 57         while ((*ucs1 == __le16_to_cpu(*ucs2)) && *ucs1 && --n) {
 58                 ucs1++;
 59                 ucs2++;
 60         }
 61         return (int) *ucs1 - (int) __le16_to_cpu(*ucs2);
 62 }
 63 
 64 /*
 65  * UniStrncpy_to_le:  Copy length limited string with pad to little-endian
 66  */
 67 static inline __le16 *UniStrncpy_to_le(__le16 * ucs1, const wchar_t * ucs2,
 68                                        size_t n)
 69 {
 70         __le16 *anchor = ucs1;
 71 
 72         while (n-- && *ucs2)    /* Copy the strings */
 73                 *ucs1++ = cpu_to_le16(*ucs2++);
 74 
 75         n++;
 76         while (n--)             /* Pad with nulls */
 77                 *ucs1++ = 0;
 78         return anchor;
 79 }
 80 
 81 /*
 82  * UniStrncpy_from_le:  Copy length limited string with pad from little-endian
 83  */
 84 static inline wchar_t *UniStrncpy_from_le(wchar_t * ucs1, const __le16 * ucs2,
 85                                           size_t n)
 86 {
 87         wchar_t *anchor = ucs1;
 88 
 89         while (n-- && *ucs2)    /* Copy the strings */
 90                 *ucs1++ = __le16_to_cpu(*ucs2++);
 91 
 92         n++;
 93         while (n--)             /* Pad with nulls */
 94                 *ucs1++ = 0;
 95         return anchor;
 96 }
 97 
 98 /*
 99  * UniToupper:  Convert a unicode character to upper case
100  */
101 static inline wchar_t UniToupper(wchar_t uc)
102 {
103         const struct UniCaseRange *rp;
104 
105         if (uc < sizeof(NlsUniUpperTable)) {    /* Latin characters */
106                 return uc + NlsUniUpperTable[uc];       /* Use base tables */
107         } else {
108                 rp = NlsUniUpperRange;  /* Use range tables */
109                 while (rp->start) {
110                         if (uc < rp->start)     /* Before start of range */
111                                 return uc;      /* Uppercase = input */
112                         if (uc <= rp->end)      /* In range */
113                                 return uc + rp->table[uc - rp->start];
114                         rp++;   /* Try next range */
115                 }
116         }
117         return uc;              /* Past last range */
118 }
119 
120 
121 /*
122  * UniStrupr:  Upper case a unicode string
123  */
124 static inline wchar_t *UniStrupr(wchar_t * upin)
125 {
126         wchar_t *up;
127 
128         up = upin;
129         while (*up) {           /* For all characters */
130                 *up = UniToupper(*up);
131                 up++;
132         }
133         return upin;            /* Return input pointer */
134 }
135 
136 #endif                          /* !_H_JFS_UNICODE */
137 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php