1/* 2 * Copyright (c) 2000-2005 Apple Computer, 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_MAC 0 48#define TARGET_OS_WIN32 0 49#define TARGET_OS_UNIX 0 50 51#define PRAGMA_IMPORT 0 52#define PRAGMA_STRUCT_ALIGN 1 53#define PRAGMA_ONCE 0 54#define PRAGMA_STRUCT_PACK 0 55#define PRAGMA_STRUCT_PACKPUSH 0 56 57#if __GNUC__ >= 2 58 #define TYPE_LONGLONG 1 59#else 60 #define TYPE_LONGLONG 0 61#endif 62#ifdef __cplusplus 63 #define TYPE_BOOL 1 64#else 65 #define TYPE_BOOL 0 66#endif 67 68#define EXTERN_API(_type) extern _type 69#define EXTERN_API_C(_type) extern _type 70 71#define CALLBACK_API_C(_type, _name) _type ( * _name) 72 73#define TARGET_API_MACOS_X 1 74#define TARGET_API_MAC_OS8 0 75#define TARGET_API_MAC_CARBON 0 76 77 78 79/****** START OF MACOSTYPES *********/ 80 81 82/* 83 4.4BSD's sys/types.h defines size_t without defining __size_t__: 84 Things are a lot clearer from here on if we define __size_t__ now. 85 */ 86#define __size_t__ 87 88/* 89 Convert kernel's diagnostic flag to MacOS's 90*/ 91#if HFS_DIAGNOSTIC 92 #define DEBUG_BUILD 1 93#else 94 #define DEBUG_BUILD 0 95#endif /* DIAGNOSTIC */ 96 97/******************************************************************************** 98 99 Special values in C 100 101 NULL The C standard for an impossible pointer value 102 nil A carry over from pascal, NULL is prefered for C 103 104*********************************************************************************/ 105#ifndef NULL 106 #define NULL 0 107#endif 108 109#ifndef nil 110 #define nil NULL 111#endif 112 113typedef char * Ptr; 114typedef long Size; 115 116typedef int16_t OSErr; 117typedef u_int32_t ItemCount; 118typedef u_int32_t ByteCount; 119typedef u_int8_t * BytePtr; 120typedef u_int32_t ByteOffset; 121 122typedef u_int16_t UniChar; 123typedef unsigned char Str255[256]; 124typedef unsigned char Str31[32]; 125typedef unsigned char * StringPtr; 126typedef const unsigned char * ConstStr255Param; 127typedef const unsigned char * ConstStr31Param; 128typedef const unsigned char * ConstUTF8Param; 129 130typedef u_int8_t Byte; 131 132typedef u_int32_t TextEncoding; 133typedef UniChar * UniCharArrayPtr; 134typedef const UniChar * ConstUniCharArrayPtr; 135 136 137/******************************************************************************** 138 139 Boolean types and values 140 141 Boolean A one byte value, holds "false" (0) or "true" (1) 142 false The Boolean value of zero (0) 143 true The Boolean value of one (1) 144 145*********************************************************************************/ 146/* 147 The identifiers "true" and "false" are becoming keywords in C++ 148 and work with the new built-in type "bool" 149 "Boolean" will remain an unsigned char for compatibility with source 150 code written before "bool" existed. 151*/ 152#if !TYPE_BOOL 153 154enum { 155 false = 0, 156 true = 1 157}; 158 159#endif /* !TYPE_BOOL */ 160 161 162EXTERN_API( void ) DebugStr(const char * debuggerMsg); 163 164/********************************************************************************* 165 166 Added types for HFSPlus MacOS X functionality. Needs to be incorporated to 167 other places 168 169*********************************************************************************/ 170 171typedef struct vnode* FileReference; 172 173 174/***** START OF MACOSSTUBS ********/ 175 176 177/* 178 SizeTDef.h -- Common definitions 179 180 size_t - this type is defined by several ANSI headers. 181*/ 182#if ! defined (__size_t__) 183 #define __size_t__ 184 #if defined (__xlc) || defined (__xlC) || defined (__xlC__) || defined (__MWERKS__) 185 typedef unsigned long size_t; 186 #else /* __xlC */ 187 typedef unsigned int size_t; 188 #endif /* __xlC */ 189#endif /* __size_t__ */ 190 191 192/* 193 File: Errors.h 194 195*/ 196enum { 197 noErr = 0, 198 dskFulErr = -34, /*disk full*/ 199 bdNamErr = -37, /*there may be no bad names in the final system!*/ 200 paramErr = -50, /*error in user parameter list*/ 201 memFullErr = -108, /*Not enough room in heap zone*/ 202 fileBoundsErr = -1309, /*file's EOF, offset, mark or size is too big*/ 203 kTECUsedFallbacksStatus = -8783, 204 205}; 206 207 208enum { 209 /* Finder Flags */ 210 kHasBeenInited = 0x0100, 211 kHasCustomIcon = 0x0400, 212 kIsStationery = 0x0800, 213 kNameLocked = 0x1000, 214 kHasBundle = 0x2000, 215 kIsInvisible = 0x4000, 216 kIsAlias = 0x8000 217}; 218 219enum { 220 fsRtParID = 1, 221 fsRtDirID = 2 222}; 223 224 225enum { 226 /* Mac OS encodings*/ 227 kTextEncodingMacRoman = 0L, 228 kTextEncodingMacJapanese = 1, 229 kTextEncodingMacChineseTrad = 2, 230 kTextEncodingMacKorean = 3, 231 kTextEncodingMacArabic = 4, 232 kTextEncodingMacHebrew = 5, 233 kTextEncodingMacGreek = 6, 234 kTextEncodingMacCyrillic = 7, 235 kTextEncodingMacDevanagari = 9, 236 kTextEncodingMacGurmukhi = 10, 237 kTextEncodingMacGujarati = 11, 238 kTextEncodingMacOriya = 12, 239 kTextEncodingMacBengali = 13, 240 kTextEncodingMacTamil = 14, 241 kTextEncodingMacTelugu = 15, 242 kTextEncodingMacKannada = 16, 243 kTextEncodingMacMalayalam = 17, 244 kTextEncodingMacSinhalese = 18, 245 kTextEncodingMacBurmese = 19, 246 kTextEncodingMacKhmer = 20, 247 kTextEncodingMacThai = 21, 248 kTextEncodingMacLaotian = 22, 249 kTextEncodingMacGeorgian = 23, 250 kTextEncodingMacArmenian = 24, 251 kTextEncodingMacChineseSimp = 25, 252 kTextEncodingMacTibetan = 26, 253 kTextEncodingMacMongolian = 27, 254 kTextEncodingMacEthiopic = 28, 255 kTextEncodingMacCentralEurRoman = 29, 256 kTextEncodingMacVietnamese = 30, 257 kTextEncodingMacExtArabic = 31, /* The following use script code 0, smRoman*/ 258 kTextEncodingMacSymbol = 33, 259 kTextEncodingMacDingbats = 34, 260 kTextEncodingMacTurkish = 35, 261 kTextEncodingMacCroatian = 36, 262 kTextEncodingMacIcelandic = 37, 263 kTextEncodingMacRomanian = 38, 264 kTextEncodingMacUnicode = 0x7E, 265 266 kTextEncodingMacFarsi = 0x8C, /* Like MacArabic but uses Farsi digits */ /* The following use script code 7, smCyrillic */ 267 kTextEncodingMacUkrainian = 0x98, /* The following use script code 32, smUnimplemented */ 268}; 269 270 271/* PROTOTYPES */ 272 273#if HFS_DIAGNOSTIC 274 extern void RequireFileLock(FileReference vp, int shareable); 275 #define REQUIRE_FILE_LOCK(vp,s) RequireFileLock((vp),(s)) 276#else 277 #define REQUIRE_FILE_LOCK(vp,s) 278#endif 279 280 281EXTERN_API( void ) 282BlockMoveData(const void * srcPtr, void * destPtr, Size byteCount); 283 284#define BlockMoveData(src, dest, len) bcopy((src), (dest), (len)) 285 286EXTERN_API_C( void ) 287ClearMemory(void * start, u_int32_t length); 288 289#define ClearMemory(start, length) bzero((start), (size_t)(length)); 290 291 292EXTERN_API( Ptr ) 293NewPtr(Size byteCount); 294 295EXTERN_API( Ptr ) 296NewPtrSysClear(Size byteCount); 297 298EXTERN_API( void ) 299DisposePtr(Ptr p); 300 301#endif /* __APPLE_API_PRIVATE */ 302#endif /* KERNEL */ 303#endif /* __HFS_MACOS_TYPES__ */ 304