|
|
1.1 ! root 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 "../HFSVolumes.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: ! 94: extern OSErr ConvertUTF8ToUnicode ( ByteCount srcLen, ! 95: const unsigned char* srcStr, ! 96: ByteCount maxDstLen, ! 97: ByteCount *actualDstLen, ! 98: UniCharArrayPtr dstStr ); ! 99: ! 100: extern OSErr ConvertUnicodeToUTF8 ( ByteCount srcLen, ! 101: ConstUniCharArrayPtr srcStr, ! 102: ByteCount maxDstLen, ! 103: ByteCount *actualDstLen, ! 104: unsigned char* dstStr ); ! 105: ! 106: /* ! 107: This routine compares two Unicode names based on an ordering defined by the HFS Plus B-tree. ! 108: This ordering must stay fixed for all time. ! 109: ! 110: Output: ! 111: -n name1 < name2 (i.e. name 1 sorts before name 2) ! 112: 0 name1 = name2 ! 113: +n name1 > name2 ! 114: ! 115: NOTE: You should not depend on the magnitude of the result, just its sign. That is, when name1 < name2, then any ! 116: negative number may be returned. ! 117: */ ! 118: ! 119: extern SInt32 FastUnicodeCompare(register ConstUniCharArrayPtr str1, register ItemCount length1, ! 120: register ConstUniCharArrayPtr str2, register ItemCount length2); ! 121: ! 122: ! 123: extern SInt32 FastRelString( ConstStr255Param str1, ConstStr255Param str2 ); ! 124: ! 125: ! 126: extern HFSCatalogNodeID GetEmbeddedFileID( ConstStr31Param filename, UInt32 length, UInt32 *prefixLength ); ! 127:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.