OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright (c) 2008 Secure Endpoints Inc. 00003 * 00004 * Permission is hereby granted, free of charge, to any person 00005 * obtaining a copy of this software and associated documentation 00006 * files (the "Software"), to deal in the Software without 00007 * restriction, including without limitation the rights to use, copy, 00008 * modify, merge, publish, distribute, sublicense, and/or sell copies 00009 * of the Software, and to permit persons to whom the Software is 00010 * furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be 00013 * included in all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00016 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00018 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00019 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00020 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00021 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00022 * SOFTWARE. 00023 */ 00024 00025 #ifndef OPENAFS_WINNT_AFSD_CM_NLS_H 00026 #define OPENAFS_WINNT_AFSD_CM_NLS_H 1 00027 00028 /* Character types 00029 00030 There are three character types that we use as implementation 00031 types. These should generally only be referenced by the 00032 nationalization code. 00033 00034 - ::cm_unichar_t 00035 00036 - ::cm_normchar_t 00037 00038 - ::cm_utf8char_t 00039 00040 The character types that are used by code are : 00041 00042 - ::clientchar_t 00043 00044 - ::normchar_t 00045 00046 - ::fschar_t 00047 00048 */ 00049 00051 typedef wchar_t cm_unichar_t; 00052 00054 typedef wchar_t cm_normchar_t; 00055 00057 typedef unsigned char cm_utf8char_t; 00058 00060 typedef cm_unichar_t clientchar_t; 00061 00063 typedef cm_utf8char_t fschar_t; 00064 00066 typedef cm_normchar_t normchar_t; 00067 00068 #define __paste(a,b) a ## b 00069 #define _C(s) __paste(L,s) 00070 #define _FS(s) s 00071 #define _N(s) __paste(L,s) 00072 00073 #define cm_ClientStringToNormStringAlloc cm_NormalizeStringAlloc 00074 #define cm_ClientStringToFsStringAlloc cm_Utf16ToUtf8Alloc 00075 #define cm_ClientStringToUtf8Alloc cm_Utf16ToUtf8Alloc 00076 #define cm_FsStringToClientStringAlloc cm_Utf8ToUtf16Alloc 00077 #define cm_FsStringToNormStringAlloc cm_NormalizeUtf8StringToUtf16Alloc 00078 #define cm_Utf8ToNormStringAlloc cm_NormalizeUtf8StringToUtf16Alloc 00079 #define cm_Utf8ToClientStringAlloc cm_Utf8ToUtf16Alloc 00080 00081 #define cm_ClientStringToUtf16 cm_Utf16ToUtf16 00082 #define cm_ClientStringToUtf8 cm_Utf16ToUtf8 00083 #define cm_ClientStringToFsString cm_Utf16ToUtf8 00084 #define cm_ClientStringToNormString cm_NormalizeString 00085 #define cm_FsStringToClientString cm_Utf8ToUtf16 00086 #define cm_FsStringToNormString cm_NormalizeUtf8StringToUtf16 00087 #define cm_Utf8ToClientString cm_Utf8ToUtf16 00088 #define cm_OemToClientString(s,cchs,d,cchd) MultiByteToWideChar(CP_OEMCP, 0, s, cchs, d, cchd) 00089 #define cm_AnsiToClientString(s,cchs,d,cchd) MultiByteToWideChar(CP_ACP, 0, s, cchs, d, cchd) 00090 00091 #define cm_ClientStrCmp wcscmp 00092 #define cm_ClientStrCmpI cm_stricmp_utf16 00093 #define cm_ClientStrCmpIA cm_stricmp_utf16 00094 #define cm_ClientStrCmpNI cm_strnicmp_utf16 00095 #define cm_ClientStrCmpN wcsncmp 00096 #define cm_ClientStrChr wcschr 00097 #define cm_ClientStrRChr wcsrchr 00098 #define cm_ClientStrCpy(d,cch,s) StringCchCopyW(d,cch,s) 00099 #define cm_ClientStrCpyN(d,cch,s,n) StringCchCopyNW(d,cch,s,n) 00100 #define cm_ClientStrDup wcsdup 00101 #define cm_ClientStrCat(d,cch,s) StringCchCatW(d,cch,s) 00102 #define cm_ClientStrCatN(d,cch,s,n) StringCchCatNW(d,cch,s,n) 00103 #define cm_ClientStrPrintfN StringCchPrintfW 00104 #define cm_ClientStrPrintfV StringCchVPrintfW 00105 //#define cm_ClientStrPrintf swprintf 00106 #define cm_ClientStrLen wcslen 00107 #define cm_ClientStrLwr cm_strlwr_utf16 00108 #define cm_ClientStrUpr cm_strupr_utf16 00109 #define cm_ClientStrSpn wcsspn 00110 #define cm_ClientStrCSpn wcscspn 00111 #define osi_LogSaveClientString osi_LogSaveStringW 00112 #define cm_ClientCharThis char_this_utf16 00113 #define cm_ClientCharNext char_next_utf16 00114 #define cm_ClientCharPrev char_prev_utf16 00115 00116 #define cm_FsStrDup strdup 00117 #define cm_FsStrLen strlen 00118 #define cm_FsStrCat StringCchCatA 00119 #define cm_FsStrPrintf StringCchPrintfA 00120 #define cm_FsStrRChr strrchr 00121 #define cm_FsStrChr strchr 00122 #define cm_FsStrCmpIA cm_stricmp_utf8 00123 #define cm_FsStrCmpI cm_stricmp_utf8 00124 #define cm_FsStrCmpA strcmp 00125 #define cm_FsStrCmp strcmp 00126 #define cm_FsStrCpy(d,cch,s) StringCchCopyA(d,cch,s) 00127 #define osi_LogSaveFsString osi_LogSaveString 00128 #define cm_FsStrCpyN(d,cch,s,n) StringCchCopyN(d,cch,s,n) 00129 00130 #define cm_NormStrDup wcsdup 00131 #define cm_NormStrCmpI cm_stricmp_utf16 00132 #define cm_NormStrCmp wcscmp 00133 #define cm_NormCharUpr towupper 00134 00135 #define cm_IsValidClientString(s) cm_is_valid_utf16((s), -1) 00136 #define cm_IsValidNormString(s) cm_is_valid_utf16((s), -1) 00137 00138 #define cm_Utf16ToClientString cm_Utf16ToUtf16 00139 00140 extern long cm_InitNormalization(void); 00141 00142 /* Functions annotated in accordance with sal.h */ 00143 00144 #ifndef __in_z 00145 00146 #define __out_ecount_full_z(x) 00147 #define __out_ecount_full_z_opt(x) 00148 #define __in_z 00149 #define __out_z 00150 #define __inout_z 00151 00152 #endif 00153 00154 extern __out_ecount_full_z(*pcch_dest) __checkReturn __success(return != NULL) cm_normchar_t * 00155 cm_NormalizeStringAlloc 00156 (__in_ecount(cch_src) const cm_unichar_t * s, 00157 int cch_src, 00158 __out_ecount_full_opt(1) int *pcch_dest); 00159 00160 extern __success(return != 0) int 00161 cm_NormalizeString 00162 (__in_ecount(cch_src) const cm_unichar_t * s, 00163 int cch_src, 00164 __out_ecount_full_z_opt(cch_dest) cm_normchar_t * dest, 00165 int cch_dest); 00166 00167 extern __out_ecount_full_z(*pcch_dest) __checkReturn __success(return != NULL) cm_utf8char_t * 00168 cm_Utf16ToUtf8Alloc 00169 (__in_ecount(cch_src) const cm_unichar_t * s, 00170 int cch_src, 00171 __out_ecount_full_opt(1) int *pcch_dest); 00172 00173 extern __out_ecount_full_z(*pcch_dest) __checkReturn __success(return != NULL) cm_unichar_t * 00174 cm_Utf8ToUtf16Alloc 00175 (__in_ecount(cch_src) const cm_utf8char_t * src, 00176 int cch_src, 00177 __out_ecount_full_opt(1) int *pcch_dest); 00178 00179 extern __success(return != 0) long 00180 cm_NormalizeUtf8StringToUtf16 00181 (__in_ecount(cch_src) const char * src, 00182 int cch_src, 00183 __out_ecount_full_z_opt(cch_dest) cm_normchar_t * dest, 00184 int cch_dest); 00185 00186 extern __out_ecount_full_z(*pcch_dest) __checkReturn __success(return != NULL) cm_normchar_t * 00187 cm_NormalizeUtf8StringToUtf16Alloc 00188 (__in_ecount(cch_src) const cm_utf8char_t * src, 00189 int cch_src, 00190 __out_ecount_full_opt(1) int *pcch_dest); 00191 00192 extern __success(return != 0) int 00193 cm_Utf8ToUtf16 00194 (__in_ecount(cch_src) const cm_utf8char_t * src, 00195 int cch_src, 00196 __out_ecount_full_z_opt(cch_dest) cm_unichar_t * dest, 00197 int cch_dest); 00198 00199 extern __success(return != 0) int 00200 cm_Utf16ToUtf8 00201 (__in_ecount(cch_src) const cm_unichar_t * src, 00202 int cch_src, 00203 __out_ecount_full_z_opt(cch_dest) cm_utf8char_t * dest, 00204 int cch_dest); 00205 00206 extern __success(return != 0) int 00207 cm_Utf16ToUtf16 00208 (__in_ecount(cch_src) const cm_unichar_t * src, 00209 int cch_src, 00210 __out_ecount_full_z_opt(cch_dest) cm_unichar_t * dest, 00211 int cch_dest); 00212 00213 extern int 00214 cm_strnicmp_utf16 00215 (__in_z const cm_unichar_t * str1, 00216 __in_z const cm_unichar_t * str2, 00217 int len); 00218 00219 extern int 00220 cm_stricmp_utf16 00221 (__in_z const cm_unichar_t * str1, 00222 __in_z const cm_unichar_t * str2); 00223 00224 /* The cm_stricmp_utf8N function is identical to cm_stricmp_utf8 00225 except it is used in instances where one of the strings is always 00226 known to be ASCII. */ 00227 extern int 00228 cm_stricmp_utf8N 00229 (__in_z const char * str1, 00230 __in_z const char * str2); 00231 #define cm_stricmp_utf8N cm_stricmp_utf8 00232 00233 extern int 00234 cm_stricmp_utf8 00235 (__in_z const char * str1, 00236 __in_z const char * str2); 00237 00238 /* The cm_strnicmp_utf8N function is identical to cm_strnicmp_utf8 00239 except it is used in instances where one of the strings is always 00240 known to be ASCII. */ 00241 extern int 00242 cm_strnicmp_utf8N 00243 (__in_z const char * str1, 00244 __in_z const char * str2, int n); 00245 #define cm_strnicmp_utf8N cm_strnicmp_utf8 00246 00247 extern int 00248 cm_strnicmp_utf8 00249 (__in_z const char * str1, 00250 __in_z const char * str2, int n); 00251 00252 extern __out_z wchar_t * 00253 char_next_utf16 00254 (__in_z const wchar_t * c); 00255 00256 extern __out_z wchar_t * 00257 char_prev_utf16 00258 (__in_z const wchar_t * c); 00259 00260 extern __out_z wchar_t * 00261 char_this_utf16 00262 (__in_z const wchar_t * c); 00263 00264 extern __out_z cm_unichar_t * 00265 cm_strlwr_utf16(__inout_z cm_unichar_t * str); 00266 00267 extern __out_z cm_unichar_t * 00268 cm_strupr_utf16(__inout_z cm_unichar_t * str); 00269 00270 extern int 00271 cm_is_valid_utf16(__in_z const wchar_t * c, int cch); 00272 00273 #ifdef DEBUG 00274 wchar_t * cm_GetRawCharsAlloc(const wchar_t * c, int len); 00275 #endif 00276 00277 #if 0 00278 00279 extern long cm_NormalizeUtf16StringToUtf8(const wchar_t * src, int cch_src, 00280 char * adest, int cch_adest); 00281 00282 extern char * char_next_utf8(const char * c); 00283 00284 extern char * char_prev_utf8(const char * c); 00285 00286 extern char * strupr_utf8(char * str, size_t cbstr); 00287 00288 #endif 00289 00290 #define lengthof(a) (sizeof(a)/sizeof(a[0])) 00291 #endif