您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CFDataGetBytes函数代码示例

51自学网 2021-06-01 19:58:35
  C++
这篇教程C++ CFDataGetBytes函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CFDataGetBytes函数的典型用法代码示例。如果您正苦于以下问题:C++ CFDataGetBytes函数的具体用法?C++ CFDataGetBytes怎么用?C++ CFDataGetBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CFDataGetBytes函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getContext

/** * /brief Retrieves the values from the context. * * /param context the context * /param receiver the receiving object which will be signaled when the *	notification is clicked. May be NULL. * /param clicked_slot the slot to be signaled when the notification is clicked. * /param timeout_slot the slot to be signaled when the notification isn't clicked. * /param context the context which will be passed back to the slot *	May be NULL. */void getContext( CFPropertyListRef context, GrowlNotifierSignaler** signaler, const QObject** receiver, const char** clicked_slot, const char** timeout_slot, void** qcontext/*, pid_t* pid*/){	CFDataRef data;	if (signaler) {		data = (CFDataRef) CFArrayGetValueAtIndex((CFArrayRef) context, 0);		CFDataGetBytes(data, CFRangeMake(0,CFDataGetLength(data)), (UInt8*) signaler);	}	if (receiver){		data = (CFDataRef) CFArrayGetValueAtIndex((CFArrayRef) context, 1);		CFDataGetBytes(data, CFRangeMake(0,CFDataGetLength(data)), (UInt8*) receiver);	}		if (clicked_slot) {		data = (CFDataRef) CFArrayGetValueAtIndex((CFArrayRef) context, 2);		CFDataGetBytes(data, CFRangeMake(0,CFDataGetLength(data)), (UInt8*) clicked_slot);	}		if (timeout_slot) {		data = (CFDataRef) CFArrayGetValueAtIndex((CFArrayRef) context, 3);		CFDataGetBytes(data, CFRangeMake(0,CFDataGetLength(data)), (UInt8*) timeout_slot);	}		if (qcontext) {		data = (CFDataRef) CFArrayGetValueAtIndex((CFArrayRef) context, 4);		CFDataGetBytes(data, CFRangeMake(0,CFDataGetLength(data)), (UInt8*) qcontext);	}	//if (pid) {	//	data = (CFDataRef) CFArrayGetValueAtIndex((CFArrayRef) context, 5);	//	CFDataGetBytes(data, CFRangeMake(0,CFDataGetLength(data)), (UInt8*) pid);	//}}
开发者ID:ZloeSabo,项目名称:qutim-0.2-growlnotifications,代码行数:45,


示例2: __CFWriteStreamClientCallBack

void __CFWriteStreamClientCallBack(CFWriteStreamRef stream, CFStreamEventType eventType, void *clientCallBackInfo) {    // Extract the context    tnet_transport_t *transport = (tnet_transport_t *) clientCallBackInfo;	transport_context_t *context = transport->context;        /* lock context */    tsk_safeobj_lock(context);        // Extract the native socket    CFDataRef data = CFWriteStreamCopyProperty(stream, kCFStreamPropertySocketNativeHandle);    CFSocketNativeHandle fd;    CFDataGetBytes(data, CFRangeMake(0, sizeof(CFSocketNativeHandle)), (UInt8*) &fd);    CFRelease(data);    transport_socket_t *sock = (transport_socket_t *) getSocket(context, fd);        switch(eventType) {        case kCFStreamEventOpenCompleted:        {            TSK_DEBUG_INFO("__CFWriteStreamClientCallBack --> kCFStreamEventOpenCompleted");                        if (TNET_SOCKET_TYPE_IS_SECURE(sock->type)) {#if !TARGET_OS_IPHONE                SSLContextRef sslContext = NULL;                data = CFWriteStreamCopyProperty(stream, kCFStreamPropertySocketSSLContext);                CFDataGetBytes(data, CFRangeMake(0, sizeof(SSLContextRef)), (UInt8*) &sslContext);                CFRelease(data);                                // TODO: Set the client certificates#endif            }                        break;        }        case kCFStreamEventEndEncountered:        case kCFStreamEventErrorOccurred:        {            // Get the error code            CFErrorRef error = CFWriteStreamCopyError(stream);            CFIndex index = CFErrorGetCode(error);            CFRelease(error);                        TSK_DEBUG_INFO("__CFWriteStreamClientCallBack --> Error %lu", index);                        TSK_RUNNABLE_ENQUEUE(transport, event_error, transport->callback_data, sock->fd);            removeSocket(sock, context);            break;        }        default:        {            // Not Implemented            assert(42 == 0);            break;        }    }        /* unlock context */    tsk_safeobj_unlock(context);}
开发者ID:wangzhengnan,项目名称:rtcp-project,代码行数:58,


示例3: CFDataGetBytes

unsigned char * CGImageLuminanceSource::getMatrix() {    int size = width_ * height_;    unsigned char* result = new unsigned char[size];    if (left_ == 0 && top_ == 0 && dataWidth_ == width_ && dataHeight_ == height_) {        CFDataGetBytes(data_, CFRangeMake(0, size), result);    } else {        for (int row = 0; row < height_; row++) {            CFRange dataRange = CFRangeMake((top_ + row) * dataWidth_ + left_, width_);            CFDataGetBytes(data_, dataRange, result + row * width_);        }    }        return result;}
开发者ID:conradev,项目名称:QuickQR,代码行数:14,


示例4: CFDataGetLength

////	We've already read the data into a dataRef.//	Just spoon it out to the caller as they ask for it.//unsigned intURLAccessCFBinInputStream::readBytes(XMLByte* const    toFill                                    , const unsigned int    maxToRead){    //	If we don't have a dataRef, we can't return any data    if (!mDataRef)        return 0;    //	Get the length of the data we've fetched    CFIndex dataLength = CFDataGetLength(mDataRef);    //	Calculate how much to return based on how much    //	we've already returned, and how much the user wants    CFIndex n = dataLength - mBytesProcessed;			// Amount remaining    CFIndex desired = maxToRead & 0x7fffffff;			// CFIndex is signed    if (n > desired)									// Amount desired        n = desired;    //	Read the appropriate bytes into the user buffer    CFRange range = CFRangeMake(mBytesProcessed, n);    CFDataGetBytes(mDataRef, range, reinterpret_cast<UInt8*>(toFill));	    //	Update bytes processed    mBytesProcessed += n;    //	Return the number of bytes delivered    return n;}
开发者ID:mydw,项目名称:mydw,代码行数:32,


示例5: gfx_assert_param

 void Blob::getBytes(Range range, UInt8 *outBuffer) {     gfx_assert_param(outBuffer);     gfx_assert(range.location < length() && range.max() < length(), str("out of bounds range"));          CFDataGetBytes(getStorage(), range, outBuffer); }
开发者ID:decarbonization,项目名称:gfx,代码行数:7,


示例6: genUid

Status genUid(id_t& uid, uuid_string_t& uuid_str) {  CFDataRef uuid = nullptr;  if (!genUnlockIdent(uuid).ok()) {    if (uuid != nullptr) {      CFRelease(uuid);    }    return Status(1, "Could not get unlock ident");  }  CFDataGetBytes(uuid, CFRangeMake(0, CFDataGetLength(uuid)), (UInt8*)uuid_str);  if (uuid != nullptr) {    CFRelease(uuid);  }    uuid_t uuidT = {0};  if (uuid_parse(uuid_str, uuidT) != 0) {    return Status(1, "Could not parse UUID");  }  // id_type >=0 are all valid id types  int id_type = -1;  if (mbr_uuid_to_id(uuidT, &uid, &id_type) != 0 && id_type != ID_TYPE_UID) {    return Status(1, "Could not get uid from uuid");  }  return Status(0, "ok");}
开发者ID:1514louluo,项目名称:osquery,代码行数:27,


示例7: CFDataCreateMutable

//-----------------------------------------------------------------------------bool IPlatformBitmap::createMemoryPNGRepresentation (IPlatformBitmap* bitmap, void** ptr, uint32_t& size){	bool result = false;#if !TARGET_OS_IPHONE	CGBitmap* cgBitmap = dynamic_cast<CGBitmap*> (bitmap);	if (cgBitmap)	{		CGImageRef image = cgBitmap->getCGImage ();		if (image)		{			CFMutableDataRef data = CFDataCreateMutable (NULL, 0);			if (data)			{				CGImageDestinationRef dest = CGImageDestinationCreateWithData (data, kUTTypePNG, 1, 0);				if (dest)				{					CGImageDestinationAddImage (dest, image, 0);					if (CGImageDestinationFinalize (dest))					{						size = (uint32_t)CFDataGetLength (data);						*ptr = malloc (size);						CFDataGetBytes (data, CFRangeMake (0, size), (UInt8*)*ptr);						result = true;					}					CFRelease (dest);				}				CFRelease (data);			}		}	}#endif	return result;}
开发者ID:DaniM,项目名称:lyngo,代码行数:34,


示例8: CreateStringFromData

static CFStringRef CreateStringFromData(CFDataRef data)	// Some IOKit strings are encoded in CFDataRefs; extract as a CFStringRef.	// Also remove any trailing null characters, which can lurk in the 	// I/O Registry strings.{    CFIndex len;	assert(data != NULL);		// Decrement len until to eliminate any trailing null characters.	        len = CFDataGetLength(data);    do {        char ch;                if (len < 1) {            break;        }        CFDataGetBytes(data, CFRangeMake(len - 1, 1), (UInt8 *) &ch);        if (ch != 0) {            break;        }        len -= 1;    } while (true);        return CFStringCreateWithBytes(NULL,                             CFDataGetBytePtr(data), len, kCFStringEncodingMacRoman, false );}
开发者ID:fruitsamples,项目名称:MoreIsBetter,代码行数:28,


示例9: mailstream_low_cfstream_get_fd

static int mailstream_low_cfstream_get_fd(mailstream_low * s){  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;}
开发者ID:PhDroid,项目名称:libetpan,代码行数:33,


示例10: stringFromCFData

std::string stringFromCFData(const CFDataRef& cf_data) {  CFRange range = CFRangeMake(0, CFDataGetLength(cf_data));  char* buffer = (char*)malloc(range.length + 1);  if (buffer == nullptr) {    return "";  }  memset(buffer, 0, range.length + 1);  std::stringstream result;  uint8_t byte;  CFDataGetBytes(cf_data, range, (UInt8*)buffer);  for (CFIndex i = 0; i < range.length; ++i) {    byte = buffer[i];    if (isprint(byte)) {      result << byte;    } else if (buffer[i] == 0) {      result << ' ';    } else {      result << '%' << std::setfill('0') << std::setw(2) << std::hex             << (int)byte;    }  }  // Cleanup allocations.  free(buffer);  return result.str();}
开发者ID:aalness,项目名称:osquery,代码行数:28,


示例11: CFStringCreateExternalRepresentation

std::wstring MacUtils::CFStringRefToWString(CFStringRef aString){    if (aString == NULL) {        return L"";    }        if (!aString)        return false;    CFDataRef cfData = CFStringCreateExternalRepresentation(kCFAllocatorDefault,                                                            aString, kCFStringEncodingUTF32, 0);    CFRelease(aString);    if (!cfData)        return false;    int out_byte_len = CFDataGetLength(cfData);    out_byte_len -= sizeof(wchar_t); // don't count the 32 bit BOM char at start    int out_len = out_byte_len / sizeof(wchar_t);    wchar_t *tmp = new wchar_t[out_len + 1];    // start after the BOM, hence sizeof(wchar_t)    CFDataGetBytes(cfData, CFRangeMake(sizeof(wchar_t), out_byte_len),                   (UInt8*)tmp);    CFRelease(cfData);    tmp[out_len] = 0;    std::wstring result = tmp;    delete[] tmp;        return result;}
开发者ID:cristiantm,项目名称:webcrypto-key-certificate-discovery-js,代码行数:27,


示例12: _cairo_quartz_load_truetype_table

static cairo_int_status_t_cairo_quartz_load_truetype_table (void	            *abstract_font,				   unsigned long     tag,				   long              offset,				   unsigned char    *buffer,				   unsigned long    *length){    cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face (abstract_font);    CFDataRef data = NULL;    if (likely (CGFontCopyTableForTagPtr))	data = CGFontCopyTableForTagPtr (font_face->cgFont, tag);    if (!data)        return CAIRO_INT_STATUS_UNSUPPORTED;    if (buffer == NULL) {	*length = CFDataGetLength (data);	CFRelease (data);	return CAIRO_STATUS_SUCCESS;    }    if (CFDataGetLength (data) < offset + (long) *length) {	CFRelease (data);	return CAIRO_INT_STATUS_UNSUPPORTED;    }    CFDataGetBytes (data, CFRangeMake (offset, *length), buffer);    CFRelease (data);    return CAIRO_STATUS_SUCCESS;}
开发者ID:Lucas-Gluchowski,项目名称:Indigo,代码行数:32,


示例13: lookup_mac_address

CFStringRef lookup_mac_address(const char* serviceName){    unsigned char macaddrBytes[6];    CFStringRef res = NULL;    io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceNameMatching(serviceName));        if(service)    {        CFDataRef macData = IORegistryEntryCreateCFProperty(service, CFSTR("local-mac-address"), kCFAllocatorDefault, 0);        if(macData != NULL)        {            CFDataGetBytes(macData, CFRangeMake(0,6), macaddrBytes);                res = CFStringCreateWithFormat(kCFAllocatorDefault,                                        NULL,                                        CFSTR("%02x:%02x:%02x:%02x:%02x:%02x"),                                        macaddrBytes[0],                                        macaddrBytes[1],                                        macaddrBytes[2],                                        macaddrBytes[3],                                        macaddrBytes[4],                                        macaddrBytes[5]);            CFRelease(macData);        }        IOObjectRelease(service);    }    return res;}
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:29,


示例14: copy_bluetooth_mac_address

CFStringRef copy_bluetooth_mac_address() {    io_service_t service;    CFDataRef macaddrData;    CFStringRef macaddr;    unsigned char macaddrBytes[6];        service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceNameMatching("bluetooth"));    if(!service) {        printf("unable to find bluetooth service/n");        return NULL;    }        macaddrData= IORegistryEntryCreateCFProperty(service, CFSTR("local-mac-address"), kCFAllocatorDefault, 0);    if(macaddrData == NULL) {        printf("bluetooth local-mac-address not found/n");        IOObjectRelease(service);        return NULL;    }    CFDataGetBytes(macaddrData, CFRangeMake(0,6), macaddrBytes);        macaddr = CFStringCreateWithFormat(kCFAllocatorDefault,                                        NULL,                                        CFSTR("%02x:%02x:%02x:%02x:%02x:%02x"),                                        macaddrBytes[0],                                        macaddrBytes[1],                                        macaddrBytes[2],                                        macaddrBytes[3],                                        macaddrBytes[4],                                        macaddrBytes[5]);    return macaddr;}
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:32,


示例15: OSACopyScriptingDefinition

static PyObject *AE_CopyScriptingDefinition(PyObject* self, PyObject* args){	PyObject *res;	FSRef fsRef;	CFDataRef sdef;	CFIndex dataSize;	char *data;	OSAError  err;		if (!PyArg_ParseTuple(args, "O&", AE_GetFSRef, &fsRef))		return NULL;	err = OSACopyScriptingDefinition(&fsRef, 0, &sdef);	if (err) return AE_MacOSError(err);	dataSize = CFDataGetLength(sdef);	data = (char *)CFDataGetBytePtr(sdef);	if (data != NULL) {		res = PyBytes_FromStringAndSize(data, dataSize);	} else {		data = malloc(dataSize);		CFDataGetBytes(sdef, CFRangeMake(0, dataSize), (UInt8 *)data);		res = PyBytes_FromStringAndSize(data, dataSize);		free(data);	}	CFRelease(sdef);	return res;}
开发者ID:AdminCNP,项目名称:appscript,代码行数:26,


示例16: CreateMACFromData

static CFStringRef CreateMACFromData(CFDataRef data)	// Extracts a MAC address as a colon delimited string from 	// a CFDataRef extracted from I/O Registry.{    // mac addresses are 6 bytes long, which translates to 18 chars.    UInt8 bytes[6];    UInt8 *p = &bytes[0];    char s [19];    char *cp = &s[0];    CFIndex len;	assert(data != NULL);		len = CFDataGetLength( data );    // make sure it's valid        if ( len != 6 )        return NULL;    CFDataGetBytes( data, CFRangeMake( 0, 6 ), &bytes[0] );    // add digits in pairs with colon separators    while ( len-- )        cp += sprintf( cp, "%2.2x:", *p++ );    // terminate string    s[17] = '/0';    return CFStringCreateWithCString( NULL, s, kCFStringEncodingMacRoman );}
开发者ID:fruitsamples,项目名称:MoreIsBetter,代码行数:34,


示例17: gst_vtenc_negotiate_downstream

static gbooleangst_vtenc_negotiate_downstream (GstVTEnc * self, CMSampleBufferRef sbuf){  gboolean result;  GstCaps *caps;  GstStructure *s;  if (self->caps_width == self->negotiated_width &&      self->caps_height == self->negotiated_height &&      self->caps_fps_n == self->negotiated_fps_n &&      self->caps_fps_d == self->negotiated_fps_d) {    return TRUE;  }  caps = gst_pad_get_pad_template_caps (self->srcpad);  caps = gst_caps_make_writable (caps);  s = gst_caps_get_structure (caps, 0);  gst_structure_set (s,      "width", G_TYPE_INT, self->negotiated_width,      "height", G_TYPE_INT, self->negotiated_height,      "framerate", GST_TYPE_FRACTION,      self->negotiated_fps_n, self->negotiated_fps_d, NULL);  if (self->details->format_id == kVTFormatH264) {    CMFormatDescriptionRef fmt;    CFDictionaryRef atoms;    CFStringRef avccKey;    CFDataRef avcc;    gpointer codec_data;    gsize codec_data_size;    GstBuffer *codec_data_buf;    fmt = CMSampleBufferGetFormatDescription (sbuf);    atoms = CMFormatDescriptionGetExtension (fmt,        kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);    avccKey = CFStringCreateWithCString (NULL, "avcC", kCFStringEncodingUTF8);    avcc = CFDictionaryGetValue (atoms, avccKey);    CFRelease (avccKey);    codec_data_size = CFDataGetLength (avcc);    codec_data = g_malloc (codec_data_size);    CFDataGetBytes (avcc, CFRangeMake (0, codec_data_size), codec_data);    codec_data_buf = gst_buffer_new_wrapped (codec_data, codec_data_size);    gst_structure_set (s, "codec_data", GST_TYPE_BUFFER, codec_data_buf, NULL);    gst_buffer_unref (codec_data_buf);  }  result = gst_pad_push_event (self->srcpad, gst_event_new_caps (caps));  gst_caps_unref (caps);  self->caps_width = self->negotiated_width;  self->caps_height = self->negotiated_height;  self->caps_fps_n = self->negotiated_fps_n;  self->caps_fps_d = self->negotiated_fps_d;  return result;}
开发者ID:asdlei00,项目名称:gst-plugins-bad,代码行数:58,


示例18: gst_vtenc_negotiate_downstream

static gbooleangst_vtenc_negotiate_downstream (GstVTEnc * self, CMSampleBufferRef sbuf){  gboolean result;  GstCMApi *cm = self->ctx->cm;  GstCaps *caps;  GstStructure *s;  if (self->caps_width == self->negotiated_width &&      self->caps_height == self->negotiated_height &&      self->caps_fps_n == self->negotiated_fps_n &&      self->caps_fps_d == self->negotiated_fps_d) {    return TRUE;  }  caps = gst_caps_copy (gst_pad_get_pad_template_caps (self->srcpad));  s = gst_caps_get_structure (caps, 0);  gst_structure_set (s,      "width", G_TYPE_INT, self->negotiated_width,      "height", G_TYPE_INT, self->negotiated_height,      "framerate", GST_TYPE_FRACTION,      self->negotiated_fps_n, self->negotiated_fps_d, NULL);  if (self->details->format_id == kVTFormatH264) {    CMFormatDescriptionRef fmt;    CFDictionaryRef atoms;    CFStringRef avccKey;    CFDataRef avcc;    GstBuffer *codec_data;    fmt = cm->CMSampleBufferGetFormatDescription (sbuf);    atoms = cm->CMFormatDescriptionGetExtension (fmt,        *(cm->kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms));    avccKey = CFStringCreateWithCString (NULL, "avcC", kCFStringEncodingUTF8);    avcc = CFDictionaryGetValue (atoms, avccKey);    CFRelease (avccKey);    codec_data = gst_buffer_new_and_alloc (CFDataGetLength (avcc));    CFDataGetBytes (avcc, CFRangeMake (0, CFDataGetLength (avcc)),        GST_BUFFER_DATA (codec_data));    gst_structure_set (s, "codec_data", GST_TYPE_BUFFER, codec_data, NULL);    gst_buffer_unref (codec_data);  }  result = gst_pad_set_caps (self->srcpad, caps);  gst_caps_unref (caps);  self->caps_width = self->negotiated_width;  self->caps_height = self->negotiated_height;  self->caps_fps_n = self->negotiated_fps_n;  self->caps_fps_d = self->negotiated_fps_d;  return result;}
开发者ID:dylansong77,项目名称:gstreamer,代码行数:56,


示例19: GetMACAddress

// Given an iterator across a set of Ethernet interfaces, return the MAC address of the last one.// If no interfaces are found the MAC address is set to an empty string.// In this sample the iterator should contain just the primary interface.static kern_return_t GetMACAddress(io_iterator_t intfIterator, UInt8 *MACAddress, UInt8 bufferSize){    io_object_t    intfService;    io_object_t    controllerService;    kern_return_t  kernResult = KERN_FAILURE;        // Make sure the caller provided enough buffer space. Protect against buffer overflow problems.	if (bufferSize < kIOEthernetAddressSize) {		return kernResult;	}		// Initialize the returned address    bzero(MACAddress, bufferSize);        // IOIteratorNext retains the returned object, so release it when we're done with it.    while (intfService = IOIteratorNext(intfIterator))    {        CFTypeRef  MACAddressAsCFData;        		        // IONetworkControllers can't be found directly by the IOServiceGetMatchingServices call,         // since they are hardware nubs and do not participate in driver matching. In other words,        // registerService() is never called on them. So we've found the IONetworkInterface and will         // get its parent controller by asking for it specifically.                // IORegistryEntryGetParentEntry retains the returned object, so release it when we're done with it.        kernResult = IORegistryEntryGetParentEntry(intfService,												   kIOServicePlane,												   &controllerService);		        if (KERN_SUCCESS != kernResult) {            printf("IORegistryEntryGetParentEntry returned 0x%08x/n", kernResult);        }        else {            // Retrieve the MAC address property from the I/O Registry in the form of a CFData            MACAddressAsCFData = IORegistryEntryCreateCFProperty(controllerService,																 CFSTR(kIOMACAddress),																 kCFAllocatorDefault,																 0);            if (MACAddressAsCFData) {                // CFShow(MACAddressAsCFData); // for display purposes only; output goes to stderr                                // Get the raw bytes of the MAC address from the CFData                CFDataGetBytes(MACAddressAsCFData, CFRangeMake(0, kIOEthernetAddressSize), MACAddress);                CFRelease(MACAddressAsCFData);            }			            // Done with the parent Ethernet controller object so we release it.            (void) IOObjectRelease(controllerService);        }                // Done with the Ethernet interface object so we release it.        (void) IOObjectRelease(intfService);    }	    return kernResult;}
开发者ID:AsherBond,项目名称:DimSim,代码行数:59,


示例20: getIdleTime

static long int getIdleTime (void)/* returns mouse and keyboard idle time in TIMER_RESOLUTION seconds; returns -1 on error */{	mach_port_t		masterPort = 0;	io_iterator_t		iter = 0;	io_registry_entry_t     curObj = 0;	CFMutableDictionaryRef  properties = NULL;	CFTypeRef		obj = NULL;	CFTypeID		type = 0;	uint64_t		idletime = -1;	if (IOMasterPort (MACH_PORT_NULL, &masterPort) != KERN_SUCCESS) {		message (LOG_ERR, "can't get IOMasterPort/n");		goto error;	}	IOServiceGetMatchingServices (masterPort, IOServiceMatching(kIOHIDSystemClass), &iter);	if (iter == 0) {		message (LOG_ERR, "can't access IOHIDSystem/n");		goto error;	}	curObj = IOIteratorNext(iter);	if (curObj == 0) {		message (LOG_ERR, "got empty IOIterator/n");		goto error;	}	if (IORegistryEntryCreateCFProperties(curObj, &properties, kCFAllocatorDefault, 0) != KERN_SUCCESS || ! properties) {		message (LOG_ERR, "can't access HIDIdleTime/n");		goto error;	}	obj = CFDictionaryGetValue(properties, CFSTR(kIOHIDIdleTimeKey));	CFRetain (obj);	type = CFGetTypeID(obj);	if (type == CFDataGetTypeID())		CFDataGetBytes ((CFDataRef) obj, CFRangeMake(0, sizeof(idletime)), (UInt8 *) &idletime);   	else if (type == CFNumberGetTypeID())		CFNumberGetValue ((CFNumberRef) obj, kCFNumberSInt64Type, &idletime);	else { 		message (LOG_ERR, "unsupported idle time data type/n", (int) type);		goto error;	}	idletime /= 1000000000l * TIMER_RESOLUTION;      /* transform from 10**-9 to TIMER_RESOLUTION seconds */error :	if (masterPort)		mach_port_deallocate (mach_task_self(), masterPort);	if (obj)		CFRelease(obj);	if (curObj)		IOObjectRelease (curObj);	if (iter)		IOObjectRelease (iter);	if (properties)		CFRelease ((CFTypeRef) properties);	return (idletime);}
开发者ID:Gems,项目名称:majormaco,代码行数:54,


示例21: cga_prepare_set

STATIC voidcga_prepare_set(struct in6_cga_prepare * cga_prep,		CFDataRef modifier, uint8_t security_level){    CFDataGetBytes(modifier,		   CFRangeMake(0, CFDataGetLength(modifier)),		   cga_prep->cga_modifier.octets);    cga_prep->cga_security_level = security_level;    bzero(cga_prep->reserved_A, sizeof(cga_prep->reserved_A));    return;}
开发者ID:carriercomm,项目名称:osx-2,代码行数:11,


示例22: cga_parameters_set

STATIC boolcga_parameters_set(CFDataRef priv, CFDataRef pub, 		   CFDataRef modifier, uint8_t security_level){    UInt8 			buf[CGA_PARAMETERS_MAX_SIZE];    uint16_t			key_len;    UInt8 *			offset;    offset = buf;    /* cga_prepare */    cga_prepare_set((struct in6_cga_prepare *)offset, modifier, security_level);    offset += sizeof(struct in6_cga_prepare);    /* private key length (uint16_t) */    key_len = CFDataGetLength(priv);    bcopy(&key_len, offset, sizeof(key_len));    offset += sizeof(key_len);    /* private key */    CFDataGetBytes(priv, CFRangeMake(0, key_len), offset);    offset += key_len;        /* public key length (uint16_t) */    key_len = CFDataGetLength(pub);    bcopy(&key_len, offset, sizeof(key_len));    offset += sizeof(key_len);    /* public key */    CFDataGetBytes(pub, CFRangeMake(0, key_len), offset);    offset += key_len;    if (sysctlbyname(knet_inet6_send_cga_parameters,		     NULL, NULL, buf, (offset - buf)) != 0) {	my_log_fl(LOG_NOTICE, "sysctl(%s) failed, %s",		  knet_inet6_send_cga_parameters,		  strerror(errno));	return (FALSE);    }    return (TRUE);}
开发者ID:carriercomm,项目名称:osx-2,代码行数:41,


示例23: SMCOpen

kern_return_t SMCOpen(void){    kern_return_t result;    mach_port_t   masterPort;    io_iterator_t iterator;    io_object_t   device;        result = IOMasterPort(MACH_PORT_NULL, &masterPort);        CFMutableDictionaryRef matchingDictionary = IOServiceMatching("AppleSMC");    result = IOServiceGetMatchingServices(masterPort, matchingDictionary, &iterator);    if (result != kIOReturnSuccess)    {        printf("Error: IOServiceGetMatchingServices() = %08x/n", result);        return 1;    }        device = IOIteratorNext(iterator);    IOObjectRelease(iterator);    if (device == 0)    {        printf("Error: no SMC found/n");        return 1;    }        result = IOServiceOpen(device, mach_task_self(), 0, &conn);    IOObjectRelease(device);    if (result != kIOReturnSuccess)    {        printf("Error: IOServiceOpen() = %08x/n", result);        return 1;    }        io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));    if (platformExpert) {        CFTypeRef CFProductData = IORegistryEntryCreateCFProperty(platformExpert,                                        CFSTR("product-name"),                                        kCFAllocatorDefault, 0);        if (CFProductData) {            CFIndex length = CFDataGetLength((CFDataRef)CFProductData);            char buffer[length];            CFDataGetBytes((CFDataRef) CFProductData, CFRangeMake(0,length), (UInt8*)buffer);            CFRelease(CFProductData);            modelNo = *new std::string(buffer);        }                IOObjectRelease(platformExpert);    }        return kIOReturnSuccess;}
开发者ID:IMCG,项目名称:lockfree-link-list,代码行数:51,


示例24: copy_device_csr

void copy_device_csr(io_registry_entry_t dev, uint32_t *rom){    // Attempt to extract the "FireWire Device ROM" property    CFDictionaryRef romdict = IORegistryEntryCreateCFProperty(dev,                                                              CFSTR("FireWire Device ROM"),                                                              NULL,                                                              0);    memset(rom, '/0', FORENSIC1394_CSR_SZ * sizeof(uint32_t));    // Ensure the ROM dictionary exists    if (romdict)    {        // And that it is really a dictionary        if (CFGetTypeID(romdict) == CFDictionaryGetTypeID())        {            // The ROM itself is stored in the "Offset 0" key            CFDataRef romdata = CFDictionaryGetValue(romdict, CFSTR("Offset 0"));            // Ensure the ROM data exists            if (romdata)            {                // And that it is really a data type                if (CFGetTypeID(romdata) == CFDataGetTypeID())                {                    int i;                    CFRange datarange = CFRangeMake(0, CFDataGetLength(romdata));                    // Check the size is not > 1024 bytes                    assert(datarange.length <= (FORENSIC1394_CSR_SZ * sizeof(uint32_t)));                    // Copy the data to the buffer                    CFDataGetBytes(romdata, datarange, (UInt8 *) rom);                    // Convert from big-endian to CPU-endian (no-op on PPC Macs)                    for (i = 0; i < (datarange.length / sizeof(uint32_t)); i++)                    {                        rom[i] = CSR_HOST_QUADLET(rom[i]);                    }                }                // Release the data                CFRelease(romdata);            }        }        // Release the dictionary        CFRelease(romdict);    }}
开发者ID:WorkIdea,项目名称:libforensic1394,代码行数:51,


示例25: IOMasterPort

int IdlePlatform::secondsIdle(){  mach_port_t masterPort;  io_iterator_t iter;  io_registry_entry_t curObj;  IOMasterPort(MACH_PORT_NULL, &masterPort);  IOServiceGetMatchingServices(masterPort, IOServiceMatching("IOHIDSystem"), &iter);  if (iter == 0)    return -1;  curObj = IOIteratorNext(iter);  if (curObj == 0)    return -1;  CFMutableDictionaryRef properties = 0;  CFTypeRef obj;  int result = -1;  if (IORegistryEntryCreateCFProperties(curObj, &properties, kCFAllocatorDefault, 0) == KERN_SUCCESS && properties != NULL) {    obj = CFDictionaryGetValue(properties, CFSTR("HIDIdleTime"));    CFRetain(obj);  } else    obj = NULL;  if (obj) {    uint64_t tHandle;    CFTypeID type = CFGetTypeID(obj);    if (type == CFDataGetTypeID())      CFDataGetBytes((CFDataRef) obj, CFRangeMake(0, sizeof(tHandle)), (UInt8*) &tHandle);    else if (type == CFNumberGetTypeID())      CFNumberGetValue((CFNumberRef)obj, kCFNumberSInt64Type, &tHandle);    else      return -1;    CFRelease(obj);    // essentially divides by 10^9    tHandle >>= 30;    result = tHandle;  }  /* Release our resources */  IOObjectRelease(curObj);  IOObjectRelease(iter);  CFRelease((CFTypeRef)properties);  return result;}
开发者ID:ChALkeR,项目名称:vacuum-im,代码行数:50,


示例26: encodeLegacySessionState

RefPtr<API::Data> encodeLegacySessionState(const SessionState& sessionState){    auto sessionHistoryDictionary = encodeSessionHistory(sessionState.backForwardListState);    auto provisionalURLString = sessionState.provisionalURL.isNull() ? nullptr : sessionState.provisionalURL.string().createCFString();    RetainPtr<CFNumberRef> renderTreeSizeNumber(adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sessionState.renderTreeSize)));    RetainPtr<CFDictionaryRef> stateDictionary;    if (provisionalURLString) {        stateDictionary = createDictionary({            { sessionHistoryKey, sessionHistoryDictionary.get() },            { provisionalURLKey, provisionalURLString.get() },            { renderTreeSizeKey, renderTreeSizeNumber.get() }        });    } else {        stateDictionary = createDictionary({            { sessionHistoryKey, sessionHistoryDictionary.get() },            { renderTreeSizeKey, renderTreeSizeNumber.get() }        });    }    auto writeStream = adoptCF(CFWriteStreamCreateWithAllocatedBuffers(kCFAllocatorDefault, nullptr));    if (!writeStream)        return nullptr;    if (!CFWriteStreamOpen(writeStream.get()))        return nullptr;    if (!CFPropertyListWrite(stateDictionary.get(), writeStream.get(), kCFPropertyListBinaryFormat_v1_0, 0, nullptr))        return nullptr;    auto data = adoptCF(static_cast<CFDataRef>(CFWriteStreamCopyProperty(writeStream.get(), kCFStreamPropertyDataWritten)));    CFIndex length = CFDataGetLength(data.get());    size_t bufferSize = length + sizeof(uint32_t);    auto buffer = MallocPtr<uint8_t>::malloc(bufferSize);    // Put the session state version number at the start of the buffer    buffer.get()[0] = (sessionStateDataVersion & 0xff000000) >> 24;    buffer.get()[1] = (sessionStateDataVersion & 0x00ff0000) >> 16;    buffer.get()[2] = (sessionStateDataVersion & 0x0000ff00) >> 8;    buffer.get()[3] = (sessionStateDataVersion & 0x000000ff);    // Copy in the actual session state data    CFDataGetBytes(data.get(), CFRangeMake(0, length), buffer.get() + sizeof(uint32_t));    return API::Data::createWithoutCopying(buffer.leakPtr(), bufferSize, [] (unsigned char* buffer, const void* context) {        fastFree(buffer);    }, nullptr);}
开发者ID:eocanha,项目名称:webkit,代码行数:50,


示例27: LoadPrefs

void LoadPrefs (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 = (CFDataRef) CFPreferencesCopyAppValue(mref, kCFPreferencesCurrentApplication);				if (data)				{					if (CFDataGetLength(data) == prefList[i].size)						CFDataGetBytes(data, CFRangeMake(0, prefList[i].size), (UInt8 *) prefList[i].itemPointer);					CFRelease(data);				}				CFRelease(sref);			}			CFRelease(mref);		}	}	mref = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFSTR("Preferences_SaveFolder"));	if (mref)	{		sref = (CFStringRef) CFPreferencesCopyAppValue(mref, kCFPreferencesCurrentApplication);		if (sref)			saveFolderPath = sref;		CFRelease(mref);	}	sref = (CFStringRef) CFPreferencesCopyAppValue(CFSTR("LastVersionUsed"), kCFPreferencesCurrentApplication);	if (!sref) {		Settings.SoundInputRate = 31950;		macSoundBuffer_ms = 80;	}	else CFRelease(sref);}
开发者ID:libretro,项目名称:snes9x,代码行数:48,


示例28: MacQTOpenVideoComponent

static void MacQTOpenVideoComponent(ComponentInstance *rci){		OSStatus			err;	ComponentInstance	ci;		ci = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);	CheckError((ci == nil), 01);		CFDataRef	data;	data = (CFDataRef) CFPreferencesCopyAppValue(CFSTR("QTVideoSetting"), kCFPreferencesCurrentApplication);	if (data)	{		CFIndex	len;		Handle	hdl;				len = CFDataGetLength(data);		hdl = NewHandleClear((Size) len);		if (MemError() == noErr)		{				HLock(hdl);			CFDataGetBytes(data, CFRangeMake(0, len), (unsigned char *) *hdl);			err = SCSetInfo(ci, scSettingsStateType, &hdl);					DisposeHandle(hdl);		}		CFRelease(data);	}	else	{		SCSpatialSettings	ss;		SCTemporalSettings	ts;				ss.codecType       = kAnimationCodecType;		ss.codec           = 0;		ss.depth           = 16;		ss.spatialQuality  = codecMaxQuality;		err = SCSetInfo(ci, scSpatialSettingsType, &ss);				ts.frameRate       = FixRatio(Memory.ROMFramesPerSecond, 1);		ts.keyFrameRate    = Memory.ROMFramesPerSecond;		ts.temporalQuality = codecMaxQuality;		err = SCSetInfo(ci, scTemporalSettingsType, &ts);	}	*rci = ci;}
开发者ID:alesegdia,项目名称:snes-sdk,代码行数:48,


示例29: CFStringCreateWithCString

/** * Retrieve the stored data specified by the given 'app' and data 'name'.  Requires * 'buffer' be pre-allocated and contains enough space to hold the data.  Pass in * the size of 'buffer' with 'buffersize'. * * @returns 0 on success, -1 on error */int RudeRegistryCF::QueryByte(const TCHAR *app, const TCHAR *name, void *buffer, int *buffersize){	CFStringRef key = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII);	CFPropertyListRef value = CFPreferencesCopyAppValue(key, kCFPreferencesCurrentApplication);		if(value == 0)		return -1;		if(CFDataGetLength((CFDataRef) value) != *buffersize)		return -1;		CFRange range = CFRangeMake(0, *buffersize);	CFDataGetBytes((CFDataRef) value, range, (UInt8 *) buffer);	return 0;}
开发者ID:dreamsxin,项目名称:golf,代码行数:23,



注:本文中的CFDataGetBytes函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CFDataGetLength函数代码示例
C++ CFDataGetBytePtr函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。