本文整理匯總了C++中CFDictionaryCreate函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFDictionaryCreate函數的具體用法?C++ CFDictionaryCreate怎麽用?C++ CFDictionaryCreate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFDictionaryCreate函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: setCookies
void setCookies(const KURL& url, const KURL& policyURL, const String& value)
{
#if USE(CFNETWORK)
if (!ResourceHandle::cookieStorage())
return;
RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
RetainPtr<CFURLRef> policyURLCF(AdoptCF, policyURL.createCFURL());
// <http://bugzilla.opendarwin.org/show_bug.cgi?id=6531>, <rdar://4409034>
// cookiesWithResponseHeaderFields doesn't parse cookies without a value
String cookieString = value.contains('=') ? value : value + "=";
RetainPtr<CFStringRef> cookieStringCF(AdoptCF, cookieString.createCFString());
RetainPtr<CFDictionaryRef> headerFieldsCF(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, (const void**)&s_setCookieKeyCF,
(const void**)&cookieStringCF, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault,
headerFieldsCF.get(), urlCF.get()));
CFHTTPCookieStorageSetCookies(ResourceHandle::cookieStorage(), cookiesCF.get(), urlCF.get(), policyURLCF.get());
#else
// FIXME: Deal with the policy URL.
DeprecatedString str = url.url();
str.append((UChar)'\0');
DeprecatedString val = value.deprecatedString();
val.append((UChar)'\0');
InternetSetCookie((UChar*)str.unicode(), 0, (UChar*)val.unicode());
#endif
}
示例2: _CFErrorFromStreamError
CF_PRIVATE CFErrorRef _CFErrorFromStreamError(CFAllocatorRef alloc, CFStreamError *streamError) {
CFErrorRef result;
Boolean canUpCall;
__CFLock(&(CFNetworkSupport.lock));
if (!__CFBitIsSet(CFNetworkSupport.flags, kTriedToLoad)) initializeCFNetworkSupport();
canUpCall = (CFNetworkSupport._CFErrorCreateWithStreamError != NULL);
__CFUnlock(&(CFNetworkSupport.lock));
if (canUpCall) {
result = CFNETWORK_CALL(_CFErrorCreateWithStreamError, (alloc, streamError));
} else {
if (streamError->domain == kCFStreamErrorDomainPOSIX) {
return CFErrorCreate(alloc, kCFErrorDomainPOSIX, streamError->error, NULL);
} else if (streamError->domain == kCFStreamErrorDomainMacOSStatus) {
return CFErrorCreate(alloc, kCFErrorDomainOSStatus, streamError->error, NULL);
} else {
CFStringRef key = CFSTR("CFStreamErrorDomainKey");
CFNumberRef value = CFNumberCreate(alloc, kCFNumberCFIndexType, &streamError->domain);
CFDictionaryRef dict = CFDictionaryCreate(alloc, (const void **)(&key), (const void **)(&value), 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
result = CFErrorCreate(alloc, CFSTR("BogusCFStreamErrorCompatibilityDomain"), streamError->error, dict);
CFRelease(value);
CFRelease(dict);
}
}
return result;
}
示例3: SendSkypeCommand
void SendSkypeCommand(CFStringRef command)
{
if (delegate == NULL)
{
printf("Can't send message, no delegate set\n");
return;
}
if (command == NULL)
return;
if (!client_id)
{
printf("Can't send message, not connected\n");
return;
}
CFRetain(command);
CFNumberRef id_number = CFNumberCreate(NULL, kCFNumberIntType, &client_id);
CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
const void *keys[] = {(void *)CFSTR("SKYPE_API_COMMAND"), (void *)CFSTR("SKYPE_API_CLIENT_ID")};
const void *values[] = {command, id_number};
CFDictionaryRef userInfo = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
//send message
CFNotificationCenterPostNotification(
center,
CFSTR("SKSkypeAPICommand"),
NULL,
userInfo,
FALSE);
CFRelease(command);
CFRelease(id_number);
CFRelease(userInfo);
}
示例4: CFDictionaryCreate
bool
OSXKeyState::getGroups(GroupList& groups) const
{
CFIndex n;
bool gotLayouts = false;
// get number of layouts
CFStringRef keys[] = { kTISPropertyInputSourceCategory };
CFStringRef values[] = { kTISCategoryKeyboardInputSource };
CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 1, NULL, NULL);
CFArrayRef kbds = TISCreateInputSourceList(dict, false);
n = CFArrayGetCount(kbds);
gotLayouts = (n != 0);
if (!gotLayouts) {
LOG((CLOG_DEBUG1 "can't get keyboard layouts"));
return false;
}
// get each layout
groups.clear();
for (CFIndex i = 0; i < n; ++i) {
bool addToGroups = true;
TISInputSourceRef keyboardLayout =
(TISInputSourceRef)CFArrayGetValueAtIndex(kbds, i);
if (addToGroups)
groups.push_back(keyboardLayout);
}
return true;
}
示例5: __JSONParserAppendMapEnd
inline int __JSONParserAppendMapEnd(void *context) {
int success = 0;
__JSONRef json = (__JSONRef)context;
__JSONStackEntryRef entry = __JSONStackPop(json->stack);
if (entry) {
if (entry->keysIndex == entry->valuesIndex) {
CFTypeRef *keys = __JSONStackEntryCreateKeys(entry, json->elements);
if (keys) {
CFTypeRef *values = __JSONStackEntryCreateValues(entry, json->elements);
if (values) {
json->elements[entry->index] = CFDictionaryCreate(json->allocator, keys, values, entry->keysIndex, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFAllocatorDeallocate(entry->allocator, values);
success = 1;
}
CFAllocatorDeallocate(entry->allocator, keys);
}
} else {
// TODO: The number of keys and values does not match
}
__JSONStackEntryRelease(entry);
} else {
// TODO: Container on the stack can't be NULL (too deep?)
}
return success;
}
示例6: GTMCFLaunchCreateUnlocalizedError
static CFErrorRef GTMCFLaunchCreateUnlocalizedError(CFIndex code,
CFStringRef format, ...) {
CFDictionaryRef user_info = NULL;
if (format) {
va_list args;
va_start(args, format);
CFStringRef string
= CFStringCreateWithFormatAndArguments(kCFAllocatorDefault,
NULL,
format,
args);
user_info = CFDictionaryCreate(kCFAllocatorDefault,
(const void **)&kCFErrorDescriptionKey,
(const void **)&string,
1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease(string);
va_end(args);
}
CFErrorRef error = CFErrorCreate(kCFAllocatorDefault,
kCFErrorDomainPOSIX,
code,
user_info);
if (user_info) {
CFRelease(user_info);
}
return error;
}
示例7: CFNetworkCopyProxiesForURL
CFArrayRef CFNetworkCopyProxiesForURL(CFURLRef url, CFDictionaryRef proxySettings) {
CFDictionaryRef noSettings = CFDictionaryCreate(NULL,
(CFTypeRef*)&kCFProxyTypeKey, (CFTypeRef*)&kCFProxyTypeNone, 1,
&kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFArrayRef proxies = CFArrayCreate(NULL, (CFTypeRef*)&noSettings, 1, &kCFTypeArrayCallBacks);
CFRelease(noSettings);
return proxies;
}
示例8: createPixelBufferOptionsDictionary
static CFDictionaryRef createPixelBufferOptionsDictionary(QTPixelBuffer::Type contextType)
{
const void* key = kQTVisualContextPixelBufferAttributesKey;
const void* value = QTPixelBuffer::createPixelBufferAttributesDictionary(contextType);
CFDictionaryRef pixelBufferOptions = CFDictionaryCreate(kCFAllocatorDefault, &key, &value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFRelease(value);
return pixelBufferOptions;
}
示例9: IPv6ConfigDictCreate
static CFDictionaryRef
IPv6ConfigDictCreate(const char * ifname,
int argc, char * argv[], const char * cmd,
const char * method_name,
CFStringRef config_method)
{
CFDictionaryRef dict;
CFMutableDictionaryRef ipv6_dict;
CFStringRef ipv6_key;
ipv6_dict = CFDictionaryCreateMutable(NULL, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(ipv6_dict, kSCPropNetIPv6ConfigMethod,
config_method);
if (config_method == kSCValNetIPv6ConfigMethodManual) {
struct in6_addr ip_address;
int prefix_length;
if (argc != 2) {
fprintf(stderr, "usage: ipconfig %s %s "
"%s6 <ipv6-address> <prefix-length>\n",
cmd, ifname, method_name);
goto failed;
}
if (inet_pton(AF_INET6, argv[0], &ip_address) != 1) {
fprintf(stderr, "Invalid IPv6 address %s\n", argv[0]);
goto failed;
}
my_CFDictionarySetIPv6AddressAsArrayValue(ipv6_dict,
kSCPropNetIPv6Addresses,
&ip_address);
prefix_length = (int)strtol(argv[1], NULL, 0);
if (prefix_length < 0 || prefix_length > 128) {
fprintf(stderr, "Invalid prefix_length %s\n", argv[1]);
goto failed;
}
my_CFDictionarySetIntegerAsArrayValue(ipv6_dict,
kSCPropNetIPv6PrefixLength,
prefix_length);
}
else if (argc != 0) {
fprintf(stderr, "too many arguments for method\n");
goto failed;
}
ipv6_key = kSCEntNetIPv6;
dict = CFDictionaryCreate(NULL,
(const void * *)&ipv6_key,
(const void * *)&ipv6_dict, 1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease(ipv6_dict);
return (dict);
failed:
my_CFRelease(&ipv6_dict);
return (NULL);
}
示例10: createImageSourceOptions
static RetainPtr<CFDictionaryRef> createImageSourceOptions(SubsamplingLevel subsamplingLevel)
{
if (!subsamplingLevel) {
const unsigned numOptions = 3;
const void* keys[numOptions] = { kCGImageSourceShouldCache, kCGImageSourceShouldPreferRGB32, kCGImageSourceSkipMetadata };
const void* values[numOptions] = { kCFBooleanTrue, kCFBooleanTrue, kCFBooleanTrue };
return CFDictionaryCreate(nullptr, keys, values, numOptions, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
short constrainedSubsamplingLevel = std::min<short>(3, std::max<short>(0, subsamplingLevel));
int subsampleInt = 1 << constrainedSubsamplingLevel; // [0..3] => [1, 2, 4, 8]
RetainPtr<CFNumberRef> subsampleNumber = adoptCF(CFNumberCreate(nullptr, kCFNumberIntType, &subsampleInt));
const CFIndex numOptions = 4;
const void* keys[numOptions] = { kCGImageSourceShouldCache, kCGImageSourceShouldPreferRGB32, kCGImageSourceSkipMetadata, kCGImageSourceSubsampleFactor };
const void* values[numOptions] = { kCFBooleanTrue, kCFBooleanTrue, kCFBooleanTrue, subsampleNumber.get() };
return adoptCF(CFDictionaryCreate(nullptr, keys, values, numOptions, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
}
示例11: CFDataCreate
CFDictionaryRef
AppleVTDecoder::CreateDecoderExtensions()
{
AutoCFRelease<CFDataRef> avc_data =
CFDataCreate(kCFAllocatorDefault,
mExtraData->Elements(),
mExtraData->Length());
const void* atomsKey[] = { CFSTR("avcC") };
const void* atomsValue[] = { avc_data };
static_assert(ArrayLength(atomsKey) == ArrayLength(atomsValue),
"Non matching keys/values array size");
AutoCFRelease<CFDictionaryRef> atoms =
CFDictionaryCreate(kCFAllocatorDefault,
atomsKey,
atomsValue,
ArrayLength(atomsKey),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
const void* extensionKeys[] =
{ kCVImageBufferChromaLocationBottomFieldKey,
kCVImageBufferChromaLocationTopFieldKey,
AppleCMLinker::skPropExtensionAtoms,
AppleCMLinker::skPropFullRangeVideo /* Not defined in 10.6 */ };
const void* extensionValues[] =
{ kCVImageBufferChromaLocation_Left,
kCVImageBufferChromaLocation_Left,
atoms,
kCFBooleanTrue };
static_assert(ArrayLength(extensionKeys) == ArrayLength(extensionValues),
"Non matching keys/values array size");
return CFDictionaryCreate(kCFAllocatorDefault,
extensionKeys,
extensionValues,
AppleCMLinker::skPropFullRangeVideo ?
ArrayLength(extensionKeys) :
ArrayLength(extensionKeys) - 1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
示例12: CFQDictionaryCreateWithArrayOfKeysAndValues
extern pascal OSStatus CFQDictionaryCreateWithArrayOfKeysAndValues(CFArrayRef keys,
CFArrayRef values,
CFDictionaryRef *result)
// See comment in header.
{
OSStatus err;
CFIndex count;
CFTypeRef * keysBuffer;
CFTypeRef * valuesBuffer;
assert(keys != NULL);
assert(values != NULL);
assert( CFArrayGetCount(keys) == CFArrayGetCount(values) );
assert( result != NULL);
assert(*result == NULL);
keysBuffer = NULL;
valuesBuffer = NULL;
// Check that the arrays are of a like size.
err = noErr;
count = CFArrayGetCount(keys);
if ( count != CFArrayGetCount(values) ) {
err = paramErr;
}
// Allocate a buffer for both keys and values.
if (err == noErr) {
err = CFQAllocate(sizeof(CFTypeRef) * count, (void **) &keysBuffer);
}
if (err == noErr) {
err = CFQAllocate(sizeof(CFTypeRef) * count, (void **) &valuesBuffer);
}
// Get the keys and values into their buffers, and create a
// dictionary based on the buffer.
if (err == noErr) {
CFArrayGetValues(keys, CFRangeMake(0, count), keysBuffer);
CFArrayGetValues(values, CFRangeMake(0, count), valuesBuffer);
*result = CFDictionaryCreate(NULL, keysBuffer, valuesBuffer, count, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
if (*result == NULL) {
err = coreFoundationUnknownErr;
}
}
// Clean up.
CFQDeallocate(keysBuffer);
CFQDeallocate(valuesBuffer);
return err;
}
示例13: AddIdentityToKeychain
/* Create and identity and try to retrieve it. */
static void AddIdentityToKeychain(void)
{
SecCertificateRef cert = NULL;
SecKeyRef privKey = NULL;
//SecIdentityRef identity = NULL;
isnt(cert = SecCertificateCreateWithBytes(NULL, _c1, sizeof(_c1)),
NULL, "create certificate");
#if TARGET_OS_IPHONE
privKey = SecKeyCreateRSAPrivateKey(NULL, _k1, sizeof(_k1),
kSecKeyEncodingPkcs1);
#else
#warning TODO
privKey = NULL;
#endif
isnt(privKey, NULL, "create private key");
const void *certkeys[] = {
kSecValueRef
};
const void *certvalues[] = {
cert
};
CFDictionaryRef certDict = CFDictionaryCreate(NULL, certkeys, certvalues,
array_size(certkeys), NULL, NULL);
ok_status(SecItemAdd(certDict, NULL), "add certificate");
CFReleaseNull(certDict);
CFReleaseNull(cert);
const void *privkeys[] = {
kSecValueRef
};
const void *privvalues[] = {
privKey
};
CFDictionaryRef privDict = CFDictionaryCreate(NULL, privkeys, privvalues,
array_size(privkeys), NULL, NULL);
ok_status(SecItemAdd(privDict, NULL), "add private key");
CFReleaseNull(privDict);
CFReleaseNull(privKey);
}
示例14: _CFErrorCreateEmptyDictionary
/* Returns a shared empty dictionary (unless the allocator is not kCFAllocatorSystemDefault, in which case returns a newly allocated one).
*/
static CFDictionaryRef _CFErrorCreateEmptyDictionary(CFAllocatorRef allocator) {
if (allocator == NULL) allocator = __CFGetDefaultAllocator();
if (_CFAllocatorIsSystemDefault(allocator)) {
static CFDictionaryRef emptyErrorDictionary = NULL;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
emptyErrorDictionary = CFDictionaryCreate(allocator, NULL, NULL, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
});
return (CFDictionaryRef)CFRetain(emptyErrorDictionary);
} else {
示例15: SDMMD__CreateTemporaryServConn
SDMMD_AMConnectionRef SDMMD__CreateTemporaryServConn(uint32_t socket, SSL *ssl) {
SDMMD_AMConnectionRef handle = NULL;
CFStringRef closeInvalid = CFSTR("CloseOnInvalidate");
CFDictionaryRef dict = CFDictionaryCreate(kCFAllocatorDefault, (const void**)&closeInvalid, (const void**)&kCFBooleanFalse, 0x1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
if (dict) {
handle = SDMMD_AMDServiceConnectionCreate(socket, ssl, dict);
CFSafeRelease(dict);
}
return handle;
}