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

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

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

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

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

示例1: IOHIDManagerCreate

//  open - open 1 or more devices////    Inputs://	max = maximum number of devices to open//	vid = Vendor ID, or -1 if any//	pid = Product ID, or -1 if any//	usage_page = top level usage page, or -1 if any//	usage = top level usage number, or -1 if any//    Output://	actual number of devices opened//int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage){    static IOHIDManagerRef hid_manager=NULL;    CFMutableDictionaryRef dict;    CFNumberRef num;    IOReturn ret;    hid_t *p;    int count=0;    if (first_hid) free_all_hid();    //printf("pjrc_rawhid_open, max=%d/n", max);    if (max < 1) return 0;    // Start the HID Manager    // http://developer.apple.com/technotes/tn2007/tn2187.html    if (!hid_manager) {        hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);        if (hid_manager == NULL || CFGetTypeID(hid_manager) != IOHIDManagerGetTypeID()) {            if (hid_manager) CFRelease(hid_manager);            return 0;        }    }    if (vid > 0 || pid > 0 || usage_page > 0 || usage > 0) {        // Tell the HID Manager what type of devices we want        dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,                                         &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);        if (!dict) return 0;        if (vid > 0) {            num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &vid);            CFDictionarySetValue(dict, CFSTR(kIOHIDVendorIDKey), num);            CFRelease(num);        }        if (pid > 0) {            num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &pid);            CFDictionarySetValue(dict, CFSTR(kIOHIDProductIDKey), num);            CFRelease(num);        }        if (usage_page > 0) {            num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage_page);            CFDictionarySetValue(dict, CFSTR(kIOHIDPrimaryUsagePageKey), num);            CFRelease(num);        }        if (usage > 0) {            num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage);            CFDictionarySetValue(dict, CFSTR(kIOHIDPrimaryUsageKey), num);            CFRelease(num);        }        IOHIDManagerSetDeviceMatching(hid_manager, dict);        CFRelease(dict);    } else {        IOHIDManagerSetDeviceMatching(hid_manager, NULL);    }    // set up a callbacks for device attach & detach    IOHIDManagerScheduleWithRunLoop(hid_manager, CFRunLoopGetCurrent(),                                    kCFRunLoopDefaultMode);    IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, attach_callback, NULL);    IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, detach_callback, NULL);    ret = IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone);    if (ret != kIOReturnSuccess) {        printf("Could not start IOHIDManager");        IOHIDManagerUnscheduleFromRunLoop(hid_manager,                                          CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);        CFRelease(hid_manager);        return 0;    }    printf("run loop/n");    // let it do the callback for all devices    while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true) == kCFRunLoopRunHandledSource) ;    // count up how many were added by the callback    for (p = first_hid; p; p = p->next) count++;    return count;}
开发者ID:samguns,项目名称:OpenPilot,代码行数:82,


示例2: add_supplemental

