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