这篇教程C++ CFDataGetLength函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CFDataGetLength函数的典型用法代码示例。如果您正苦于以下问题:C++ CFDataGetLength函数的具体用法?C++ CFDataGetLength怎么用?C++ CFDataGetLength使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CFDataGetLength函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: printEntrystatic void printEntry(const void *key, const void *value, void *context){ struct indent_ctxt * ctxt = context;#if 1 // IOKit pretty CFDataRef data; indent(false, ctxt->depth, ctxt->stackOfBits); printf(" "); printCFString( (CFStringRef)key ); printf(" = "); data = IOCFSerialize((CFStringRef)value, kNilOptions); if( data) { if( 10000 > CFDataGetLength(data)) printf(CFDataGetBytePtr(data)); else printf("<is BIG>"); CFRelease(data); } else printf("<IOCFSerialize failed>"); printf("/n");#else // CF ugly CFStringRef keyStr = (CFStringRef) key; CFStringRef valueStr = CFCopyDescription((CFTypeRef) val); CFStringRef outStr; indent(false, ctxt->depth, ctxt->stackOfBits); outStr = CFStringCreateWithFormat(kCFAllocatorDefault, 0, CFSTR(" %@ = %@/n"), keyStr, valueStr); assert(outStr); printCFString(outStr); CFRelease(valueStr); CFRelease(outStr);#endif}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:39,
示例2: schan_imp_get_session_peer_certificateSECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session, PCCERT_CONTEXT *cert){ struct mac_session* s = (struct mac_session*)session; SECURITY_STATUS ret = SEC_E_INTERNAL_ERROR; CFArrayRef certs; OSStatus status; TRACE("(%p/%p, %p)/n", s, s->context, cert); status = SSLCopyPeerCertificates(s->context, &certs); if (status == noErr && certs) { SecCertificateRef mac_cert; CFDataRef data; if (CFArrayGetCount(certs) && (mac_cert = (SecCertificateRef)CFArrayGetValueAtIndex(certs, 0)) && (SecKeychainItemExport(mac_cert, kSecFormatX509Cert, 0, NULL, &data) == noErr)) { *cert = CertCreateCertificateContext(X509_ASN_ENCODING, CFDataGetBytePtr(data), CFDataGetLength(data)); if (*cert) ret = SEC_E_OK; else { ret = GetLastError(); WARN("CertCreateCertificateContext failed: %x/n", ret); } CFRelease(data); } else WARN("Couldn't extract certificate data/n"); CFRelease(certs); } else WARN("SSLCopyPeerCertificates failed: %ld/n", (long)status); return ret;}
开发者ID:YokoZar,项目名称:wine,代码行数:39,
示例3: dataReadstatic CFIndex dataRead(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info) { _CFReadDataStreamContext *dataCtxt = (_CFReadDataStreamContext *)info; const UInt8 *bytePtr = CFDataGetBytePtr(dataCtxt->data); CFIndex length = CFDataGetLength(dataCtxt->data); CFIndex bytesToCopy = bytePtr + length - dataCtxt->loc; if (bytesToCopy > bufferLength) { bytesToCopy = bufferLength; } if (bytesToCopy < 0) { bytesToCopy = 0; } if (bytesToCopy != 0) { memmove(buffer, dataCtxt->loc, bytesToCopy); dataCtxt->loc += bytesToCopy; } error->error = 0; *atEOF = (dataCtxt->loc < bytePtr + length) ? FALSE : TRUE; if (dataCtxt->scheduled && !*atEOF) { CFReadStreamSignalEvent(stream, kCFStreamEventHasBytesAvailable, NULL); } return bytesToCopy;}
开发者ID:nagyistge,项目名称:swift-corelibs-foundation,代码行数:22,
示例4: PasteboardCreateGHOST_TUns8* GHOST_SystemCarbon::getClipboard(bool selection) const{ PasteboardRef inPasteboard; PasteboardItemID itemID; CFDataRef flavorData; OSStatus err = noErr; GHOST_TUns8 * temp_buff; CFRange range; OSStatus syncFlags; err = PasteboardCreate(kPasteboardClipboard, &inPasteboard); if(err != noErr) { return NULL;} syncFlags = PasteboardSynchronize( inPasteboard ); /* as we always get in a new string, we can safely ignore sync flags if not an error*/ if(syncFlags <0) { return NULL;} err = PasteboardGetItemIdentifier( inPasteboard, 1, &itemID ); if(err != noErr) { return NULL;} err = PasteboardCopyItemFlavorData( inPasteboard, itemID, CFSTR("public.utf8-plain-text"), &flavorData); if(err != noErr) { return NULL;} range = CFRangeMake(0, CFDataGetLength(flavorData)); temp_buff = (GHOST_TUns8*) malloc(range.length+1); CFDataGetBytes(flavorData, range, (UInt8*)temp_buff); temp_buff[range.length] = '/0'; if(temp_buff) { return temp_buff; } else { return NULL; }}
开发者ID:BHCLL,项目名称:blendocv,代码行数:38,
示例5: metadata_realm_encryption_keystd::vector<char> metadata_realm_encryption_key(){ const size_t key_size = 64; const std::string service = "io.realm.sync.keychain"; const std::string account = "metadata"; auto search_dictionary = build_search_dictionary(account, service, none); CFDataRef retained_key_data; if (OSStatus status = SecItemCopyMatching(search_dictionary.get(), (CFTypeRef *)&retained_key_data)) { if (status != errSecItemNotFound) { throw KeychainAccessException(status); } // Key was not found. Generate a new key, store it, and return it. std::vector<char> key(key_size); arc4random_buf(key.data(), key_size); auto key_data = adoptCF(CFDataCreate(nullptr, reinterpret_cast<const UInt8 *>(key.data()), key_size)); if (!key_data) { throw std::bad_alloc(); } CFDictionaryAddValue(search_dictionary.get(), kSecValueData, key_data.get()); if (OSStatus status = SecItemAdd(search_dictionary.get(), nullptr)) { throw KeychainAccessException(status); } return key; } CFPtr<CFDataRef> key_data = adoptCF(retained_key_data); // Key was previously stored. Extract it. if (key_size != CFDataGetLength(key_data.get())) { throw std::runtime_error("Password stored in keychain was not expected size."); } auto key_bytes = reinterpret_cast<const char *>(CFDataGetBytePtr(key_data.get())); return std::vector<char>(key_bytes, key_bytes + key_size);}
开发者ID:bamse16,项目名称:Trucks,代码行数:38,
示例6: __DAQueueResponsestatic void __DAQueueResponse( DASessionRef session, void * address, void * context, _DACallbackKind kind, DADiskRef disk, CFTypeRef response, SInt32 responseID ){ CFDataRef _response = NULL; if ( response ) _response = _DASerialize( kCFAllocatorDefault, response ); _DAServerSessionQueueResponse( _DASessionGetID( session ), ( uintptr_t ) address, ( uintptr_t ) context, ( int32_t ) kind, ( caddr_t ) _DADiskGetID( disk ), ( vm_address_t ) ( _response ? CFDataGetBytePtr( _response ) : 0 ), ( mach_msg_type_number_t ) ( _response ? CFDataGetLength( _response ) : 0 ), ( int32_t ) responseID ); if ( _response ) CFRelease( _response );}
开发者ID:alexzhang2015,项目名称:osx-10.9,代码行数:23,
示例7: img3_flash_NOR_imageint img3_flash_NOR_image(io_connect_t norServiceConnection, CFDataRef imageData, int isLLB) { restored_log("%s: flashing %s data/n", "img3_flash_NOR_image", (isLLB ? "LLB" : "NOR")); size_t imgLen = CFDataGetLength(imageData); void *mappedImage = mmap(NULL, imgLen, PROT_READ | PROT_WRITE, MAP_SHARED, -1, 0); if(mappedImage == MAP_FAILED) { int err = errno; restored_log("mmap (size = %d) failed: %s/n", imgLen, strerror(err)); return err; } const void *imageDataPtr = CFDataGetBytePtr(imageData); bcopy(imageDataPtr, mappedImage, imgLen); kern_return_t result; if((result = IOConnectCallStructMethod(norServiceConnection, 0, mappedImage, imgLen, NULL, 0)) != KERN_SUCCESS) { restored_log("IOConnectCallStructMethod failed: 0x%x/n", result); } munmap(mappedImage, imgLen); return result;}
开发者ID:jfranks67,项目名称:restored_pwn,代码行数:23,
示例8: dumpLogicalVolumeExtentsstatic voiddumpLogicalVolumeExtents(CFMutableDictionaryRef lv){ CFStringRef lvUUID = CFDictionaryGetValue(lv, CFSTR(kAppleLVMVolumeUUIDKey)); if (!lvUUID) { printf("/ninternal error, no uuid in lv dict/n"); return; }; CFDataRef extentData = (CFDataRef)AppleLVMGetVolumeExtents(lvUUID); if (!extentData) { printf("/nno extent data found?/n"); return; }; AppleRAIDExtentOnDisk * extentList = (AppleRAIDExtentOnDisk *)CFDataGetBytePtr(extentData); UInt64 extentCount = CFDataGetLength(extentData) / sizeof(AppleRAIDExtentOnDisk); if (!extentCount || !extentList) { printf("/nextent data empty?/n"); return; }; printf("/textent list:/n"); UInt32 i; for (i = 0; i < extentCount; i++) { printf(" %20llu - %12llu (%llu)/n", extentList[i].extentByteOffset, extentList[i].extentByteOffset + extentList[i].extentByteCount - 1, extentList[i].extentByteCount); }}
开发者ID:RomiPierre,项目名称:osx,代码行数:23,
示例9: TSICTStringCreateDataFromIntermediateRepresentationstatic inline CFDataRef TSICTStringCreateDataFromIntermediateRepresentation(TStringIRep* rep){ CFIndex len = CFDataGetLength(rep->data); CFMutableDataRef buffer = CFDataCreateMutableCopy(kCFAllocatorDefault, (len + 12), rep->data); UInt8* bufferBytes = CFDataGetMutableBytePtr(buffer); size_t prefixLength = strlen(rep->length) + 1; CFDataReplaceBytes(buffer, BeginningRange, (const UInt8*)rep->length, (CFIndex)prefixLength); if (rep->format == kTSITStringFormatTNetstring) { const UInt8 ftag = (UInt8)TNetstringTypes[rep->type]; CFDataAppendBytes(buffer, &ftag, 1); bufferBytes[(prefixLength - 1)] = TNetstringSeparator; } else if (rep->format == kTSITStringFormatOTNetstring) { const UInt8 ftag = (UInt8)OTNetstringTypes[rep->type]; bufferBytes[(prefixLength - 1)] = ftag; } CFDataRef dataRep = CFDataCreateCopy(kCFAllocatorDefault, buffer); CFRelease(buffer); return dataRep;}
开发者ID:4justinstewart,项目名称:Polity,代码行数:23,
示例10: mailstream_low_cfstream_get_fdstatic int mailstream_low_cfstream_get_fd(mailstream_low * s){#if HAVE_CFNETWORK struct mailstream_cfstream_data * cfstream_data = NULL; CFDataRef native_handle_data = NULL; CFSocketNativeHandle native_handle_value = -1; CFIndex native_data_len = 0; CFIndex native_value_len = 0; if (!s) return -1; cfstream_data = (struct mailstream_cfstream_data *) s->data; if (!cfstream_data->readStream) return -1; native_handle_data = (CFDataRef)CFReadStreamCopyProperty(cfstream_data->readStream, kCFStreamPropertySocketNativeHandle); if (!native_handle_data) return -1; native_data_len = CFDataGetLength(native_handle_data); native_value_len = (CFIndex)sizeof(native_handle_value); if (native_data_len != native_value_len) { CFRelease(native_handle_data); return -1; } CFDataGetBytes(native_handle_data, CFRangeMake(0, MIN(native_data_len, native_value_len)), (UInt8 *)&native_handle_value); CFRelease(native_handle_data); return native_handle_value;#else return -1;#endif}
开发者ID:AlexandrPonomarev,项目名称:Gmail,代码行数:37,
示例11: start_pastevoid start_paste(widget_list *widget){ OSStatus err = noErr; PasteboardRef gClipboard; PasteboardItemID itemID; CFDataRef flavorData; char* flavorText; err = PasteboardCreate( kPasteboardClipboard, &gClipboard ); //require_noerr( err, CantCreateClipboard ); err = PasteboardGetItemIdentifier( gClipboard, 1, &itemID ); err = PasteboardCopyItemFlavorData( gClipboard, itemID, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData ); int flavorDataSize = CFDataGetLength(flavorData); flavorText=(char*)malloc(flavorDataSize+1); short dataIndex; for(dataIndex = 0; dataIndex <= flavorDataSize; dataIndex++ ) { char byte = *(CFDataGetBytePtr( flavorData ) + dataIndex); flavorText[dataIndex] = (byte>32) ? byte : ' '; } flavorText[flavorDataSize] = '/0'; CFRelease(flavorData); if (widget == NULL) { do_paste (flavorText); } else { do_paste_to_text_field(widget, flavorText); } free(flavorText); CFRelease( gClipboard );}
开发者ID:Sir-Odie,项目名称:Eternal-Lands,代码行数:37,
示例12: iSCSIDaemonCreateCFPropertiesForSession/*! Creates a dictionary of session parameters for the session associated with * the specified target, if one exists. * @param handle a handle to a daemon connection. * @param target the target to check for associated sessions to generate * a dictionary of session parameters. * @return a dictionary of session properties. */CFDictionaryRef iSCSIDaemonCreateCFPropertiesForSession(iSCSIDaemonHandle handle, iSCSITargetRef target){ // Validate inputs if(handle < 0 || !target) return NULL; CFDictionaryRef properties = NULL; CFDataRef targetData = iSCSITargetCreateData(target); // Send command to daemon iSCSIDMsgCreateCFPropertiesForSessionCmd cmd = iSCSIDMsgCreateCFPropertiesForSessionCmdInit; cmd.targetLength = (UInt32)CFDataGetLength(targetData); errno_t error = iSCSIDaemonSendMsg(handle,(iSCSIDMsgGeneric *)&cmd, targetData,NULL); CFRelease(targetData); iSCSIDMsgCreateCFPropertiesForSessionRsp rsp; if(!error) error = iSCSIDaemonRecvMsg(handle,(iSCSIDMsgGeneric*)&rsp,NULL); if(!error) { CFDataRef data = NULL; error = iSCSIDaemonRecvMsg(handle,0,&data,rsp.dataLength,NULL); if(!error && data) { CFPropertyListFormat format; properties = CFPropertyListCreateWithData(kCFAllocatorDefault,data,0,&format,NULL); CFRelease(data); } } return properties;}
开发者ID:BestMacsBen,项目名称:iSCSIInitiator,代码行数:43,
示例13: IOPMSleepSystemWithOptions/* Private call for Apple Internal use only */IOReturn IOPMSleepSystemWithOptions ( io_connect_t fb, CFDictionaryRef options ){ uint64_t rtn = 0; size_t len = sizeof(uint32_t); kern_return_t err; CFDataRef serializedOptions = NULL; if( !options ) { return IOPMSleepSystem( fb ); } serializedOptions = IOCFSerialize( options, 0 ); if (!serializedOptions) { return kIOReturnInternalError; } /* kPMSleepSystemOptions * in: serialized CFDictionary of options * out: IOReturn code returned from sleepSystem */ err = IOConnectCallStructMethod( fb, kPMSleepSystemOptions, CFDataGetBytePtr(serializedOptions), /* inputStruct */ CFDataGetLength(serializedOptions), /* inputStructCnt */ &rtn, /* outputStruct */ &len); /* outputStructCnt */ CFRelease(serializedOptions); if (kIOReturnSuccess != err) return err; else return (IOReturn) rtn;}
开发者ID:wzw19890321,项目名称:IOKitUser,代码行数:38,
示例14: CFNetDiagnosticDiagnoseProblemInteractivelyCFNetDiagnosticStatus CFNetDiagnosticDiagnoseProblemInteractively(CFNetDiagnosticRef details) { SInt32 retval = 0; mach_port_t port = MACH_PORT_NULL; CFDataRef msgData = NULL; kern_return_t err; //build message CFWriteStreamRef stream = CFWriteStreamCreateWithAllocatedBuffers(kCFAllocatorDefault, kCFAllocatorDefault); CFWriteStreamOpen(stream); CFIndex len = CFPropertyListWriteToStream(details, stream, kCFPropertyListBinaryFormat_v1_0, NULL); CFWriteStreamClose(stream); if(len > 0) { msgData = CFWriteStreamCopyProperty(stream, kCFStreamPropertyDataWritten); } CFRelease(stream); if(msgData) { err = bootstrap_look_up(bootstrap_port, *((name_t*)(&_CFNetDiagnosticMachPortName)), &port); if (err == KERN_SUCCESS) { err = _CFNetDiagnosticClient_passDescriptor( port, _CFNetDiagnosticMachProtocolVersion, (vm_address_t)CFDataGetBytePtr(msgData), CFDataGetLength(msgData)); if (err == KERN_SUCCESS) { //FIXME Yay!!! } } CFRelease(msgData); } return (CFNetDiagnosticStatus)retval;}
开发者ID:annp,项目名称:CFNetwork,代码行数:36,
示例15: SDMMD_MB2SendFileStreamsdmmd_return_t SDMMD_MB2SendFileStream(SDMMD_AMConnectionRef conn, CFStringRef path, CFDataRef file) { sdmmd_return_t result = kAMDSuccess; CFDataRef file_path = CFStringCreateExternalRepresentation(kCFAllocatorDefault, path, kCFStringEncodingUTF8, 0); result = SDMMD_ServiceSend(SDMMD_TranslateConnectionToSocket(conn), file_path); CFSafeRelease(file_path); CheckErrorAndReturn(result); char data_chunk[1] = { 0x0C }; CFMutableDataRef data_separator = CFDataCreateMutable(kCFAllocatorDefault, 0); CFDataAppendBytes(data_separator, (const UInt8 *)data_chunk, sizeof(uint8_t)); CFDataAppendBytes(data_separator, CFDataGetBytePtr(file), CFDataGetLength(file)); result = SDMMD_ServiceSend(SDMMD_TranslateConnectionToSocket(conn), data_separator); CFSafeRelease(data_separator); CheckErrorAndReturn(result); char zero_chunk[1] = { 0x0 }; CFDataRef data_end = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)zero_chunk, sizeof(uint8_t)); result = SDMMD_ServiceSend(SDMMD_TranslateConnectionToSocket(conn), data_end); CFSafeRelease(data_end); CheckErrorAndReturn(result); ExitLabelAndReturn(result);}
开发者ID:iH8sn0w,项目名称:SDMMobileDevice,代码行数:24,
示例16: mallocCFDataRef SC_MachMessagePort::messagePortCallBack(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info){ // CFShow(data); SC_MachMessagePort *port = (SC_MachMessagePort *) info; OSC_Packet* packet = (OSC_Packet *) malloc(sizeof(OSC_Packet)); bzero(&packet->mReplyAddr, sizeof(ReplyAddress)); packet->mReplyAddr.mReplyFunc = port->mReplyPort ? mach_reply_func : null_reply_func; packet->mReplyAddr.mReplyData = 0; packet->mReplyAddr.mSocket = (int)(int64)port->mReplyPort; packet->mSize = CFDataGetLength(data); packet->mData = (char*) memcpy(malloc(packet->mSize), CFDataGetBytePtr(data), packet->mSize); World *world = port->mWorld; if (world->mDumpOSC) dumpOSC(world->mDumpOSC, packet->mSize, packet->mData); if (!ProcessOSCPacket(world, packet)) { scprintf("command FIFO full/n"); free(packet->mData); free(packet); } // how can we send a reply? we could block here until the message is processed... return NULL;}
开发者ID:GaryHomewood,项目名称:supercollider-android-bootstrap,代码行数:24,
示例17: convertOidstatic int convertOid( CFTypeRef inRef, CSSM_OID *outOid){ if (!inRef || !outOid) return errSecParam; unsigned char *oidData = NULL; unsigned int oidLen = 0; if (CFGetTypeID(inRef) == CFStringGetTypeID()) { // CFStringRef: OID representation is a dotted-decimal string CFStringRef inStr = (CFStringRef)inRef; CFIndex max = CFStringGetLength(inStr) * 3; char buf[max]; if (!CFStringGetCString(inStr, buf, max-1, kCFStringEncodingASCII)) return errSecParam; if(encodeOid((unsigned char *)buf, &oidData, &oidLen) != 0) return errSecParam; } else if (CFGetTypeID(inRef) == CFDataGetTypeID()) { // CFDataRef: OID representation is in binary DER format CFDataRef inData = (CFDataRef)inRef; oidLen = (unsigned int) CFDataGetLength(inData); oidData = (unsigned char *) malloc(oidLen); memcpy(oidData, CFDataGetBytePtr(inData), oidLen); } else { // Not in a format we understand return errSecParam; } outOid->Length = oidLen; outOid->Data = (uint8 *)oidData; return 0;}
开发者ID:darlinghq,项目名称:darling-security,代码行数:36,
示例18: IOURLWriteDataAndPropertiesToResourceBoolean IOURLWriteDataAndPropertiesToResource(CFURLRef url, CFDataRef data, CFDictionaryRef propertyDict, SInt32 *errorCode) { CFStringRef scheme = CFURLCopyScheme(url); if (!scheme) { if (errorCode) *errorCode = kIOURLImproperArgumentsError; return FALSE; } else if (CFStringCompare(scheme, CFSTR("file"), 0) == kCFCompareEqualTo) { Boolean success = TRUE; CFRelease(scheme); if (errorCode) *errorCode = 0; if (data) { char cPath[CFMaxPathSize]; if (!CFURLGetFileSystemRepresentation(url, TRUE, cPath, CFMaxPathSize)) { if (errorCode) *errorCode = kIOURLImproperArgumentsError; success = FALSE; } else if (CFURLHasDirectoryPath(url)) { // Create a directory success = !mkdir(cPath, 0777); if (!success && errorCode) *errorCode = kIOURLUnknownError; } else { // Write data SInt32 length = CFDataGetLength(data); const void *bytes = (0 == length) ? (const void *)"" : CFDataGetBytePtr(data); success = _IOWriteBytesToFile(cPath, bytes, length); if (!success && errorCode) *errorCode = kIOURLUnknownError; } } if (propertyDict) { if (!_IOFileURLWritePropertiesToResource(url, propertyDict, errorCode)) success = FALSE; } return success; } else { if (errorCode) *errorCode = kIOURLUnknownSchemeError; return FALSE; }}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:36,
示例19: Base64Datastatic int Base64Data(CFDataRef cfData, int for_encoding, CFDataRef* encoded_data){ int result = -1; // Guilty until proven CNEncodings encoding = kCNEncodingBase64; CNStatus status = kCCSuccess; CNEncodingDirection direction = (for_encoding) ? kCNEncode : kCNDecode; unsigned char buffer[1024]; size_t encoded_data_length = 1024; if (NULL == cfData || NULL == encoded_data) { return result; } memset(buffer, 0, 1024); *encoded_data = NULL; status = CNEncode(encoding, direction, CFDataGetBytePtr(cfData), CFDataGetLength(cfData), buffer, &encoded_data_length); if (kCCSuccess == status) { *encoded_data = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)buffer, encoded_data_length); result = (NULL == *encoded_data) ? -1 : 0; } return result; }
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:24,
示例20: SDMMD_DirectServiceReceivesdmmd_return_t SDMMD_DirectServiceReceive(SocketConnection handle, CFDataRef *data) { uint32_t size = (data && *data ? (uint32_t)CFDataGetLength(*data) : 0); if (size) { if (CheckIfExpectingResponse(handle, 1000)) { unsigned char *buffer = malloc(size); uint32_t remainder = size; size_t recieved; while (remainder) { if (handle.isSSL) { recieved = SSL_read(handle.socket.ssl, &buffer[size-remainder], remainder); } else { recieved = recv(handle.socket.conn, &buffer[size-remainder], remainder, 0); } if (!recieved) break; remainder -= recieved; } *data = CFDataCreate(kCFAllocatorDefault, buffer, size); free(buffer); } return kAMDSuccess; } return kAMDSuccess;}
开发者ID:AgileBits,项目名称:SDMMobileDevice,代码行数:24,
示例21: SDMMD_ServiceSendsdmmd_return_t SDMMD_ServiceSend(SocketConnection handle, CFDataRef data) { CFIndex msgLen = (data ? CFDataGetLength(data) : 0); if (msgLen) { msgLen = htonl((uint32_t)msgLen); uint64_t result; // Send 32-bit data length header if (handle.isSSL) { if (SSL_is_init_finished(handle.socket.ssl)) { result = SSL_write(handle.socket.ssl, &msgLen, sizeof(uint32_t)); } else { return kAMDNotConnectedError; } } else { result = send(handle.socket.conn, &msgLen, sizeof(uint32_t), 0); } // Send data body if (result == sizeof(uint32_t)) { msgLen = ntohl(msgLen); if (handle.isSSL) { result = SSL_write(handle.socket.ssl, CFDataGetBytePtr(data), (uint32_t)msgLen); } else { result = send(handle.socket.conn, CFDataGetBytePtr(data), msgLen, 0); } return (result == msgLen ? kAMDSuccess : kAMDInvalidResponseError); } else { return kAMDNotConnectedError; } } else { return kAMDInvalidArgumentError; }}
开发者ID:iH8sn0w,项目名称:SDMMobileDevice,代码行数:36,
示例22: decoderTagLib::ByteVector TagLib::DecodeBase64(const TagLib::ByteVector& input){ SFB::CFError error; SFB::SecTransform decoder(SecDecodeTransformCreate(kSecBase64Encoding, &error)); if(!decoder) { LOGGER_WARNING("org.sbooth.AudioEngine", "SecDecodeTransformCreate failed: " << error); return {}; } SFB::CFData sourceData(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, (const UInt8 *)input.data(), (CFIndex)input.size(), kCFAllocatorNull)); if(!sourceData) return {}; if(!SecTransformSetAttribute(decoder, kSecTransformInputAttributeName, sourceData, &error)) { LOGGER_WARNING("org.sbooth.AudioEngine", "SecTransformSetAttribute failed: " << error); return {}; } SFB::CFData decodedData((CFDataRef)SecTransformExecute(decoder, &error)); if(!decodedData) return {}; return {(const char *)CFDataGetBytePtr((CFDataRef)decodedData), (size_t)CFDataGetLength((CFDataRef)decodedData)};}
开发者ID:sbooth,项目名称:SFBAudioEngine,代码行数:24,
示例23: iSCSIDaemonPreferencesIOUnlockAndSync/*! Synchronizes cached preference changes to disk and releases the locked * semaphore, allowing other clients to make changes. If the prefereneces * parameter is NULL, then no changes are made to disk and the semaphore is * unlocked. * @param handle a handle to a daemon connection. * @param preferences the preferences to be synchronized * @return an error code indicating whether the operating was successful. */errno_t iSCSIDaemonPreferencesIOUnlockAndSync(iSCSIDaemonHandle handle, iSCSIPreferencesRef preferences){ // Validate inputs if(handle < 0) return EINVAL; CFDataRef preferencesData = NULL; iSCSIDMsgPreferencesIOUnlockAndSyncCmd cmd = iSCSIDMsgPreferencesIOUnlockAndSyncCmdInit; if(preferences) { preferencesData = iSCSIPreferencesCreateData(preferences); cmd.preferencesLength = (UInt32)CFDataGetLength(preferencesData); } else cmd.preferencesLength = 0; errno_t error = iSCSIDaemonSendMsg(handle,(iSCSIDMsgGeneric *)&cmd,preferencesData,NULL); if(preferencesData) CFRelease(preferencesData); if(error) return error; iSCSIDMsgPreferencesIOUnlockAndSyncRsp rsp; if(recv(handle,&rsp,sizeof(rsp),0) != sizeof(rsp)) return EIO; if(rsp.funcCode != kiSCSIDPreferencesIOUnlockAndSync) return EIO; return rsp.errorCode;}
开发者ID:jeditekunum,项目名称:iSCSIInitiator,代码行数:43,
示例24: createHTMLDataCFDataRef createHTMLData(CFDataRef nfo) { // Load HTML constants (UCS2) CFDataRef preNfo = createUCS2FromConst(PRE_NFO_HTML, sizeof(PRE_NFO_HTML)); CFDataRef postNfo = createUCS2FromConst(POST_NFO_HTML, sizeof(POST_NFO_HTML)); CFDataRef preBlock = createUCS2FromConst(PRE_BLOCK_HTML, sizeof(PRE_BLOCK_HTML)); CFDataRef postBlock = createUCS2FromConst(POST_BLOCK_HTML, sizeof(POST_BLOCK_HTML)); CFMutableDataRef result = CFDataCreateMutable(NULL, 0); appendCFData(result, preNfo); CFRelease(preNfo); const UInt8* inPtr = CFDataGetBytePtr(nfo); size_t inCharsLeft = CFDataGetLength(nfo) / sizeof(UInt16); const UInt8* bsPtr = inPtr; bool inRun = false; while (inCharsLeft-- > 0) { UInt16 chr = *((const UInt16*)inPtr); // Look ahead for new state bool newState = inRun; if(!inRun) { if(ISBLOCKORBOX(chr)) { newState = true; } } else { if(!ISBLOCKORBOX(chr) && !ISWHITESPACE(chr)) { newState = false; } } // Process change of state, append data if(inRun != newState) { if(inPtr != bsPtr) { if(inRun) { appendCFData(result, preBlock); CFDataAppendBytes(result, (const UInt8*)bsPtr, (inPtr - bsPtr)); appendCFData(result, postBlock); } else { CFDataAppendBytes(result, (const UInt8*)bsPtr, (inPtr - bsPtr)); } bsPtr = inPtr; } inRun = newState; } inPtr += sizeof(UInt16); } // Append trailing data if(inPtr > bsPtr) { if(inRun) { appendCFData(result, preBlock); CFDataAppendBytes(result, (const UInt8*)bsPtr, (inPtr - bsPtr)); appendCFData(result, postBlock); } else { CFDataAppendBytes(result, (const UInt8*)bsPtr, (inPtr - bsPtr)); } } CFRelease(preBlock); CFRelease(postBlock); appendCFData(result, postNfo); CFRelease(postNfo); return result;}
开发者ID:Critter,项目名称:QuickNFO,代码行数:74,
示例25: appendCFDatavoid appendCFData(CFMutableDataRef dst, CFDataRef src) { CFDataAppendBytes(dst, CFDataGetBytePtr(src), CFDataGetLength(src));}
开发者ID:Critter,项目名称:QuickNFO,代码行数:3,
示例26: CFDataCreateMutableCopyCFMutableDataRef CFDataCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDataRef data) { // Do not allow magic allocator for now for mutable datas, because it // isn't remembered for proper handling later when growth of the buffer // has to occur. Boolean wasMagic = _CFAllocatorIsGCRefZero(allocator); if (0 == capacity) allocator = _CFConvertAllocatorToNonGCRefZeroEquivalent(allocator); CFMutableDataRef r = (CFMutableDataRef) __CFDataInit(allocator, (0 == capacity) ? kCFMutable : kCFFixedMutable, capacity, CFDataGetBytePtr(data), CFDataGetLength(data), NULL); if (wasMagic) CFMakeCollectable(r); return r;}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:10,
示例27: CFDataCreateCopyCFDataRef CFDataCreateCopy(CFAllocatorRef allocator, CFDataRef data) { CFIndex length = CFDataGetLength(data); return __CFDataInit(allocator, kCFImmutable, length, CFDataGetBytePtr(data), length, NULL);}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:4,
示例28: switchbool CDVDVideoCodecVDA::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options){ if (CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVDA) && !hints.software) { CCocoaAutoPool pool; // int width = hints.width; int height = hints.height; int level = hints.level; int profile = hints.profile; switch(profile) { case FF_PROFILE_H264_HIGH_10: case FF_PROFILE_H264_HIGH_10_INTRA: case FF_PROFILE_H264_HIGH_422: case FF_PROFILE_H264_HIGH_422_INTRA: case FF_PROFILE_H264_HIGH_444_PREDICTIVE: case FF_PROFILE_H264_HIGH_444_INTRA: case FF_PROFILE_H264_CAVLC_444: CLog::Log(LOGNOTICE, "%s - unsupported h264 profile(%d)", __FUNCTION__, hints.profile); return false; break; } if (width <= 0 || height <= 0) { CLog::Log(LOGNOTICE, "%s - bailing with bogus hints, width(%d), height(%d)", __FUNCTION__, width, height); return false; } if (Cocoa_GPUForDisplayIsNvidiaPureVideo3() && !CDVDCodecUtils::IsVP3CompatibleWidth(width)) { CLog::Log(LOGNOTICE, "%s - Nvidia 9400 GPU hardware limitation, cannot decode a width of %d", __FUNCTION__, width); return false; } CFDataRef avcCData; switch (hints.codec) { case AV_CODEC_ID_H264: m_bitstream = new CBitstreamConverter; if (!m_bitstream->Open(hints.codec, (uint8_t*)hints.extradata, hints.extrasize, false)) return false; avcCData = CFDataCreate(kCFAllocatorDefault, (const uint8_t*)m_bitstream->GetExtraData(), m_bitstream->GetExtraSize()); m_format = 'avc1'; m_pFormatName = "vda-h264"; break; default: return false; break; } // check the avcC atom's sps for number of reference frames and // bail if interlaced, VDA does not handle interlaced h264. uint32_t avcc_len = CFDataGetLength(avcCData); if (avcc_len < 8) { // avcc atoms with length less than 8 are borked. CFRelease(avcCData); delete m_bitstream, m_bitstream = NULL; return false; } else { bool interlaced = true; uint8_t *spc = (uint8_t*)CFDataGetBytePtr(avcCData) + 6; uint32_t sps_size = BS_RB16(spc); if (sps_size) m_bitstream->parseh264_sps(spc+3, sps_size-1, &interlaced, &m_max_ref_frames); if (interlaced) { CLog::Log(LOGNOTICE, "%s - possible interlaced content.", __FUNCTION__); CFRelease(avcCData); return false; } } if (profile == FF_PROFILE_H264_MAIN && level == 32 && m_max_ref_frames > 4) { // [email C++ CFDictionaryAddValue函数代码示例 C++ CFDataGetBytes函数代码示例
|