static voidadd_supplemental(CFMutableArrayRef proxies, CFDictionaryRef proxy, uint32_t defaultOrder){	CFArrayRef	domains;	CFIndex		i;	CFIndex		n_domains;	CFArrayRef	orders;	domains = CFDictionaryGetValue(proxy, kSCPropNetProxiesSupplementalMatchDomains);	n_domains = isA_CFArray(domains) ? CFArrayGetCount(domains) : 0;	if (n_domains == 0) {		return;	}	orders = CFDictionaryGetValue(proxy, kSCPropNetProxiesSupplementalMatchOrders);	if (orders != NULL) {		if (!isA_CFArray(orders) || (n_domains != CFArrayGetCount(orders))) {			return;		}	}	/*	 * yes, this is a "supplemental" proxy configuration, expand	 * the match domains and add each to the proxies list.	 */	for (i = 0; i < n_domains; i++) {		CFStringRef		match_domain;		CFNumberRef		match_order;		CFMutableDictionaryRef	match_proxy;		match_domain = CFArrayGetValueAtIndex(domains, i);		if (!isA_CFString(match_domain)) {			continue;		}		match_proxy = CFDictionaryCreateMutableCopy(NULL, 0, proxy);		// set supplemental proxy match "domain"		match_domain = _SC_trimDomain(match_domain);		if (match_domain != NULL) {			CFDictionarySetValue(match_proxy, kSCPropNetProxiesSupplementalMatchDomain, match_domain);			CFRelease(match_domain);		} else {			CFDictionaryRemoveValue(match_proxy, kSCPropNetProxiesSupplementalMatchDomain);		}		// set supplemental proxy match "order"		match_order = (orders != NULL) ? CFArrayGetValueAtIndex(orders, i) : NULL;		if (isA_CFNumber(match_order)) {			CFDictionarySetValue(match_proxy, PROXY_MATCH_ORDER_KEY, match_order);		} else {			CFNumberRef     num;			num = CFNumberCreate(NULL, kCFNumberIntType, &defaultOrder);			CFDictionarySetValue(match_proxy, PROXY_MATCH_ORDER_KEY, num);			CFRelease(num);			defaultOrder++;		// if multiple domains, maintain ordering		}		// remove keys we don't want in a supplemental proxy		CFDictionaryRemoveValue(match_proxy, kSCPropNetProxiesSupplementalMatchDomains);		CFDictionaryRemoveValue(match_proxy, kSCPropNetProxiesSupplementalMatchOrders);		CFDictionaryRemoveValue(match_proxy, kSCPropInterfaceName);		add_proxy(proxies, match_proxy);		CFRelease(match_proxy);	}	return;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:71,


示例3: __addKeysAndValues

static void __addKeysAndValues(const void *key, const void *value, void *context) {    CFDictionarySetValue((CFMutableDictionaryRef)context, key, value);}
开发者ID:Crackerized,项目名称:CF,代码行数:3,


示例4: add_supplemental_proxies

static voidadd_supplemental_proxies(CFMutableArrayRef proxies, CFDictionaryRef services, CFArrayRef service_order){	const void *		keys_q[N_QUICK];	const void **		keys	= keys_q;	CFIndex			i;	CFIndex			n_order;	CFIndex			n_services;	const void *		vals_q[N_QUICK];	const void **		vals	= vals_q;	n_services = isA_CFDictionary(services) ? CFDictionaryGetCount(services) : 0;	if (n_services == 0) {		return;		// if no services	}	if (n_services > (CFIndex)(sizeof(keys_q) / sizeof(CFTypeRef))) {		keys = CFAllocatorAllocate(NULL, n_services * sizeof(CFTypeRef), 0);		vals = CFAllocatorAllocate(NULL, n_services * sizeof(CFTypeRef), 0);	}	n_order = isA_CFArray(service_order) ? CFArrayGetCount(service_order) : 0;	CFDictionaryGetKeysAndValues(services, keys, vals);	for (i = 0; i < n_services; i++) {		uint32_t		defaultOrder;		CFDictionaryRef		proxy;		CFMutableDictionaryRef	proxyWithDNS	= NULL;		CFDictionaryRef		service		= (CFDictionaryRef)vals[i];		if (!isA_CFDictionary(service)) {			continue;		}		proxy = CFDictionaryGetValue(service, kSCEntNetProxies);		if (!isA_CFDictionary(proxy)) {			continue;		}		if ((G_supplemental_proxies_follow_dns != NULL) && CFBooleanGetValue(G_supplemental_proxies_follow_dns)) {			CFDictionaryRef	dns;			CFArrayRef	matchDomains;			CFArrayRef	matchOrders;			if (!CFDictionaryContainsKey(proxy, kSCPropNetProxiesSupplementalMatchDomains) &&			    CFDictionaryGetValueIfPresent(service, kSCEntNetDNS, (const void **)&dns) &&			    isA_CFDictionary(dns) &&			    CFDictionaryGetValueIfPresent(dns, kSCPropNetDNSSupplementalMatchDomains, (const void **)&matchDomains) &&			    isA_CFArray(matchDomains)) {				proxyWithDNS = CFDictionaryCreateMutableCopy(NULL, 0, proxy);				CFDictionarySetValue(proxyWithDNS, kSCPropNetProxiesSupplementalMatchDomains, matchDomains);				if (CFDictionaryGetValueIfPresent(dns, kSCPropNetDNSSupplementalMatchOrders, (const void **)&matchOrders) &&				    isA_CFArray(matchOrders)) {					CFDictionarySetValue(proxyWithDNS, kSCPropNetProxiesSupplementalMatchOrders, matchOrders);				} else {					CFDictionaryRemoveValue(proxyWithDNS, kSCPropNetProxiesSupplementalMatchOrders);				}				proxy = proxyWithDNS;			}		}		defaultOrder = DEFAULT_MATCH_ORDER			       - (DEFAULT_MATCH_ORDER / 2)			       + ((DEFAULT_MATCH_ORDER / 1000) * i);		if ((n_order > 0) &&		    !CFArrayContainsValue(service_order, CFRangeMake(0, n_order), keys[i])) {			// push out services not specified in service order			defaultOrder += (DEFAULT_MATCH_ORDER / 1000) * n_services;		}		add_supplemental(proxies, proxy, defaultOrder);		if (proxyWithDNS != NULL) CFRelease(proxyWithDNS);	}	if (keys != keys_q) {		CFAllocatorDeallocate(NULL, keys);		CFAllocatorDeallocate(NULL, vals);	}	return;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:81,


示例5: copy_scoped_proxies

static CFDictionaryRefcopy_scoped_proxies(CFDictionaryRef services, CFArrayRef order){	CFIndex			i;	CFIndex			n_order;	CFMutableDictionaryRef	scoped	= NULL;	// iterate over services	n_order = isA_CFArray(order) ? CFArrayGetCount(order) : 0;	for (i = 0; i < n_order; i++) {		char			if_name[IF_NAMESIZE];		CFStringRef		interface;		CFMutableDictionaryRef	newProxy;		CFDictionaryRef		proxy;		CFDictionaryRef		service;		CFStringRef		serviceID;		serviceID = CFArrayGetValueAtIndex(order, i);		service = CFDictionaryGetValue(services, serviceID);		if (!isA_CFDictionary(service)) {			// if no service			continue;		}		proxy = CFDictionaryGetValue(service, kSCEntNetProxies);		if (!isA_CFDictionary(proxy)) {			// if no proxy			continue;		}		interface = CFDictionaryGetValue(proxy, kSCPropInterfaceName);		if (interface == NULL) {			// if no [scoped] interface			continue;		}		if ((scoped != NULL) &&		    CFDictionaryContainsKey(scoped, interface)) {			// if we've already processed this [scoped] interface			continue;		}		if ((_SC_cfstring_to_cstring(interface,					     if_name,					     sizeof(if_name),					     kCFStringEncodingASCII) == NULL) ||		    ((if_nametoindex(if_name)) == 0)) {			// if interface index not available			continue;		}		// add [scoped] proxy entry		// ... and remove keys we don't want in a [scoped] proxy		CFRetain(interface);		newProxy = CFDictionaryCreateMutableCopy(NULL, 0, proxy);		CFDictionaryRemoveValue(newProxy, kSCPropNetProxiesSupplementalMatchDomains);		CFDictionaryRemoveValue(newProxy, kSCPropNetProxiesSupplementalMatchOrders);		CFDictionaryRemoveValue(newProxy, kSCPropInterfaceName);		if (scoped == NULL) {			scoped = CFDictionaryCreateMutable(NULL,							   0,							   &kCFTypeDictionaryKeyCallBacks,							   &kCFTypeDictionaryValueCallBacks);		}		CFDictionarySetValue(scoped, interface, newProxy);		CFRelease(newProxy);		CFRelease(interface);	}	return scoped;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:71,


示例6: stream

bool SFB::Audio::MP3Metadata::_ReadMetadata(CFErrorRef *error){	UInt8 buf [PATH_MAX];	if(!CFURLGetFileSystemRepresentation(mURL, false, buf, PATH_MAX))		return false;		std::unique_ptr<TagLib::FileStream> stream(new TagLib::FileStream((const char *)buf, true));	if(!stream->isOpen()) {		if(error) {			SFB::CFString description(CFCopyLocalizedString(CFSTR("The file “%@” could not be opened for reading."), ""));			SFB::CFString failureReason(CFCopyLocalizedString(CFSTR("Input/output error"), ""));			SFB::CFString recoverySuggestion(CFCopyLocalizedString(CFSTR("The file may have been renamed, moved, deleted, or you may not have appropriate permissions."), ""));			*error = CreateErrorForURL(Metadata::ErrorDomain, Metadata::InputOutputError, description, mURL, failureReason, recoverySuggestion);		}		return false;	}	TagLib::MPEG::File file(stream.get(), TagLib::ID3v2::FrameFactory::instance());	if(!file.isValid()) {		if(nullptr != error) {			SFB::CFString description(CFCopyLocalizedString(CFSTR("The file “%@” is not a valid MPEG file."), ""));			SFB::CFString failureReason(CFCopyLocalizedString(CFSTR("Not an MPEG file"), ""));			SFB::CFString recoverySuggestion(CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), ""));						*error = CreateErrorForURL(Metadata::ErrorDomain, Metadata::InputOutputError, description, mURL, failureReason, recoverySuggestion);		}				return false;	}		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MP3"));	if(file.audioProperties()) {		auto properties = file.audioProperties();		AddAudioPropertiesToDictionary(mMetadata, properties);		// TODO: Is this too much information?#if 0		switch(properties->version()) {			case TagLib::MPEG::Header::Version1:				switch(properties->layer()) {					case 1:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-1 Layer I"));		break;					case 2:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-1 Layer II"));	break;					case 3:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-1 Layer III"));	break;				}				break;			case TagLib::MPEG::Header::Version2:				switch(properties->layer()) {					case 1:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-2 Layer I"));		break;					case 2:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-2 Layer II"));	break;					case 3:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-2 Layer III"));	break;				}				break;			case TagLib::MPEG::Header::Version2_5:				switch(properties->layer()) {					case 1:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-2.5 Layer I"));	break;					case 2:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-2.5 Layer II"));	break;					case 3:		CFDictionarySetValue(mMetadata, kFormatNameKey, CFSTR("MPEG-2.5 Layer III"));	break;				}				break;		}#endif		if(properties->xingHeader() && properties->xingHeader()->totalFrames())			AddIntToDictionary(mMetadata, kTotalFramesKey, (int)properties->xingHeader()->totalFrames());	}	if(file.APETag())		AddAPETagToDictionary(mMetadata, mPictures, file.APETag());	if(file.ID3v1Tag())		AddID3v1TagToDictionary(mMetadata, file.ID3v1Tag());	if(file.ID3v2Tag())		AddID3v2TagToDictionary(mMetadata, mPictures, file.ID3v2Tag());	return true;}
开发者ID:sbooth,项目名称:SFBAudioEngine,代码行数:80,


