• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IOServiceGetMatchingServices函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: qWarning

// static
void QextSerialEnumerator::scanPortsOSX(QList<QextPortInfo> & infoList)
{
    io_iterator_t serialPortIterator = 0;
    kern_return_t kernResult = KERN_FAILURE;
    CFMutableDictionaryRef matchingDictionary;

    // first try to get any serialbsd devices, then try any USBCDC devices
    if( !(matchingDictionary = IOServiceMatching(kIOSerialBSDServiceValue) ) ) {
        qWarning("IOServiceMatching returned a NULL dictionary.");
        return;
    }
    CFDictionaryAddValue(matchingDictionary, CFSTR(kIOSerialBSDTypeKey), CFSTR(kIOSerialBSDAllTypes));

    // then create the iterator with all the matching devices
    if( IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDictionary, &serialPortIterator) != KERN_SUCCESS ) {
        qCritical() << "IOServiceGetMatchingServices failed, returned" << kernResult;
        return;
    }
    iterateServicesOSX(serialPortIterator, infoList);
    IOObjectRelease(serialPortIterator);
    serialPortIterator = 0;

    if( !(matchingDictionary = IOServiceNameMatching("AppleUSBCDC")) ) {
        qWarning("IOServiceNameMatching returned a NULL dictionary.");
        return;
    }

    if( IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDictionary, &serialPortIterator) != KERN_SUCCESS ) {
        qCritical() << "IOServiceGetMatchingServices failed, returned" << kernResult;
        return;
    }
    iterateServicesOSX(serialPortIterator, infoList);
    IOObjectRelease(serialPortIterator);
}
开发者ID:ArtTech86,项目名称:the-bus-pirate,代码行数:35,代码来源:qextserialenumerator.cpp


示例2: createSerialIterator

static kern_return_t createSerialIterator(io_iterator_t *serialIterator)
{
    kern_return_t   kernResult;
    mach_port_t     masterPort;
    CFMutableDictionaryRef  classesToMatch;

    if ((kernResult = IOMasterPort(0, &masterPort)) != KERN_SUCCESS)
    {
        printf("IOMasterPort returned %d\n", kernResult);
        return kernResult;
    }

    if ((classesToMatch = IOServiceMatching(kIOSerialBSDServiceValue)) == NULL)
    {
        printf("IOServiceMatching returned NULL\n");
        return kernResult;
    }

    CFDictionarySetValue(classesToMatch, CFSTR(kIOSerialBSDTypeKey),CFSTR(kIOSerialBSDAllTypes));
    kernResult = IOServiceGetMatchingServices(masterPort, classesToMatch, serialIterator);
    if (kernResult != KERN_SUCCESS)
    {
        printf("IOServiceGetMatchingServices returned %d\n", kernResult);
    }

    return kernResult;
}
开发者ID:RayGralak,项目名称:phd2,代码行数:27,代码来源:serialport_mac.cpp


示例3: SMCOpen

kern_return_t SMCOpen(io_connect_t *conn, const char *serviceName)
{
    kern_return_t result;
    mach_port_t   masterPort;
    io_iterator_t iterator;
    io_object_t   device;

    IOMasterPort(MACH_PORT_NULL, &masterPort);

    CFMutableDictionaryRef matchingDictionary = IOServiceMatching(serviceName);
    result = IOServiceGetMatchingServices(masterPort, matchingDictionary, &iterator);
    if (result != kIOReturnSuccess)
    {
        //printf("Error: IOServiceGetMatchingServices() = %08x\n", result);
        return 1;
    }

    device = IOIteratorNext(iterator);
    IOObjectRelease((io_object_t)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;
    }

    return kIOReturnSuccess;
}
开发者ID:ritzcarltn,项目名称:HWSensors,代码行数:35,代码来源:smc.c


示例4: getstats

