#include <CoreFoundation/CFRunLoop.h>
#include "CFInternal.h"
+
#define __kCFLogUserNotification 20
#define CFUserNotificationLog(alertHeader, alertMessage) CFLog(__kCFLogUserNotification, CFSTR("%@: %@"), alertHeader, alertMessage);
*bytes = NULL;
+
#if defined(__WIN32__)
fd = open(path, O_RDONLY|CF_OPENFLGS, 0666|_S_IREAD);
#else
#include "auto_stubs.h"
#include <libkern/OSAtomic.h>
+
#if defined(__MACH__)
#if defined(__ppc__)
// This hack is in here because B&I kernel does not set up comm page with Tiger additions yet.
# Misc additional options
#
-CURRENT_PROJECT_VERSION = 368.26
+CURRENT_PROJECT_VERSION = 368.27
# common items all build styles should be defining
CFLAGS += -DCF_BUILDING_CF=1
#include <math.h>
#include <ctype.h>
+
__private_extern__ bool allowMissingSemi = false;
// Should move this somewhere else
#endif
#endif
+
// Public CFBundle Info plist keys
CONST_STRING_DECL(kCFBundleInfoDictionaryVersionKey, "CFBundleInfoDictionaryVersion")
CONST_STRING_DECL(kCFBundleExecutableKey, "CFBundleExecutable")
CFLog(__kCFLogBundle, CFSTR("Cannot recognize type of executable for %@"), bundle);
break;
}
+ if (result && bundle->_plugInData._isPlugIn) _CFBundlePlugInLoaded(bundle);
return result;
}
// If an image path corresponds to a bundle, we see if there is already a bundle instance. If there is and it is NOT in the _dynamicBundles array, it is added to the staticBundles. Do not add the main bundle to the list here.
CFBundleRef bundle;
CFURLRef curURL = _CFBundleCopyFrameworkURLForExecutablePath(NULL, imagePath);
+ Boolean doFinalProcessing = false;
if (curURL != NULL) {
bundle = _CFBundleFindByURL(curURL, true);
if (bundle == NULL) {
- bundle = _CFBundleCreate(NULL, curURL, true, true);
+ bundle = _CFBundleCreate(NULL, curURL, true, false);
+ doFinalProcessing = true;
}
if (bundle != NULL && !bundle->_isLoaded) {
// make sure that these bundles listed as loaded, and mark them frameworks (we probably can't see anything else here, and we cannot unload them)
#endif /* BINARY_SUPPORT_DYLD */
bundle->_isLoaded = true;
}
+ // Perform delayed final processing steps.
+ // This must be done after _isLoaded has been set.
+ if (bundle && doFinalProcessing) {
+ _CFBundleCheckWorkarounds(bundle);
+ if (_CFBundleNeedsInitPlugIn(bundle)) {
+ __CFSpinUnlock(&CFBundleGlobalDataLock);
+ _CFBundleInitPlugIn(bundle);
+ __CFSpinLock(&CFBundleGlobalDataLock);
+ }
+ }
CFRelease(curURL);
}
}
extern Boolean _CFBundleNeedsInitPlugIn(CFBundleRef bundle);
extern void _CFBundleInitPlugIn(CFBundleRef bundle);
+extern void _CFBundlePlugInLoaded(CFBundleRef bundle);
extern void _CFBundleDeallocatePlugIn(CFBundleRef bundle);
extern void _CFPlugInWillUnload(CFPlugInRef plugIn);
#include "CFBundle_Internal.h"
#include "CFInternal.h"
+
static void _registerFactory(const void *key, const void *val, void *context) {
CFStringRef factoryIDStr = (CFStringRef)key;
CFStringRef factoryFuncStr = (CFStringRef)val;
CFDictionaryApplyFunction(typeDict, _registerType, bundle);
}
- /* Now do dynamic registration if necessary */
+ /* Now set key for dynamic registration if necessary */
if (doDynamicReg) {
+ CFDictionarySetValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"), CFSTR("YES"));
+ if (CFBundleIsExecutableLoaded(bundle)) _CFBundlePlugInLoaded(bundle);
+ }
+}
+
+__private_extern__ void _CFBundlePlugInLoaded(CFBundleRef bundle) {
+ CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
+ CFStringRef tempStr;
+ CFPlugInDynamicRegisterFunction func = NULL;
+
+ if (!__CFBundleGetPlugInData(bundle)->_isPlugIn || __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration || !infoDict || !CFBundleIsExecutableLoaded(bundle)) return;
+
+ tempStr = CFDictionaryGetValue(infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
+ if (tempStr != NULL && CFGetTypeID(tempStr) == CFStringGetTypeID() && CFStringCompare(tempStr, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
tempStr = CFDictionaryGetValue(infoDict, kCFPlugInDynamicRegisterFunctionKey);
if (tempStr == NULL || CFGetTypeID(tempStr) != CFStringGetTypeID() || CFStringGetLength(tempStr) <= 0) {
tempStr = CFSTR("CFPlugInDynamicRegister");
}
__CFBundleGetPlugInData(bundle)->_loadOnDemand = false;
+ __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true;
- if (CFBundleLoadExecutable(bundle)) {
- CFPlugInDynamicRegisterFunction func = NULL;
-
- __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true;
-
- /* Find the symbol and call it. */
- func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr);
- if (func) {
- func(bundle);
- // MF:!!! Unload function is never called. Need to deal with this!
- }
+ /* Find the symbol and call it. */
+ func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr);
+ if (func) {
+ func(bundle);
+ // MF:!!! Unload function is never called. Need to deal with this!
+ }
- __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false;
- if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && (__CFBundleGetPlugInData(bundle)->_instanceCount == 0)) {
- /* Unload now if we can/should. */
- CFBundleUnloadExecutable(bundle);
- }
+ __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false;
+ if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && (__CFBundleGetPlugInData(bundle)->_instanceCount == 0)) {
+ /* Unload now if we can/should. */
+ CFBundleUnloadExecutable(bundle);
}
+ } else {
+ CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
}
}
}
CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL) {
- return (CFPlugInRef)CFBundleCreate(allocator, plugInURL);
+ CFBundleRef bundle = CFBundleCreate(allocator, plugInURL);
+ return (CFPlugInRef)bundle;
}
CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn) {
#include <CoreFoundation/CFUniChar.h>
#include <CoreFoundation/CFNumber.h>
+
static Boolean _CFApplicationPreferencesSynchronizeNoLock(_CFApplicationPreferences *self);
void _CFPreferencesDomainSetMultiple(CFPreferencesDomainRef domain, CFDictionaryRef dict);
static void updateDictRep(_CFApplicationPreferences *self);
#include <math.h>
#include <mach/mach_time.h>
+
#define __kCFMessagePortMaxNameLengthMax 255
#if defined(BOOTSTRAP_MAX_NAME_LEN)
Boolean didRegister = false;
kern_return_t ret;
-//#warning CF: This should be an assert
+ //#warning CF: This should be an assert
// if (!__CFMessagePortIsRemote(remote)) return -999;
if (!__CFMessagePortIsValid(remote)) return kCFMessagePortIsInvalid;
__CFMessagePortLock(remote);
#if defined(__MACH__)
#define MAX_STACK_BUFFER_LEN (255)
const UTF16Char *characters = CFStringGetCharactersPtr(string);
+ CFIndex length = CFStringGetLength(string);
uint32_t usedBufLen;
- if (NULL == characters) {
- CFIndex length = CFStringGetLength(string);
+ if (maxBufLen < length) return false; // Since we're using UTF-8, the byte length is never shorter than the char length. Also, it filters out 0 == maxBufLen
+ if (NULL == characters) {
if (length > MAX_STACK_BUFFER_LEN) {
UTF16Char charactersBuffer[MAX_STACK_BUFFER_LEN];
CFRange range = CFRangeMake(0, MAX_STACK_BUFFER_LEN);
usedBufLen = 0;
- while (length > 0) {
+ while ((length > 0) && (maxBufLen > usedBufLen)) {
CFStringGetCharacters(string, range, charactersBuffer);
if (CFUniCharIsSurrogateHighCharacter(charactersBuffer[range.length - 1])) --range.length; // Backup for a high surrogate
buffer += usedBufLen;
}
} else {
- if (!CFUniCharDecompose(characters, CFStringGetLength(string), NULL, (void *)buffer, maxBufLen, &usedBufLen, true, kCFUniCharUTF8Format, true)) return false;
+ if (!CFUniCharDecompose(characters, length, NULL, (void *)buffer, maxBufLen, &usedBufLen, true, kCFUniCharUTF8Format, true)) return false;
buffer += usedBufLen;
}
#
ifeq "$(PLATFORM)" "Darwin"
-C_WARNING_FLAGS += -Wno-four-char-constants -Wall
-CPP_WARNING_FLAGS += -Wno-four-char-constants -Wall
+C_WARNING_FLAGS += -Wno-precomp -Wno-four-char-constants -Wall
+CPP_WARNING_FLAGS += -Wno-precomp -Wno-four-char-constants -Wall
endif
ifeq "$(PLATFORM)" "CYGWIN"