本文整理匯總了C++中CFDataCreate函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFDataCreate函數的具體用法?C++ CFDataCreate怎麽用?C++ CFDataCreate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFDataCreate函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CFRetain
CFDataRef SharedBuffer::createCFData()
{
if (m_cfData) {
CFRetain(m_cfData.get());
return m_cfData.get();
}
// Internal data in SharedBuffer can be segmented. We need to get the contiguous buffer.
const Vector<char>& contiguousBuffer = buffer();
return CFDataCreate(0, reinterpret_cast<const UInt8*>(contiguousBuffer.data()), contiguousBuffer.size());
}
示例2: NPN_GetStringIdentifier
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name) {
//notice("psst: GetStringIdentifier '%s'", name);
CFDataRef data = CFDataCreate(NULL, (unsigned char *) name, strlen(name));
CFDataRef ret = CFSetGetValue(identifier_set, data);
if(!ret) {
CFSetAddValue(identifier_set, data);
ret = data;
}
CFRelease(data);
return (NPIdentifier) ret;
}
示例3: deviceRGB
void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& point)
{
RetainPtr<CGColorSpaceRef> deviceRGB(AdoptCF, CGColorSpaceCreateDeviceRGB());
// FIXME: Creating CFData is non-optimal, but needed to avoid crashing when printing. Ideally we should
// make a custom CGDataProvider that controls the WindowsBitmap lifetime. see <rdar://6394455>
RetainPtr<CFDataRef> imageData(AdoptCF, CFDataCreate(kCFAllocatorDefault, image->buffer(), image->bufferLength()));
RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(imageData.get()));
RetainPtr<CGImageRef> cgImage(AdoptCF, CGImageCreate(image->size().width(), image->size().height(), 8, 32, image->bytesPerRow(), deviceRGB.get(),
kCGBitmapByteOrder32Little | kCGImageAlphaFirst, dataProvider.get(), 0, true, kCGRenderingIntentDefault));
CGContextDrawImage(m_data->m_cgContext.get(), CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get());
}
示例4: LOG
void WebResourceLoader::didReceiveData(const IPC::DataReference& data, int64_t encodedDataLength)
{
LOG(Network, "(WebProcess) WebResourceLoader::didReceiveData of size %i for '%s'", (int)data.size(), m_coreLoader->url().string().utf8().data());
#if USE(QUICK_LOOK)
if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle()) {
if (quickLookHandle->didReceiveData(adoptCF(CFDataCreate(kCFAllocatorDefault, data.data(), data.size())).get()))
return;
}
#endif
m_coreLoader->didReceiveData(reinterpret_cast<const char*>(data.data()), data.size(), encodedDataLength, DataPayloadBytes);
}
示例5: BIMSendMessageToUIServer
static OSStatus BIMSendMessageToUIServer( BasicMessageID inMessageID )
{
OSStatus result;
CFDataRef sendData;
CFDataRef replyData;
CFMessagePortRef serverPortRef;
BasicMessageHeader header;
result = noErr;
sendData = NULL;
replyData = NULL;
serverPortRef = NULL;
// Create a reference to the remote message port. We identify the port using a unique,
// system-wide name, in this case defined by kBasicServerPortName.
serverPortRef = CFMessagePortCreateRemote( NULL, CFSTR( kBasicServerPortName ) );
if( serverPortRef == NULL )
result = -1;
// Create our message header.
if( result == noErr )
result = GetCurrentProcess( &header.fProcessSerialNumber );
if( result == noErr ) {
sendData = CFDataCreate( NULL, (UInt8 *) &header, sizeof( BasicMessageHeader ) );
if (sendData == NULL)
result = memFullErr;
}
// Send the message specified in iMessageID to the server. We send the message header
// as data.
if( result == noErr ) {
if( CFMessagePortSendRequest( serverPortRef, inMessageID, sendData,
10, 10, NULL, &replyData ) != kCFMessagePortSuccess )
result = -2;
}
// Release everything.
if( sendData )
CFRelease( sendData );
if( replyData )
CFRelease( replyData );
if( serverPortRef )
CFRelease( serverPortRef );
// Return an error code to the caller.
return result;
}
示例6: interface_update_link_issues
__private_extern__
void
interface_update_link_issues(const char *if_name,
uint64_t timestamp,
uint8_t *modid,
size_t modid_size,
uint8_t *info,
size_t info_size)
{
CFDataRef infoData;
CFStringRef key;
CFDataRef modidData;
CFMutableDictionaryRef newDict;
CFDateRef timeStamp;
key = create_link_issues_key(if_name);
newDict = copy_entity(key);
modidData = CFDataCreate(NULL, modid, modid_size);
CFDictionarySetValue(newDict, kSCPropNetLinkIssuesModuleID, modidData);
CFRelease(modidData);
if (info_size != 0) {
infoData = CFDataCreate(NULL, info, info_size);
CFDictionarySetValue(newDict, kSCPropNetLinkIssuesInfo, infoData);
CFRelease(infoData);
} else {
CFDictionaryRemoveValue(newDict, kSCPropNetLinkIssuesInfo);
}
timeStamp = CFDateCreate(NULL, timestamp);
CFDictionarySetValue(newDict, kSCPropNetLinkIssuesTimeStamp, timeStamp);
CFRelease(timeStamp);
cache_SCDynamicStoreSetValue(store, key, newDict);
CFRelease(newDict);
CFRelease(key);
return;
}
示例7: SavePrefs
void SavePrefs (void)
{
CFMutableStringRef mref;
CFStringRef sref;
CFDataRef data;
for (unsigned int i = 0; i < kPrefListSize; i++)
{
mref = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFSTR("Preferences_"));
if (mref)
{
sref = CFStringCreateWithBytes(kCFAllocatorDefault, (UInt8 *) &(prefList[i].itemName), sizeof(OSType), kCFStringEncodingMacRoman, false);
if (sref)
{
CFStringAppend(mref, sref);
data = CFDataCreate(kCFAllocatorDefault, (UInt8 *) prefList[i].itemPointer, prefList[i].size);
if (data)
{
CFPreferencesSetAppValue(mref, data, kCFPreferencesCurrentApplication);
CFRelease(data);
}
CFRelease(sref);
}
CFRelease(mref);
}
}
mref = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFSTR("Preferences_SaveFolder"));
if (mref)
{
if (saveFolderPath)
{
CFPreferencesSetAppValue(mref, saveFolderPath, kCFPreferencesCurrentApplication);
CFRelease(saveFolderPath);
}
else
CFPreferencesSetAppValue(mref, NULL, kCFPreferencesCurrentApplication);
CFRelease(mref);
}
sref = (CFStringRef) CFDictionaryGetValue(CFBundleGetInfoDictionary(CFBundleGetMainBundle()), CFSTR("CFBundleShortVersionString"));
if (sref)
{
CFPreferencesSetAppValue(CFSTR("LastVersionUsed"), sref, kCFPreferencesCurrentApplication);
}
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
}
示例8: SDMMD_MB2SendEndStream
sdmmd_return_t SDMMD_MB2SendEndStream(SDMMD_AMConnectionRef conn) {
sdmmd_return_t result = kAMDSuccess;
uint32_t zero_stream = 0x0;
CFDataRef stream_end = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)&zero_stream, sizeof(uint32_t));
result = SDMMD_DirectServiceSend(SDMMD_TranslateConnectionToSocket(conn), stream_end);
CFSafeRelease(stream_end);
CFMutableArrayRef status_response = SDMMD_MB2StatusResponseMessage();
result = SDMMD_ServiceSendMessage(SDMMD_TranslateConnectionToSocket(conn), status_response, kCFPropertyListBinaryFormat_v1_0);
return result;
}
示例9: WebKit_win32_NATIVE
JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(CFDataCreate)
(JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jint arg2)
{
jbyte *lparg1=NULL;
jintLong rc = 0;
WebKit_win32_NATIVE_ENTER(env, that, CFDataCreate_FUNC);
if (arg1) if ((lparg1 = env->GetByteArrayElements(arg1, NULL)) == NULL) goto fail;
rc = (jintLong)CFDataCreate((CFAllocatorRef)arg0, (const UInt8 *)lparg1, (CFIndex)arg2);
fail:
if (arg1 && lparg1) env->ReleaseByteArrayElements(arg1, lparg1, 0);
WebKit_win32_NATIVE_EXIT(env, that, CFDataCreate_FUNC);
return rc;
}
示例10: stream_buffer_read_cfdata
static inline CFDataRef stream_buffer_read_cfdata(stream_buffer_t *sb, size_t size)
{
CFDataRef cfdata;
if (sb->cursor + size > sb->size) {
return NULL;
}
cfdata = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)(sb->bytes + sb->cursor), size);
sb->cursor += size;
return cfdata;
}
示例11: decodeCFData
static bool decodeCFData(Decoder& decoder, RetainPtr<CFDataRef>& data)
{
uint64_t size = 0;
if (!decoder.decode(size))
return false;
Vector<uint8_t> vector(size);
if (!decoder.decodeFixedLengthData(vector.data(), vector.size()))
return false;
data = adoptCF(CFDataCreate(nullptr, vector.data(), vector.size()));
return true;
}
示例12: trust_settings_import
extern int trust_settings_import(int argc, char * const *argv)
{
extern char *optarg;
extern int optind;
OSStatus ortn;
int arg;
char *settingsFile = NULL;
unsigned char *settingsData = NULL;
size_t settingsLen = 0;
CFDataRef settings = NULL;
SecTrustSettingsDomain domain = kSecTrustSettingsDomainUser;
int rtn;
if(argc < 2) {
return 2; /* @@@ Return 2 triggers usage message. */
}
optind = 1;
while ((arg = getopt(argc, argv, "dh")) != -1) {
switch (arg) {
case 'd':
domain = kSecTrustSettingsDomainAdmin;
break;
default:
return 2;
}
}
if(optind != (argc - 1)) {
/* no args left for settings file */
return 2;
}
settingsFile = argv[optind];
rtn = readFileSizet(settingsFile, &settingsData, &settingsLen);
if(rtn) {
fprintf(stderr, "Error (%d) reading %s.\n", rtn, settingsFile);
return 1;
}
settings = CFDataCreate(NULL, (const UInt8 *)settingsData, settingsLen);
free(settingsData);
ortn = SecTrustSettingsImportExternalRepresentation(domain, settings);
CFRelease(settings);
if(ortn) {
cssmPerror("SecTrustSettingsImportExternalRepresentation", ortn);
rtn = 1;
}
else if(!do_quiet) {
fprintf(stdout, "...Trust Settings imported successfully.\n");
rtn = 0;
}
return rtn;
}
示例13: tests
static void tests(void)
{
CFDataRef attached_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, attached_signed_data_der, attached_signed_data_der_len, kCFAllocatorNull);
CFDataRef detached_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, detached_signed_data_der, detached_signed_data_der_len, kCFAllocatorNull);
CFDataRef attached_no_data_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, attached_no_data_signed_data_der, attached_no_data_signed_data_der_len, kCFAllocatorNull);
CFDataRef detached_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, detached_content, detached_content_len, kCFAllocatorNull);
CFDataRef no_data = CFDataCreate(kCFAllocatorDefault, NULL, 0);
SecPolicyRef policy = SecPolicyCreateBasicX509();
SecTrustRef trust = NULL;
ok_status(SecCMSVerifyCopyDataAndAttributes(attached_signed_data, NULL, policy, &trust, NULL, NULL), "verify attached data");
CFRelease(trust);
ok_status(SecCMSVerifyCopyDataAndAttributes(detached_signed_data, detached_data, policy, &trust, NULL, NULL), "verify detached data");
CFRelease(trust);
ok_status(SecCMSVerifyCopyDataAndAttributes(attached_no_data_signed_data, NULL, policy, &trust, NULL, NULL), "verify attached no data");
CFRelease(trust);
ok_status(SecCMSVerifyCopyDataAndAttributes(attached_no_data_signed_data, no_data, policy, &trust, NULL, NULL), "verify attached no data");
CFRelease(trust);
SecCertificateRef cert = NULL;
SecKeyRef privKey = NULL;
SecIdentityRef identity = NULL;
isnt(cert = SecCertificateCreateWithBytes(NULL, signer_der, signer_der_len), NULL, "create certificate");
isnt(privKey = SecKeyCreateRSAPrivateKey(NULL, privkey_der, privkey_der_len, kSecKeyEncodingPkcs1), NULL, "create private key");
isnt(identity = SecIdentityCreate(NULL, cert, privKey), NULL, "create identity");
CFReleaseSafe(privKey);
CFMutableDataRef cms_data = CFDataCreateMutable(kCFAllocatorDefault, 0);
ok_status(SecCMSCreateSignedData(identity, detached_data, NULL, NULL, cms_data), "create attached data");
//write_data("/var/tmp/attached", cms_data);
CFDataSetLength(cms_data, 0);
CFDictionaryRef detached_cms_dict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&kSecCMSSignDetached, (const void **)&kCFBooleanTrue, 1, NULL, NULL);
ok_status(SecCMSCreateSignedData(identity, detached_data, detached_cms_dict, NULL, cms_data), "create attached data");
CFRelease(detached_cms_dict);
//write_data("/var/tmp/detached", cms_data);
CFDataSetLength(cms_data, 0);
ok_status(SecCMSCreateSignedData(identity, NULL, NULL, NULL, cms_data), "create attached data");
//write_data("/var/tmp/empty_attached", cms_data);
CFReleaseSafe(cms_data);
CFReleaseSafe(cert);
CFReleaseNull(identity);
CFRelease(attached_signed_data);
CFRelease(detached_signed_data);
CFRelease(attached_no_data_signed_data);
CFRelease(detached_data);
CFRelease(no_data);
CFRelease(policy);
}
示例14: setHTTPBody
void setHTTPBody(CFMutableURLRequestRef request, PassRefPtr<FormData> formData)
{
if (!formData) {
wkCFURLRequestSetHTTPRequestBodyParts(request, 0);
return;
}
size_t count = formData->elements().size();
if (count == 0)
return;
// Handle the common special case of one piece of form data, with no files.
if (count == 1) {
const FormDataElement& element = formData->elements()[0];
if (element.m_type == FormDataElement::data) {
CFDataRef data = CFDataCreate(0, reinterpret_cast<const UInt8 *>(element.m_data.data()), element.m_data.size());
// CFURLRequestSetHTTPRequestBody(request, data); //Ricardo: comentando por error
CFRelease(data);
return;
}
}
RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
for (size_t i = 0; i < count; ++i) {
const FormDataElement& element = formData->elements()[i];
if (element.m_type == FormDataElement::data) {
RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(0, reinterpret_cast<const UInt8*>(element.m_data.data()), element.m_data.size()));
CFArrayAppendValue(array.get(), data.get());
} else {
RetainPtr<CFStringRef> filename(AdoptCF, element.m_filename.createCFString());
CFArrayAppendValue(array.get(), filename.get());
}
}
wkCFURLRequestSetHTTPRequestBodyParts(request, array.get());
}
示例15: testInvalidLicenseFile
void testInvalidLicenseFile(void)
{
CFDataRef invalidLicenseFileData = CFDataCreate(NULL,
(const UInt8 *)invalidLicenseFileContents,
(CFIndex)strlen(invalidLicenseFileContents));
Boolean licenseIsValid = APVerifyLicenseData(invalidLicenseFileData);
CFRelease(invalidLicenseFileData);
if (!licenseIsValid) {
CFShow(CFSTR("Test OK: Invalid file recognised as invalid"));
} else {
CFShow(CFSTR("Test FAILED: Invalid file not recognised as invalid"));
}
}