static int
getstats(void)
{
    time_t                 now;
    io_iterator_t          drivelist;
    io_registry_entry_t    drive;
    CFMutableDictionaryRef match;
    kern_return_t          status;

    now = time(NULL);	/* register current time and check wether cache can be used */
    if (cache_time + CACHE_TIMEOUT > now) {
        return 0;
    }

    /*  Retrieve a list of drives. */
    match = IOServiceMatching("IOMedia");
    CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
    status = IOServiceGetMatchingServices(masterPort, match, &drivelist);
    if (status != KERN_SUCCESS) {
	snmp_log(LOG_ERR, "diskio: couldn't match whole IOMedia devices\n");
/*	fprintf(stderr,"Couldn't match whole IOMedia devices\n"); */
	return(1);
    }

    num_drives = 0;  /* NB: Incremented by handle_drive */
    while ((drive = IOIteratorNext(drivelist)) && (num_drives < MAXDRIVES)) {
	handle_drive(drive, &drivestat[num_drives]);
	IOObjectRelease(drive);
    }
    IOObjectRelease(drivelist);

    cache_time = now;
    return (0);
}
开发者ID:pexip,项目名称:os-net-snmp,代码行数:34,代码来源:diskio.c


示例5: serial_enumerate_device_names

void
serial_enumerate_device_names (serial_enumerate_device_names_callback *callback) {
    io_object_t serialPort;
    io_iterator_t serialPortIterator;

// ask for all the serial ports
    IOServiceGetMatchingServices(kIOMasterPortDefault,
       IOServiceMatching(kIOSerialBSDServiceValue),
       &serialPortIterator);

// loop through all the serial ports and add them to the array
    while ((serialPort = IOIteratorNext(serialPortIterator))) {
        CFStringRef string = IORegistryEntryCreateCFProperty(serialPort, CFSTR(kIOCalloutDeviceKey),  kCFAllocatorDefault, 0);
        CFIndex length = CFStringGetLength(string);
        CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
        char *buffer = (char *)malloc(maxSize);
        if (CFStringGetCString(string, buffer, maxSize, kCFStringEncodingUTF8)) {
            callback(buffer);
        }
        free(buffer);
        CFRelease(string);
        IOObjectRelease(serialPort);
    }

    IOObjectRelease(serialPortIterator);
}
开发者ID:tuscland,项目名称:lw-serial-port,代码行数:26,代码来源:serial.c


示例6: MediaTypeForBSDName

/**
 * Given a BSD device node name, guess its media type
 */
MythMediaType MediaTypeForBSDName(const char *bsdName)
{
    CFMutableDictionaryRef  matchingDict;
    kern_return_t           kernResult;
    io_iterator_t           iter;
    io_service_t            service;
    QString                 msg = QString("MediaTypeForBSDName(%1)")
                                  .arg(bsdName);
    MythMediaType           mediaType;


    if (!bsdName || !*bsdName)
    {
        LOG(VB_GENERAL, LOG_ALERT, msg + " - No name supplied?");
        return MEDIATYPE_UNKNOWN;
    }

    matchingDict = IOBSDNameMatching(sMasterPort, 0, bsdName);
    if (!matchingDict)
    {
        LOG(VB_GENERAL, LOG_ALERT, 
                 msg + " - IOBSDNameMatching() returned a NULL dictionary.");
        return MEDIATYPE_UNKNOWN;
    }

    // Return an iterator across all objects with the matching
    // BSD node name. Note that there should only be one match!
    kernResult = IOServiceGetMatchingServices(sMasterPort, matchingDict, &iter);

    if (KERN_SUCCESS != kernResult)
    {
        LOG(VB_GENERAL, LOG_ALERT,
                 QString(msg + " - IOServiceGetMatchingServices() returned %2")
                         .arg(kernResult));
        return MEDIATYPE_UNKNOWN;
    }
    if (!iter)
    {
        LOG(VB_GENERAL, LOG_ALERT,
                 msg + " - IOServiceGetMatchingServices() returned a NULL "
                       "iterator");
        return MEDIATYPE_UNKNOWN;
    }

    service = IOIteratorNext(iter);

    // Release this now because we only expect
    // the iterator to contain a single io_service_t.
    IOObjectRelease(iter);

    if (!service)
    {
        LOG(VB_GENERAL, LOG_ALERT, 
                 msg + " - IOIteratorNext() returned a NULL iterator");
        return MEDIATYPE_UNKNOWN;
    }
    mediaType = FindMediaType(service);
    IOObjectRelease(service);
    return mediaType;
}
开发者ID:royboy626,项目名称:mythtv,代码行数:63,代码来源:mediamonitor-darwin.cpp


