本文整理匯總了C++中CFDictionaryGetCount函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFDictionaryGetCount函數的具體用法?C++ CFDictionaryGetCount怎麽用?C++ CFDictionaryGetCount使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFDictionaryGetCount函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例5: encode
void 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]);
}
}
示例6: CFDictionaryCreateMutableCopy
CFDictionaryRef 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;
}
示例7: getVolatileKeysAndValues
static 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;
}
示例8: CFURLRequestGetURL
void 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());
}
示例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;
}
示例10: getXMLKeysAndValues
static 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);
}
示例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);
}
}
}
}
}
示例12: debugCallback
void
debugCallback(
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]));
}
}
示例13: ivar_dict_foreach
static void
ivar_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);
}
示例14: isSoftwareUpdateDevelopment
static 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;
}
示例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);
}
}