2 * Copyright (c) 2012 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 /* CFBundle_Internal.h
25 Copyright (c) 1999-2012, Apple Inc. All rights reserved.
28 #if !defined(__COREFOUNDATION_CFBUNDLE_INTERNAL__)
29 #define __COREFOUNDATION_CFBUNDLE_INTERNAL__ 1
31 #include <CoreFoundation/CFDate.h>
32 #include <CoreFoundation/CFBundle.h>
33 #include <CoreFoundation/CFPlugIn.h>
34 #include <CoreFoundation/CFError.h>
35 #include "CFInternal.h"
36 #include "CFPlugIn_Factory.h"
37 #include "CFBundle_BinaryTypes.h"
41 #define __kCFLogBundle 3
42 #define __kCFLogPlugIn 3
44 #if DEPLOYMENT_TARGET_WINDOWS
45 #define PLATFORM_PATH_STYLE kCFURLWindowsPathStyle
47 #define PLATFORM_PATH_STYLE kCFURLPOSIXPathStyle
50 #define CFBundleExecutableNotFoundError 4
51 #define CFBundleExecutableNotLoadableError 3584
52 #define CFBundleExecutableArchitectureMismatchError 3585
53 #define CFBundleExecutableRuntimeMismatchError 3586
54 #define CFBundleExecutableLoadError 3587
55 #define CFBundleExecutableLinkError 3588
57 // uncomment this to enable the new look up algorithm
58 #define CFBUNDLE_NEWLOOKUP
60 // uncomment this to enable the checking for 8302591
61 //#define CFBUNDLE_NO_TRAVERSE_OUTSIDE
63 typedef struct __CFResourceData
{
64 CFMutableDictionaryRef _stringTableCache
;
65 Boolean _executableLacksResourceFork
;
66 Boolean _infoDictionaryFromResourceFork
;
70 extern _CFResourceData
*__CFBundleGetResourceData(CFBundleRef bundle
);
72 typedef struct __CFPlugInData
{
74 Boolean _loadOnDemand
;
75 Boolean _isDoingDynamicRegistration
;
77 UInt32 _instanceCount
;
78 CFMutableArrayRef _factories
;
81 extern _CFPlugInData
*__CFBundleGetPlugInData(CFBundleRef bundle
);
83 /* Private CFBundle API */
85 extern Boolean
_CFIsResourceAtURL(CFURLRef url
, Boolean
*isDir
);
86 extern Boolean
_CFIsResourceAtPath(CFStringRef path
, Boolean
*isDir
);
88 extern Boolean
_CFBundleURLLooksLikeBundleVersion(CFURLRef url
, UInt8
*version
);
89 extern CFDictionaryRef
_CFBundleCopyInfoDictionaryInDirectory(CFAllocatorRef alloc
, CFURLRef url
, UInt8
*version
);
90 extern CFDictionaryRef
_CFBundleCopyInfoDictionaryInDirectoryWithVersion(CFAllocatorRef alloc
, CFURLRef url
, UInt8 version
);
91 extern CFURLRef
_CFBundleCopySupportFilesDirectoryURLInDirectory(CFURLRef bundleURL
, UInt8 version
);
92 extern CFURLRef
_CFBundleCopyResourcesDirectoryURLInDirectory(CFURLRef bundleURL
, UInt8 version
);
94 extern Boolean
_CFBundleCouldBeBundle(CFURLRef url
);
95 extern CFURLRef
_CFBundleCopyResourceForkURLMayBeLocal(CFBundleRef bundle
, Boolean mayBeLocal
);
96 extern CFDictionaryRef
_CFBundleCopyInfoDictionaryInResourceForkWithAllocator(CFAllocatorRef alloc
, CFURLRef url
);
97 #if DEPLOYMENT_TARGET_MACOSX
98 __private_extern__ CFStringRef
_CFBundleCopyBundleDevelopmentRegionFromVersResource(CFBundleRef bundle
);
100 extern CFDictionaryRef
_CFBundleCopyInfoDictionaryInExecutable(CFURLRef url
);
101 extern CFArrayRef
_CFBundleCopyArchitecturesForExecutable(CFURLRef url
);
103 extern void _CFBundleAddPreferredLprojNamesInDirectory(CFAllocatorRef alloc
, CFURLRef bundleURL
, UInt8 version
, CFDictionaryRef infoDict
, CFMutableArrayRef lprojNames
, CFStringRef devLang
);
105 extern CFStringRef
_CFBundleGetPlatformExecutablesSubdirectoryName(void);
106 extern CFStringRef
_CFBundleGetAlternatePlatformExecutablesSubdirectoryName(void);
107 extern CFStringRef
_CFBundleGetOtherPlatformExecutablesSubdirectoryName(void);
108 extern CFStringRef
_CFBundleGetOtherAlternatePlatformExecutablesSubdirectoryName(void);
110 extern CFStringRef
_CFCreateStringFromVersionNumber(CFAllocatorRef alloc
, UInt32 vers
);
111 extern UInt32
_CFVersionNumberFromString(CFStringRef versStr
);
113 extern void _CFBundleScheduleForUnloading(CFBundleRef bundle
);
114 extern void _CFBundleUnscheduleForUnloading(CFBundleRef bundle
);
115 extern void _CFBundleUnloadScheduledBundles(void);
117 __private_extern__ CFStringRef
_CFBundleGetBundlePath(CFBundleRef bundle
);
118 __private_extern__
void _CFBundleSetResourceDir(UniChar
*buffer
, CFIndex
*currLen
, CFIndex maxLen
, uint8_t version
);
119 __private_extern__ CFURLRef
_CFBundleCopyResourceForkURLWithoutLocal(CFBundleRef bundle
);
120 __private_extern__ CFDictionaryRef
_CFBundleCreateQueryTableAtPath(CFBundleRef bundle
, CFURLRef bundleURL
, CFArrayRef languages
, UniChar
*resDir
, CFIndex resDirLen
, UniChar
*subDir
, CFIndex subDirLen
);
121 __private_extern__ CFDictionaryRef
_CFBundleCopyQueryTable(CFBundleRef bundle
, CFURLRef bundleURL
, CFArrayRef languages
, UniChar
*resDir
, CFIndex resDirLen
, UniChar
*subDirBuffer
, CFIndex subDirLen
);
122 __private_extern__ CFArrayRef
_CFFindBundleResourcesNoBlock(CFBundleRef bundle
, CFURLRef bundleURL
, CFStringRef subDirName
, CFArrayRef searchLanguages
, CFStringRef resName
, CFArrayRef resTypes
, CFIndex limit
, uint8_t version
);
123 __private_extern__ CFTypeRef
_CFBundleCopyFindResourcesWithNoBlock(CFBundleRef bundle
, CFURLRef bundleURL
, CFArrayRef languages
, CFStringRef resourceName
, CFStringRef resourceType
, CFStringRef subPath
, CFStringRef lproj
, Boolean returnArray
, Boolean localized
);
125 #if defined(BINARY_SUPPORT_DYLD)
127 extern __CFPBinaryType
_CFBundleGrokBinaryType(CFURLRef executableURL
);
128 extern CFArrayRef
_CFBundleDYLDCopyLoadedImagePathsIfChanged(void);
129 extern CFArrayRef
_CFBundleDYLDCopyLoadedImagePathsForHint(CFStringRef hint
);
130 #if !defined(BINARY_SUPPORT_DLFCN)
131 extern Boolean
_CFBundleDYLDCheckLoaded(CFBundleRef bundle
);
132 extern Boolean
_CFBundleDYLDLoadBundle(CFBundleRef bundle
, Boolean forceGlobal
, CFErrorRef
*error
);
133 extern Boolean
_CFBundleDYLDLoadFramework(CFBundleRef bundle
, CFErrorRef
*error
);
134 extern void _CFBundleDYLDUnloadBundle(CFBundleRef bundle
);
135 extern void *_CFBundleDYLDGetSymbolByName(CFBundleRef bundle
, CFStringRef symbolName
);
136 #endif /* !BINARY_SUPPORT_DLFCN */
137 #endif /* BINARY_SUPPORT_DYLD */
139 #if defined(BINARY_SUPPORT_DLFCN)
141 extern Boolean
_CFBundleDlfcnCheckLoaded(CFBundleRef bundle
);
142 extern Boolean
_CFBundleDlfcnPreflight(CFBundleRef bundle
, CFErrorRef
*error
);
143 extern Boolean
_CFBundleDlfcnLoadBundle(CFBundleRef bundle
, Boolean forceGlobal
, CFErrorRef
*error
);
144 extern Boolean
_CFBundleDlfcnLoadFramework(CFBundleRef bundle
, CFErrorRef
*error
);
145 extern void _CFBundleDlfcnUnload(CFBundleRef bundle
);
146 extern void *_CFBundleDlfcnGetSymbolByName(CFBundleRef bundle
, CFStringRef symbolName
);
147 #endif /* BINARY_SUPPORT_DLFCN */
149 #if defined(BINARY_SUPPORT_DLL)
150 extern Boolean
_CFBundleDLLLoad(CFBundleRef bundle
, CFErrorRef
*error
);
151 extern void _CFBundleDLLUnload(CFBundleRef bundle
);
152 extern void *_CFBundleDLLGetSymbolByName(CFBundleRef bundle
, CFStringRef symbolName
);
153 #endif /* BINARY_SUPPORT_DLL */
156 /* Private PlugIn-related CFBundle API */
158 extern Boolean
_CFBundleNeedsInitPlugIn(CFBundleRef bundle
);
159 extern void _CFBundleInitPlugIn(CFBundleRef bundle
);
160 extern void _CFBundlePlugInLoaded(CFBundleRef bundle
);
161 extern void _CFBundleDeallocatePlugIn(CFBundleRef bundle
);
163 extern void _CFPlugInWillUnload(CFPlugInRef plugIn
);
165 extern void _CFPlugInAddPlugInInstance(CFPlugInRef plugIn
);
166 extern void _CFPlugInRemovePlugInInstance(CFPlugInRef plugIn
);
168 extern void _CFPlugInAddFactory(CFPlugInRef plugIn
, _CFPFactoryRef factory
);
169 extern void _CFPlugInRemoveFactory(CFPlugInRef plugIn
, _CFPFactoryRef factory
);
172 /* Strings for parsing bundle structure */
173 #define _CFBundleSupportFilesDirectoryName1 CFSTR("Support Files")
174 #define _CFBundleSupportFilesDirectoryName2 CFSTR("Contents")
175 #define _CFBundleResourcesDirectoryName CFSTR("Resources")
176 #define _CFBundleExecutablesDirectoryName CFSTR("Executables")
177 #define _CFBundleNonLocalizedResourcesDirectoryName CFSTR("Non-localized Resources")
179 #define _CFBundleSupportFilesURLFromBase1 CFSTR("Support%20Files/")
180 #define _CFBundleSupportFilesURLFromBase2 CFSTR("Contents/")
181 #define _CFBundleResourcesURLFromBase0 CFSTR("Resources/")
182 #define _CFBundleResourcesURLFromBase1 CFSTR("Support%20Files/Resources/")
183 #define _CFBundleResourcesURLFromBase2 CFSTR("Contents/Resources/")
184 #define _CFBundleAppStoreReceiptURLFromBase0 CFSTR("_MASReceipt/receipt")
185 #define _CFBundleAppStoreReceiptURLFromBase1 CFSTR("Support%20Files/_MASReceipt/receipt")
186 #define _CFBundleAppStoreReceiptURLFromBase2 CFSTR("Contents/_MASReceipt/receipt")
187 #define _CFBundleExecutablesURLFromBase1 CFSTR("Support%20Files/Executables/")
188 #define _CFBundleExecutablesURLFromBase2 CFSTR("Contents/")
189 #define _CFBundleInfoURLFromBase0 CFSTR("Resources/Info.plist")
190 #define _CFBundleInfoURLFromBase1 CFSTR("Support%20Files/Info.plist")
191 #define _CFBundleInfoURLFromBase2 CFSTR("Contents/Info.plist")
192 #define _CFBundleInfoURLFromBase3 CFSTR("Info.plist")
193 #define _CFBundleInfoFileName CFSTR("Info.plist")
194 #define _CFBundleInfoURLFromBaseNoExtension0 CFSTR("Resources/Info")
195 #define _CFBundleInfoURLFromBaseNoExtension1 CFSTR("Support%20Files/Info")
196 #define _CFBundleInfoURLFromBaseNoExtension2 CFSTR("Contents/Info")
197 #define _CFBundleInfoURLFromBaseNoExtension3 CFSTR("Info")
198 #define _CFBundleInfoExtension CFSTR("plist")
199 #define _CFBundleLocalInfoName CFSTR("InfoPlist")
200 #define _CFBundlePkgInfoURLFromBase1 CFSTR("Support%20Files/PkgInfo")
201 #define _CFBundlePkgInfoURLFromBase2 CFSTR("Contents/PkgInfo")
202 #define _CFBundlePseudoPkgInfoURLFromBase CFSTR("PkgInfo")
203 #define _CFBundlePrivateFrameworksURLFromBase0 CFSTR("Frameworks/")
204 #define _CFBundlePrivateFrameworksURLFromBase1 CFSTR("Support%20Files/Frameworks/")
205 #define _CFBundlePrivateFrameworksURLFromBase2 CFSTR("Contents/Frameworks/")
206 #define _CFBundleSharedFrameworksURLFromBase0 CFSTR("SharedFrameworks/")
207 #define _CFBundleSharedFrameworksURLFromBase1 CFSTR("Support%20Files/SharedFrameworks/")
208 #define _CFBundleSharedFrameworksURLFromBase2 CFSTR("Contents/SharedFrameworks/")
209 #define _CFBundleSharedSupportURLFromBase0 CFSTR("SharedSupport/")
210 #define _CFBundleSharedSupportURLFromBase1 CFSTR("Support%20Files/SharedSupport/")
211 #define _CFBundleSharedSupportURLFromBase2 CFSTR("Contents/SharedSupport/")
212 #define _CFBundleBuiltInPlugInsURLFromBase0 CFSTR("PlugIns/")
213 #define _CFBundleBuiltInPlugInsURLFromBase1 CFSTR("Support%20Files/PlugIns/")
214 #define _CFBundleBuiltInPlugInsURLFromBase2 CFSTR("Contents/PlugIns/")
215 #define _CFBundleAlternateBuiltInPlugInsURLFromBase0 CFSTR("Plug-ins/")
216 #define _CFBundleAlternateBuiltInPlugInsURLFromBase1 CFSTR("Support%20Files/Plug-ins/")
217 #define _CFBundleAlternateBuiltInPlugInsURLFromBase2 CFSTR("Contents/Plug-ins/")
219 #define _CFBundleLprojExtension CFSTR("lproj")
220 #define _CFBundleLprojExtensionWithDot CFSTR(".lproj")
221 #define _CFBundleDot CFSTR(".")
222 #define _CFBundleAllFiles CFSTR("_CFBAF_")
223 #define _CFBundleTypeIndicator CFSTR("_CFBT_")
224 // This directory contains resources (especially nibs) that may look up localized resources or may fall back to the development language resources
225 #define _CFBundleBaseDirectory CFSTR("Base")
227 #define _CFBundleMacOSXPlatformName CFSTR("macos")
228 #define _CFBundleAlternateMacOSXPlatformName CFSTR("macosx")
229 #define _CFBundleiPhoneOSPlatformName CFSTR("iphoneos")
230 #define _CFBundleMacOS8PlatformName CFSTR("macosclassic")
231 #define _CFBundleAlternateMacOS8PlatformName CFSTR("macos8")
232 #define _CFBundleWindowsPlatformName CFSTR("windows")
233 #define _CFBundleHPUXPlatformName CFSTR("hpux")
234 #define _CFBundleSolarisPlatformName CFSTR("solaris")
235 #define _CFBundleLinuxPlatformName CFSTR("linux")
236 #define _CFBundleFreeBSDPlatformName CFSTR("freebsd")
238 #define _CFBundleDefaultStringTableName CFSTR("Localizable")
239 #define _CFBundleStringTableType CFSTR("strings")
240 #define _CFBundleStringDictTableType CFSTR("stringsdict")
242 #define _CFBundleUserLanguagesPreferenceName CFSTR("AppleLanguages")
243 #define _CFBundleOldUserLanguagesPreferenceName CFSTR("NSLanguages")
245 #define _CFBundleLocalizedResourceForkFileName CFSTR("Localized")
247 #define _CFBundleWindowsResourceDirectoryExtension CFSTR("resources")
249 /* Old platform names (no longer used) */
250 #define _CFBundleMacOSXPlatformName_OLD CFSTR("macintosh")
251 #define _CFBundleAlternateMacOSXPlatformName_OLD CFSTR("nextstep")
252 #define _CFBundleWindowsPlatformName_OLD CFSTR("windows")
253 #define _CFBundleAlternateWindowsPlatformName_OLD CFSTR("winnt")
255 #define _CFBundleMacOSXInfoPlistPlatformName_OLD CFSTR("macos")
256 #define _CFBundleWindowsInfoPlistPlatformName_OLD CFSTR("win32")
260 #endif /* ! __COREFOUNDATION_CFBUNDLE_INTERNAL__ */