示例7: isComputerIdle

bool isComputerIdle(int idle_secs)
{
    int64_t os_idle_secs = 0;
    io_iterator_t iter = 0;
    if (IOServiceGetMatchingServices(kIOMasterPortDefault, 
                                     IOServiceMatching("IOHIDSystem"), 
                                     &iter) == KERN_SUCCESS)
    {
        io_registry_entry_t entry = IOIteratorNext(iter);
        if (entry)
        {
            CFMutableDictionaryRef dict = NULL;
            if (IORegistryEntryCreateCFProperties(entry, &dict, 
                                                  kCFAllocatorDefault, 
                                                  0) == KERN_SUCCESS)
            {
                CFNumberRef obj = static_cast<CFNumberRef>
                (CFDictionaryGetValue(dict, 
                                      CFSTR("HIDIdleTime")));
                if (obj)
                {
                    int64_t nanoseconds = 0;
                    if (CFNumberGetValue(obj, kCFNumberSInt64Type, 
                                         &nanoseconds))
                    {
// Divide by 10^9 to convert from nanoseconds to seconds.
                        os_idle_secs = (nanoseconds >> 30); 
                    }
                }
            }
开发者ID:CowPanda,项目名称:TeamTalk5,代码行数:30,代码来源:common.cpp


示例8: getSerialModemList

CFArrayRef getSerialModemList() {
    uint32_t serialModemCount = 0;
    CFMutableArrayRef devicePaths = CFArrayCreateMutable(kCFAllocatorDefault, serialModemCount, &kCFTypeArrayCallBacks);
    
    kern_return_t kernalReturnValue;
    
    CFMutableDictionaryRef deviceMatchingDictionary = NULL;
    deviceMatchingDictionary = IOServiceMatching(kIOSerialBSDServiceValue);
    io_iterator_t deviceIterator;
    kernalReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceMatchingDictionary,
                                                     &deviceIterator);
    if (kernalReturnValue != KERN_SUCCESS) {
        return NULL;
    }
    
    io_service_t device;
    while ((device = IOIteratorNext(deviceIterator)))
    {
        CFMutableDictionaryRef deviceProperties = NULL;
        kernalReturnValue = IORegistryEntryCreateCFProperties(device, &deviceProperties, kCFAllocatorDefault, kNilOptions);
        if (kernalReturnValue != KERN_SUCCESS) {
            return NULL;
        }
        
        CFStringRef devicePathKey = CFStringCreateWithCString(kCFAllocatorDefault, kIOCalloutDeviceKey, kCFStringEncodingASCII);
        CFStringRef devicePath = CFDictionaryGetValue(deviceProperties, devicePathKey);
        IOObjectRelease(device);
        CFArrayAppendValue(devicePaths, devicePath);
    }
    
    IOObjectRelease(deviceIterator);
    return CFArrayCreateCopy(kCFAllocatorDefault, devicePaths);
}
开发者ID:adrian-kemp,项目名称:iCutMyself,代码行数:33,代码来源:SerialCommunication.c


示例9: measureIoLoad

// This function is much inspired by record_all_devices() from
// http://opensource.apple.com/source/system_cmds/system_cmds-230/iostat.tproj/iostat.c
static void measureIoLoad(meter_sysload_t *load) {
  dynamic_accumulator_t *ioLoad = (dynamic_accumulator_t*)load->user;
  dynamic_accumulator_startReporting(ioLoad);
  
  // For all devices..
  io_iterator_t drivelist;
  io_registry_entry_t drive;
  CFMutableDictionaryRef match;
  kern_return_t status;
  
  // Get an iterator for IOMedia objects.
  match = IOServiceMatching("IOMedia");
  CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
  status = IOServiceGetMatchingServices(masterPort, match, &drivelist);
  assert(status == KERN_SUCCESS);
  
  // Scan all of the IOMedia objects, report each object that has a parent
  // IOBlockStorageDriver
  while ((drive = IOIteratorNext(drivelist))) {
    reportDrive(ioLoad, drive);
    
    IOObjectRelease(drive);
  }
  IOObjectRelease(drivelist);
  
  load->ioLoad = dynamic_accumulator_getLoadPercentage(ioLoad);
}
开发者ID:hdfssk,项目名称:bubblemon,代码行数:29,代码来源:osx-meter.c


示例10: main

int
main(void)
{
    kern_return_t          kr;
    io_iterator_t          io_hw_sensors;
    io_service_t           io_hw_sensor;
    CFMutableDictionaryRef sensor_properties;
    CFStringEncoding       systemEncoding = CFStringGetSystemEncoding();
   
    kr = IOServiceGetMatchingServices(kIOMasterPortDefault,
             IOServiceNameMatching("IOHWSensor"), &io_hw_sensors);
   
    while ((io_hw_sensor = IOIteratorNext(io_hw_sensors))) {
        kr = IORegistryEntryCreateCFProperties(io_hw_sensor, &sensor_properties,
                 kCFAllocatorDefault, kNilOptions);
        if (kr == KERN_SUCCESS)
            printTemperatureSensor(sensor_properties, systemEncoding);
   
        CFRelease(sensor_properties);
        IOObjectRelease(io_hw_sensor);
    }
   
    IOObjectRelease(io_hw_sensors);
   
    exit(kr);
}
开发者ID:Leask,项目名称:Mac-OS-X-Internals,代码行数:26,代码来源:lstemperature.c


示例11: open_and_connect_user_client

io_connect_t open_and_connect_user_client(char* service_name, int type) {
    kern_return_t err;
    io_connect_t conn = MACH_PORT_NULL;
    
    CFMutableDictionaryRef matching = IOServiceMatching("IOGraphicsAccelerator2");
    if(!matching){
        printf("unable to create service matching dictionary\n");
        return conn;
    }
    
    io_iterator_t iterator;
    err = IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &iterator);
    if (err != KERN_SUCCESS){
        printf("no matches\n");
        return conn;
    }
    
    io_service_t service = IOIteratorNext(iterator);
    
    if (service == IO_OBJECT_NULL){
        printf("unable to find service\n");
        return conn;
    }
    printf("got service: %x\n", service);
    
    
    err = IOServiceOpen(service, mach_task_self(), type, &conn);
    if (err != KERN_SUCCESS){
        printf("unable to get user client connection\n");
        return MACH_PORT_NULL;
    }
    //getchar();
    printf("got userclient connection: %x\n", conn);
    return conn;
}
开发者ID:LucaBongiorni,项目名称:Bug_POCs,代码行数:35,代码来源:main.cpp


示例12: darwin_get_service_from_location_id

IOReturn darwin_get_service_from_location_id ( unsigned int location_id, io_service_t *service )
{
	io_iterator_t deviceIterator;
	unsigned int found_location_id;

	CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOUSBDeviceClassName);

	if (!matchingDict)
		return kIOReturnError;

	IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &deviceIterator);

	while ((*service = IOIteratorNext (deviceIterator))) {
		/* get the location from the i/o registry */

		found_location_id = GetLocationID(*service);

		if (location_id == found_location_id) {
		  found_location_id = GetLocationID(*service);
		  IOObjectRelease(deviceIterator);
		  return kIOReturnSuccess;
		}
	}
	/* not found, shouldn't happen */
	IOObjectRelease(deviceIterator);
	return kIOReturnError;
}
开发者ID:johnfreed,项目名称:usbutils,代码行数:27,代码来源:usbmisc.c