示例7: drives_available

drives_s* drives_available(){  CFMutableDictionaryRef  main_dict = NULL;  CFMutableDictionaryRef  sec_dict  = NULL;  io_iterator_t           itt = IO_OBJECT_NULL;  io_name_t               cls_name;  io_service_t            sd = IO_OBJECT_NULL;  IOCFPlugInInterface     **plg_in_intf = NULL;  SCSITaskDeviceInterface **dev_intf = NULL;  MMCDeviceInterface      **mmc_intf = NULL;  SInt32                  score = 0;  int count;  int ret = 1;  drive_s* d = 0;  drives_s* dd = 0;  if((main_dict = CFDictionaryCreateMutable(kCFAllocatorDefault,0,&kCFTypeDictionaryKeyCallBacks,&kCFTypeDictionaryValueCallBacks)) != NULL){    if((sec_dict = CFDictionaryCreateMutable(kCFAllocatorDefault,0,&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)) != NULL){      CFDictionarySetValue(sec_dict,CFSTR(kIOPropertySCSITaskDeviceCategory),CFSTR(kIOPropertySCSITaskAuthoringDevice));      CFDictionarySetValue(main_dict,CFSTR(kIOPropertyMatchKey),sec_dict);      CFRelease(sec_dict);    }  }  if(IOServiceGetMatchingServices(kIOMasterPortDefault,main_dict,&itt)){    printf("no matching services/n");    return 0;  }  count = 0;  while((sd = IOIteratorNext(itt))) {    if(!IOObjectGetClass(sd,cls_name)){      if(!IOCreatePlugInInterfaceForService(sd,kIOMMCDeviceUserClientTypeID,kIOCFPlugInInterfaceID,&plg_in_intf,&score) &&          !(*plg_in_intf)->QueryInterface(plg_in_intf,CFUUIDGetUUIDBytes(kIOMMCDeviceInterfaceID),(LPVOID*)&mmc_intf))      {        dev_intf = (*mmc_intf)->GetSCSITaskDeviceInterface(mmc_intf);        if(dev_intf){          drive_data_s dd;          dd.mmc_intf = mmc_intf;          dd.plg_in_intf = plg_in_intf;          dd.itt = itt;          dd.dev_intf = dev_intf;          if(drive_type((int)&dd) == T_CDROM){            inquiry_s* inq;            count++;            d = (drive_s*)realloc(d,count*sizeof(drive_s));            inq = drive_inquiry((int)&dd);            memcpy(&d[count-1].name,inq->p_id,sizeof(inq->p_id));            d[count-1].id = count;            free(inq);          }        }      }      if(IOObjectRelease(sd)) ret = 0;    }    if(mmc_intf != NULL)(*mmc_intf)->Release(mmc_intf);    if(plg_in_intf != NULL)IODestroyPlugInInterface(plg_in_intf);  }  IOObjectRelease(itt);  dd = (drives_s*)malloc(sizeof(drives_s));  if(dd){    dd->drives = d;    dd->number = count;  }else{    free(d);    return 0;  }  if(ret)    return dd;  else return 0;}
开发者ID:devilsclaw,项目名称:flasher,代码行数:71,


示例8: cert_load_defaults

