]> git.saurik.com Git - apple/cf.git/blob - PlugIn.subproj/CFBundle.h
CF-299.32.tar.gz
[apple/cf.git] / PlugIn.subproj / CFBundle.h
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* CFBundle.h
26 Copyright (c) 1999-2003, Apple, Inc. All rights reserved.
27 */
28
29 #if !defined(__COREFOUNDATION_CFBUNDLE__)
30 #define __COREFOUNDATION_CFBUNDLE__ 1
31
32 #include <CoreFoundation/CFBase.h>
33 #include <CoreFoundation/CFArray.h>
34 #include <CoreFoundation/CFDictionary.h>
35 #include <CoreFoundation/CFString.h>
36 #include <CoreFoundation/CFURL.h>
37
38 #if defined(__cplusplus)
39 extern "C" {
40 #endif
41
42 typedef struct __CFBundle *CFBundleRef;
43 typedef struct __CFBundle *CFPlugInRef;
44
45 /* ===================== Standard Info.plist keys ===================== */
46 CF_EXPORT
47 const CFStringRef kCFBundleInfoDictionaryVersionKey;
48 /* The version of the Info.plist format */
49 CF_EXPORT
50 const CFStringRef kCFBundleExecutableKey;
51 /* The name of the executable in this bundle (if any) */
52 CF_EXPORT
53 const CFStringRef kCFBundleIdentifierKey;
54 /* The bundle identifier (for CFBundleGetBundleWithIdentifier()) */
55 CF_EXPORT
56 const CFStringRef kCFBundleVersionKey;
57 /* The version number of the bundle. Clients should use CFBundleGetVersionNumber() instead of accessing this key directly
58 since that function will properly convert a version number in string format into its interger representation. */
59 CF_EXPORT
60 const CFStringRef kCFBundleDevelopmentRegionKey;
61 /* The name of the development language of the bundle. */
62 CF_EXPORT
63 const CFStringRef kCFBundleNameKey;
64 /* The human-readable name of the bundle. This key is often found in the InfoPlist.strings since it is usually localized. */
65 #if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
66 CF_EXPORT
67 const CFStringRef kCFBundleLocalizationsKey;
68 /* Allows an unbundled application that handles localization itself to specify which localizations it has available. */
69 #endif
70
71 /* ===================== Finding Bundles ===================== */
72
73 CF_EXPORT
74 CFBundleRef CFBundleGetMainBundle(void);
75
76 CF_EXPORT
77 CFBundleRef CFBundleGetBundleWithIdentifier(CFStringRef bundleID);
78 /* A bundle can name itself by providing a key in the info dictionary. */
79 /* This facility is meant to allow bundle-writers to get hold of their */
80 /* bundle from their code without having to know where it was on the disk. */
81 /* This is meant to be a replacement mechanism for +bundleForClass: users. */
82 /* Note that this does not search for bundles on the disk; it will locate */
83 /* only bundles already loaded or otherwise known to the current process. */
84
85 CF_EXPORT
86 CFArrayRef CFBundleGetAllBundles(void);
87 /* This is potentially expensive. Use with care. */
88
89 /* ===================== Creating Bundles ===================== */
90
91 CF_EXPORT
92 UInt32 CFBundleGetTypeID(void);
93
94 CF_EXPORT
95 CFBundleRef CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL);
96 /* Might return an existing instance with the ref-count bumped. */
97
98 CF_EXPORT
99 CFArrayRef CFBundleCreateBundlesFromDirectory(CFAllocatorRef allocator, CFURLRef directoryURL, CFStringRef bundleType);
100 /* Create instances for all bundles in the given directory matching the given */
101 /* type (or all of them if bundleType is NULL) */
102
103 /* ==================== Basic Bundle Info ==================== */
104
105 CF_EXPORT
106 CFURLRef CFBundleCopyBundleURL(CFBundleRef bundle);
107
108 CF_EXPORT
109 CFTypeRef CFBundleGetValueForInfoDictionaryKey(CFBundleRef bundle, CFStringRef key);
110 /* Returns a localized value if available, otherwise the global value. */
111 /* This is the recommended function for examining the info dictionary. */
112
113 CF_EXPORT
114 CFDictionaryRef CFBundleGetInfoDictionary(CFBundleRef bundle);
115 /* This is the global info dictionary. Note that CFBundle may add */
116 /* extra keys to the dictionary for its own use. */
117
118 CF_EXPORT
119 CFDictionaryRef CFBundleGetLocalInfoDictionary(CFBundleRef bundle);
120 /* This is the localized info dictionary. */
121
122 CF_EXPORT
123 void CFBundleGetPackageInfo(CFBundleRef bundle, UInt32 *packageType, UInt32 *packageCreator);
124
125 CF_EXPORT
126 CFStringRef CFBundleGetIdentifier(CFBundleRef bundle);
127
128 CF_EXPORT
129 UInt32 CFBundleGetVersionNumber(CFBundleRef bundle);
130
131 CF_EXPORT
132 CFStringRef CFBundleGetDevelopmentRegion(CFBundleRef bundle);
133
134 CF_EXPORT
135 CFURLRef CFBundleCopySupportFilesDirectoryURL(CFBundleRef bundle);
136
137 CF_EXPORT
138 CFURLRef CFBundleCopyResourcesDirectoryURL(CFBundleRef bundle);
139
140 CF_EXPORT
141 CFURLRef CFBundleCopyPrivateFrameworksURL(CFBundleRef bundle);
142
143 CF_EXPORT
144 CFURLRef CFBundleCopySharedFrameworksURL(CFBundleRef bundle);
145
146 CF_EXPORT
147 CFURLRef CFBundleCopySharedSupportURL(CFBundleRef bundle);
148
149 CF_EXPORT
150 CFURLRef CFBundleCopyBuiltInPlugInsURL(CFBundleRef bundle);
151
152 /* ------------- Basic Bundle Info without a CFBundle instance ------------- */
153 /* This API is provided to enable developers to retrieve basic information */
154 /* about a bundle without having to create an instance of CFBundle. */
155 /* Because of caching behavior when a CFBundle instance exists, it will be faster */
156 /* to actually create a CFBundle if you need to retrieve multiple pieces of info. */
157 CF_EXPORT
158 CFDictionaryRef CFBundleCopyInfoDictionaryInDirectory(CFURLRef bundleURL);
159
160 CF_EXPORT
161 Boolean CFBundleGetPackageInfoInDirectory(CFURLRef url, UInt32 *packageType, UInt32 *packageCreator);
162
163 /* ==================== Resource Handling API ==================== */
164
165 CF_EXPORT
166 CFURLRef CFBundleCopyResourceURL(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName);
167
168 CF_EXPORT
169 CFArrayRef CFBundleCopyResourceURLsOfType(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName);
170
171 CF_EXPORT
172 CFStringRef CFBundleCopyLocalizedString(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName);
173
174 #define CFCopyLocalizedString(key, comment) \
175 CFBundleCopyLocalizedString(CFBundleGetMainBundle(), (key), (key), NULL)
176 #define CFCopyLocalizedStringFromTable(key, tbl, comment) \
177 CFBundleCopyLocalizedString(CFBundleGetMainBundle(), (key), (key), (tbl))
178 #define CFCopyLocalizedStringFromTableInBundle(key, tbl, bundle, comment) \
179 CFBundleCopyLocalizedString((bundle), (key), (key), (tbl))
180 #define CFCopyLocalizedStringWithDefaultValue(key, tbl, bundle, value, comment) \
181 CFBundleCopyLocalizedString((bundle), (key), (value), (tbl))
182
183 /* ------------- Resource Handling without a CFBundle instance ------------- */
184 /* This API is provided to enable developers to use the CFBundle resource */
185 /* searching policy without having to create an instance of CFBundle. */
186 /* Because of caching behavior when a CFBundle instance exists, it will be faster */
187 /* to actually create a CFBundle if you need to access several resources. */
188
189 CF_EXPORT
190 CFURLRef CFBundleCopyResourceURLInDirectory(CFURLRef bundleURL, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName);
191
192 CF_EXPORT
193 CFArrayRef CFBundleCopyResourceURLsOfTypeInDirectory(CFURLRef bundleURL, CFStringRef resourceType, CFStringRef subDirName);
194
195 /* =========== Localization-specific Resource Handling API =========== */
196 /* This API allows finer-grained control over specific localizations, */
197 /* as distinguished from the above API, which always uses the user's */
198 /* preferred localizations for the bundle in the current app context. */
199
200 CF_EXPORT
201 CFArrayRef CFBundleCopyBundleLocalizations(CFBundleRef bundle);
202 /* Lists the localizations that a bundle contains. */
203
204 CF_EXPORT
205 CFArrayRef CFBundleCopyPreferredLocalizationsFromArray(CFArrayRef locArray);
206 /* Given an array of possible localizations, returns the one or more */
207 /* of them that CFBundle would use in the current application context. */
208 /* To determine the localizations that would be used for a particular */
209 /* bundle in the current application context, apply this function to the */
210 /* result of CFBundleCopyBundleLocalizations. */
211
212 #if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
213 CF_EXPORT
214 CFArrayRef CFBundleCopyLocalizationsForPreferences(CFArrayRef locArray, CFArrayRef prefArray);
215 /* Given an array of possible localizations, returns the one or more of */
216 /* them that CFBundle would use, without reference to the current application */
217 /* context, if the user's preferred localizations were given by prefArray. */
218 /* If prefArray is NULL, the current user's actual preferred localizations will */
219 /* be used. This is not the same as CFBundleCopyPreferredLocalizationsFromArray, */
220 /* because that function takes the current application context into account. */
221 /* To determine the localizations that another application would use, apply */
222 /* this function to the result of CFBundleCopyBundleLocalizations. */
223 #endif
224
225 CF_EXPORT
226 CFURLRef CFBundleCopyResourceURLForLocalization(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName, CFStringRef localizationName);
227
228 CF_EXPORT
229 CFArrayRef CFBundleCopyResourceURLsOfTypeForLocalization(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName, CFStringRef localizationName);
230
231 #if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
232 /* =================== Unbundled application info ===================== */
233 /* This API is provided to enable developers to retrieve bundle-related */
234 /* information about an application that may be bundled or unbundled. */
235 CF_EXPORT
236 CFDictionaryRef CFBundleCopyInfoDictionaryForURL(CFURLRef url);
237 /* For a directory URL, this is equivalent to CFBundleCopyInfoDictionaryInDirectory. */
238 /* For a plain file URL representing an unbundled application, this will attempt to read */
239 /* an info dictionary either from the (__TEXT, __info_plist) section (for a Mach-o file) */
240 /* or from a 'plst' resource. */
241
242 CF_EXPORT
243 CFArrayRef CFBundleCopyLocalizationsForURL(CFURLRef url);
244 /* For a directory URL, this is equivalent to calling CFBundleCopyBundleLocalizations */
245 /* on the corresponding bundle. For a plain file URL representing an unbundled application, */
246 /* this will attempt to determine its localizations using the CFBundleLocalizations and */
247 /* CFBundleDevelopmentRegion keys in the dictionary returned by CFBundleCopyInfoDictionaryForURL,*/
248 /* or a 'vers' resource if those are not present. */
249 #endif
250
251 /* ==================== Primitive Code Loading API ==================== */
252 /* This API abstracts the various different executable formats supported on */
253 /* various platforms. It can load DYLD, CFM, or DLL shared libraries (on their */
254 /* appropriate platforms) and gives a uniform API for looking up functions. */
255 /* Note that Cocoa-based bundles containing Objective-C or Java code must */
256 /* be loaded with NSBundle, not CFBundle. Once they are loaded, however, */
257 /* either CFBundle or NSBundle can be used. */
258
259 CF_EXPORT
260 CFURLRef CFBundleCopyExecutableURL(CFBundleRef bundle);
261
262 CF_EXPORT
263 Boolean CFBundleIsExecutableLoaded(CFBundleRef bundle);
264
265 CF_EXPORT
266 Boolean CFBundleLoadExecutable(CFBundleRef bundle);
267
268 CF_EXPORT
269 void CFBundleUnloadExecutable(CFBundleRef bundle);
270
271 CF_EXPORT
272 void *CFBundleGetFunctionPointerForName(CFBundleRef bundle, CFStringRef functionName);
273
274 CF_EXPORT
275 void CFBundleGetFunctionPointersForNames(CFBundleRef bundle, CFArrayRef functionNames, void *ftbl[]);
276
277 CF_EXPORT
278 void *CFBundleGetDataPointerForName(CFBundleRef bundle, CFStringRef symbolName);
279
280 CF_EXPORT
281 void CFBundleGetDataPointersForNames(CFBundleRef bundle, CFArrayRef symbolNames, void *stbl[]);
282
283 CF_EXPORT
284 CFURLRef CFBundleCopyAuxiliaryExecutableURL(CFBundleRef bundle, CFStringRef executableName);
285 /* This function can be used to find executables other than your main */
286 /* executable. This is useful, for instance, for applications that have */
287 /* some command line tool that is packaged with and used by the application. */
288 /* The tool can be packaged in the various platform executable directories */
289 /* in the bundle and can be located with this function. This allows an */
290 /* app to ship versions of the tool for each platform as it does for the */
291 /* main app executable. */
292
293 /* ==================== Getting a bundle's plugIn ==================== */
294
295 CF_EXPORT
296 CFPlugInRef CFBundleGetPlugIn(CFBundleRef bundle);
297
298 /* ==================== Resource Manager-Related API ==================== */
299
300 CF_EXPORT
301 short CFBundleOpenBundleResourceMap(CFBundleRef bundle);
302 /* This function opens the non-localized and the localized resource files */
303 /* (if any) for the bundle, creates and makes current a single read-only */
304 /* resource map combining both, and returns a reference number for it. */
305 /* If it is called multiple times, it opens the files multiple times, */
306 /* and returns distinct reference numbers. */
307
308 CF_EXPORT
309 SInt32 CFBundleOpenBundleResourceFiles(CFBundleRef bundle, short *refNum, short *localizedRefNum);
310 /* Similar to CFBundleOpenBundleResourceMap, except that it creates two */
311 /* separate resource maps and returns reference numbers for both. */
312
313 CF_EXPORT
314 void CFBundleCloseBundleResourceMap(CFBundleRef bundle, short refNum);
315
316 #if defined(__cplusplus)
317 }
318 #endif
319
320 #endif /* ! __COREFOUNDATION_CFBUNDLE__ */
321