]> git.saurik.com Git - apple/hfs.git/blob - core/hfs_macos_defs.h
hfs-522.100.5.tar.gz
[apple/hfs.git] / core / hfs_macos_defs.h
1 /*
2 * Copyright (c) 2000-2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #ifndef __HFS_MACOS_TYPES__
30 #define __HFS_MACOS_TYPES__
31
32 #include <sys/appleapiopts.h>
33
34 #ifdef KERNEL
35 #ifdef __APPLE_API_PRIVATE
36
37 #include <sys/param.h>
38
39 #include <libkern/OSTypes.h>
40 #include <libkern/libkern.h>
41 #include <sys/systm.h>
42 #include <sys/types.h>
43 #include <sys/time.h>
44 #include <sys/proc.h>
45
46
47 #define TARGET_OS_WIN32 0
48 #define TARGET_OS_UNIX 0
49
50 #define PRAGMA_IMPORT 0
51 #define PRAGMA_STRUCT_ALIGN 1
52 #define PRAGMA_ONCE 0
53 #define PRAGMA_STRUCT_PACK 0
54 #define PRAGMA_STRUCT_PACKPUSH 0
55
56 #if __GNUC__ >= 2
57 #define TYPE_LONGLONG 1
58 #else
59 #define TYPE_LONGLONG 0
60 #endif
61 #ifdef __cplusplus
62 #define TYPE_BOOL 1
63 #else
64 #define TYPE_BOOL 0
65 #endif
66
67 #define EXTERN_API(_type) extern _type
68 #define EXTERN_API_C(_type) extern _type
69
70 #define CALLBACK_API_C(_type, _name) _type ( * _name)
71
72 #define TARGET_API_MACOS_X 1
73 #define TARGET_API_MAC_OS8 0
74 #define TARGET_API_MAC_CARBON 0
75
76
77
78 /****** START OF MACOSTYPES *********/
79
80
81 /*
82 4.4BSD's sys/types.h defines size_t without defining __size_t__:
83 Things are a lot clearer from here on if we define __size_t__ now.
84 */
85 #define __size_t__
86
87 /********************************************************************************
88
89 Special values in C
90
91 NULL The C standard for an impossible pointer value
92 nil A carry over from pascal, NULL is prefered for C
93
94 *********************************************************************************/
95 #ifndef NULL
96 #define NULL 0
97 #endif
98
99 #ifndef nil
100 #define nil NULL
101 #endif
102
103 typedef char * Ptr;
104 typedef long Size;
105
106 typedef int16_t OSErr;
107 typedef u_int32_t ItemCount;
108 typedef u_int32_t ByteCount;
109 typedef u_int8_t * BytePtr;
110 typedef u_int32_t ByteOffset;
111
112 typedef u_int16_t UniChar;
113 typedef unsigned char Str255[256];
114 typedef unsigned char Str31[32];
115 typedef unsigned char * StringPtr;
116 typedef const unsigned char * ConstStr255Param;
117 typedef const unsigned char * ConstStr31Param;
118 typedef const unsigned char * ConstUTF8Param;
119
120 typedef u_int8_t Byte;
121
122 typedef u_int32_t TextEncoding;
123 typedef UniChar * UniCharArrayPtr;
124 typedef const UniChar * ConstUniCharArrayPtr;
125
126
127 /********************************************************************************
128
129 Boolean types and values
130
131 Boolean A one byte value, holds "false" (0) or "true" (1)
132 false The Boolean value of zero (0)
133 true The Boolean value of one (1)
134
135 *********************************************************************************/
136 /*
137 The identifiers "true" and "false" are becoming keywords in C++
138 and work with the new built-in type "bool"
139 "Boolean" will remain an unsigned char for compatibility with source
140 code written before "bool" existed.
141 */
142 #if !TYPE_BOOL && !__bool_true_false_are_defined
143
144 enum {
145 false = 0,
146 true = 1
147 };
148
149 #endif /* !TYPE_BOOL */
150
151
152 EXTERN_API( void ) DebugStr(const char * debuggerMsg);
153
154 /*********************************************************************************
155
156 Added types for HFSPlus MacOS X functionality. Needs to be incorporated to
157 other places
158
159 *********************************************************************************/
160
161 typedef struct vnode* FileReference;
162
163
164 /***** START OF MACOSSTUBS ********/
165
166
167 /*
168 SizeTDef.h -- Common definitions
169
170 size_t - this type is defined by several ANSI headers.
171 */
172 #if ! defined (__size_t__)
173 #define __size_t__
174 #if defined (__xlc) || defined (__xlC) || defined (__xlC__) || defined (__MWERKS__)
175 typedef unsigned long size_t;
176 #else /* __xlC */
177 typedef unsigned int size_t;
178 #endif /* __xlC */
179 #endif /* __size_t__ */
180
181
182 /*
183 File: Errors.h
184
185 */
186 enum {
187 noErr = 0,
188 dskFulErr = -34, /*disk full*/
189 bdNamErr = -37, /*there may be no bad names in the final system!*/
190 paramErr = -50, /*error in user parameter list*/
191 memFullErr = -108, /*Not enough room in heap zone*/
192 fileBoundsErr = -1309, /*file's EOF, offset, mark or size is too big*/
193 kTECUsedFallbacksStatus = -8783,
194
195 };
196
197
198 enum {
199 /* Finder Flags */
200 kHasBeenInited = 0x0100,
201 kHasCustomIcon = 0x0400,
202 kIsStationery = 0x0800,
203 kNameLocked = 0x1000,
204 kHasBundle = 0x2000,
205 kIsInvisible = 0x4000,
206 kIsAlias = 0x8000
207 };
208
209 enum {
210 fsRtParID = 1,
211 fsRtDirID = 2
212 };
213
214
215 enum {
216 /* Mac OS encodings*/
217 kTextEncodingMacRoman = 0L,
218 kTextEncodingMacJapanese = 1,
219 kTextEncodingMacChineseTrad = 2,
220 kTextEncodingMacKorean = 3,
221 kTextEncodingMacArabic = 4,
222 kTextEncodingMacHebrew = 5,
223 kTextEncodingMacGreek = 6,
224 kTextEncodingMacCyrillic = 7,
225 kTextEncodingMacDevanagari = 9,
226 kTextEncodingMacGurmukhi = 10,
227 kTextEncodingMacGujarati = 11,
228 kTextEncodingMacOriya = 12,
229 kTextEncodingMacBengali = 13,
230 kTextEncodingMacTamil = 14,
231 kTextEncodingMacTelugu = 15,
232 kTextEncodingMacKannada = 16,
233 kTextEncodingMacMalayalam = 17,
234 kTextEncodingMacSinhalese = 18,
235 kTextEncodingMacBurmese = 19,
236 kTextEncodingMacKhmer = 20,
237 kTextEncodingMacThai = 21,
238 kTextEncodingMacLaotian = 22,
239 kTextEncodingMacGeorgian = 23,
240 kTextEncodingMacArmenian = 24,
241 kTextEncodingMacChineseSimp = 25,
242 kTextEncodingMacTibetan = 26,
243 kTextEncodingMacMongolian = 27,
244 kTextEncodingMacEthiopic = 28,
245 kTextEncodingMacCentralEurRoman = 29,
246 kTextEncodingMacVietnamese = 30,
247 kTextEncodingMacExtArabic = 31, /* The following use script code 0, smRoman*/
248 kTextEncodingMacSymbol = 33,
249 kTextEncodingMacDingbats = 34,
250 kTextEncodingMacTurkish = 35,
251 kTextEncodingMacCroatian = 36,
252 kTextEncodingMacIcelandic = 37,
253 kTextEncodingMacRomanian = 38,
254 kTextEncodingMacUnicode = 0x7E,
255
256 kTextEncodingMacFarsi = 0x8C, /* Like MacArabic but uses Farsi digits */ /* The following use script code 7, smCyrillic */
257 kTextEncodingMacUkrainian = 0x98, /* The following use script code 32, smUnimplemented */
258 };
259
260
261 /* PROTOTYPES */
262
263 #if DEBUG
264 extern void RequireFileLock(FileReference vp, int shareable);
265 #define REQUIRE_FILE_LOCK(vp,s) RequireFileLock((vp),(s))
266 #else
267 #define REQUIRE_FILE_LOCK(vp,s)
268 #endif
269
270
271 EXTERN_API( void )
272 BlockMoveData(const void * srcPtr, void * destPtr, Size byteCount);
273
274 #define BlockMoveData(src, dest, len) bcopy((src), (dest), (len))
275
276 EXTERN_API_C( void )
277 ClearMemory(void * start, u_int32_t length);
278
279 #define ClearMemory(start, length) bzero((start), (size_t)(length));
280
281 /*
282 * The maximum number UTF-16 code units required to represent a HFS
283 * standard file name. The derivation for this number is not
284 * documented; it has been this value for some time. Mark, our
285 * resident Unicode expert, says "I'm not entirely certain, but I
286 * think it is the worst case for Korean Hangul conjoining jamos. The
287 * '15' is because a Str31 can contain at most 15 two-byte characters
288 * (in MacKorean encoding). Worst case, each one of those characters
289 * gets normalized to up to 5 UTF-16 code points. Each character is
290 * composed of up to three jamos; up to two of those jamos might not
291 * be in Unicode plane 0, which means they can take two UTF-16 code
292 * points (each) to represent. So your '5' is '2 + 2 + 1'." Sounds
293 * plausible! Safe to ship it, I say!
294 */
295 #define MAX_HFS_UNICODE_CHARS (15*5)
296
297 #endif /* __APPLE_API_PRIVATE */
298 #endif /* KERNEL */
299 #endif /* __HFS_MACOS_TYPES__ */