static value cert_load_defaults(){#if defined(NEKO_WINDOWS)	value v;	HCERTSTORE store;	PCCERT_CONTEXT cert;	mbedtls_x509_crt *chain = (mbedtls_x509_crt *)alloc(sizeof(mbedtls_x509_crt));	mbedtls_x509_crt_init( chain );	if( store = CertOpenSystemStore(0, (LPCSTR)"Root") ){		cert = NULL;		while( cert = CertEnumCertificatesInStore(store, cert) )			mbedtls_x509_crt_parse_der( chain, (unsigned char *)cert->pbCertEncoded, cert->cbCertEncoded );		CertCloseStore(store, 0);	}	v = alloc_abstract(k_cert, chain);	val_gc(v,free_cert);	return v;#elif defined(NEKO_MAC)	CFMutableDictionaryRef search;	CFArrayRef result;	SecKeychainRef keychain;	SecCertificateRef item;	CFDataRef dat;	value v;	mbedtls_x509_crt *chain = NULL;	// Load keychain	if( SecKeychainOpen("/System/Library/Keychains/SystemRootCertificates.keychain",&keychain) != errSecSuccess )		return val_null;	// Search for certificates	search = CFDictionaryCreateMutable( NULL, 0, NULL, NULL );	CFDictionarySetValue( search, kSecClass, kSecClassCertificate );	CFDictionarySetValue( search, kSecMatchLimit, kSecMatchLimitAll );	CFDictionarySetValue( search, kSecReturnRef, kCFBooleanTrue );	CFDictionarySetValue( search, kSecMatchSearchList, CFArrayCreate(NULL, (const void **)&keychain, 1, NULL) );	if( SecItemCopyMatching( search, (CFTypeRef *)&result ) == errSecSuccess ){		CFIndex n = CFArrayGetCount( result );		for( CFIndex i = 0; i < n; i++ ){			item = (SecCertificateRef)CFArrayGetValueAtIndex( result, i );			// Get certificate in DER format			dat = SecCertificateCopyData( item );			if( dat ){				if( chain == NULL ){					chain = (mbedtls_x509_crt *)alloc(sizeof(mbedtls_x509_crt));					mbedtls_x509_crt_init( chain );				}				mbedtls_x509_crt_parse_der( chain, (unsigned char *)CFDataGetBytePtr(dat), CFDataGetLength(dat) );				CFRelease( dat );			}		}	}	CFRelease(keychain);	if( chain != NULL ){		v = alloc_abstract(k_cert, chain);		val_gc(v,free_cert);		return v;	}else{		return val_null;	}#else	return val_null;#endif}
开发者ID:jonasmalacofilho,项目名称:neko,代码行数:64,


示例9: copy_cdsa_certificate

static CFArrayRef				/* O - Array of certificates */copy_cdsa_certificate(    cupsd_client_t *con)			/* I - Client connection */{  OSStatus		err;		/* Error info */  SecKeychainRef	keychain = NULL;/* Keychain reference */  SecIdentitySearchRef	search = NULL;	/* Search reference */  SecIdentityRef	identity = NULL;/* Identity */  CFArrayRef		certificates = NULL;					/* Certificate array */  SecPolicyRef		policy = NULL;	/* Policy ref */  CFStringRef		servername = NULL;					/* Server name */  CFMutableDictionaryRef query = NULL;	/* Query qualifiers */  CFArrayRef		list = NULL;	/* Keychain list */#    if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)  char			localname[1024];/* Local hostname */#    endif /* HAVE_DNSSD || HAVE_AVAHI */  cupsdLogMessage(CUPSD_LOG_DEBUG,                  "copy_cdsa_certificate: Looking for certs for /"%s/".",		  con->servername);  if ((err = SecKeychainOpen(ServerCertificate, &keychain)))  {    cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot open keychain /"%s/" - %s (%d)",	            ServerCertificate, cssmErrorString(err), (int)err);    goto cleanup;  }  servername = CFStringCreateWithCString(kCFAllocatorDefault, con->servername,					 kCFStringEncodingUTF8);  policy = SecPolicyCreateSSL(1, servername);  if (servername)    CFRelease(servername);  if (!policy)  {    cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot create ssl policy reference");    goto cleanup;  }  if (!(query = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,					  &kCFTypeDictionaryKeyCallBacks,					  &kCFTypeDictionaryValueCallBacks)))  {    cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot create query dictionary");    goto cleanup;  }  list = CFArrayCreate(kCFAllocatorDefault, (const void **)&keychain, 1,                       &kCFTypeArrayCallBacks);  CFDictionaryAddValue(query, kSecClass, kSecClassIdentity);  CFDictionaryAddValue(query, kSecMatchPolicy, policy);  CFDictionaryAddValue(query, kSecReturnRef, kCFBooleanTrue);  CFDictionaryAddValue(query, kSecMatchLimit, kSecMatchLimitOne);  CFDictionaryAddValue(query, kSecMatchSearchList, list);  CFRelease(list);  err = SecItemCopyMatching(query, (CFTypeRef *)&identity);#    if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)  if (err && DNSSDHostName)  {   /*    * Search for the connection server name failed; try the DNS-SD .local    * hostname instead...    */    snprintf(localname, sizeof(localname), "%s.local", DNSSDHostName);    cupsdLogMessage(CUPSD_LOG_DEBUG,		    "copy_cdsa_certificate: Looking for certs for /"%s/".",		    localname);    servername = CFStringCreateWithCString(kCFAllocatorDefault, localname,					   kCFStringEncodingUTF8);    CFRelease(policy);    policy = SecPolicyCreateSSL(1, servername);    if (servername)      CFRelease(servername);    if (!policy)    {      cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot create ssl policy reference");      goto cleanup;    }    CFDictionarySetValue(query, kSecMatchPolicy, policy);    err = SecItemCopyMatching(query, (CFTypeRef *)&identity);  }//.........这里部分代码省略.........
开发者ID:jelmer,项目名称:cups,代码行数:101,


示例10: Q_ASSERT

/**  * @brief open - open 1 or more devices  * @param[in] max maximum number of devices to open  * @param[in] vid Vendor ID, or -1 if any  * @param[in] pid Product ID, or -1 if any  * @param[in] usage_page top level usage page, or -1 if any  * @param[in] usage top level usage number, or -1 if any  * @returns actual number of devices opened  */int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage){    CFMutableDictionaryRef dict;    CFNumberRef num;    IOReturn ret;    Q_ASSERT(hid_manager == NULL);    Q_ASSERT(device_open == false);    attach_count = 0;    // Start the HID Manager    hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);    if (hid_manager == NULL || CFGetTypeID(hid_manager) != IOHIDManagerGetTypeID()) {        if (hid_manager) CFRelease(hid_manager);        return 0;    }    if (vid > 0 || pid > 0 || usage_page > 0 || usage > 0) {        // Tell the HID Manager what type of devices we want        dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,                                         &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);        if (!dict) return 0;        if (vid > 0) {            num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &vid);            CFDictionarySetValue(dict, CFSTR(kIOHIDVendorIDKey), num);            CFRelease(num);        }        if (pid > 0) {            num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &pid);            CFDictionarySetValue(dict, CFSTR(kIOHIDProductIDKey), num);            CFRelease(num);        }        if (usage_page > 0) {            num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage_page);            CFDictionarySetValue(dict, CFSTR(kIOHIDPrimaryUsagePageKey), num);            CFRelease(num);        }        if (usage > 0) {            num = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage);            CFDictionarySetValue(dict, CFSTR(kIOHIDPrimaryUsageKey), num);            CFRelease(num);        }        IOHIDManagerSetDeviceMatching(hid_manager, dict);        CFRelease(dict);    } else {        IOHIDManagerSetDeviceMatching(hid_manager, NULL);    }    // Set the run loop reference before configuring the attach callback    the_correct_runloop = CFRunLoopGetCurrent();    // set up a callbacks for device attach & detach    IOHIDManagerScheduleWithRunLoop(hid_manager, CFRunLoopGetCurrent(),                                    kCFRunLoopDefaultMode);    IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, pjrc_rawhid::attach_callback, this);    IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, pjrc_rawhid::dettach_callback, this);    ret = IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone);    if (ret != kIOReturnSuccess) {        IOHIDManagerUnscheduleFromRunLoop(hid_manager,                                          CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);        CFRelease(hid_manager);        return 0;    }    // let it do the callback for all devices    while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true) == kCFRunLoopRunHandledSource) ;    // count up how many were added by the callback    return attach_count;}
开发者ID:BangBo,项目名称:OpenPilot,代码行数:80,


示例11: IOServiceMatching

brick_t *find_usb_devices (		void *usb, 		int32_t vendor, 	int32_t product,		int32_t configuration, 	int32_t interface,		brick_type_t type) {	usb_handle_t 			*h = (usb_handle_t *) usb;	CFMutableDictionaryRef 		matching;	kern_return_t			kr;	io_iterator_t			devices;	io_service_t			device;	brick_t				*bricks 	= NULL;	int				count;	if (configuration) {		matching = IOServiceMatching (kIOUSBInterfaceClassName);	} else {		matching = IOServiceMatching (kIOUSBDeviceClassName);	}		if (!matching) {		return NULL;	}	CFDictionarySetValue (matching, CFSTR (kUSBVendorID),				CFNumberCreate (kCFAllocatorDefault, 					kCFNumberSInt32Type, &vendor));	CFDictionarySetValue (matching, CFSTR (kUSBProductID),				CFNumberCreate (kCFAllocatorDefault, 					kCFNumberSInt32Type, &product));	if (configuration) {		CFDictionarySetValue (matching, CFSTR (kUSBConfigurationValue),					CFNumberCreate (kCFAllocatorDefault, 						kCFNumberSInt32Type, &configuration));		CFDictionarySetValue (matching, CFSTR (kUSBInterfaceNumber),					CFNumberCreate (kCFAllocatorDefault, 						kCFNumberSInt32Type, &interface));	}		kr = IOServiceGetMatchingServices (h->port, matching, &devices);	if (kr) {		fprintf (stderr, "IOService matching error = %08x/n", kr);		return NULL;	}		count = 0;	while ((device = IOIteratorNext (devices)))		count++;		if (count > 0) {		int i = 0;		IOIteratorReset (devices);		bricks = malloc ((sizeof (brick_t)) * (count + 1));		memset ((void *) bricks, 0, (sizeof (brick_t )) * (count + 1));		while ((device = IOIteratorNext (devices))) {			IOUSBInterfaceInterface182	**intf 			= NULL;			IOUSBDeviceInterface		**dev 			= NULL;			IOCFPlugInInterface		**plugInInterface 	= NULL;			brick_t				*b			= &(bricks[i]);			HRESULT				result;			SInt32				score;			if (configuration) {				kr = IOCreatePlugInInterfaceForService (					device, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID,					&plugInInterface, &score				);			} else {				kr = IOCreatePlugInInterfaceForService (					device, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID,					&plugInInterface, &score				);			}			if (kr || !plugInInterface) {				continue;			}			if (configuration) {				result = (*plugInInterface)->QueryInterface (						plugInInterface,						CFUUIDGetUUIDBytes (kIOUSBInterfaceInterfaceID182),						(LPVOID *) &intf				);			} else {				result = (*plugInInterface)->QueryInterface (						plugInInterface,						CFUUIDGetUUIDBytes (kIOUSBDeviceInterfaceID),						(LPVOID *) &dev				);			}							(*plugInInterface)->Release (plugInInterface);						if (result || !(dev || intf)) {				continue;			}//.........这里部分代码省略.........
开发者ID:bsmr-misc-forks,项目名称:kroc,代码行数:101,


示例12: mailstream_cfstream_set_ssl_enabled

int mailstream_cfstream_set_ssl_enabled(mailstream * s, int ssl_enabled){#if HAVE_CFNETWORK  struct mailstream_cfstream_data * cfstream_data;  int r;    cfstream_data = (struct mailstream_cfstream_data *) s->low->data;  cfstream_data->ssl_enabled = ssl_enabled;  if (ssl_enabled) {    CFMutableDictionaryRef settings;        settings = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);    switch (cfstream_data->ssl_level) {      case MAILSTREAM_CFSTREAM_SSL_LEVEL_NONE:        CFDictionarySetValue(settings, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelNone);        break;      case MAILSTREAM_CFSTREAM_SSL_LEVEL_SSLv2:        CFDictionarySetValue(settings, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelSSLv2);        break;      case MAILSTREAM_CFSTREAM_SSL_LEVEL_SSLv3:        CFDictionarySetValue(settings, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelSSLv3);        break;      case MAILSTREAM_CFSTREAM_SSL_LEVEL_TLSv1:        CFDictionarySetValue(settings, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelTLSv1);        break;      case MAILSTREAM_CFSTREAM_SSL_LEVEL_NEGOCIATED_SSL:        CFDictionarySetValue(settings, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelNegotiatedSSL);        break;    }        if ((cfstream_data->ssl_certificate_verification_mask & MAILSTREAM_CFSTREAM_SSL_ALLOWS_EXPIRED_CERTIFICATES) != 0) {      CFDictionarySetValue(settings, kCFStreamSSLAllowsExpiredCertificates, kCFBooleanTrue);    }    if ((cfstream_data->ssl_certificate_verification_mask & MAILSTREAM_CFSTREAM_SSL_ALLOWS_EXPIRED_ROOTS) != 0) {      CFDictionarySetValue(settings, kCFStreamSSLAllowsExpiredRoots, kCFBooleanTrue);    }    if ((cfstream_data->ssl_certificate_verification_mask & MAILSTREAM_CFSTREAM_SSL_ALLOWS_ANY_ROOT) != 0) {      CFDictionarySetValue(settings, kCFStreamSSLAllowsAnyRoot, kCFBooleanTrue);    }    if ((cfstream_data->ssl_certificate_verification_mask & MAILSTREAM_CFSTREAM_SSL_DISABLE_VALIDATES_CERTIFICATE_CHAIN) != 0) {      CFDictionarySetValue(settings, kCFStreamSSLValidatesCertificateChain, kCFBooleanFalse);    }        CFReadStreamSetProperty(cfstream_data->readStream, kCFStreamPropertySSLSettings, settings);    CFWriteStreamSetProperty(cfstream_data->writeStream, kCFStreamPropertySSLSettings, settings);    CFRelease(settings);  }  else {    CFMutableDictionaryRef settings;        settings = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);    CFDictionarySetValue(settings, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelNone);		CFReadStreamSetProperty(cfstream_data->readStream, kCFStreamPropertySSLSettings, settings);		CFWriteStreamSetProperty(cfstream_data->writeStream, kCFStreamPropertySSLSettings, settings);    CFRelease(settings);        //fprintf(stderr, "is not ssl/n");  }    // We need to investigate more about how to establish a STARTTLS connection.  // For now, wait until we get the certificate chain.  while (1) {    r = wait_runloop(s->low, STATE_WAIT_SSL);    if (r != WAIT_RUNLOOP_EXIT_NO_ERROR) {      return -1;    }    if (cfstream_data->writeSSLResult < 0)      return -1;    if (cfstream_data->readSSLResult < 0)      return -1;        SecTrustRef secTrust = (SecTrustRef)CFReadStreamCopyProperty(cfstream_data->readStream, kCFStreamPropertySSLPeerTrust);    if (secTrust == NULL) {      // No trust, wait more.      continue;    }        CFIndex count = SecTrustGetCertificateCount(secTrust);    CFRelease(secTrust);        if (count == 0) {      // No certificates, wait more.      continue;    }    break;  }    return 0;#else  return -1;#endif}
开发者ID:AlexandrPonomarev,项目名称:Gmail,代码行数:92,


示例13: CFDictionaryRemoveAllValues

bool FLACMetadata::ReadMetadata(CFErrorRef *error){	// Start from scratch	CFDictionaryRemoveAllValues(mMetadata);	CFDictionaryRemoveAllValues(mChangedMetadata);	UInt8 buf [PATH_MAX];	if(!CFURLGetFileSystemRepresentation(mURL, false, buf, PATH_MAX))		return false;	auto stream = new TagLib::FileStream(reinterpret_cast<const char *>(buf), true);	TagLib::FLAC::File file(stream, TagLib::ID3v2::FrameFactory::instance());	if(!file.isValid()) {		if(nullptr != error) {			CFStringRef description = CFCopyLocalizedString(CFSTR("The file “%@” is not a valid FLAC file."), "");			CFStringRef failureReason = CFCopyLocalizedString(CFSTR("Not a FLAC file"), "");			CFStringRef recoverySuggestion = CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), "");						*error = CreateErrorForURL(AudioMetadataErrorDomain, AudioMetadataInputOutputError, description, mURL, failureReason, recoverySuggestion);						CFRelease(description), description = nullptr;			CFRelease(failureReason), failureReason = nullptr;			CFRelease(recoverySuggestion), recoverySuggestion = nullptr;		}		return false;	}	CFDictionarySetValue(mMetadata, kPropertiesFormatNameKey, CFSTR("FLAC"));	if(file.audioProperties()) {		auto properties = file.audioProperties();		AddAudioPropertiesToDictionary(mMetadata, properties);		if(properties->sampleWidth())			AddIntToDictionary(mMetadata, kPropertiesBitsPerChannelKey, properties->sampleWidth());		if(properties->sampleFrames())			AddLongLongToDictionary(mMetadata, kPropertiesTotalFramesKey, properties->sampleFrames());	}	// Add all tags that are present	if(file.ID3v1Tag())		AddID3v1TagToDictionary(mMetadata, file.ID3v1Tag());	if(file.ID3v2Tag()) {		std::vector<AttachedPicture *> pictures;		AddID3v2TagToDictionary(mMetadata, pictures, file.ID3v2Tag());		for(auto picture : pictures)			AddSavedPicture(picture);	}	if(file.xiphComment()) {		std::vector<AttachedPicture *> pictures;		AddXiphCommentToDictionary(mMetadata, pictures, file.xiphComment());		for(auto picture : pictures)			AddSavedPicture(picture);	}	// Add album art	for(auto iter : file.pictureList()) {		CFDataRef data = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(iter->data().data()), iter->data().size());		CFStringRef description = nullptr;		if(!iter->description().isNull())			description = CFStringCreateWithCString(kCFAllocatorDefault, iter->description().toCString(true), kCFStringEncodingUTF8);		AttachedPicture *picture = new AttachedPicture(data, static_cast<AttachedPicture::Type>(iter->type()), description);		AddSavedPicture(picture);		if(data)			CFRelease(data), data = nullptr;		if(description)			CFRelease(description), description = nullptr;	}	return true;}
开发者ID:LionelWang,项目名称:SFBAudioEngine,代码行数:79,


示例14: emit_item

static int emit_item(pkcs12_context * context, NSS_Attribute **attrs,     CFStringRef item_key, CFTypeRef item_value){    int result = -1;	/* parse attrs into friendlyName, localKeyId; ignoring generic attrs */    CFMutableDictionaryRef attr_dict = CFDictionaryCreateMutable(kCFAllocatorDefault,         0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);    require(attr_dict, out);	unsigned numAttrs = nssArraySize((const void **)attrs);    unsigned int dex;	for(dex = 0; dex < numAttrs; dex++) {		NSS_Attribute *attr = attrs[dex];		unsigned numValues = nssArraySize((const void**)attr->attrValue);		DERItem type = { attr->attrType.Data, attr->attrType.Length };		if(DEROidCompare(&type, &oidFriendlyName)) {			/* 			 * BMP string (UniCode). Spec says only one legal value.			 */			require(numValues == 1, out);            SecAsn1Item friendly_name_asn1;			require_noerr(decode_item(context, attr->attrValue[0],					kSecAsn1BMPStringTemplate, &friendly_name_asn1), out);            CFStringRef friendly_name = CFStringCreateWithBytes(kCFAllocatorDefault,                 friendly_name_asn1.Data, friendly_name_asn1.Length,                 kCFStringEncodingUnicode, true);            if (friendly_name) {                CFDictionarySetValue(attr_dict, kSecImportItemLabel, friendly_name);                CFRelease(friendly_name);            }		}		else if(DEROidCompare(&type, &oidLocalKeyId)) {			/* 			 * Octet string. Spec says only one legal value.			 */			require(numValues == 1, out);            SecAsn1Item local_key_id;			require_noerr(decode_item(context, attr->attrValue[0],					kSecAsn1OctetStringTemplate, &local_key_id), out);            CFDataRef keyid = CFDataCreate(kCFAllocatorDefault, local_key_id.Data, local_key_id.Length);            if (keyid) {                CFDictionarySetValue(attr_dict, kSecImportItemKeyID, keyid);                CFRelease(keyid);            }		}	}    CFTypeRef key = CFDictionaryGetValue(attr_dict, kSecImportItemKeyID);    if (!key)        key = CFDictionaryGetValue(attr_dict, kSecImportItemLabel);    if (!key)        key = item_value;    CFMutableDictionaryRef item = (CFMutableDictionaryRef)CFDictionaryGetValue(context->items, key);    if (item) {        CFDictionarySetValue(item, item_key, item_value);    } else {        CFDictionarySetValue(attr_dict, item_key, item_value);        CFDictionarySetValue(context->items, key, attr_dict);    }    result = 0;out:    CFReleaseSafe(attr_dict);    return result;}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:64,


示例15: apple_init_profile

static voidapple_init_profile(    ppd_file_t             *ppd,	/* I - PPD file */    cups_array_t	   *languages,	/* I - Languages in the PPD file */    CFMutableDictionaryRef profile,	/* I - Profile dictionary */    unsigned               id,		/* I - Profile ID */    const char             *name,	/* I - Profile name */    const char             *text,	/* I - Profile UI text */    const char             *iccfile)	/* I - ICC filename */{  CFURLRef		url;		/* URL for profile filename */  CFMutableDictionaryRef dict;		/* Dictionary for name */  char			*language;	/* Current language */  ppd_attr_t		*attr;		/* Profile attribute */  CFStringRef		cflang,		/* Language string */			cftext;		/* Localized text */  (void)id; /*  * Build the profile name dictionary...  */  dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,				   &kCFTypeDictionaryKeyCallBacks,				   &kCFTypeDictionaryValueCallBacks);  if (!dict)  {    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to initialize profile /"%s/".",                    iccfile);    return;  }  cftext = CFStringCreateWithCString(kCFAllocatorDefault, text,				     kCFStringEncodingUTF8);  if (cftext)  {    CFDictionarySetValue(dict, CFSTR("en_US"), cftext);    CFRelease(cftext);  }  if (languages)  {   /*    * Find localized names for the color profiles...    */    cupsArraySave(ppd->sorted_attrs);    for (language = (char *)cupsArrayFirst(languages);	 language;	 language = (char *)cupsArrayNext(languages))    {      if (iccfile)      {        if ((attr = _ppdLocalizedAttr(ppd, "cupsICCProfile", name,	                              language)) == NULL)	  attr = _ppdLocalizedAttr(ppd, "APTiogaProfile", name, language);      }      else        attr = _ppdLocalizedAttr(ppd, "ColorModel", name, language);      if (attr && attr->text[0])      {	cflang = CFStringCreateWithCString(kCFAllocatorDefault, language,					   kCFStringEncodingUTF8);	cftext = CFStringCreateWithCString(kCFAllocatorDefault, attr->text,					   kCFStringEncodingUTF8);        if (cflang && cftext)	  CFDictionarySetValue(dict, cflang, cftext);        if (cflang)	  CFRelease(cflang);        if (cftext)	  CFRelease(cftext);      }    }    cupsArrayRestore(ppd->sorted_attrs);  } /*  * Fill in the profile data...  */ if (iccfile && *iccfile) {    url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)iccfile, (CFIndex)strlen(iccfile), false);    if (url)    {      CFDictionarySetValue(profile, kColorSyncDeviceProfileURL, url);      CFRelease(url);    }  }//.........这里部分代码省略.........
开发者ID:Cacauu,项目名称:cups,代码行数:101,


示例16: FindEthernetInterfaces

// Returns an iterator containing the primary (built-in) Ethernet interface. The caller is responsible for// releasing the iterator after the caller is done with it.static kern_return_t FindEthernetInterfaces(io_iterator_t *matchingServices){    kern_return_t    kernResult;     CFMutableDictionaryRef  matchingDict;    CFMutableDictionaryRef  propertyMatchDict;        // Ethernet interfaces are instances of class kIOEthernetInterfaceClass.     // IOServiceMatching is a convenience function to create a dictionary with the key kIOProviderClassKey and     // the specified value.    matchingDict = IOServiceMatching(kIOEthernetInterfaceClass);	    // Note that another option here would be:    // matchingDict = IOBSDMatching("en0");	    if (NULL == matchingDict) {        printf("IOServiceMatching returned a NULL dictionary./n");    }    else {        // Each IONetworkInterface object has a Boolean property with the key kIOPrimaryInterface. Only the        // primary (built-in) interface has this property set to TRUE.                // IOServiceGetMatchingServices uses the default matching criteria defined by IOService. This considers        // only the following properties plus any family-specific matching in this order of precedence         // (see IOService::passiveMatch):        //        // kIOProviderClassKey (IOServiceMatching)        // kIONameMatchKey (IOServiceNameMatching)        // kIOPropertyMatchKey        // kIOPathMatchKey        // kIOMatchedServiceCountKey        // family-specific matching        // kIOBSDNameKey (IOBSDNameMatching)        // kIOLocationMatchKey                // The IONetworkingFamily does not define any family-specific matching. This means that in                    // order to have IOServiceGetMatchingServices consider the kIOPrimaryInterface property, we must        // add that property to a separate dictionary and then add that to our matching dictionary        // specifying kIOPropertyMatchKey.		        propertyMatchDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,													  &kCFTypeDictionaryKeyCallBacks,													  &kCFTypeDictionaryValueCallBacks);		        if (NULL == propertyMatchDict) {            printf("CFDictionaryCreateMutable returned a NULL dictionary./n");        }        else {            // Set the value in the dictionary of the property with the given key, or add the key             // to the dictionary if it doesn't exist. This call retains the value object passed in.            CFDictionarySetValue(propertyMatchDict, CFSTR(kIOPrimaryInterface), kCFBooleanTrue);                         // Now add the dictionary containing the matching value for kIOPrimaryInterface to our main            // matching dictionary. This call will retain propertyMatchDict, so we can release our reference             // on propertyMatchDict after adding it to matchingDict.            CFDictionarySetValue(matchingDict, CFSTR(kIOPropertyMatchKey), propertyMatchDict);            CFRelease(propertyMatchDict);        }    }        // IOServiceGetMatchingServices retains the returned iterator, so release the iterator when we're done with it.    // IOServiceGetMatchingServices also consumes a reference on the matching dictionary so we don't need to release    // the dictionary explicitly.    kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, matchingServices);        if (KERN_SUCCESS != kernResult) {        printf("IOServiceGetMatchingServices returned 0x%08x/n", kernResult);    }	    return kernResult;}
开发者ID:AsherBond,项目名称:DimSim,代码行数:71,


示例17: apple_register_profiles

//.........这里部分代码省略.........	                   cupsdLogFCMessage, p))	  iccfile[0] = '/0';	cupsArraySave(ppd->sorted_attrs);	if ((profileid_attr = ppdFindAttr(ppd, "cupsProfileID",					  attr->spec)) != NULL &&	    profileid_attr->value && isdigit(profileid_attr->value[0] & 255))	  profile_id = (unsigned)strtoul(profileid_attr->value, NULL, 10);	else	  profile_id = _ppdHashName(attr->spec);	cupsArrayRestore(ppd->sorted_attrs);	profile = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,					    &kCFTypeDictionaryKeyCallBacks,					    &kCFTypeDictionaryValueCallBacks);	if (!profile)	{	  cupsdLogMessage(CUPSD_LOG_ERROR,	                  "Unable to allocate memory for color profile.");	  CFRelease(profiles);	  ppdClose(ppd);	  return;	}	apple_init_profile(ppd, languages, profile, profile_id, attr->spec,	                   attr->text[0] ? attr->text : attr->spec, iccfile);	dict_key = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,	                                    CFSTR("%u"), profile_id);	if (dict_key)	{	  CFDictionarySetValue(profiles, dict_key, profile);	  CFRelease(dict_key);	}	CFRelease(profile);       /*        * See if this is the default profile...	*/        if (!default_profile_id && q1_choice && q2_choice && q3_choice)	{	  snprintf(selector, sizeof(selector), "%s.%s.%s", q1_choice, q2_choice,	           q3_choice);	  if (!strcmp(selector, attr->spec))	    default_profile_id = profile_id;	}        if (!default_profile_id && q1_choice && q2_choice)	{	  snprintf(selector, sizeof(selector), "%s.%s.", q1_choice, q2_choice);	  if (!strcmp(selector, attr->spec))	    default_profile_id = profile_id;	}        if (!default_profile_id && q1_choice && q3_choice)	{	  snprintf(selector, sizeof(selector), "%s..%s", q1_choice, q3_choice);	  if (!strcmp(selector, attr->spec))	    default_profile_id = profile_id;	}        if (!default_profile_id && q1_choice)
开发者ID:Cacauu,项目名称:cups,代码行数:67,


示例18: writeVolatileValue

static void writeVolatileValue(CFTypeRef  context, void *domain, CFStringRef  key, CFTypeRef  value) {    if (value)        CFDictionarySetValue((CFMutableDictionaryRef  )domain, key, value);    else        CFDictionaryRemoveValue((CFMutableDictionaryRef  )domain, key);}
开发者ID:Crackerized,项目名称:CF,代码行数:6,


示例19: do_dictSetKey

//.........这里部分代码省略.........				    (strcasecmp(argv[0], "t"   ) == 0) ||				    (strcasecmp(argv[0], "yes" ) == 0) ||				    (strcasecmp(argv[0], "y"   ) == 0) ||				    (strcmp    (argv[0], "1"   ) == 0)) {				val = CFRetain(kCFBooleanTrue);			} else if ((strcasecmp(argv[0], "false") == 0) ||				   (strcasecmp(argv[0], "f"    ) == 0) ||				   (strcasecmp(argv[0], "no"   ) == 0) ||				   (strcasecmp(argv[0], "n"    ) == 0) ||				   (strcmp    (argv[0], "0"    ) == 0)) {				val = CFRetain(kCFBooleanFalse);			} else {				SCPrint(TRUE, stdout, CFSTR("d.add: invalid data./n"));				if (doArray) CFRelease(array);				CFRelease(key);				return;			}		} else if (doData) {			uint8_t			*bytes;			CFMutableDataRef	data;			int			i;			int			j;			int			n;			n = strlen(argv[0]);			if ((n % 2) == 1) {				SCPrint(TRUE, stdout, CFSTR("d.add: not enough bytes./n"));				if (doArray) CFRelease(array);				CFRelease(key);				return;			}			data = CFDataCreateMutable(NULL, (n / 2));			CFDataSetLength(data, (n / 2));			bytes = (uint8_t *)CFDataGetBytePtr(data);			for (i = 0, j = 0; i < n; i += 2, j++) {				unsigned long	byte;				char		*end;				char		str[3]	= { 0 };				str[0] = argv[0][i];				str[1] = argv[0][i + 1];				errno = 0;				byte = strtoul(str, &end, 16);				if ((*end != '/0') || (errno != 0)) {					CFRelease(data);					data = NULL;					break;				}				bytes[j] = byte;			}			if (data == NULL) {				SCPrint(TRUE, stdout, CFSTR("d.add: invalid data./n"));				if (doArray) CFRelease(array);				CFRelease(key);				return;			}			val = data;		} else if (doNumeric) {			int	intValue;			if (sscanf(argv[0], "%d", &intValue) == 1) {				val = CFNumberCreate(NULL, kCFNumberIntType, &intValue);			} else {				SCPrint(TRUE, stdout, CFSTR("d.add: invalid data./n"));				if (doArray) CFRelease(array);				CFRelease(key);				return;			}		} else {			val = (CFPropertyListRef)CFStringCreateWithCString(NULL, argv[0], kCFStringEncodingUTF8);		}		if (doArray) {			CFArrayAppendValue(array, val);			CFRelease(val);			argv++; argc--;		} else {			break;		}	}	newValue = CFDictionaryCreateMutableCopy(NULL, 0, value);	if (doArray) {		CFDictionarySetValue(newValue, key, array);		CFRelease(array);	} else if (val != NULL) {		CFDictionarySetValue(newValue, key, val);		CFRelease(val);	}	CFRelease(key);	CFRelease(value);	value = newValue;	return;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:101,


示例20: defined

// Return a list of all serial portswxArrayString Serial::port_list(){	wxArrayString list;#if defined(LINUX)	// This is ugly guessing, but Linux doesn't seem to provide anything else.	// If there really is an API to discover serial devices on Linux, please	// email [email
C++ CFE_EVS_SendEvent函数代码示例
C++ CFDictionaryRemoveValue函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。