]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfscommon/headers/HFSUnicodeWrappers.h
xnu-201.5.tar.gz
[apple/xnu.git] / bsd / hfs / hfscommon / headers / HFSUnicodeWrappers.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 File: HFSUnicodeWrappers.h
24
25 Contains: IPI to Unicode routines used by File Manager.
26
27 Version: HFS Plus 1.0
28
29 Written by: Mark Day
30
31 Copyright: © 1996-1997 by Apple Computer, Inc., all rights reserved.
32
33 File Ownership:
34
35 DRI: xxx put dri here xxx
36
37 Other Contact: xxx put other contact here xxx
38
39 Technology: xxx put technology here xxx
40
41 Writers:
42
43 (DSH) Deric Horn
44 (msd) Mark Day
45 (djb) Don Brady
46
47 Change History (most recent first):
48
49 <CS11> 11/16/97 djb Change Unicode.h to UnicodeConverter.h.
50 <CS10> 11/7/97 msd Remove prototype for CompareUnicodeNames(). Add prototype for
51 FastUnicodeCompare().
52 <CS9> 10/13/97 djb Add encoding/index macros and add prototypes for new Get/Set
53 encodding routines.
54 <CS8> 9/15/97 djb InitUnicodeConverter now takes a boolean.
55 <CS7> 9/10/97 msd Add prototype for InitializeEncodingContext.
56 <CS6> 6/26/97 DSH Include "MockConverter" prototype for DFA usage.
57 <CS5> 6/25/97 DSH Removed Prototype definitions, and checked in Unicode.h and
58 TextCommon.h from Julio Gonzales into InternalInterfaces.
59 <CS4> 6/25/97 msd Add prototypes for some new Unicode routines that haven't
60 appeared in MasterInterfaces yet.
61 <CS3> 6/18/97 djb Add more ConversionContexts routines.
62 <CS2> 6/13/97 djb Switched to ConvertUnicodeToHFSName, ConvertHFSNameToUnicode, &
63 CompareUnicodeNames.
64 <CS1> 4/28/97 djb first checked in
65 <HFS1> 12/12/96 msd first checked in
66
67 */
68
69 #include "../../hfs_macos_defs.h"
70 #include "../../hfs_format.h"
71
72 // Encoding vs. Index
73 //
74 // For runtime table lookups and for the volume encoding bitmap we
75 // need to map some encodings to keep them in a reasonable range.
76 //
77
78 enum {
79 kIndexMacUkrainian = 48, // MacUkrainian encoding is 152
80 kIndexMacFarsi = 49 // MacFarsi encoding is 140
81 };
82
83 #define MapEncodingToIndex(e) \
84 ( (e) < 48 ? (e) : ( (e) == kTextEncodingMacUkrainian ? kIndexMacUkrainian : ( (e) == kTextEncodingMacFarsi ? kIndexMacFarsi : kTextEncodingMacRoman) ) )
85
86 #define MapIndexToEncoding(i) \
87 ( (i) == kIndexMacFarsi ? kTextEncodingMacFarsi : ( (i) == kIndexMacUkrainian ? kTextEncodingMacUkrainian : (i) ) )
88
89 #define ValidMacEncoding(e) \
90 ( ((e) < 39) || ((e) == kTextEncodingMacFarsi) || ((e) == kTextEncodingMacUkrainian) )
91
92
93 extern OSErr ConvertUnicodeToUTF8Mangled ( ByteCount srcLen,
94 ConstUniCharArrayPtr srcStr,
95 ByteCount maxDstLen,
96 ByteCount *actualDstLen,
97 unsigned char* dstStr ,
98 HFSCatalogNodeID cnid);
99
100 /*
101 This routine compares two Unicode names based on an ordering defined by the HFS Plus B-tree.
102 This ordering must stay fixed for all time.
103
104 Output:
105 -n name1 < name2 (i.e. name 1 sorts before name 2)
106 0 name1 = name2
107 +n name1 > name2
108
109 NOTE: You should not depend on the magnitude of the result, just its sign. That is, when name1 < name2, then any
110 negative number may be returned.
111 */
112
113 extern SInt32 FastUnicodeCompare(register ConstUniCharArrayPtr str1, register ItemCount length1,
114 register ConstUniCharArrayPtr str2, register ItemCount length2);
115
116
117 extern SInt32 FastRelString( ConstStr255Param str1, ConstStr255Param str2 );
118
119
120 extern HFSCatalogNodeID GetEmbeddedFileID( ConstStr31Param filename, UInt32 length, UInt32 *prefixLength );
121