示例13: 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, char* interfaceName)
{
    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.
  // Note by mike: we're not using this method and then filtering by kIOPropertyMatchKey anymore,
  // because that way we were getting authorization errors for some people for whom, for whatever reason,
  // kIOPropertyMatchKey was not TRUE for their en0 interface
    //matchingDict = IOServiceMatching(kIOEthernetInterfaceClass);

    matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, interfaceName);

    if (NULL == matchingDict) {
      printf("IOBSDNameMatching returned a NULL dictionary.\n");
    }

    // 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:DX94,项目名称:BumpTop,代码行数:32,代码来源:GetPrimaryMACAddress.cpp


示例14: IOServiceMatching

 kern_return_t 
 CPUTemp::SMCOpen(void)
 {
     kern_return_t result;
     io_iterator_t iterator;
     io_object_t   device;
 
     CFMutableDictionaryRef matchingDictionary = IOServiceMatching("AppleSMC");
     result = IOServiceGetMatchingServices(kIOMasterPortDefault, 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;
     }
 
     return kIOReturnSuccess;
 }
开发者ID:tempbottle,项目名称:cpusensor,代码行数:33,代码来源:cpu-temp.cpp


示例15: inputopen

int inputopen(usbdevice* kb){
    // Open master port (if not done yet)
    static mach_port_t master = 0;
    kern_return_t res;
    if(!master&& (res = IOMasterPort(bootstrap_port, &master)) != KERN_SUCCESS){
        master = 0;
        printf("Unable to open master port: 0x%08x\n", res);
        return 0;
    }
    // Open an HID service
    io_iterator_t iter;
    if((res = IOServiceGetMatchingServices(master, IOServiceMatching(kIOHIDSystemClass), &iter)) != KERN_SUCCESS){
        printf("Unable to get input service iterator: 0x%08x\n", res);
        return 0;
    }
    if((res = IOServiceOpen(IOIteratorNext(iter), mach_task_self(), kIOHIDParamConnectType, &kb->event)) != KERN_SUCCESS){
        IOObjectRelease(iter);
        printf("Unable to open IO service: 0x%08x\n", res);
        kb->event = 0;
        return 0;
    }
    IOObjectRelease(iter);
    clearkeys(kb);
    return 1;
}
开发者ID:chocoop,项目名称:ckb,代码行数:25,代码来源:input_mac.c


