]> git.saurik.com Git - apple/cf.git/blob - CFBundle_Internal.h
CF-744.12.tar.gz
[apple/cf.git] / CFBundle_Internal.h
1 /*
2 * Copyright (c) 2012 Apple Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* CFBundle_Internal.h
25 Copyright (c) 1999-2012, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFBUNDLE_INTERNAL__)
29 #define __COREFOUNDATION_CFBUNDLE_INTERNAL__ 1
30
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"
38
39 CF_EXTERN_C_BEGIN
40
41 #define __kCFLogBundle 3
42 #define __kCFLogPlugIn 3
43
44 #if DEPLOYMENT_TARGET_WINDOWS
45 #define PLATFORM_PATH_STYLE kCFURLWindowsPathStyle
46 #else
47 #define PLATFORM_PATH_STYLE kCFURLPOSIXPathStyle
48 #endif
49
50 #define CFBundleExecutableNotFoundError 4
51 #define CFBundleExecutableNotLoadableError 3584
52 #define CFBundleExecutableArchitectureMismatchError 3585
53 #define CFBundleExecutableRuntimeMismatchError 3586
54 #define CFBundleExecutableLoadError 3587
55 #define CFBundleExecutableLinkError 3588
56
57 // uncomment this to enable the new look up algorithm
58 #define CFBUNDLE_NEWLOOKUP
59
60 // uncomment this to enable the checking for 8302591
61 //#define CFBUNDLE_NO_TRAVERSE_OUTSIDE
62
63 typedef struct __CFResourceData {
64 CFMutableDictionaryRef _stringTableCache;
65 Boolean _executableLacksResourceFork;
66 Boolean _infoDictionaryFromResourceFork;
67 char _padding[2];
68 } _CFResourceData;
69
70 extern _CFResourceData *__CFBundleGetResourceData(CFBundleRef bundle);
71
72 typedef struct __CFPlugInData {
73 Boolean _isPlugIn;
74 Boolean _loadOnDemand;
75 Boolean _isDoingDynamicRegistration;
76 Boolean _unused1;
77 UInt32 _instanceCount;
78 CFMutableArrayRef _factories;
79 } _CFPlugInData;
80
81 extern _CFPlugInData *__CFBundleGetPlugInData(CFBundleRef bundle);
82
83 /* Private CFBundle API */
84
85 extern Boolean _CFIsResourceAtURL(CFURLRef url, Boolean *isDir);
86 extern Boolean _CFIsResourceAtPath(CFStringRef path, Boolean *isDir);
87
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);
93
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);
99 #endif
100 extern CFDictionaryRef _CFBundleCopyInfoDictionaryInExecutable(CFURLRef url);
101 extern CFArrayRef _CFBundleCopyArchitecturesForExecutable(CFURLRef url);
102
103 extern void _CFBundleAddPreferredLprojNamesInDirectory(CFAllocatorRef alloc, CFURLRef bundleURL, UInt8 version, CFDictionaryRef infoDict, CFMutableArrayRef lprojNames, CFStringRef devLang);
104
105 extern CFStringRef _CFBundleGetPlatformExecutablesSubdirectoryName(void);
106 extern CFStringRef _CFBundleGetAlternatePlatformExecutablesSubdirectoryName(void);
107 extern CFStringRef _CFBundleGetOtherPlatformExecutablesSubdirectoryName(void);
108 extern CFStringRef _CFBundleGetOtherAlternatePlatformExecutablesSubdirectoryName(void);
109
110 extern CFStringRef _CFCreateStringFromVersionNumber(CFAllocatorRef alloc, UInt32 vers);
111 extern UInt32 _CFVersionNumberFromString(CFStringRef versStr);
112
113 extern void _CFBundleScheduleForUnloading(CFBundleRef bundle);
114 extern void _CFBundleUnscheduleForUnloading(CFBundleRef bundle);
115 extern void _CFBundleUnloadScheduledBundles(void);
116
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);
124
125 #if defined(BINARY_SUPPORT_DYLD)
126 // DYLD API
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 */
138
139 #if defined(BINARY_SUPPORT_DLFCN)
140 // dlfcn API
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 */
148
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 */
154
155
156 /* Private PlugIn-related CFBundle API */
157
158 extern Boolean _CFBundleNeedsInitPlugIn(CFBundleRef bundle);
159 extern void _CFBundleInitPlugIn(CFBundleRef bundle);
160 extern void _CFBundlePlugInLoaded(CFBundleRef bundle);
161 extern void _CFBundleDeallocatePlugIn(CFBundleRef bundle);
162
163 extern void _CFPlugInWillUnload(CFPlugInRef plugIn);
164
165 extern void _CFPlugInAddPlugInInstance(CFPlugInRef plugIn);
166 extern void _CFPlugInRemovePlugInInstance(CFPlugInRef plugIn);
167
168 extern void _CFPlugInAddFactory(CFPlugInRef plugIn, _CFPFactoryRef factory);
169 extern void _CFPlugInRemoveFactory(CFPlugInRef plugIn, _CFPFactoryRef factory);
170
171
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")
178
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/")
218
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")
226
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")
237
238 #define _CFBundleDefaultStringTableName CFSTR("Localizable")
239 #define _CFBundleStringTableType CFSTR("strings")
240 #define _CFBundleStringDictTableType CFSTR("stringsdict")
241
242 #define _CFBundleUserLanguagesPreferenceName CFSTR("AppleLanguages")
243 #define _CFBundleOldUserLanguagesPreferenceName CFSTR("NSLanguages")
244
245 #define _CFBundleLocalizedResourceForkFileName CFSTR("Localized")
246
247 #define _CFBundleWindowsResourceDirectoryExtension CFSTR("resources")
248
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")
254
255 #define _CFBundleMacOSXInfoPlistPlatformName_OLD CFSTR("macos")
256 #define _CFBundleWindowsInfoPlistPlatformName_OLD CFSTR("win32")
257
258 CF_EXTERN_C_END
259
260 #endif /* ! __COREFOUNDATION_CFBUNDLE_INTERNAL__ */
261