int getPstateTable(PSTATE_CTL_INFO* info){ int count = 0; io_service_t IOService = IOServiceGetMatchingService(0, IOServiceMatching(SERVICE_NAME)); if (! IOService ) return 0; CFDictionaryRef CDictionary = (CFDictionaryRef) IORegistryEntryCreateCFProperty(IOService, CFSTR("Characteristics"),kCFAllocatorDefault,0); CFArrayRef PSArray = CFArrayCreateCopy(kCFAllocatorDefault, (CFArrayRef) CFDictionaryGetValue(CDictionary, CFSTR("PStates"))); if (PSArray) { count = CFArrayGetCount(PSArray); for( int k = 0; k < count; k++ ){ CFDictionaryRef PSDictionary = CFDictionaryCreateCopy(kCFAllocatorDefault, (CFDictionaryRef) CFArrayGetValueAtIndex(PSArray, k)); info->frequency = GetNumber(CFSTR("Frequency"), PSDictionary); info->voltage = GetNumber(CFSTR("Voltage"), PSDictionary); info->fid = GetNumber(CFSTR("FID"), PSDictionary); info->did = GetNumber(CFSTR("DID"), PSDictionary); info->vid = GetNumber(CFSTR("VID"), PSDictionary); info->pstate = k; info++; CFRelease(PSDictionary); } CFRelease(PSArray); } CFRelease(CDictionary); return count; }
CFArrayRef getSerialModemList() { uint32_t serialModemCount = 0; CFMutableArrayRef devicePaths = CFArrayCreateMutable(kCFAllocatorDefault, serialModemCount, &kCFTypeArrayCallBacks); kern_return_t kernalReturnValue; CFMutableDictionaryRef deviceMatchingDictionary = NULL; deviceMatchingDictionary = IOServiceMatching(kIOSerialBSDServiceValue); io_iterator_t deviceIterator; kernalReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceMatchingDictionary, &deviceIterator); if (kernalReturnValue != KERN_SUCCESS) { return NULL; } io_service_t device; while ((device = IOIteratorNext(deviceIterator))) { CFMutableDictionaryRef deviceProperties = NULL; kernalReturnValue = IORegistryEntryCreateCFProperties(device, &deviceProperties, kCFAllocatorDefault, kNilOptions); if (kernalReturnValue != KERN_SUCCESS) { return NULL; } CFStringRef devicePathKey = CFStringCreateWithCString(kCFAllocatorDefault, kIOCalloutDeviceKey, kCFStringEncodingASCII); CFStringRef devicePath = CFDictionaryGetValue(deviceProperties, devicePathKey); IOObjectRelease(device); CFArrayAppendValue(devicePaths, devicePath); } IOObjectRelease(deviceIterator); return CFArrayCreateCopy(kCFAllocatorDefault, devicePaths); }
CFArrayRef AudioDecoder::CreateSupportedFileExtensions() { CFMutableArrayRef supportedExtensions = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); CFArrayRef decoderExtensions = nullptr; decoderExtensions = FLACDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; decoderExtensions = WavPackDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; decoderExtensions = MPEGDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; decoderExtensions = OggVorbisDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; decoderExtensions = OggSpeexDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; #if !TARGET_OS_IPHONE decoderExtensions = MusepackDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; decoderExtensions = MonkeysAudioDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; decoderExtensions = MODDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; decoderExtensions = TrueAudioDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; decoderExtensions = LibsndfileDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; #endif decoderExtensions = CoreAudioDecoder::CreateSupportedFileExtensions(); CFArrayAppendArray(supportedExtensions, decoderExtensions, CFRangeMake(0, CFArrayGetCount(decoderExtensions))); CFRelease(decoderExtensions), decoderExtensions = nullptr; CFArrayRef result = CFArrayCreateCopy(kCFAllocatorDefault, supportedExtensions); CFRelease(supportedExtensions), supportedExtensions = nullptr; return result; }
/* * Obtain an array of the certificates in a timestamp response. Elements of the * returned array are SecCertificateRefs. The caller must CFRelease the returned * array. This timestamp is an authenticated timestamp provided by * a timestamping authority. * * Returns errSecParam if the CMS message was not signed or if signerIndex * is greater than the number of signers of the message minus one. It returns * errSecItemNotFound if no certificates were found. * * This cannot be called until after CMSDecoderFinalizeMessage() is called. */ OSStatus CMSDecoderCopySignerTimestampCertificates( CMSDecoderRef cmsDecoder, size_t signerIndex, /* usually 0 */ CFArrayRef *certificateRefs) /* RETURNED */ { OSStatus status = errSecParam; SecCmsMessageRef cmsg = NULL; SecCmsSignedDataRef signedData = NULL; int numContentInfos = 0; CFIndex tsn = 0; bool good = false; require(cmsDecoder && certificateRefs, xit); require_noerr(CMSDecoderGetCmsMessage(cmsDecoder, &cmsg), xit); numContentInfos = SecCmsMessageContentLevelCount(cmsg); for (int dex = 0; !signedData && dex < numContentInfos; dex++) { SecCmsContentInfoRef ci = SecCmsMessageContentLevel(cmsg, dex); SECOidTag tag = SecCmsContentInfoGetContentTypeTag(ci); if (tag == SEC_OID_PKCS7_SIGNED_DATA) if ((signedData = SecCmsSignedDataRef(SecCmsContentInfoGetContent(ci)))) if (SecCmsSignerInfoRef signerInfo = SecCmsSignedDataGetSignerInfo(signedData, (int)signerIndex)) { CFArrayRef certList = SecCmsSignerInfoGetTimestampCertList(signerInfo); require_action(certList, xit, status = errSecItemNotFound); CFMutableArrayRef certs = CFArrayCreateMutableCopy(kCFAllocatorDefault, CFArrayGetCount(certList), certList); if(certs){ //reorder certificates: tsn = CFArrayGetCount(certs); good = tsn > 0 && Security::CodeSigning::isAppleCA(SecCertificateRef(CFArrayGetValueAtIndex(certs, tsn-1))); if ( good == false ) { //change TS certificate ordering. for (CFIndex n = 0; n < tsn; n++) { if (SecCertificateRef tsRoot = SecCertificateRef(CFArrayGetValueAtIndex(certs, n))) if ((good = Security::CodeSigning::isAppleCA(tsRoot))) { CFArrayExchangeValuesAtIndices(certs, n, tsn-1); break; } } } *certificateRefs = CFArrayCreateCopy(kCFAllocatorDefault, certs); CFRelease(certs); status = errSecSuccess; } break; } } xit: return status; }
const CFArrayRef FWUtilGlobals::CopyDevices() { pthread_mutex_lock( & gGlobals.mDevicesLock ) ; CFArrayRef resultArray = CFArrayCreateCopy( kCFAllocatorDefault, gGlobals.mDevices ) ; pthread_mutex_unlock( & gGlobals.mDevicesLock ) ; return resultArray ; }
CFArrayRef AudioDecoder::CreateSupportedMIMETypes() { CFMutableArrayRef supportedMIMETypes = CFArrayCreateMutable(kCFAllocatorDefault, 32, &kCFTypeArrayCallBacks); CFArrayRef decoderMIMETypes = NULL; #if BUILD_FOR_MAC_OSX decoderMIMETypes = FLACDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; decoderMIMETypes = WavPackDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; decoderMIMETypes = MPEGDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; decoderMIMETypes = OggVorbisDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; decoderMIMETypes = MusepackDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; decoderMIMETypes = MonkeysAudioDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; decoderMIMETypes = OggSpeexDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; decoderMIMETypes = MODDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; decoderMIMETypes = LibsndfileDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; #endif decoderMIMETypes = CoreAudioDecoder::CreateSupportedMIMETypes(); CFArrayAppendArray(supportedMIMETypes, decoderMIMETypes, CFRangeMake(0, CFArrayGetCount(decoderMIMETypes))); CFRelease(decoderMIMETypes), decoderMIMETypes = NULL; CFArrayRef result = CFArrayCreateCopy(kCFAllocatorDefault, supportedMIMETypes); CFRelease(supportedMIMETypes), supportedMIMETypes = NULL; return result; }
static CFArrayRef __CFLocaleCopyCStringsAsArray(const char* const* p) { CFMutableArrayRef working = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks); for (; *p; ++p) { CFStringRef string = CFStringCreateWithCString(kCFAllocatorSystemDefault, *p, kCFStringEncodingASCII); CFArrayAppendValue(working, string); CFRelease(string); } CFArrayRef result = CFArrayCreateCopy(kCFAllocatorSystemDefault, working); CFRelease(working); return result; }
CFURLEnumeratorRef CFURLEnumeratorCreateForDirectoryURL(CFAllocatorRef alloc, CFURLRef directoryURL, CFURLEnumeratorOptions option, CFArrayRef propertyKeys) { struct __CFURLEnumerator *enumerator = _CFURLEnumeratorCreate(alloc); enumerator->directoryURL = (CFURLRef)CFRetain(directoryURL); enumerator->options = option; if (propertyKeys != NULL) { enumerator->propertyKeys = CFArrayCreateCopy(alloc, propertyKeys); } enumerator->urlStack = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); enumerator->dirFileInfos = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); if (CFURLEnumeratorPushURL(enumerator, directoryURL, NULL) <= 0) { CFRelease(enumerator); return NULL; } return (CFURLEnumeratorRef)enumerator; }
CF_EXPORT void CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, CFOptionFlags options) { // since this is not cross process, we can just deliver all of the notifs immediately OSSpinLockLock(¢er->lock); CFArrayRef observers = CFArrayCreateCopy(kCFAllocatorDefault, center->observers); OSSpinLockUnlock(¢er->lock); CFIndex count = CFArrayGetCount(observers); for (CFIndex idx = 0; idx < count; idx++) { CFNotificationObserver *observer = (CFNotificationObserver *)CFArrayGetValueAtIndex(observers, idx); if (name == NULL || observer->name == NULL || CFStringCompare(observer->name, name, 0) == kCFCompareEqualTo) { if (object == NULL || observer->object == NULL || object == observer->object) { observer->callBack(center, (void *)observer->observer, name, object, userInfo); } } } CFRelease(observers); }
CFArrayRef SFB::Audio::CoreAudioDecoder::CreateSupportedMIMETypes() { CFArrayRef supportedMIMETypes = nullptr; UInt32 size = sizeof(supportedMIMETypes); OSStatus result = AudioFileGetGlobalInfo(kAudioFileGlobalInfo_AllMIMETypes, 0, nullptr, &size, &supportedMIMETypes); if(noErr != result) { LOGGER_ERR("org.sbooth.AudioEngine.Decoder.CoreAudio", "AudioFileGetGlobalInfo (kAudioFileGlobalInfo_AllMIMETypes) failed: " << result << "'" << SFB::StringForOSType((OSType)result) << "'"); return nullptr; } return CFArrayCreateCopy(kCFAllocatorDefault, supportedMIMETypes); }
void mainThreadRunLoopSourceCallback(void *info) { int pthreadError; CFArrayRef copiedQueueArray; CFIndex queueCount, queueIndex; // take the lock on the message queue pthreadError = pthread_mutex_lock(&queueLock); if (pthreadError) { #if DEBUG printf("AddToMessageQueue: pthread_mutex_lock failed (%d)\n", pthreadError); #endif return; } // copy the array of queued objects, copiedQueueArray = CFArrayCreateCopy(kCFAllocatorDefault, queueArray); // and remove the queued objects CFArrayRemoveAllValues(queueArray); // release the lock pthreadError = pthread_mutex_unlock(&queueLock); if (pthreadError) { #if DEBUG printf("AddToMessageQueue: pthread_mutex_unlock failed (%d)\n", pthreadError); #endif CFRelease(copiedQueueArray); return; } // for each object in the array, call a function to process it queueCount = CFArrayGetCount(copiedQueueArray); for (queueIndex = 0; queueIndex < queueCount; queueIndex++) { CFTypeRef object; object = (CFDictionaryRef)CFArrayGetValueAtIndex(copiedQueueArray, queueIndex); handler(object, handlerRefCon); } CFRelease(copiedQueueArray); return; }
CFArrayRef CFStringCreateArrayBySeparatingStrings (CFAllocatorRef alloc, CFStringRef str, CFStringRef separator) { /* This is basically a port of -componentsSeparatedByString: */ CFIndex end; CFRange search; CFRange found; CFStringRef tmp; CFArrayRef ret; CFMutableArrayRef array; array = CFArrayCreateMutable (alloc, 0, &kCFTypeArrayCallBacks); search = CFRangeMake (0, CFStringGetLength(str)); end = search.length; while (CFStringFindWithOptions(str, separator, search, 0, &found)) { CFRange current; current = CFRangeMake (search.location, found.location - search.location); tmp = CFStringCreateWithSubstring(alloc, str, current); CFArrayAppendValue (array, tmp); CFRelease (tmp); search = CFRangeMake (found.location + found.length, end - found.location - found.length); } /* Add the last search string range */ tmp = CFStringCreateWithSubstring(alloc, str, search); CFArrayAppendValue (array, tmp); CFRelease (tmp); ret = CFArrayCreateCopy (alloc, array); CFRelease(array); return ret; }
// ---------------------------------------------------------------------------- // get_active_server // ---------------------------------------------------------------------------- CFArrayRef get_active_servers(struct vpn_params *params) { SCPreferencesRef prefs = 0; CFPropertyListRef active_servers; CFArrayRef arrayCopy = 0; char pathStr[MAXPATHLEN]; // open the prefs file prefs = SCPreferencesCreate(0, CFSTR("vpnd"), kRASServerPrefsFileName); if (prefs == NULL) { CFStringGetCString(kRASServerPrefsFileName, pathStr, MAXPATHLEN, kCFStringEncodingMacRoman); vpnlog(LOG_ERR, "Unable to read vpnd prefs file '%s'\n", pathStr); return 0; } // get active servers list from the plist active_servers = SCPreferencesGetValue(prefs, kRASActiveServers); if (active_servers && isArray(active_servers)) if (CFArrayGetCount(active_servers) > 0) arrayCopy = CFArrayCreateCopy(0, active_servers); CFRelease(prefs); return arrayCopy; }
OSStatus SecPolicyCopyAll(CSSM_CERT_TYPE certificateType, CFArrayRef* policies) { BEGIN_SECAPI Required(policies); CFMutableArrayRef currPolicies = NULL; currPolicies = CFArrayCreateMutable(NULL, 0, NULL); if ( currPolicies ) { SecPointer<PolicyCursor> cursor(new PolicyCursor(NULL, NULL)); SecPointer<Policy> policy; while ( cursor->next(policy) ) /* copies the next policy */ { CFArrayAppendValue(currPolicies, policy->handle()); /* 'SecPolicyRef' appended */ CFRelease(policy->handle()); /* refcount bumped up when appended to array */ } *policies = CFArrayCreateCopy(NULL, currPolicies); CFRelease(currPolicies); CFRelease(cursor->handle()); } END_SECAPI }
CFDataRef CreatePropertyFromCertificate(const SecCertificateRef& cert, const CFTypeRef& oid) { // Set the list of attributes. auto keys = CFArrayCreateMutable(nullptr, 0, &kCFTypeArrayCallBacks); CFArrayAppendValue(keys, oid); // SecCertificateOIDs.h // Request dictionary of dictionaries (one for each attribute). auto certificate_values = SecCertificateCopyValues(cert, keys, nullptr); CFRelease(keys); if (!CFDictionaryContainsKey(certificate_values, oid)) { // Certificate does not have the requested property. CFRelease(certificate_values); return nullptr; } auto values = (CFDictionaryRef)CFDictionaryGetValue(certificate_values, oid); if (!CFDictionaryContainsKey(values, kSecPropertyKeyValue)) { // Odd, there was not value in the property result. CFRelease(certificate_values); return nullptr; } // Create copy of the property value, which is an index to owned dict. auto property = (CFDataRef)CFDictionaryGetValue(values, kSecPropertyKeyValue); if (CFGetTypeID(property) == CFArrayGetTypeID()) { property = (CFDataRef)CFArrayCreateCopy(nullptr, (CFArrayRef)property); } else if (CFGetTypeID(property) == CFNumberGetTypeID()) { property = (CFDataRef)CFNumberCreateCopy((CFNumberRef)property); } else { property = nullptr; } // Release and give the caller control of the property. CFRelease(certificate_values); return property; }
static CFArrayRef __CFLocaleCopyUEnumerationAsArray(UEnumeration *enumer, UErrorCode *icuErr) { const UChar *next = NULL; int32_t len = 0; CFMutableArrayRef working = NULL; if (U_SUCCESS(*icuErr)) { working = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks); } while ((next = uenum_unext(enumer, &len, icuErr)) && U_SUCCESS(*icuErr)) { CFStringRef string = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (const UniChar *)next, (CFIndex) len); CFArrayAppendValue(working, string); CFRelease(string); } if (*icuErr == U_INDEX_OUTOFBOUNDS_ERROR) { *icuErr = U_ZERO_ERROR; // Temp: Work around bug (ICU 5220) in ucurr enumerator } CFArrayRef result = NULL; if (U_SUCCESS(*icuErr)) { result = CFArrayCreateCopy(kCFAllocatorSystemDefault, working); } if (working != NULL) { CFRelease(working); } return result; }
QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths, QStringList *files, QStringList *directories) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 stop(); wait(); QMutexLocker locker(&mutex); QStringList failedToAdd; // if we have a running FSStreamEvent, we have to kill it, we'll re-add the stream soon. FSEventStreamEventId idToCheck; if (fsStream) { idToCheck = FSEventStreamGetLatestEventId(fsStream); cleanupFSStream(fsStream); } else { idToCheck = kFSEventStreamEventIdSinceNow; } // Brain-dead approach, but works. FSEvents actually can already read sub-trees, but since it's // work to figure out if we are doing a double register, we just register it twice as FSEvents // seems smart enough to only deliver one event. We also duplicate directory entries in here // (e.g., if you watch five files in the same directory, you get that directory included in the // array 5 times). This stupidity also makes remove work correctly though. I'll freely admit // that we could make this a bit smarter. If you do, check the auto-tests, they should catch at // least a couple of the issues. QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); for (int i = 0; i < paths.size(); ++i) { const QString &path = paths.at(i); QFileInfo fileInfo(path); if (!fileInfo.exists()) { failedToAdd.append(path); continue; } if (fileInfo.isDir()) { if (directories->contains(path)) { failedToAdd.append(path); continue; } else { directories->append(path); // Full file path for dirs. QCFString cfpath(createFSStreamPath(fileInfo.canonicalFilePath())); addPathToHash(dirPathInfoHash, cfpath, fileInfo, path); CFArrayAppendValue(tmpArray, cfpath); } } else { if (files->contains(path)) { failedToAdd.append(path); continue; } else { // Just the absolute path (minus it's filename) for files. QCFString cfpath(createFSStreamPath(fileInfo.canonicalPath())); files->append(path); addPathToHash(filePathInfoHash, cfpath, fileInfo, path); CFArrayAppendValue(tmpArray, cfpath); } } } if (!pathsToWatch && failedToAdd.size() == paths.size()) { return failedToAdd; } if (CFArrayGetCount(tmpArray) > 0) { if (pathsToWatch) { CFArrayAppendArray(tmpArray, pathsToWatch, CFRangeMake(0, CFArrayGetCount(pathsToWatch))); CFRelease(pathsToWatch); } pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray); } FSEventStreamContext context = { 0, this, 0, 0, 0 }; fsStream = FSEventStreamCreate(kCFAllocatorDefault, QFSEventsFileSystemWatcherEngine::fseventsCallback, &context, pathsToWatch, idToCheck, Latency, QtFSEventFlags); warmUpFSEvents(); return failedToAdd; #else Q_UNUSED(paths); Q_UNUSED(files); Q_UNUSED(directories); return QStringList(); #endif }
QStringList QFSEventsFileSystemWatcherEngine::removePaths(const QStringList &paths, QStringList *files, QStringList *directories) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 stop(); wait(); QMutexLocker locker(&mutex); // short circuit for smarties that call remove before add and we have nothing. if (pathsToWatch == 0) return paths; QStringList failedToRemove; // if we have a running FSStreamEvent, we have to stop it, we'll re-add the stream soon. FSEventStreamEventId idToCheck; if (fsStream) { idToCheck = FSEventStreamGetLatestEventId(fsStream); cleanupFSStream(fsStream); fsStream = 0; } else { idToCheck = kFSEventStreamEventIdSinceNow; } CFIndex itemCount = CFArrayGetCount(pathsToWatch); QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutableCopy(kCFAllocatorDefault, itemCount, pathsToWatch); CFRelease(pathsToWatch); pathsToWatch = 0; for (int i = 0; i < paths.size(); ++i) { // Get the itemCount at the beginning to avoid any overruns during the iteration. itemCount = CFArrayGetCount(tmpArray); const QString &path = paths.at(i); QFileInfo fi(path); QCFString cfpath(createFSStreamPath(fi.canonicalPath())); CFIndex index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfpath); if (index != -1) { CFArrayRemoveValueAtIndex(tmpArray, index); files->removeAll(path); removePathFromHash(filePathInfoHash, cfpath, path); } else { // Could be a directory we are watching instead. QCFString cfdirpath(createFSStreamPath(fi.canonicalFilePath())); index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfdirpath); if (index != -1) { CFArrayRemoveValueAtIndex(tmpArray, index); directories->removeAll(path); removePathFromHash(dirPathInfoHash, cfpath, path); } else { failedToRemove.append(path); } } } itemCount = CFArrayGetCount(tmpArray); if (itemCount != 0) { pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray); FSEventStreamContext context = { 0, this, 0, 0, 0 }; fsStream = FSEventStreamCreate(kCFAllocatorDefault, QFSEventsFileSystemWatcherEngine::fseventsCallback, &context, pathsToWatch, idToCheck, Latency, QtFSEventFlags); warmUpFSEvents(); } return failedToRemove; #else Q_UNUSED(paths); Q_UNUSED(files); Q_UNUSED(directories); return QStringList(); #endif }
CFStringRef FSCopyFormatNameForFSType(CFStringRef fsType, int16_t fsSubtype, bool localized, bool encrypted) { CFTypeRef formatName; CFStringRef formatNameTableKey; CFIndex indx; if (NULL == fsType) return NULL; // Create a key for cache localized name table (i.e. "0hfs0") formatNameTableKey = CFStringCreateWithFormat(NULL, NULL, CFSTR("%d%@%d"), (localized ? 1 : 0), fsType, fsSubtype); // Use OSSpinLock to protect the table accessed from multiple threads OSSpinLockLock(&__FSLocalizedNameTableLock); formatName = (void*)((NULL == __FSLocalizedNameTable) ? NULL : CFDictionaryGetValue(__FSLocalizedNameTable, (const void *)formatNameTableKey)); OSSpinLockUnlock(&__FSLocalizedNameTableLock); if (NULL == formatName) { // not in the cache CFBundleRef bundle = NULL; CFURLRef bundleURL; CFStringRef fsTypeName; static CFArrayRef searchPaths = NULL; /* Construct a bundle path URL from the fsType argument and create a CFBundle. We search (using CFCopySearchPathForDirectoriesInDomains) /Network/Library/Filesystems, /Library/Filesystems, and /System/Library/Filesystems. */ // Create CFURL for /System/Library/Filesystems and cache it if (NULL == searchPaths) { CFArrayRef tmpPaths = CFCopySearchPathForDirectoriesInDomains(kCFLibraryDirectory, kCFSystemDomainMask | kCFNetworkDomainMask | kCFLocalDomainMask, true); CFMutableArrayRef tmpStrings; CFIndex i; if (NULL == tmpPaths) return NULL; // No directories to search?!?! tmpStrings = CFArrayCreateMutable(NULL, CFArrayGetCount(tmpPaths), NULL); if (tmpStrings == NULL) goto done; for (i = 0; i < CFArrayGetCount(tmpPaths); i++) { CFStringRef tStr; CFURLRef tURL; char path[PATH_MAX + 1]; CFTypeRef tobject = CFArrayGetValueAtIndex(tmpPaths, i); if (CFGetTypeID(tobject) == CFURLGetTypeID()) { if (false == CFURLGetFileSystemRepresentation( tobject, false, (UInt8*)path, sizeof(path))) { goto done; } } else if (CFGetTypeID(tobject) == CFStringGetTypeID()) { CFStringGetCString(tobject, path, sizeof(path), kCFStringEncodingUTF8); } else { goto done; } strlcat(path, "/Filesystems", sizeof(path)); tStr = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8); if (tStr == NULL) goto done; tURL = CFURLCreateWithFileSystemPath(NULL, tStr, kCFURLPOSIXPathStyle, true); if (tURL) { CFArrayAppendValue(tmpStrings, tURL); } CFRelease(tStr); } searchPaths = CFArrayCreateCopy(NULL, tmpStrings); done: CFRelease(tmpStrings); CFRelease(tmpPaths); if (searchPaths == NULL) return NULL; } for (indx = 0; indx < CFArrayGetCount(searchPaths); indx++) { CFURLRef libRef = CFArrayGetValueAtIndex(searchPaths, indx); fsTypeName = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.fs"), fsType); bundleURL = CFURLCreateWithFileSystemPathRelativeToBase(NULL, fsTypeName, kCFURLPOSIXPathStyle, true, libRef); bundle = CFBundleCreate(NULL, bundleURL); CFRelease(fsTypeName); CFRelease(bundleURL); if (NULL != bundle) { break; } } if (NULL != bundle) { // the bundle exists at path CFDictionaryRef localPersonalities = NULL; // Access the Info dictionary in the bundle CFDictionaryRef bundleDict = CFBundleGetInfoDictionary(bundle); // Get localized FSPersonalities only if we want localized name if (localized == true) { localPersonalities = CFBundleGetValueForInfoDictionaryKey(bundle, KEY_FS_PERSONALITIES); //NSLog(CFSTR("localPersonalities = %@\n"), localPersonalities); } /* Get global FSPersonalities. We need to access this since FSSubType exists only * in global FSPersonalities */ CFDictionaryRef globalPersonalities = CFDictionaryGetValue(bundleDict, (const void *) KEY_FS_PERSONALITIES); //NSLog(CFSTR("globalPersonalities = %@\n"), globalPersonalities); CFIndex numPersonalities; if (((NULL != localPersonalities) || (localized == false)) && // localPersonalities or we don't want localizations (NULL != globalPersonalities) && ((numPersonalities = CFDictionaryGetCount(globalPersonalities)) > 0)) { // read all FSPersonalities keys and values CFDictionaryRef valuesBuffer[MAX_FS_SUBTYPES]; CFStringRef keysBuffer[MAX_FS_SUBTYPES]; CFDictionaryRef *values = ((numPersonalities > MAX_FS_SUBTYPES) ? (CFDictionaryRef *)malloc(sizeof(CFDictionaryRef) * numPersonalities) : valuesBuffer); CFStringRef *keys = ((numPersonalities > MAX_FS_SUBTYPES) ? (CFStringRef *)malloc(sizeof(CFStringRef) * numPersonalities) : keysBuffer); CFDictionaryGetKeysAndValues(globalPersonalities, (const void **)keys, (const void **)values); // create CFNumberRef for the FSSubType CFNumberRef subTypeID = CFNumberCreate(NULL, kCFNumberSInt16Type, (const void *)&fsSubtype); CFStringRef FSNameKey = NULL; // search for valid FSSubType - we will use its key from global FSPersonalties to // access FSName from localized FSPersonalities CFIndex index; CFNumberRef readSubTypeID; for (index = 0; index < numPersonalities; index++) { if ((true == CFDictionaryGetValueIfPresent(values[index], (const void *)KEY_FS_SUBTYPE, (const void **)&readSubTypeID)) && (CFNumberCompare(subTypeID, readSubTypeID, NULL) == 0)) { FSNameKey = keys[index]; break; } } CFRelease(subTypeID); /* If a personality hasn't been found, use the last value in the dictionary (note the content of CFDictionary is unordered so choosing the last doesn't produce consistent result) */ if (NULL == FSNameKey) { FSNameKey = keys[numPersonalities - 1]; // is selecting the last entry right ? } // Get FSName from the FSPersonalities entry CFDictionaryRef FSNameDict; if (localized == true) { FSNameDict = CFDictionaryGetValue(localPersonalities, FSNameKey); } else { FSNameDict = CFDictionaryGetValue(globalPersonalities, FSNameKey); } if (NULL != FSNameDict) { CFStringRef tempName = CFDictionaryGetValue(FSNameDict, (const void *)KEY_FS_NAME); CFStringRef encrName = CFDictionaryGetValue(FSNameDict, CFSTR(kFSCoreStorageEncryptNameKey)); if (tempName) { if (encrName) { formatName = (void*)CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); if (formatName != NULL) { (void)CFDictionarySetValue((void*)formatName, tempName, encrName); } } else { formatName = tempName; } } } if (values != valuesBuffer) free(values); if (keys != keysBuffer) free(keys); } } // If all failed, return "Unknown format (f_fstypename)" as the last resort if (NULL == formatName) { static CFStringRef unknownTypeString = NULL; CFStringRef unknownFSNameString = NULL; // This should use the framework bundle this code resides. CarbonCore ??? */ if (NULL == unknownTypeString) unknownTypeString = CFCopyLocalizedString(UNKNOWN_FS_NAME, "This string is displayed when localized file system name cannot be determined."); unknownFSNameString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%@)"), unknownTypeString, fsType); formatName = (void*)unknownFSNameString; } // Cache the result OSSpinLockLock(&__FSLocalizedNameTableLock); if (NULL == __FSLocalizedNameTable) __FSLocalizedNameTable = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); // NSLog(CFSTR("Setting value %@ for key %@\n"), formatName, formatNameTableKey); CFDictionarySetValue(__FSLocalizedNameTable, (const void *)formatNameTableKey, (const void *)formatName); OSSpinLockUnlock(&__FSLocalizedNameTableLock); // NSLog(CFSTR("Localized Name Table = %@\n"), __FSLocalizedNameTable); if (NULL != bundle) CFRelease(bundle); // it has to be released here since formatName might be owned by the bundle } CFRelease(formatNameTableKey); if (CFGetTypeID(formatName) == CFStringGetTypeID()) { return CFRetain(formatName); } else if (CFGetTypeID(formatName) == CFDictionaryGetTypeID()) { // Dictionary with the (possibly localized) name as the key, and the encrypted name as the value // If we want the encrypted name, we return the value, else we return the key size_t numEntries = CFDictionaryGetCount((void*)formatName); void *keyNames[numEntries]; void *values[numEntries]; CFDictionaryGetKeysAndValues((void*)formatName, (const void**)&keyNames, (const void**)&values); if (encrypted) return CFRetain(values[0]); else return CFRetain(keyNames[0]); } return CFRetain(formatName); }
OSStatus SecAccessCopyOwnerAndACL(SecAccessRef accessRef, uid_t* userId, gid_t* groupId, SecAccessOwnerType* ownerType, CFArrayRef* aclList) { CSSM_ACL_OWNER_PROTOTYPE_PTR owner = NULL; CSSM_ACL_ENTRY_INFO_PTR acls = NULL; uint32 aclCount = 0; OSStatus result = SecAccessGetOwnerAndACL(accessRef, &owner, &aclCount, &acls); if (errSecSuccess != result ) { return result; } if (NULL != owner) { CSSM_LIST_ELEMENT_PTR listHead = owner->TypedSubject.Head; if (listHead != NULL && listHead->ElementType == CSSM_LIST_ELEMENT_WORDID) { CSSM_LIST_ELEMENT_PTR nextElement = listHead->NextElement; if (listHead->WordID == CSSM_ACL_SUBJECT_TYPE_PROCESS && listHead->ElementType == CSSM_LIST_ELEMENT_WORDID) { // nextElement contains the required data CSSM_ACL_PROCESS_SUBJECT_SELECTOR* selectorPtr = (CSSM_ACL_PROCESS_SUBJECT_SELECTOR*)nextElement->Element.Word.Data; if (NULL != selectorPtr) { if (NULL != userId) { *userId = (uid_t)selectorPtr->uid; } if (NULL != groupId) { *groupId = (gid_t)selectorPtr->gid; } if (NULL != ownerType) { *ownerType = (SecAccessOwnerType)selectorPtr->mask; } } } } } if (NULL != aclList) { #ifndef NDEBUG CFShow(CFSTR("SecAccessCopyOwnerAndACL: processing the ACL list")); #endif CFMutableArrayRef stringArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); CSSM_ACL_OWNER_PROTOTYPE_PTR protoPtr = NULL; uint32 numAcls = 0L; CSSM_ACL_ENTRY_INFO_PTR aclEntry = NULL; result = SecAccessGetOwnerAndACL(accessRef, &protoPtr, &numAcls, &aclEntry); if (errSecSuccess == result) { #ifndef NDEBUG CFStringRef tempStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("SecAccessCopyOwnerAndACL: numAcls = %d"), numAcls); CFShow(tempStr); CFRelease(tempStr); #endif for (uint32 iCnt = 0; iCnt < numAcls; iCnt++) { CSSM_ACL_ENTRY_PROTOTYPE prototype = aclEntry[iCnt].EntryPublicInfo; CSSM_AUTHORIZATIONGROUP authGroup = prototype.Authorization; int numAuthTags = (int)authGroup.NumberOfAuthTags; for (int jCnt = 0; jCnt < numAuthTags; jCnt++) { sint32 aTag = authGroup.AuthTags[jCnt]; CFStringRef aString = GetAuthStringFromACLAuthorizationTag(aTag); CFArrayAppendValue(stringArray, aString); } } } if (NULL != stringArray) { if (0 < CFArrayGetCount(stringArray)) { *aclList = CFArrayCreateCopy(kCFAllocatorDefault, stringArray); } CFRelease(stringArray); } } return result; }
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // GetPropertyData() //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void FormatList::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const { Float64* rates; AudioValueRange* rateRanges; UInt32 theNumberRates; UInt32 theNumberRateRanges; UInt32 theIndex; CMFormatDescriptionRef format = NULL; switch (address.mSelector) { case kCMIOStreamPropertyFormatDescription: ThrowIf(dataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFormatDescription"); if (NULL != GetCurrentFormat()) CFRetain(GetCurrentFormat()); *static_cast<CMFormatDescriptionRef*>(data) = GetCurrentFormat(); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyFormatDescriptions: ThrowIf(dataSize != sizeof(CFArrayRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFormatDescriptions"); *static_cast<CFArrayRef*>(data) = CFArrayCreateCopy(NULL, mDescriptions.GetCFArray()); dataUsed = sizeof(CFArrayRef); break; case kCMIOStreamPropertyStillImage: ThrowIf(dataSize != sizeof(CMSampleBufferRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyStillImage"); ThrowIf(qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyStillImage"); *static_cast<CMSampleBufferRef*>(data) = GetStillImage(*static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData))); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyStillImageFormatDescriptions: ThrowIf(dataSize != sizeof(CFArrayRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyStillImageFormatDescriptions"); *static_cast<CFArrayRef*>(data) = CFArrayCreateCopy(NULL, mStillImageDescriptions.GetCFArray()); dataUsed = sizeof(CFArrayRef); break; case kCMIOStreamPropertyFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFrameRate"); *(static_cast<Float64*>(data)) = GetCurrentFrameRate(); dataUsed = sizeof(Float64); break; case kCMIOStreamPropertyFrameRates: ThrowIf(qualifierDataSize != 0 and qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyFrameRates"); format = (0 == qualifierDataSize) ? mCurrentFormat.Get() : *static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData)); theNumberRates = std::min((UInt32)(dataSize / sizeof(Float64)), GetNumberFrameRates(format)); rates = static_cast<Float64*>(data); for(theIndex = 0; theIndex < theNumberRates; ++theIndex) { rates[theIndex] = GetFrameRateByIndex(format, theIndex); } dataUsed = theNumberRates * sizeof(Float64); break; case kCMIOStreamPropertyMinimumFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyMinimumFrameRate"); *(static_cast<Float64*>(data)) = GetMinimumFrameRate(); dataUsed = sizeof(Float64); break; case kCMIOStreamPropertyFrameRateRanges: ThrowIf(qualifierDataSize != 0 and qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyFrameRateRanges"); format = (0 == qualifierDataSize) ? mCurrentFormat.Get() : *static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData)); theNumberRateRanges = std::min((UInt32)(dataSize / sizeof(AudioValueRange)), GetNumberFrameRateRanges(format)); rateRanges = static_cast<AudioValueRange*>(data); for(theIndex = 0; theIndex < theNumberRateRanges; ++theIndex) { rateRanges[theIndex] = GetFrameRateRangeByIndex(format, theIndex); } dataUsed = theNumberRateRanges * sizeof(AudioValueRange); break; case kCMIOStreamPropertyPreferredFormatDescription: ThrowIf(dataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyPreferredFormatDescription"); if (NULL != GetPreferredFormat()) CFRetain(GetPreferredFormat()); *static_cast<CMFormatDescriptionRef*>(data) = GetPreferredFormat(); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyPreferredFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyPreferredFrameRate"); *(static_cast<Float64*>(data)) = GetPreferredFrameRate(); dataUsed = sizeof(Float64); break; }; }
__private_extern__ Boolean __SCDynamicStoreReconnectNotifications(SCDynamicStoreRef store) { dispatch_queue_t dispatchQueue = NULL; __SCDynamicStoreNotificationStatus notifyStatus; Boolean ok = TRUE; CFArrayRef rlList = NULL; SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; // save old SCDynamicStore [notification] state notifyStatus = storePrivate->notifyStatus; // before tearing down our [old] notifications, make sure we've // retained any information that will be lost when we cancel the // current no-longer-valid handler switch (notifyStatus) { case Using_NotifierInformViaRunLoop : if (storePrivate->rlList != NULL) { rlList = CFArrayCreateCopy(NULL, storePrivate->rlList); } case Using_NotifierInformViaDispatch : dispatchQueue = storePrivate->dispatchQueue; if (dispatchQueue != NULL) dispatch_retain(dispatchQueue); break; default : break; } // cancel [old] notifications if (!SCDynamicStoreNotifyCancel(store)) { // if we could not cancel / reconnect SCLog(TRUE, LOG_DEBUG, CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreNotifyCancel() failed: %s"), SCErrorString(SCError())); } // set notification keys & patterns if ((storePrivate->keys != NULL) || (storePrivate->patterns)) { ok = SCDynamicStoreSetNotificationKeys(store, storePrivate->keys, storePrivate->patterns); if (!ok) { SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE), LOG_ERR, CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreSetNotificationKeys() failed")); goto done; } } switch (notifyStatus) { case Using_NotifierInformViaRunLoop : { CFIndex i; CFIndex n; CFRunLoopSourceRef rls; rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0); if (rls == NULL) { SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE), LOG_ERR, CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreCreateRunLoopSource() failed")); ok = FALSE; break; } n = (rlList != NULL) ? CFArrayGetCount(rlList) : 0; for (i = 0; i < n; i += 3) { CFRunLoopRef rl = (CFRunLoopRef)CFArrayGetValueAtIndex(rlList, i+1); CFStringRef rlMode = (CFStringRef) CFArrayGetValueAtIndex(rlList, i+2); CFRunLoopAddSource(rl, rls, rlMode); } CFRelease(rls); break; } case Using_NotifierInformViaDispatch : ok = SCDynamicStoreSetDispatchQueue(store, dispatchQueue); if (!ok) { SCLog((SCError() != BOOTSTRAP_UNKNOWN_SERVICE), LOG_ERR, CFSTR("__SCDynamicStoreReconnectNotifications: SCDynamicStoreSetDispatchQueue() failed")); goto done; } break; default : _SCErrorSet(kSCStatusFailed); ok = FALSE; break; } done : // cleanup switch (notifyStatus) { case Using_NotifierInformViaRunLoop : if (rlList != NULL) CFRelease(rlList); break; case Using_NotifierInformViaDispatch : if (dispatchQueue != NULL) dispatch_release(dispatchQueue); break; default : break; } if (!ok) { SCLog(TRUE, LOG_ERR, CFSTR("SCDynamicStore server %s, notification (%s) not restored"), (SCError() == BOOTSTRAP_UNKNOWN_SERVICE) ? "shutdown" : "failed", notifyType[notifyStatus]); } // inform the client pushDisconnect(store); return ok; }