示例16: get_event_driver

io_connect_t get_event_driver(void){
	static  mach_port_t sEventDrvrRef = 0;
	mach_port_t masterPort, service, iter;
	kern_return_t    kr;
	
	if (!sEventDrvrRef)
	{
		// Get master device port
		kr = IOMasterPort( bootstrap_port, &masterPort );
		check( KERN_SUCCESS == kr);
		
		kr = IOServiceGetMatchingServices( masterPort, IOServiceMatching(
																		 kIOHIDSystemClass ), &iter );
		check( KERN_SUCCESS == kr);
		
		service = IOIteratorNext( iter );
		check( service );
		
		kr = IOServiceOpen( service, mach_task_self(),
							kIOHIDParamConnectType, &sEventDrvrRef );
		check( KERN_SUCCESS == kr );
		
		IOObjectRelease( service );
		IOObjectRelease( iter );
	}
	return sEventDrvrRef;
}
开发者ID:andreberg,项目名称:blacktree-alchemy,代码行数:27,代码来源:QSMediaKeys.c


示例17: genBlockDevs

QueryData genBlockDevs(QueryContext& context) {
  QueryData results;

  auto matching = IOServiceMatching(kIOMediaClassName_);
  if (matching == nullptr) {
    // No devices matched IOMedia.
    return {};
  }

  io_iterator_t it;
  auto kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &it);
  if (kr != KERN_SUCCESS) {
    return {};
  }

  std::vector<std::string> whole_devices;

  io_service_t device;
  while ((device = IOIteratorNext(it))) {
    genIOMediaDevice(device, whole_devices, results);
    IOObjectRelease(device);
  }

  IOObjectRelease(it);
  return results;
}
开发者ID:1514louluo,项目名称:osquery,代码行数:26,代码来源:block_devices.cpp


