Annotation of kernel/bsd/hfs/hfscommon/headers/system/HFSUnicodeWrappers.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: 
        !            25: /*
        !            26:        File:           HFSUnicodeWrappers.h
        !            27: 
        !            28:        Contains:       IPI to Unicode routines used by File Manager.
        !            29: 
        !            30:        Version:        HFS Plus 1.0
        !            31: 
        !            32:        Written by:     Mark Day
        !            33: 
        !            34:        Copyright:      � 1996-1997 by Apple Computer, Inc., all rights reserved.
        !            35: 
        !            36:        File Ownership:
        !            37: 
        !            38:                DRI:                            xxx put dri here xxx
        !            39: 
        !            40:                Other Contact:          xxx put other contact here xxx
        !            41: 
        !            42:                Technology:                     xxx put technology here xxx
        !            43: 
        !            44:        Writers:
        !            45: 
        !            46:                (DSH)   Deric Horn
        !            47:                (msd)   Mark Day
        !            48:                (djb)   Don Brady
        !            49: 
        !            50:        Change History (most recent first):
        !            51: 
        !            52:          <CS11>        11/16/97        djb             Change Unicode.h to UnicodeConverter.h.
        !            53:          <CS10>         11/7/97        msd             Remove prototype for CompareUnicodeNames(). Add prototype for
        !            54:                                                                        FastUnicodeCompare().
        !            55:           <CS9>        10/13/97        djb             Add encoding/index macros and add prototypes for new Get/Set
        !            56:                                                                        encodding routines.
        !            57:           <CS8>         9/15/97        djb             InitUnicodeConverter now takes a boolean.
        !            58:           <CS7>         9/10/97        msd             Add prototype for InitializeEncodingContext.
        !            59:           <CS6>         6/26/97        DSH             Include  "MockConverter" prototype for DFA usage.
        !            60:           <CS5>         6/25/97        DSH             Removed Prototype definitions, and checked in Unicode.h and
        !            61:                                                                        TextCommon.h from Julio Gonzales into InternalInterfaces.
        !            62:           <CS4>         6/25/97        msd             Add prototypes for some new Unicode routines that haven't
        !            63:                                                                        appeared in MasterInterfaces yet.
        !            64:           <CS3>         6/18/97        djb             Add more ConversionContexts routines.
        !            65:           <CS2>         6/13/97        djb             Switched to ConvertUnicodeToHFSName, ConvertHFSNameToUnicode, &
        !            66:                                                                        CompareUnicodeNames.
        !            67:           <CS1>         4/28/97        djb             first checked in
        !            68:          <HFS1>        12/12/96        msd             first checked in
        !            69: 
        !            70: */
        !            71: 
        !            72: #if TARGET_OS_MAC
        !            73: #include <Types.h>
        !            74: #include <UnicodeConverter.h>
        !            75: #include <TextCommon.h>
        !            76: #elif TARGET_OS_RHAPSODY
        !            77:        #ifndef __MACOSTYPES__
        !            78:        #include "system/MacOSTypes.h"
        !            79:        #endif
        !            80:        #ifndef __MACOSSTUBS__
        !            81:        #include "system/MacOSStubs.h"
        !            82:        #endif
        !            83: #endif         /* TARGET_OS_MAC */
        !            84: 
        !            85: #include "../HFSVolumes.h"
        !            86: 
        !            87: // Encoding vs. Index
        !            88: //
        !            89: // For runtime table lookups and for the volume encoding bitmap we
        !            90: // need to map some encodings to keep them in a reasonable range.
        !            91: //
        !            92: 
        !            93: enum {
        !            94:        kIndexMacUkrainian      = 48,           // MacUkrainian encoding is 152
        !            95:        kIndexMacFarsi          = 49            // MacFarsi encoding is 140
        !            96: };
        !            97: 
        !            98: #define MapEncodingToIndex(e) \
        !            99:        ( (e) < 48 ? (e) : ( (e) == kTextEncodingMacUkrainian ? kIndexMacUkrainian : ( (e) == kTextEncodingMacFarsi ? kIndexMacFarsi : kTextEncodingMacRoman) ) )
        !           100: 
        !           101: #define MapIndexToEncoding(i) \
        !           102:        ( (i) == kIndexMacFarsi ? kTextEncodingMacFarsi : ( (i) == kIndexMacUkrainian ? kTextEncodingMacUkrainian : (i) ) )
        !           103: 
        !           104: #define ValidMacEncoding(e)    \
        !           105:        ( ((e) < 39)  ||  ((e) == kTextEncodingMacFarsi)  ||  ((e) == kTextEncodingMacUkrainian) )
        !           106: 
        !           107: 
        !           108: 
        !           109: extern OSErr           InitUnicodeConverter( Boolean forBootVolume );
        !           110: 
        !           111: extern TextEncoding    GetDefaultTextEncoding( void );
        !           112: 
        !           113: extern OSErr           SetDefaultTextEncoding( TextEncoding encoding );
        !           114: 
        !           115: extern ItemCount       CountInstalledEncodings( void );
        !           116: 
        !           117: extern OSErr           GetTextEncodingForFont( ConstStr255Param fontName, UInt32 * textEncoding );
        !           118: 
        !           119: 
        !           120: 
        !           121: /*
        !           122:        Convert a Unicode name (UniStr255) to an HFS name (Str31 or Str27).
        !           123:        
        !           124:        If cnid equals kHFSRootFolderID, then the HFS name will be limited to 27 characters
        !           125: */
        !           126: #if 0
        !           127: extern OSErr ConvertUnicodeToHFSName( ConstHFSUniStr255Param unicodeName, TextEncoding encoding, HFSCatalogNodeID cnid, Str31 hfsName );
        !           128: #endif
        !           129: 
        !           130: 
        !           131: /*
        !           132:        Convert an HFS name (Str31 or Str27) to a Unicode name (UniStr255).
        !           133: */
        !           134: 
        !           135: extern OSErr ConvertHFSNameToUnicode( ConstStr31Param hfsName, TextEncoding encoding, HFSUniStr255 *unicodeName );
        !           136: 
        !           137: 
        !           138: extern OSErr ConvertUTF8ToUnicode ( ByteCount srcLen,
        !           139:                                                                    const unsigned char* srcStr,
        !           140:                                                                        ByteCount maxDstLen,
        !           141:                                                                        ByteCount *actualDstLen,
        !           142:                                                                        UniCharArrayPtr dstStr );
        !           143: 
        !           144: extern OSErr ConvertUnicodeToUTF8 ( ByteCount srcLen,
        !           145:                                                                        ConstUniCharArrayPtr srcStr,
        !           146:                                                                        ByteCount maxDstLen,
        !           147:                                                                        ByteCount *actualDstLen,
        !           148:                                                                        unsigned char* dstStr );
        !           149: 
        !           150: extern OSErr ConvertUTF8ToMacRoman (ByteCount srcLen,
        !           151:                                                                        const unsigned char* srcStr,
        !           152:                                                                        Str31 dstStr);
        !           153: 
        !           154: extern OSErr ConvertMacRomanToUTF8 (Str31 srcStr,
        !           155:                                                                        ByteCount maxDstLen,
        !           156:                                                                        ByteCount *actualDstLen,
        !           157:                                                                        unsigned char* dstStr);
        !           158: 
        !           159: 
        !           160: /*
        !           161:        This routine compares two Unicode names based on an ordering defined by the HFS Plus B-tree.
        !           162:        This ordering must stay fixed for all time.
        !           163:        
        !           164:        Output:
        !           165:                -n              name1 < name2   (i.e. name 1 sorts before name 2)
        !           166:                 0              name1 = name2
        !           167:                +n              name1 > name2
        !           168:        
        !           169:        NOTE: You should not depend on the magnitude of the result, just its sign.  That is, when name1 < name2, then any
        !           170:        negative number may be returned.
        !           171: */
        !           172: 
        !           173: extern SInt32 FastUnicodeCompare(register ConstUniCharArrayPtr str1, register ItemCount length1,
        !           174:                                                                 register ConstUniCharArrayPtr str2, register ItemCount length2);
        !           175: 
        !           176: 
        !           177: extern SInt32 FastRelString( ConstStr255Param str1, ConstStr255Param str2 );
        !           178: 
        !           179: extern OSErr InstallConversionContextsForInstalledScripts( void );
        !           180: 
        !           181: 
        !           182: extern OSErr InstallVolumeConversionContexts( UInt64 encodingsBitmap );
        !           183: 
        !           184: 
        !           185: extern OSErr InitializeEncodingContext( TextEncoding encoding, FSVarsRec *fsVars );
        !           186: 
        !           187: 
        !           188: extern HFSCatalogNodeID GetEmbeddedFileID( ConstStr31Param filename, UInt32 *prefixLength );
        !           189: 
        !           190: extern OSErr MockConvertFromUnicodeToPString( ByteCount unicodeLength, ConstUniCharArrayPtr unicodeStr,
        !           191:                                                                                          Str31 pascalStr );
        !           192: 
        !           193: extern OSErr MockConvertFromPStringToUnicode( ConstStr31Param pascalStr, ByteCount maxUnicodeLen,
        !           194:                                                                                          ByteCount *actualUnicodeLen, UniCharArrayPtr unicodeStr );

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.