这篇教程C++ CFDictionaryGetCount函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CFDictionaryGetCount函数的典型用法代码示例。如果您正苦于以下问题:C++ CFDictionaryGetCount函数的具体用法?C++ CFDictionaryGetCount怎么用?C++ CFDictionaryGetCount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CFDictionaryGetCount函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CFDictionaryGetCount//_____________________________________________________________________________//bool AUScope::RestoreElementNames (CFDictionaryRef& inNameDict){ static char string[32]; //first we have to see if we have enough elements and if not create them bool didAddElements = false; unsigned int maxElNum = 0; int dictSize = CFDictionaryGetCount(inNameDict); CFStringRef * keys = (CFStringRef*)CA_malloc (dictSize * sizeof (CFStringRef)); CFDictionaryGetKeysAndValues (inNameDict, reinterpret_cast<const void**>(keys), NULL); for (int i = 0; i < dictSize; i++) { unsigned int intKey; CFStringGetCString (keys[i], string, 32, kCFStringEncodingASCII); sscanf (string, "%u", &intKey); if (UInt32(intKey) > maxElNum) maxElNum = intKey; } if (maxElNum >= GetNumberOfElements()) { SetNumberOfElements (maxElNum+1); didAddElements = true; } // OK, now we have the number of elements that we need - lets restate their names for (int i = 0; i < dictSize; i++) { CFStringRef elName = reinterpret_cast<CFStringRef>(CFDictionaryGetValue (inNameDict, keys[i])); int intKey; CFStringGetCString (keys[i], string, 32, kCFStringEncodingASCII); sscanf (string, "%d", &intKey); GetElement (intKey)->SetName (elName); } free (keys); return didAddElements;}
开发者ID:abscura,项目名称:audiounitjs,代码行数:40,
示例2: checkForActivity/** * checkForActivity checks to see if any items have completed since the last invokation. * If not, a message is displayed showing what item(s) are being waited on. **/static void checkForActivity(CFRunLoopTimerRef aTimer, void* anInfo){ static CFIndex aLastStatusDictionaryCount = -1; static CFStringRef aWaitingForString = NULL; StartupContext aStartupContext = (StartupContext)anInfo; if (aStartupContext && aStartupContext->aStatusDict) { CFIndex aCount = CFDictionaryGetCount(aStartupContext->aStatusDict); if (!aWaitingForString) { aWaitingForString = LocalizedString(aStartupContext->aResourcesBundlePath, kWaitingForKey); } if (aLastStatusDictionaryCount == aCount) { CFArrayRef aRunningList = StartupItemListGetRunning(aStartupContext->aWaitingList); if (aRunningList && CFArrayGetCount(aRunningList) > 0) { CFMutableDictionaryRef anItem = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(aRunningList, 0); CFStringRef anItemDescription = StartupItemGetDescription(anItem); CFStringRef aString = aWaitingForString && anItemDescription ? CFStringCreateWithFormat(NULL, NULL, aWaitingForString, anItemDescription) : NULL; if (aString) { displayStatus(aStartupContext->aDisplayContext, aString); CFRelease(aString); } if (anItemDescription) CFRelease(anItemDescription); } if (aRunningList) CFRelease(aRunningList); } aLastStatusDictionaryCount = aCount; }}
开发者ID:aosm,项目名称:Startup,代码行数:42,
示例3: ProcessUPSEvent//---------------------------------------------------------------------------// ProcessUPSEvent////---------------------------------------------------------------------------void ProcessUPSEvent(UPSDataRef upsDataRef, CFDictionaryRef event){ UInt32 count, index; if ( !upsDataRef || !event) return; if ( (count = CFDictionaryGetCount(event)) ) { CFTypeRef * keys = (CFTypeRef *) malloc(sizeof(CFTypeRef) * count); CFTypeRef * values = (CFTypeRef *) malloc(sizeof(CFTypeRef) * count); CFDictionaryGetKeysAndValues(event, (const void **)keys, (const void **)values); for (index = 0; index < count; index++) CFDictionarySetValue(upsDataRef->upsStoreDict, keys[index], values[index]); free (keys); free (values); SCDynamicStoreSetValue(upsDataRef->upsStore, upsDataRef->upsStoreKey, upsDataRef->upsStoreDict); }}
开发者ID:hashier,项目名称:caffeinate_fix,代码行数:27,
示例4: _CFApplicationPreferencesDomainHasChanged// quick message to indicate that the given domain has changed, and we should go through and invalidate any dictReps that involve this domain.void _CFApplicationPreferencesDomainHasChanged(CFPreferencesDomainRef changedDomain) { CFAllocatorRef alloc = __CFPreferencesAllocator(); __CFSpinLock(&__CFApplicationPreferencesLock); if(__CFStandardUserPreferences) { // only grovel over the prefs if there's something there to grovel _CFApplicationPreferences **prefsArray, *prefsBuf[32]; CFIndex idx, count = CFDictionaryGetCount(__CFStandardUserPreferences); if(count < 32) { prefsArray = prefsBuf; } else { prefsArray = (_CFApplicationPreferences **)CFAllocatorAllocate(alloc, count * sizeof(_CFApplicationPreferences *), 0); } CFDictionaryGetKeysAndValues(__CFStandardUserPreferences, NULL, (const void **)prefsArray); // For this operation, giving up the lock is the last thing we want to do, so use the modified flavor of _CFApplicationPreferencesContainsDomain for(idx = 0; idx < count; idx++) { _CFApplicationPreferences *appPrefs = prefsArray[idx]; if(_CFApplicationPreferencesContainsDomainNoLock(appPrefs, changedDomain)) { updateDictRep(appPrefs); } } if(prefsArray != prefsBuf) _CFAllocatorDeallocateGC(alloc, prefsArray); } __CFSpinUnlock(&__CFApplicationPreferencesLock);}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:24,
示例5: encodevoid encode(ArgumentEncoder* encoder, CFDictionaryRef dictionary){ CFIndex size = CFDictionaryGetCount(dictionary); Vector<CFTypeRef, 32> keys(size); Vector<CFTypeRef, 32> values(size); CFDictionaryGetKeysAndValues(dictionary, keys.data(), values.data()); encoder->encodeUInt64(size); for (CFIndex i = 0; i < size; ++i) { ASSERT(keys[i]); ASSERT(CFGetTypeID(keys[i]) == CFStringGetTypeID()); ASSERT(values[i]); // Ignore values we don't recognize. if (typeFromCFTypeRef(values[i]) == Unknown) continue; encode(encoder, static_cast<CFStringRef>(keys[i])); encode(encoder, values[i]); }}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:23,
示例6: CFDictionaryCreateMutableCopyCFDictionaryRef SFB::Audio::AttachedPicture::CreateDictionaryRepresentation() const{ CFMutableDictionaryRef dictionaryRepresentation = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, mMetadata); CFIndex count = CFDictionaryGetCount(mChangedMetadata); CFTypeRef *keys = (CFTypeRef *)malloc(sizeof(CFTypeRef) * (size_t)count); CFTypeRef *values = (CFTypeRef *)malloc(sizeof(CFTypeRef) * (size_t)count); CFDictionaryGetKeysAndValues(mChangedMetadata, keys, values); for(CFIndex i = 0; i < count; ++i) { if(kCFNull == values[i]) CFDictionaryRemoveValue(dictionaryRepresentation, keys[i]); else CFDictionarySetValue(dictionaryRepresentation, keys[i], values[i]); } free(keys), keys = nullptr; free(values), values = nullptr; return dictionaryRepresentation;}
开发者ID:JanX2,项目名称:SFBAudioEngine,代码行数:23,
示例7: getVolatileKeysAndValuesstatic void getVolatileKeysAndValues(CFAllocatorRef alloc, CFTypeRef context, void *domain, void **buf[], CFIndex *numKeyValuePairs) { CFMutableDictionaryRef dict = (CFMutableDictionaryRef)domain; CFIndex count = CFDictionaryGetCount(dict); if (buf) { void **values; if ( count < *numKeyValuePairs ) { values = *buf + count; CFDictionaryGetKeysAndValues(dict, (const void **)*buf, (const void **)values); } else if (alloc != kCFAllocatorNull) { if (*buf) { *buf = (void **)CFAllocatorReallocate(alloc, *buf, count * 2 * sizeof(void *), 0); } else { *buf = (void **)CFAllocatorAllocate(alloc, count*2*sizeof(void *), 0); } if (*buf) { values = *buf + count; CFDictionaryGetKeysAndValues(dict, (const void **)*buf, (const void **)values); } } } *numKeyValuePairs = count;}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:23,
示例8: CFURLRequestGetURLvoid ResourceRequest::doUpdateResourceRequest(){ m_url = CFURLRequestGetURL(m_cfRequest.get()); m_cachePolicy = (ResourceRequestCachePolicy)CFURLRequestGetCachePolicy(m_cfRequest.get()); m_timeoutInterval = CFURLRequestGetTimeoutInterval(m_cfRequest.get()); m_firstPartyForCookies = CFURLRequestGetMainDocumentURL(m_cfRequest.get()); if (CFStringRef method = CFURLRequestCopyHTTPRequestMethod(m_cfRequest.get())) { m_httpMethod = method; CFRelease(method); } m_allowHTTPCookies = CFURLRequestShouldHandleHTTPCookies(m_cfRequest.get()); if (CFDictionaryRef headers = CFURLRequestCopyAllHTTPHeaderFields(m_cfRequest.get())) { CFIndex headerCount = CFDictionaryGetCount(headers); Vector<const void*, 128> keys(headerCount); Vector<const void*, 128> values(headerCount); CFDictionaryGetKeysAndValues(headers, keys.data(), values.data()); for (int i = 0; i < headerCount; ++i) m_httpHeaderFields.set((CFStringRef)keys[i], (CFStringRef)values[i]); CFRelease(headers); } m_responseContentDispositionEncodingFallbackArray.clear(); RetainPtr<CFArrayRef> encodingFallbacks(AdoptCF, copyContentDispositionEncodingFallbackArray(m_cfRequest.get())); if (encodingFallbacks) { CFIndex count = CFArrayGetCount(encodingFallbacks.get()); for (CFIndex i = 0; i < count; ++i) { CFStringEncoding encoding = reinterpret_cast<CFIndex>(CFArrayGetValueAtIndex(encodingFallbacks.get(), i)); if (encoding != kCFStringEncodingInvalidId) m_responseContentDispositionEncodingFallbackArray.append(CFStringConvertEncodingToIANACharSetName(encoding)); } } m_httpBody = httpBodyFromRequest(m_cfRequest.get());}
开发者ID:freeworkzz,项目名称:nook-st-oss,代码行数:36,
示例9: iSCSIDiscoveryRecCreateArrayOfPortalGroupTags/*! Creates a CFArray object containing CFString objects with portal group * tags for a particular target. * @param discoveryRec the discovery record. * @param targetIQN the name of the target. * @return an array of strings with portal group tags for the specified target. */CFArrayRef iSCSIDiscoveryRecCreateArrayOfPortalGroupTags(iSCSIDiscoveryRecRef discoveryRec, CFStringRef targetIQN){ // Validate inputs if(!discoveryRec || !targetIQN) return NULL; // If target doesn't exist return NULL CFMutableDictionaryRef targetDict; if(!CFDictionaryGetValueIfPresent(discoveryRec,targetIQN,(void *)&targetDict)) return NULL; // Otherwise get all keys, which correspond to the portal group tags const CFIndex count = CFDictionaryGetCount(targetDict); const void * keys[count]; CFDictionaryGetKeysAndValues(targetDict,keys,NULL); CFArrayRef portalGroups = CFArrayCreate(kCFAllocatorDefault, keys, count, &kCFTypeArrayCallBacks); return portalGroups;}
开发者ID:anvena,项目名称:iSCSIInitiator,代码行数:29,
示例10: getXMLKeysAndValuesstatic void getXMLKeysAndValues(CFAllocatorRef alloc, CFTypeRef context, void *xmlDomain, void **buf[], CFIndex *numKeyValuePairs) { _CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain *)xmlDomain; CFIndex count; __CFLock(&domain->_lock); if (!domain->_domainDict) { _loadXMLDomainIfStale((CFURLRef )context, domain); } count = CFDictionaryGetCount(domain->_domainDict); if (buf) { void **values; if (count <= *numKeyValuePairs) { values = *buf + count; CFDictionaryGetKeysAndValues(domain->_domainDict, (const void **)*buf, (const void **)values); } else if (alloc != kCFAllocatorNull) { *buf = (void**) CFAllocatorReallocate(alloc, (*buf ? *buf : NULL), count * 2 * sizeof(void *), 0); if (*buf) { values = *buf + count; CFDictionaryGetKeysAndValues(domain->_domainDict, (const void **)*buf, (const void **)values); } } } *numKeyValuePairs = count; __CFUnlock(&domain->_lock);}
开发者ID:JGiola,项目名称:swift-corelibs-foundation,代码行数:24,
示例11: loadDisplayBundle/** * Loads the SystemStarter display bundle at the specified path. * A no-op if SystemStarter is not starting in graphical mode. **/static void loadDisplayBundle (StartupContext aStartupContext, CFDictionaryRef anIPCMessage){ if (!gVerboseFlag && anIPCMessage && aStartupContext) { CFStringRef aBundlePath = CFDictionaryGetValue(anIPCMessage, kIPCDisplayBundlePathKey); if (aBundlePath && CFGetTypeID(aBundlePath) == CFStringGetTypeID()) { extern void LoadDisplayPlugIn(CFStringRef); if (aStartupContext->aDisplayContext) freeDisplayContext(aStartupContext->aDisplayContext); LoadDisplayPlugIn(aBundlePath); aStartupContext->aDisplayContext = initDisplayContext(); { CFStringRef aLocalizedString = LocalizedString(aStartupContext->aResourcesBundlePath, kWelcomeToMacintoshKey); if (aLocalizedString) { displayStatus(aStartupContext->aDisplayContext, aLocalizedString); displayProgress(aStartupContext->aDisplayContext, ((float)CFDictionaryGetCount(aStartupContext->aStatusDict)/((float)aStartupContext->aServicesCount + 1.0))); CFRelease(aLocalizedString); } } if (gSafeBootFlag) { CFStringRef aLocalizedString = LocalizedString(aStartupContext->aResourcesBundlePath, kSafeBootKey); if (aLocalizedString) { (void) displaySafeBootMsg(aStartupContext->aDisplayContext, aLocalizedString); CFRelease(aLocalizedString); } } } }}
开发者ID:aosm,项目名称:Startup,代码行数:40,
示例12: debugCallbackvoiddebugCallback( CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo){ int i = 0; printf("Debug callback: %s/n", CFStringToCString(name)); if (!userInfo) return; CFIndex count = CFDictionaryGetCount(userInfo); const void *keys[count]; const void *values[count]; CFDictionaryGetKeysAndValues(userInfo, keys, values); for(i = 0; i < count; i++) { printf("For i=%d, key: %s/n", i, CFStringToCString((CFStringRef)keys[i])); }}
开发者ID:dndump,项目名称:XboxLivePlugin,代码行数:24,
示例13: ivar_dict_foreachstatic voidivar_dict_foreach(CFDictionaryRef dict, int (*func)(ANYARGS), VALUE farg){ const long count = CFDictionaryGetCount(dict); if (count == 0) { return; } const void **keys = (const void **)malloc(sizeof(void *) * count); assert(keys != NULL); const void **values = (const void **)malloc(sizeof(void *) * count); assert(values != NULL); CFDictionaryGetKeysAndValues(dict, keys, values); for (long i = 0; i < count; i++) { if ((*func)(keys[i], values[i], farg) != ST_CONTINUE) { break; } } free(keys); free(values);}
开发者ID:kyab,项目名称:MacRuby,代码行数:24,
示例14: isSoftwareUpdateDevelopmentstatic bool isSoftwareUpdateDevelopment(SecTrustRef trust) { bool isPolicy = false, isEKU = false; CFArrayRef policies = NULL; /* Policy used to evaluate was SWUpdateSigning */ SecTrustCopyPolicies(trust, &policies); if (policies) { SecPolicyRef swUpdatePolicy = SecPolicyCreateAppleSWUpdateSigning(); if (swUpdatePolicy && CFArrayContainsValue(policies, CFRangeMake(0, CFArrayGetCount(policies)), swUpdatePolicy)) { isPolicy = true; } if (swUpdatePolicy) { CFRelease(swUpdatePolicy); } CFRelease(policies); } if (!isPolicy) { return false; } /* Only error was EKU on the leaf */ CFArrayRef details = SecTrustCopyFilteredDetails(trust); CFIndex ix, count = CFArrayGetCount(details); bool hasDisqualifyingError = false; for (ix = 0; ix < count; ix++) { CFDictionaryRef detail = (CFDictionaryRef)CFArrayGetValueAtIndex(details, ix); if (ix == 0) { // Leaf if (CFDictionaryGetCount(detail) != 1 || // One error CFDictionaryGetValue(detail, CFSTR("ExtendedKeyUsage")) != kCFBooleanFalse) { // kSecPolicyCheckExtendedKeyUsage hasDisqualifyingError = true; break; } } else { if (CFDictionaryGetCount(detail) > 0) { // No errors on other certs hasDisqualifyingError = true; break; } } } CFReleaseSafe(details); if (hasDisqualifyingError) { return false; } /* EKU on the leaf is the Apple Development Code Signing OID */ SecCertificateRef leaf = SecTrustGetCertificateAtIndex(trust, 0); CSSM_DATA *fieldValue = NULL; if (errSecSuccess != SecCertificateCopyFirstFieldValue(leaf, &CSSMOID_ExtendedKeyUsage, &fieldValue)) { return false; } if (fieldValue && fieldValue->Data && fieldValue->Length == sizeof(CSSM_X509_EXTENSION)) { const CSSM_X509_EXTENSION *ext = (const CSSM_X509_EXTENSION *)fieldValue->Data; if (ext->format == CSSM_X509_DATAFORMAT_PARSED) { const CE_ExtendedKeyUsage *ekus = (const CE_ExtendedKeyUsage *)ext->value.parsedValue; if (ekus && (ekus->numPurposes == 1) && ekus->purposes[0].Data && (ekus->purposes[0].Length == CSSMOID_APPLE_EKU_CODE_SIGNING_DEV.Length) && (memcmp(ekus->purposes[0].Data, CSSMOID_APPLE_EKU_CODE_SIGNING_DEV.Data, ekus->purposes[0].Length) == 0)) { isEKU = true; } } } SecCertificateReleaseFirstFieldValue(leaf, &CSSMOID_ExtendedKeyUsage, fieldValue); return isEKU;}
开发者ID:darlinghq,项目名称:darling-security,代码行数:64,
示例15: dnssdUpdateDNSSDName//.........这里部分代码省略......... } /* * Get the local hostname from the dynamic store... */ cupsdClearString(&DNSSDHostName); if ((nameRef = SCDynamicStoreCopyLocalHostName(sc)) != NULL) { if (CFStringGetCString(nameRef, nameBuffer, sizeof(nameBuffer), kCFStringEncodingUTF8)) { cupsdLogMessage(CUPSD_LOG_DEBUG, "Dynamic store host name is /"%s/".", nameBuffer); cupsdSetString(&DNSSDHostName, nameBuffer); } CFRelease(nameRef); } if (!DNSSDHostName) { /* * Use the ServerName instead... */ cupsdLogMessage(CUPSD_LOG_DEBUG, "Using ServerName /"%s/" as host name.", ServerName); cupsdSetString(&DNSSDHostName, ServerName); } /* * Get any Back-to-My-Mac domains and add them as aliases... */ cupsdFreeAliases(DNSSDAlias); DNSSDAlias = NULL; btmm = SCDynamicStoreCopyValue(sc, CFSTR("Setup:/Network/BackToMyMac")); if (btmm && CFGetTypeID(btmm) == CFDictionaryGetTypeID()) { cupsdLogMessage(CUPSD_LOG_DEBUG, "%d Back to My Mac aliases to add.", (int)CFDictionaryGetCount(btmm)); CFDictionaryApplyFunction(btmm, dnssdAddAlias, NULL); } else if (btmm) cupsdLogMessage(CUPSD_LOG_ERROR, "Bad Back to My Mac data in dynamic store!"); else cupsdLogMessage(CUPSD_LOG_DEBUG, "No Back to My Mac aliases to add."); if (btmm) CFRelease(btmm); CFRelease(sc); } else# endif /* __APPLE__ */# ifdef HAVE_AVAHI if (DNSSDClient) { const char *host_name = avahi_client_get_host_name(DNSSDClient); const char *host_fqdn = avahi_client_get_host_name_fqdn(DNSSDClient); cupsdSetString(&DNSSDComputerName, host_name ? host_name : ServerName); if (host_fqdn) cupsdSetString(&DNSSDHostName, host_fqdn); else if (strchr(ServerName, '.')) cupsdSetString(&DNSSDHostName, ServerName); else cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName); } else# endif /* HAVE_AVAHI */ { cupsdSetString(&DNSSDComputerName, ServerName); if (strchr(ServerName, '.')) cupsdSetString(&DNSSDHostName, ServerName); else cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName); } /* * Then (re)register the web interface if enabled... */ if (BrowseWebIF) { if (DNSSDComputerName) snprintf(webif, sizeof(webif), "CUPS @ %s", DNSSDComputerName); else strlcpy(webif, "CUPS", sizeof(webif)); dnssdDeregisterInstance(&WebIFSrv, from_callback); dnssdRegisterInstance(&WebIFSrv, NULL, webif, "_http._tcp", "_printer", DNSSDPort, NULL, 1, from_callback); }}
开发者ID:AndychenCL,项目名称:cups,代码行数:101,
示例16: fsbundle_find_fssubtypestatic uint32_tfsbundle_find_fssubtype(const char *bundle_path_C, const char *claimed_name_C, uint32_t claimed_fssubtype){ uint32_t result = FUSE_FSSUBTYPE_UNKNOWN; CFStringRef bundle_path_string = NULL; CFStringRef claimed_name_string = NULL; CFURLRef bundleURL = NULL; CFBundleRef bundleRef = NULL; CFDictionaryRef fspersonalities = NULL; CFIndex idx = 0; CFIndex count = 0; Boolean found = false; CFStringRef *keys = NULL; CFDictionaryRef *subdicts = NULL; bundle_path_string = CFStringCreateWithCString(kCFAllocatorDefault, bundle_path_C, kCFStringEncodingUTF8); if (!bundle_path_string) { goto out; } bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundle_path_string, kCFURLPOSIXPathStyle, true); if (!bundleURL) { goto out; } bundleRef = CFBundleCreate(kCFAllocatorDefault, bundleURL); if (!bundleRef) { goto out; } fspersonalities = CFBundleGetValueForInfoDictionaryKey( bundleRef, CFSTR(kFSPersonalitiesKey)); if (!fspersonalities) { goto out; } count = CFDictionaryGetCount(fspersonalities); if (count <= 0) { goto out; } keys = (CFStringRef *)malloc(count * sizeof(CFStringRef)); subdicts = (CFDictionaryRef *)malloc(count * sizeof(CFDictionaryRef)); if (!keys || !subdicts) { goto out; } CFDictionaryGetKeysAndValues(fspersonalities, (const void **)keys, (const void **)subdicts); if (claimed_fssubtype == (uint32_t)FUSE_FSSUBTYPE_INVALID) { goto lookupbyfsname; } for (idx = 0; idx < count; idx++) { CFNumberRef n = NULL; uint32_t candidate_fssubtype = (uint32_t)FUSE_FSSUBTYPE_INVALID; if (CFDictionaryGetValueIfPresent(subdicts[idx], (const void *)CFSTR(kFSSubTypeKey), (const void **)&n)) { if (CFNumberGetValue(n, kCFNumberIntType, &candidate_fssubtype)) { if (candidate_fssubtype == claimed_fssubtype) { found = true; result = candidate_fssubtype; break; } } } } if (found) { goto out; }lookupbyfsname: claimed_name_string = CFStringCreateWithCString(kCFAllocatorDefault, claimed_name_C, kCFStringEncodingUTF8); if (!claimed_name_string) { goto out; } for (idx = 0; idx < count; idx++) { CFRange where = CFStringFind(claimed_name_string, keys[idx], kCFCompareCaseInsensitive);//.........这里部分代码省略.........
开发者ID:ThinAir,项目名称:support,代码行数:101,
示例17: _CFPreferencesCreateDomainList__private_extern__ CFArrayRef _CFPreferencesCreateDomainList(CFStringRef userName, CFStringRef hostName) { CFAllocatorRef prefAlloc = __CFPreferencesAllocator(); CFArrayRef domains; CFMutableArrayRef marray; CFStringRef *cachedDomainKeys; CFPreferencesDomainRef *cachedDomains; SInt32 idx, cnt; CFStringRef suffix; UInt32 suffixLen; CFURLRef prefDir = _preferencesDirectoryForUserHost(userName, hostName); if (!prefDir) { return NULL; } if (hostName == kCFPreferencesAnyHost) { suffix = CFStringCreateWithCString(prefAlloc, ".plist", kCFStringEncodingASCII); } else if (hostName == kCFPreferencesCurrentHost) { CFStringRef hostID = _CFPreferencesGetByHostIdentifierString(); suffix = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR(".%@.plist"), hostID); } else { suffix = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR(".%@.plist"), hostName); // sketchy - this allows someone to create a domain list for an arbitrary hostname. } suffixLen = CFStringGetLength(suffix); domains = (CFArrayRef)CFURLCreatePropertyFromResource(prefAlloc, prefDir, kCFURLFileDirectoryContents, NULL); CFRelease(prefDir); if (domains){ marray = CFArrayCreateMutableCopy(prefAlloc, 0, domains); CFRelease(domains); } else { marray = CFArrayCreateMutable(prefAlloc, 0, & kCFTypeArrayCallBacks); } for (idx = CFArrayGetCount(marray)-1; idx >= 0; idx --) { CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(marray, idx); CFStringRef string = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); if (!CFStringHasSuffix(string, suffix)) { CFArrayRemoveValueAtIndex(marray, idx); } else { CFStringRef dom = CFStringCreateWithSubstring(prefAlloc, string, CFRangeMake(0, CFStringGetLength(string) - suffixLen)); if (CFEqual(dom, CFSTR(".GlobalPreferences"))) { CFArraySetValueAtIndex(marray, idx, kCFPreferencesAnyApplication); } else { CFArraySetValueAtIndex(marray, idx, dom); } CFRelease(dom); } CFRelease(string); } CFRelease(suffix); // Now add any domains added in the cache; delete any that have been deleted in the cache __CFSpinLock(&domainCacheLock); if (!domainCache) { __CFSpinUnlock(&domainCacheLock); return marray; } cnt = CFDictionaryGetCount(domainCache); cachedDomainKeys = (CFStringRef *)CFAllocatorAllocate(prefAlloc, 2 * cnt * sizeof(CFStringRef), 0); cachedDomains = (CFPreferencesDomainRef *)(cachedDomainKeys + cnt); CFDictionaryGetKeysAndValues(domainCache, (const void **)cachedDomainKeys, (const void **)cachedDomains); __CFSpinUnlock(&domainCacheLock); suffix = _CFPreferencesCachePrefixForUserHost(userName, hostName); suffixLen = CFStringGetLength(suffix); for (idx = 0; idx < cnt; idx ++) { CFStringRef domainKey = cachedDomainKeys[idx]; CFPreferencesDomainRef domain = cachedDomains[idx]; CFStringRef domainName; CFIndex keyCount = 0; if (!CFStringHasPrefix(domainKey, suffix)) continue; domainName = CFStringCreateWithSubstring(prefAlloc, domainKey, CFRangeMake(suffixLen, CFStringGetLength(domainKey) - suffixLen)); if (CFEqual(domainName, CFSTR("*"))) { CFRelease(domainName); domainName = (CFStringRef)CFRetain(kCFPreferencesAnyApplication); } else if (CFEqual(domainName, kCFPreferencesCurrentApplication)) { CFRelease(domainName); domainName = (CFStringRef)CFRetain(_CFProcessNameString()); } CFDictionaryRef d = _CFPreferencesDomainDeepCopyDictionary(domain); keyCount = d ? CFDictionaryGetCount(d) : 0; if (keyCount) CFRelease(d); if (keyCount == 0) { // Domain was deleted SInt32 firstIndexOfValue = CFArrayGetFirstIndexOfValue(marray, CFRangeMake(0, CFArrayGetCount(marray)), domainName); if (0 <= firstIndexOfValue) { CFArrayRemoveValueAtIndex(marray, firstIndexOfValue); } } else if (!CFArrayContainsValue(marray, CFRangeMake(0, CFArrayGetCount(marray)), domainName)) { CFArrayAppendValue(marray, domainName); } CFRelease(domainName); } CFRelease(suffix); CFAllocatorDeallocate(prefAlloc, cachedDomainKeys); return marray;}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:97,
示例18: add_supplemental_proxiesstatic voidadd_supplemental_proxies(CFMutableArrayRef proxies, CFDictionaryRef services, CFArrayRef service_order){ const void * keys_q[N_QUICK]; const void ** keys = keys_q; CFIndex i; CFIndex n_order; CFIndex n_services; const void * vals_q[N_QUICK]; const void ** vals = vals_q; n_services = isA_CFDictionary(services) ? CFDictionaryGetCount(services) : 0; if (n_services == 0) { return; // if no services } if (n_services > (CFIndex)(sizeof(keys_q) / sizeof(CFTypeRef))) { keys = CFAllocatorAllocate(NULL, n_services * sizeof(CFTypeRef), 0); vals = CFAllocatorAllocate(NULL, n_services * sizeof(CFTypeRef), 0); } n_order = isA_CFArray(service_order) ? CFArrayGetCount(service_order) : 0; CFDictionaryGetKeysAndValues(services, keys, vals); for (i = 0; i < n_services; i++) { uint32_t defaultOrder; CFDictionaryRef proxy; CFMutableDictionaryRef proxyWithDNS = NULL; CFDictionaryRef service = (CFDictionaryRef)vals[i]; if (!isA_CFDictionary(service)) { continue; } proxy = CFDictionaryGetValue(service, kSCEntNetProxies); if (!isA_CFDictionary(proxy)) { continue; } if ((G_supplemental_proxies_follow_dns != NULL) && CFBooleanGetValue(G_supplemental_proxies_follow_dns)) { CFDictionaryRef dns; CFArrayRef matchDomains; CFArrayRef matchOrders; if (!CFDictionaryContainsKey(proxy, kSCPropNetProxiesSupplementalMatchDomains) && CFDictionaryGetValueIfPresent(service, kSCEntNetDNS, (const void **)&dns) && isA_CFDictionary(dns) && CFDictionaryGetValueIfPresent(dns, kSCPropNetDNSSupplementalMatchDomains, (const void **)&matchDomains) && isA_CFArray(matchDomains)) { proxyWithDNS = CFDictionaryCreateMutableCopy(NULL, 0, proxy); CFDictionarySetValue(proxyWithDNS, kSCPropNetProxiesSupplementalMatchDomains, matchDomains); if (CFDictionaryGetValueIfPresent(dns, kSCPropNetDNSSupplementalMatchOrders, (const void **)&matchOrders) && isA_CFArray(matchOrders)) { CFDictionarySetValue(proxyWithDNS, kSCPropNetProxiesSupplementalMatchOrders, matchOrders); } else { CFDictionaryRemoveValue(proxyWithDNS, kSCPropNetProxiesSupplementalMatchOrders); } proxy = proxyWithDNS; } } defaultOrder = DEFAULT_MATCH_ORDER - (DEFAULT_MATCH_ORDER / 2) + ((DEFAULT_MATCH_ORDER / 1000) * i); if ((n_order > 0) && !CFArrayContainsValue(service_order, CFRangeMake(0, n_order), keys[i])) { // push out services not specified in service order defaultOrder += (DEFAULT_MATCH_ORDER / 1000) * n_services; } add_supplemental(proxies, proxy, defaultOrder); if (proxyWithDNS != NULL) CFRelease(proxyWithDNS); } if (keys != keys_q) { CFAllocatorDeallocate(NULL, keys); CFAllocatorDeallocate(NULL, vals); } return;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:81,
示例19: ToUInt32UInt32 CACFDictionary::Size () const{ return ToUInt32(CFDictionaryGetCount(mCFDictionary));}
开发者ID:DannyDeng2014,项目名称:CocoaSampleCode,代码行数:4,
示例20: SecTrustSetOptions/* OS X only: __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) */OSStatusSecTrustSetOptions(SecTrustRef trustRef, SecTrustOptionFlags options){ /* bridge to support API functionality for legacy callers */ OSStatus status = errSecSuccess; CFDataRef encodedExceptions = SecTrustCopyExceptions(trustRef); CFArrayRef exceptions = NULL, oldExceptions = SecTrustGetTrustExceptionsArray(trustRef); if (encodedExceptions) { exceptions = (CFArrayRef)CFPropertyListCreateWithData(kCFAllocatorDefault, encodedExceptions, kCFPropertyListImmutable, NULL, NULL); CFRelease(encodedExceptions); encodedExceptions = NULL; } if (exceptions && CFGetTypeID(exceptions) != CFArrayGetTypeID()) { CFRelease(exceptions); exceptions = NULL; } if (oldExceptions && exceptions && CFArrayGetCount(oldExceptions) > CFArrayGetCount(exceptions)) { oldExceptions = NULL; } /* verify both exceptions are for the same leaf */ if (oldExceptions && exceptions && CFArrayGetCount(oldExceptions) > 0) { CFDictionaryRef oldLeafExceptions = (CFDictionaryRef)CFArrayGetValueAtIndex(oldExceptions, 0); CFDictionaryRef leafExceptions = (CFDictionaryRef)CFArrayGetValueAtIndex(exceptions, 0); CFDataRef oldDigest = (CFDataRef)CFDictionaryGetValue(oldLeafExceptions, CFSTR("SHA1Digest")); CFDataRef digest = (CFDataRef)CFDictionaryGetValue(leafExceptions, CFSTR("SHA1Digest")); if (!oldDigest || !digest || !CFEqual(oldDigest, digest)) { oldExceptions = NULL; } } /* add only those exceptions which are allowed by the supplied options */ if (exceptions) { CFMutableArrayRef filteredExceptions = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); CFIndex i, exceptionCount = (filteredExceptions) ? CFArrayGetCount(exceptions) : 0; for (i = 0; i < exceptionCount; ++i) { CFDictionaryRef exception = (CFDictionaryRef)CFArrayGetValueAtIndex(exceptions, i); CFDictionaryRef oldException = NULL; if (oldExceptions && i < CFArrayGetCount(oldExceptions)) { oldException = (CFDictionaryRef)CFArrayGetValueAtIndex(oldExceptions, i); } CFMutableDictionaryRef filteredException = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); if (exception && filteredException) { SecExceptionFilterContext filterContext = { options, i, trustRef, filteredException, oldException }; CFDictionaryApplyFunction(exception, filter_exception, &filterContext); CFArrayAppendValue(filteredExceptions, filteredException); CFRelease(filteredException); } } if (filteredExceptions) { CFIndex filteredCount = CFArrayGetCount(filteredExceptions); /* remove empty trailing entries to match iOS behavior */ for (i = filteredCount; i-- > 1;) { CFDictionaryRef exception = (CFDictionaryRef)CFArrayGetValueAtIndex(filteredExceptions, i); if (CFDictionaryGetCount(exception) == 0) { CFArrayRemoveValueAtIndex(filteredExceptions, i); } else { break; } } encodedExceptions = CFPropertyListCreateData(kCFAllocatorDefault, filteredExceptions, kCFPropertyListBinaryFormat_v1_0, 0, NULL); CFRelease(filteredExceptions); SecTrustSetExceptions(trustRef, encodedExceptions); CFRelease(encodedExceptions); } CFRelease(exceptions); }#if SECTRUST_DEPRECATION_WARNINGS bool displayModifyMsg = false; bool displayNetworkMsg = false; bool displayPolicyMsg = false; const char *baseMsg = "WARNING: SecTrustSetOptions called with"; const char *modifyMsg = "Use SecTrustSetExceptions and SecTrustCopyExceptions to modify default trust results."; const char *networkMsg = "Use SecTrustSetNetworkFetchAllowed to specify whether missing certificates can be fetched from the network."; const char *policyMsg = "Use SecPolicyCreateRevocation to specify revocation policy requirements."; if (options & kSecTrustOptionAllowExpired) { syslog(LOG_ERR, "%s %s.", baseMsg, "kSecTrustOptionAllowExpired"); displayModifyMsg = true; } if (options & kSecTrustOptionAllowExpiredRoot) { syslog(LOG_ERR, "%s %s.", baseMsg, "kSecTrustOptionAllowExpiredRoot"); displayModifyMsg = true; } if (options & kSecTrustOptionFetchIssuerFromNet) { syslog(LOG_ERR, "%s %s.", baseMsg, "kSecTrustOptionFetchIssuerFromNet"); displayNetworkMsg = true;//.........这里部分代码省略.........
开发者ID:darlinghq,项目名称:darling-security,代码行数:101,
示例21: CFDictionaryRemoveAllValues//.........这里部分代码省略......... else if(kCFCompareEqualTo == CFStringCompare(key, CFSTR("REPLAYGAIN_REFERENCE_LOUDNESS"), kCFCompareCaseInsensitive)) { double num = CFStringGetDoubleValue(value); CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &num); CFDictionarySetValue(mMetadata, kReplayGainReferenceLoudnessKey, number); CFRelease(number), number = NULL; } else if(kCFCompareEqualTo == CFStringCompare(key, CFSTR("REPLAYGAIN_TRACK_GAIN"), kCFCompareCaseInsensitive)) { double num = CFStringGetDoubleValue(value); CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &num); CFDictionarySetValue(mMetadata, kReplayGainTrackGainKey, number); CFRelease(number), number = NULL; } else if(kCFCompareEqualTo == CFStringCompare(key, CFSTR("REPLAYGAIN_TRACK_PEAK"), kCFCompareCaseInsensitive)) { double num = CFStringGetDoubleValue(value); CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &num); CFDictionarySetValue(mMetadata, kReplayGainTrackPeakKey, number); CFRelease(number), number = NULL; } else if(kCFCompareEqualTo == CFStringCompare(key, CFSTR("REPLAYGAIN_ALBUM_GAIN"), kCFCompareCaseInsensitive)) { double num = CFStringGetDoubleValue(value); CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &num); CFDictionarySetValue(mMetadata, kReplayGainAlbumGainKey, number); CFRelease(number), number = NULL; } else if(kCFCompareEqualTo == CFStringCompare(key, CFSTR("REPLAYGAIN_ALBUM_PEAK"), kCFCompareCaseInsensitive)) { double num = CFStringGetDoubleValue(value); CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &num); CFDictionarySetValue(mMetadata, kReplayGainAlbumPeakKey, number); CFRelease(number), number = NULL; } // Put all unknown tags into the additional metadata else CFDictionarySetValue(additionalMetadata, key, value); CFRelease(key), key = NULL; CFRelease(value), value = NULL; fieldName = NULL; fieldValue = NULL; } break; case FLAC__METADATA_TYPE_PICTURE: { CFDataRef data = CFDataCreate(kCFAllocatorDefault, block->data.picture.data, block->data.picture.data_length); CFDictionarySetValue(mMetadata, kAlbumArtFrontCoverKey, data); CFRelease(data), data = NULL; } break; case FLAC__METADATA_TYPE_STREAMINFO: { CFNumberRef sampleRate = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &block->data.stream_info.sample_rate); CFDictionarySetValue(mMetadata, kPropertiesSampleRateKey, sampleRate); CFRelease(sampleRate), sampleRate = NULL; CFNumberRef channelsPerFrame = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &block->data.stream_info.channels); CFDictionarySetValue(mMetadata, kPropertiesChannelsPerFrameKey, channelsPerFrame); CFRelease(channelsPerFrame), channelsPerFrame = NULL; CFNumberRef bitsPerChannel = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &block->data.stream_info.bits_per_sample); CFDictionarySetValue(mMetadata, kPropertiesBitsPerChannelKey, bitsPerChannel); CFRelease(bitsPerChannel), bitsPerChannel = NULL; CFNumberRef totalFrames = CFNumberCreate(kCFAllocatorDefault, kCFNumberLongLongType, &block->data.stream_info.total_samples); CFDictionarySetValue(mMetadata, kPropertiesTotalFramesKey, totalFrames); CFRelease(totalFrames), totalFrames = NULL; double length = static_cast<double>(block->data.stream_info.total_samples / block->data.stream_info.sample_rate); CFNumberRef duration = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &length); CFDictionarySetValue(mMetadata, kPropertiesDurationKey, duration); CFRelease(duration), duration = NULL; double losslessBitrate = static_cast<double>(block->data.stream_info.sample_rate * block->data.stream_info.channels * block->data.stream_info.bits_per_sample) / 1000; CFNumberRef bitrate = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &losslessBitrate); CFDictionarySetValue(mMetadata, kPropertiesBitrateKey, bitrate); CFRelease(bitrate), bitrate = NULL; } break; case FLAC__METADATA_TYPE_PADDING: break; case FLAC__METADATA_TYPE_APPLICATION: break; case FLAC__METADATA_TYPE_SEEKTABLE: break; case FLAC__METADATA_TYPE_CUESHEET: break; case FLAC__METADATA_TYPE_UNDEFINED: break; default: break; } } while(FLAC__metadata_iterator_next(iterator)); if(CFDictionaryGetCount(additionalMetadata)) SetAdditionalMetadata(additionalMetadata); CFRelease(additionalMetadata), additionalMetadata = NULL; FLAC__metadata_iterator_delete(iterator), iterator = NULL; FLAC__metadata_chain_delete(chain), chain = NULL; return true;}
开发者ID:bookshelfapps,项目名称:SFBAudioEngine,代码行数:101,
示例22: APCreateDictionaryForLicenseDataCFDictionaryRef APCreateDictionaryForLicenseData(CFDataRef data){ if (!rsaKey->n || !rsaKey->e) return NULL; // Make the property list from the data CFStringRef errorString = NULL; CFPropertyListRef propertyList; propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, data, kCFPropertyListMutableContainers, &errorString); if (errorString || CFDictionaryGetTypeID() != CFGetTypeID(propertyList) || !CFPropertyListIsValid(propertyList, kCFPropertyListXMLFormat_v1_0)) { if (propertyList) CFRelease(propertyList); return NULL; } // Load the signature CFMutableDictionaryRef licenseDictionary = (CFMutableDictionaryRef)propertyList; if (!CFDictionaryContainsKey(licenseDictionary, CFSTR("Signature"))) { CFRelease(licenseDictionary); return NULL; } CFDataRef sigData = CFDictionaryGetValue(licenseDictionary, CFSTR("Signature")); CFIndex sigDataLength = CFDataGetLength(sigData); UInt8 sigBytes[sigDataLength]; CFDataGetBytes(sigData, CFRangeMake(0, sigDataLength), sigBytes); CFDictionaryRemoveValue(licenseDictionary, CFSTR("Signature")); // Decrypt the signature int checkDigestMaxSize = RSA_size(rsaKey)-11; unsigned char checkDigest[checkDigestMaxSize]; if (RSA_public_decrypt((int) sigDataLength, sigBytes, checkDigest, rsaKey, RSA_PKCS1_PADDING) != SHA_DIGEST_LENGTH) { CFRelease(licenseDictionary); return NULL; } // Get the license hash CFMutableStringRef hashCheck = CFStringCreateMutable(kCFAllocatorDefault,0); int hashIndex; for (hashIndex = 0; hashIndex < SHA_DIGEST_LENGTH; hashIndex++) CFStringAppendFormat(hashCheck, nil, CFSTR("%02x"), checkDigest[hashIndex]); APSetHash(hashCheck); CFRelease(hashCheck); if (blacklist && (CFArrayContainsValue(blacklist, CFRangeMake(0, CFArrayGetCount(blacklist)), hash) == true)) return NULL; // Get the number of elements CFIndex count = CFDictionaryGetCount(licenseDictionary); // Load the keys and build up the key array CFMutableArrayRef keyArray = CFArrayCreateMutable(kCFAllocatorDefault, count, NULL); CFStringRef keys[count]; CFDictionaryGetKeysAndValues(licenseDictionary, (const void**)&keys, NULL); int i; for (i = 0; i < count; i++) CFArrayAppendValue(keyArray, keys[i]); // Sort the array int context = kCFCompareCaseInsensitive; CFArraySortValues(keyArray, CFRangeMake(0, count), (CFComparatorFunction)CFStringCompare, &context); // Setup up the hash context SHA_CTX ctx; SHA1_Init(&ctx); // Convert into UTF8 strings for (i = 0; i < count; i++) { char *valueBytes; CFIndex valueLengthAsUTF8; CFStringRef key = CFArrayGetValueAtIndex(keyArray, i); CFStringRef value = CFDictionaryGetValue(licenseDictionary, key); // Account for the null terminator valueLengthAsUTF8 = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value), kCFStringEncodingUTF8) + 1; valueBytes = (char *)malloc(valueLengthAsUTF8); CFStringGetCString(value, valueBytes, valueLengthAsUTF8, kCFStringEncodingUTF8); SHA1_Update(&ctx, valueBytes, strlen(valueBytes)); free(valueBytes); } unsigned char digest[SHA_DIGEST_LENGTH]; SHA1_Final(digest, &ctx); if (keyArray != NULL) CFRelease(keyArray); // Check if the signature is a match for (i = 0; i < SHA_DIGEST_LENGTH; i++) { if (checkDigest[i] ^ digest[i]) { CFRelease(licenseDictionary); return NULL; } } // If it's a match, we return the dictionary; otherwise, we never reach this return licenseDictionary;}
开发者ID:samdeane,项目名称:AquaticPrime,代码行数:96,
示例23: _writeXMLFile// domain should already be locked.static Boolean _writeXMLFile(CFURLRef url, CFMutableDictionaryRef dict, Boolean isWorldReadable, Boolean *tryAgain) { Boolean success = false; CFAllocatorRef alloc = __CFPreferencesAllocator(); *tryAgain = false; if (CFDictionaryGetCount(dict) == 0) { // Destroy the file CFBooleanRef val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, url, kCFURLFileExists, NULL); if (val && CFBooleanGetValue(val)) { success = CFURLDestroyResource(url, NULL); } else { success = true; } if (val) CFRelease(val); } else { CFPropertyListFormat desiredFormat = __CFPreferencesShouldWriteXML() ? kCFPropertyListXMLFormat_v1_0 : kCFPropertyListBinaryFormat_v1_0; CFDataRef data = CFPropertyListCreateData(alloc, dict, desiredFormat, 0, NULL); if (data) { SInt32 mode;#if TARGET_OS_OSX || TARGET_OS_LINUX mode = isWorldReadable ? S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH : S_IRUSR|S_IWUSR;#else mode = 0666;#endif#if TARGET_OS_OSX { // Try quick atomic way first, then fallback to slower ways and error cases CFStringRef scheme = CFURLCopyScheme(url); if (!scheme) { *tryAgain = false; CFRelease(data); return false; } else if (CFStringCompare(scheme, CFSTR("file"), 0) == kCFCompareEqualTo) { SInt32 length = CFDataGetLength(data); const void *bytes = (0 == length) ? (const void *)"" : CFDataGetBytePtr(data); Boolean atomicWriteSuccess = __CFWriteBytesToFileWithAtomicity(url, bytes, length, mode, true); if (atomicWriteSuccess) { CFRelease(scheme); *tryAgain = false; CFRelease(data); return true; } if (!atomicWriteSuccess && thread_errno() == ENOSPC) { CFRelease(scheme); *tryAgain = false; CFRelease(data); return false; } } CFRelease(scheme); }#endif success = CFURLWriteDataAndPropertiesToResource(url, data, URLPropertyDictForPOSIXMode(mode), NULL); URLPropertyDictRelease(); if (success) { CFDataRef readData; if (!CFURLCreateDataAndPropertiesFromResource(alloc, url, &readData, NULL, NULL, NULL) || !CFEqual(readData, data)) { success = false; *tryAgain = true; } if (readData) CFRelease(readData); } else { CFBooleanRef val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, url, kCFURLFileExists, NULL); if (!val || !CFBooleanGetValue(val)) { CFURLRef tmpURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("."), kCFURLPOSIXPathStyle, true, url); // Just "." because url is not a directory URL CFURLRef parentURL = tmpURL ? CFURLCopyAbsoluteURL(tmpURL) : NULL; if (tmpURL) CFRelease(tmpURL); if (val) CFRelease(val); val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, parentURL, kCFURLFileExists, NULL); if ((!val || !CFBooleanGetValue(val)) && _createDirectory(parentURL, isWorldReadable)) { // parent directory didn't exist; now it does; try again to write success = CFURLWriteDataAndPropertiesToResource(url, data, URLPropertyDictForPOSIXMode(mode), NULL); URLPropertyDictRelease(); if (success) { CFDataRef rdData; if (!CFURLCreateDataAndPropertiesFromResource(alloc, url, &rdData, NULL, NULL, NULL) || !CFEqual(rdData, data)) { success = false; *tryAgain = true; } if (rdData) CFRelease(rdData); } } if (parentURL) CFRelease(parentURL); } if (val) CFRelease(val); } CFRelease(data); } else { // ??? This should never happen CFLog(__kCFLogAssertion, CFSTR("Could not generate XML data for property list")); success = false; } } return success;}
开发者ID:JGiola,项目名称:swift-corelibs-foundation,代码行数:95,
示例24: SCNetworkSetCopyServicesCFArrayRef /* of SCNetworkServiceRef's */SCNetworkSetCopyServices(SCNetworkSetRef set){ CFMutableArrayRef array; CFDictionaryRef dict; CFIndex n; CFStringRef path; SCNetworkSetPrivateRef setPrivate = (SCNetworkSetPrivateRef)set; if (!isA_SCNetworkSet(set)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } path = SCPreferencesPathKeyCreateSetNetworkService(NULL, setPrivate->setID, NULL); dict = SCPreferencesPathGetValue(setPrivate->prefs, path); CFRelease(path); if ((dict != NULL) && !isA_CFDictionary(dict)) { return NULL; } array = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); n = (dict != NULL) ? CFDictionaryGetCount(dict) : 0; if (n > 0) { CFIndex i; const void * keys_q[N_QUICK]; const void ** keys = keys_q; if (n > (CFIndex)(sizeof(keys_q) / sizeof(CFTypeRef))) { keys = CFAllocatorAllocate(NULL, n * sizeof(CFTypeRef), 0); } CFDictionaryGetKeysAndValues(dict, keys, NULL); for (i = 0; i < n; i++) { CFArrayRef components; CFStringRef link; path = SCPreferencesPathKeyCreateSetNetworkServiceEntity(NULL, setPrivate->setID, (CFStringRef)keys[i], NULL); link = SCPreferencesPathGetLink(setPrivate->prefs, path); CFRelease(path); if (link == NULL) { SC_log(LOG_INFO, "service /"%@/" for set /"%@/" is not a link", keys[i], setPrivate->setID); continue; // if the service is not a link } components = CFStringCreateArrayBySeparatingStrings(NULL, link, CFSTR("/")); if (CFArrayGetCount(components) == 3) { CFStringRef serviceID; serviceID = CFArrayGetValueAtIndex(components, 2); path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator serviceID, // service NULL); // entity if (CFEqual(path, link)) { SCNetworkServicePrivateRef servicePrivate; servicePrivate = __SCNetworkServiceCreatePrivate(NULL, setPrivate->prefs, serviceID, NULL); CFArrayAppendValue(array, (SCNetworkServiceRef)servicePrivate); CFRelease(servicePrivate); } CFRelease(path); } CFRelease(components); } if (keys != keys_q) { CFAllocatorDeallocate(NULL, keys); } } return array;}
开发者ID:carriercomm,项目名称:osx-2,代码行数:79,
示例25: createMkext1ForArchCFDataRef createMkext1ForArch(const NXArchInfo * arch, CFArrayRef archiveKexts, boolean_t compress){ CFMutableDataRef result = NULL; CFMutableDictionaryRef kextsByIdentifier = NULL; Mkext1Context context; mkext1_header * mkextHeader = NULL; // do not free const uint8_t * adler_point = 0; CFIndex count, i; result = CFDataCreateMutable(kCFAllocatorDefault, /* capaacity */ 0); if (!result || !createCFMutableDictionary(&kextsByIdentifier)) { OSKextLogMemError(); goto finish; } /* mkext1 can only contain 1 kext for a given bundle identifier, so we * have to pick out the most recent versions. */ count = CFArrayGetCount(archiveKexts); for (i = 0; i < count; i++) { OSKextRef theKext = (OSKextRef)CFArrayGetValueAtIndex(archiveKexts, i); CFStringRef bundleIdentifier = OSKextGetIdentifier(theKext); OSKextRef savedKext = (OSKextRef)CFDictionaryGetValue(kextsByIdentifier, bundleIdentifier); OSKextVersion thisVersion, savedVersion; if (!OSKextSupportsArchitecture(theKext, arch)) { continue; } if (!savedKext) { CFDictionarySetValue(kextsByIdentifier, bundleIdentifier, theKext); continue; } thisVersion = OSKextGetVersion(theKext); savedVersion = OSKextGetVersion(savedKext); if (thisVersion > savedVersion) { CFDictionarySetValue(kextsByIdentifier, bundleIdentifier, theKext); } } /* Add room for the mkext header and kext descriptors. */ CFDataSetLength(result, sizeof(mkext1_header) + CFDictionaryGetCount(kextsByIdentifier) * sizeof(mkext_kext)); context.mkext = result; context.kextIndex = 0; context.compressOffset = (uint32_t)CFDataGetLength(result); context.arch = arch; context.fatal = false; context.compress = compress; CFDictionaryApplyFunction(kextsByIdentifier, addToMkext1, &context); if (context.fatal) { SAFE_RELEASE_NULL(result); goto finish; } mkextHeader = (mkext1_header *)CFDataGetBytePtr(result); mkextHeader->magic = OSSwapHostToBigInt32(MKEXT_MAGIC); mkextHeader->signature = OSSwapHostToBigInt32(MKEXT_SIGN); mkextHeader->version = OSSwapHostToBigInt32(0x01008000); // 'vers' 1.0.0 mkextHeader->numkexts = OSSwapHostToBigInt32((__uint32_t)CFDictionaryGetCount(kextsByIdentifier)); mkextHeader->cputype = OSSwapHostToBigInt32(arch->cputype); mkextHeader->cpusubtype = OSSwapHostToBigInt32(arch->cpusubtype); mkextHeader->length = OSSwapHostToBigInt32((__uint32_t)CFDataGetLength(result)); adler_point = (UInt8 *)&mkextHeader->version; mkextHeader->adler32 = OSSwapHostToBigInt32(local_adler32( (UInt8 *)&mkextHeader->version, (int)(CFDataGetLength(result) - (adler_point - (uint8_t *)mkextHeader)))); OSKextLog(/* kext */ NULL, kOSKextLogProgressLevel | kOSKextLogArchiveFlag, "Created mkext for %s containing %lu kexts.", arch->name, CFDictionaryGetCount(kextsByIdentifier));finish: SAFE_RELEASE(kextsByIdentifier); return result;}
开发者ID:andyvand,项目名称:KextToolsLZVN_Mavericks,代码行数:86,
示例26: FLAC__metadata_chain_new//.........这里部分代码省略......... CFRelease(errorDictionary), errorDictionary = NULL; } FLAC__metadata_chain_delete(chain), chain = NULL; FLAC__metadata_iterator_delete(iterator), iterator = NULL; return false; } } else block = FLAC__metadata_iterator_get_block(iterator); // Standard tags SetVorbisComment(block, "ALBUM", GetAlbumTitle()); SetVorbisComment(block, "ARTIST", GetArtist()); SetVorbisComment(block, "ALBUMARTIST", GetAlbumArtist()); SetVorbisComment(block, "COMPOSER", GetComposer()); SetVorbisComment(block, "GENRE", GetGenre()); SetVorbisComment(block, "DATE", GetReleaseDate()); SetVorbisComment(block, "DESCRIPTION", GetComment()); SetVorbisComment(block, "TITLE", GetTitle()); SetVorbisCommentNumber(block, "TRACKNUMBER", GetTrackNumber()); SetVorbisCommentNumber(block, "TRACKTOTAL", GetTrackTotal()); SetVorbisCommentBoolean(block, "COMPILATION", GetCompilation()); SetVorbisCommentNumber(block, "DISCNUMBER", GetDiscNumber()); SetVorbisCommentNumber(block, "DISCTOTAL", GetDiscTotal()); SetVorbisComment(block, "ISRC", GetISRC()); SetVorbisComment(block, "MCN", GetMCN()); // Additional metadata CFDictionaryRef additionalMetadata = GetAdditionalMetadata(); if(NULL != additionalMetadata) { CFIndex count = CFDictionaryGetCount(additionalMetadata); const void * keys [count]; const void * values [count]; CFDictionaryGetKeysAndValues(additionalMetadata, reinterpret_cast<const void **>(keys), reinterpret_cast<const void **>(values)); for(CFIndex i = 0; i < count; ++i) { CFIndex keySize = CFStringGetMaximumSizeForEncoding(CFStringGetLength(reinterpret_cast<CFStringRef>(keys[i])), kCFStringEncodingASCII); char key [keySize + 1]; if(!CFStringGetCString(reinterpret_cast<CFStringRef>(keys[i]), key, keySize + 1, kCFStringEncodingASCII)) { log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("org.sbooth.AudioEngine.AudioMetadata.FLAC"); LOG4CXX_WARN(logger, "CFStringGetCString() failed"); continue; } SetVorbisComment(block, key, reinterpret_cast<CFStringRef>(values[i])); } } // ReplayGain info SetVorbisCommentDouble(block, "REPLAYGAIN_REFERENCE_LOUDNESS", GetReplayGainReferenceLoudness(), CFSTR("%2.1f dB")); SetVorbisCommentDouble(block, "REPLAYGAIN_TRACK_GAIN", GetReplayGainReferenceLoudness(), CFSTR("%+2.2f dB")); SetVorbisCommentDouble(block, "REPLAYGAIN_TRACK_PEAK", GetReplayGainTrackGain(), CFSTR("%1.8f")); SetVorbisCommentDouble(block, "REPLAYGAIN_ALBUM_GAIN", GetReplayGainAlbumGain(), CFSTR("%+2.2f dB")); SetVorbisCommentDouble(block, "REPLAYGAIN_ALBUM_PEAK", GetReplayGainAlbumPeak(), CFSTR("%1.8f")); // Write the new metadata to the file if(!FLAC__metadata_chain_write(chain, true, false)) { if(NULL != error) {
开发者ID:bookshelfapps,项目名称:SFBAudioEngine,代码行数:67,
示例27: apple_register_profiles//.........这里部分代码省略......... CFRelease(profiles); ppdClose(ppd); return; } switch (ppd->colorspace) { default : case PPD_CS_RGB : case PPD_CS_CMY : profile_id = _ppdHashName("RGB.."); apple_init_profile(ppd, NULL, profile, profile_id, "RGB", "RGB", NULL); break; case PPD_CS_RGBK : case PPD_CS_CMYK : profile_id = _ppdHashName("CMYK.."); apple_init_profile(ppd, NULL, profile, profile_id, "CMYK", "CMYK", NULL); break; case PPD_CS_GRAY : if (attr) break; case PPD_CS_N : profile_id = _ppdHashName("DeviceN.."); apple_init_profile(ppd, NULL, profile, profile_id, "DeviceN", "DeviceN", NULL); break; } if (CFDictionaryGetCount(profile) > 0) { dict_key = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%u"), profile_id); if (dict_key) { CFDictionarySetValue(profiles, dict_key, profile); CFRelease(dict_key); } } CFRelease(profile); } if (num_profiles > 0) { /* * Make sure we have a default profile ID... */ if (!default_profile_id) default_profile_id = profile_id; /* Last profile */ dict_key = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%u"), default_profile_id); if (dict_key) { CFDictionarySetValue(profiles, kColorSyncDeviceDefaultProfileID, dict_key); CFRelease(dict_key); } /*
开发者ID:Cacauu,项目名称:cups,代码行数:67,
示例28: KJSValueToJSObjectbool UserObjectImp::toBoolean(ExecState *exec) const{ bool result = false; JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec); CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0; if (cfValue) { CFTypeID cfType = CFGetTypeID(cfValue); // toPrimitive if (cfValue == GetCFNull()) { // } else if (cfType == CFBooleanGetTypeID()) { if (cfValue == kCFBooleanTrue) { result = true; } } else if (cfType == CFStringGetTypeID()) { if (CFStringGetLength((CFStringRef)cfValue)) { result = true; } } else if (cfType == CFNumberGetTypeID()) { if (cfValue != kCFNumberNaN) { double d; if (CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &d)) { if (d != 0) { result = true; } } } } else if (cfType == CFArrayGetTypeID()) { if (CFArrayGetCount((CFArrayRef)cfValue)) { result = true; } } else if (cfType == CFDictionaryGetTypeID()) { if (CFDictionaryGetCount((CFDictionaryRef)cfValue)) { result = true; } } else if (cfType == CFSetGetTypeID()) { if (CFSetGetCount((CFSetRef)cfValue)) { result = true; } } else if (cfType == CFURLGetTypeID()) { CFURLRef absURL = CFURLCopyAbsoluteURL((CFURLRef)cfValue); if (absURL) { CFStringRef cfStr = CFURLGetString(absURL); if (cfStr && CFStringGetLength(cfStr)) { result = true; } ReleaseCFType(absURL); } } } if (jsObjPtr) jsObjPtr->Release(); ReleaseCFType(cfValue); return result;}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:79,
示例29: CFBundleGetValueForInfoDictionaryKeybool PluginPackage::fetchInfo(){ if (!load()) return false; WTF::RetainPtr<CFDictionaryRef> mimeDict; WTF::RetainPtr<CFTypeRef> mimeTypesFileName = CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginMIMETypesFilename")); if (mimeTypesFileName && CFGetTypeID(mimeTypesFileName.get()) == CFStringGetTypeID()) { WTF::RetainPtr<CFStringRef> fileName = (CFStringRef)mimeTypesFileName.get(); WTF::RetainPtr<CFStringRef> homeDir = homeDirectoryPath().createCFString(); WTF::RetainPtr<CFStringRef> path = CFStringCreateWithFormat(0, 0, CFSTR("%@/Library/Preferences/%@"), homeDir.get(), fileName.get()); WTF::RetainPtr<CFDictionaryRef> plist = readPListFile(path.get(), /*createFile*/ false, m_module); if (plist) { // If the plist isn't localized, have the plug-in recreate it in the preferred language. WTF::RetainPtr<CFStringRef> localizationName = (CFStringRef)CFDictionaryGetValue(plist.get(), CFSTR("WebPluginLocalizationName")); CFLocaleRef locale = CFLocaleCopyCurrent(); if (localizationName != CFLocaleGetIdentifier(locale)) plist = readPListFile(path.get(), /*createFile*/ true, m_module); CFRelease(locale); } else { // Plist doesn't exist, ask the plug-in to create it. plist = readPListFile(path.get(), /*createFile*/ true, m_module); } mimeDict = (CFDictionaryRef)CFDictionaryGetValue(plist.get(), CFSTR("WebPluginMIMETypes")); } if (!mimeDict) mimeDict = (CFDictionaryRef)CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginMIMETypes")); if (mimeDict) { CFIndex propCount = CFDictionaryGetCount(mimeDict.get()); Vector<const void*, 128> keys(propCount); Vector<const void*, 128> values(propCount); CFDictionaryGetKeysAndValues(mimeDict.get(), keys.data(), values.data()); for (int i = 0; i < propCount; ++i) { String mimeType = (CFStringRef)keys[i]; mimeType = mimeType.lower(); WTF::RetainPtr<CFDictionaryRef> extensionsDict = (CFDictionaryRef)values[i]; WTF:RetainPtr<CFNumberRef> enabled = (CFNumberRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeEnabled")); if (enabled) { int enabledValue = 0; if (CFNumberGetValue(enabled.get(), kCFNumberIntType, &enabledValue) && enabledValue == 0) continue; } Vector<String> mimeExtensions; WTF::RetainPtr<CFArrayRef> extensions = (CFArrayRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginExtensions")); if (extensions) { CFIndex extensionCount = CFArrayGetCount(extensions.get()); for (CFIndex i = 0; i < extensionCount; ++i) { String extension =(CFStringRef)CFArrayGetValueAtIndex(extensions.get(), i); extension = extension.lower(); mimeExtensions.append(extension); } } m_mimeToExtensions.set(mimeType, mimeExtensions); String description = (CFStringRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeDescription")); m_mimeToDescriptions.set(mimeType, description); } m_name = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginName")); m_description = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginDescription")); } else { int resFile = CFBundleOpenBundleResourceMap(m_module); UseResFile(resFile); Vector<String> mimes = stringListFromResourceId(MIMEListStringStringNumber); if (mimes.size() % 2 != 0) return false; Vector<String> descriptions = stringListFromResourceId(MIMEDescriptionStringNumber); if (descriptions.size() != mimes.size() / 2) return false; for (size_t i = 0; i < mimes.size(); i += 2) { String mime = mimes[i].lower(); Vector<String> extensions; mimes[i + 1].lower().split(UChar(','), extensions); m_mimeToExtensions.set(mime, extensions); m_mimeToDescriptions.set(mime, descriptions[i / 2]); } Vector<String> names = stringListFromResourceId(PluginNameOrDescriptionStringNumber); if (names.size() == 2) { m_description = names[0]; m_name = names[1];//.........这里部分代码省略.........
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:101,
注:本文中的CFDictionaryGetCount函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CFDictionaryGetKeysAndValues函数代码示例 C++ CFDictionaryCreateMutableCopy函数代码示例 |