示例18: _findAppleRemoteDevice

static io_object_t _findAppleRemoteDevice(const char *devName)
{
    CFMutableDictionaryRef hidMatchDictionary = 0;
    io_iterator_t          hidObjectIterator = 0;
    io_object_t            hidDevice = 0;
    IOReturn               ioReturnValue;


    hidMatchDictionary = IOServiceMatching(devName);

    // check for matching devices
    ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault,
                                                 hidMatchDictionary,
                                                 &hidObjectIterator);

    if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0))
        hidDevice = IOIteratorNext(hidObjectIterator);
    else
        LOG(VB_GENERAL, LOG_ERR, LOC +
            QString("_findAppleRemoteDevice(%1) failed").arg(devName));

    // IOServiceGetMatchingServices consumes a reference to the dictionary,
    // so we don't need to release the dictionary ref.
    hidMatchDictionary = 0;
    return hidDevice;
}
开发者ID:txase,项目名称:mythtv,代码行数:26,代码来源:AppleRemote.cpp


示例19: open_iohid

// Opens HID service. Returns kIOReturnSuccess on success.
static int open_iohid(io_connect_t* connection){
    io_iterator_t iter;
    io_service_t service;
    // Open master port (if not done yet)
    static mach_port_t master = 0;
    kern_return_t res;
    if(!master && (res = IOMasterPort(bootstrap_port, &master)) != kIOReturnSuccess){
        master = 0;
        ckb_err("Unable to open master port: 0x%08x\n", res);
        goto failure;
    }
    // Open the HID service
    if((res = IOServiceGetMatchingServices(master, IOServiceMatching(kIOHIDSystemClass), &iter)) != kIOReturnSuccess)
        goto failure;
    service = IOIteratorNext(iter);
    if(!service){
        res = kIOReturnNotOpen;
        goto failure_release_iter;
    }
    if((res = IOServiceOpen(service, mach_task_self(), kIOHIDParamConnectType, connection)) != kIOReturnSuccess){
        *connection = 0;
        goto failure_release_iter;
    }
    // Finished; release objects and return success
    IOObjectRelease(service);
    failure_release_iter:
    IOObjectRelease(iter);
    failure:
    return res;
}
开发者ID:akosipc,项目名称:ckb,代码行数:31,代码来源:input_mac.c


示例20: usb_device

SCM usb_device(SCM name)
{
	io_iterator_t iterator = 0;
	
	CFDictionaryRef matchDict = IOServiceMatching(kIOUSBDeviceClassName);
	IOServiceGetMatchingServices(kIOMasterPortDefault, matchDict, &iterator);

	io_service_t device;
	int cnt = 0;
	
	int found_device = false;

	while(device = IOIteratorNext(iterator))
	{
		io_name_t dev_name;

		if(IORegistryEntryGetName(device, dev_name) == KERN_SUCCESS)
			if(!strncmp(dev_name,scm_to_locale_string(name),strlen(scm_to_locale_string(name))))
				found_device = true;
		
		IOObjectRelease(device);

		++cnt;
	}
	
	IOObjectRelease(iterator);
	
	return scm_from_int(found_device);
}
开发者ID:dohoang1102,项目名称:carmen,代码行数:29,代码来源:guiletest.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IOServiceMatching函数代码示例发布时间:2022-05-30
下一篇:
C++ IOServiceGetMatchingService函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap