当前位置: 首页>>代码示例>>C++>>正文


C++ CFDataGetBytes函数代码示例

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


在下文中一共展示了CFDataGetBytes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:growlnotification.cpp

示例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,代码来源:tnet_transport_cfsocket.c

示例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,代码来源:CGImageLuminanceSource.cpp

示例4: CFDataGetLength

//
//	We've already read the data into a dataRef.
//	Just spoon it out to the caller as they ask for it.
//
unsigned int
URLAccessCFBinInputStream::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,代码来源:URLAccessCFBinInputStream.cpp

示例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,代码来源:blob.cpp

示例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,代码来源:disk_encryption.cpp

示例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,代码来源:cgbitmap.cpp

示例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,代码来源:MoreSCFPortScanner.c

示例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,代码来源:mailstream_cfstream.c

示例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,代码来源:conversions.cpp

示例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,代码来源:MacUtils.cpp

示例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,代码来源:cairo-quartz-font.c

示例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,代码来源:registry.c

示例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,代码来源:registry.c

示例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,代码来源:ae.c


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