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

C++ IOMasterPort函数代码示例

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

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



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

示例1: sleepImmediately

static int sleepImmediately (void)
{
	mach_port_t	masterPort;
	io_connect_t	rootPort;
	IOReturn	err;

	if (IOPMSleepEnabled()) {
		if ((err = IOMasterPort(MACH_PORT_NULL, &masterPort))) {
			fprintf (stderr, "%s: can't get mach master port: %ld\n", args.progname, (long) err);
			return (1);
		}
		rootPort = IOPMFindPowerManagement(masterPort);
		if (rootPort) {
			err = IOPMSleepSystem(rootPort);
			if (err) {
				fprintf (stderr, "%s: IOPMSleepSystem failed: %ld\n", args.progname, (long) err);
				return (1);
			}
		} else {
			fprintf (stderr, "%s: IOPMFindPowerManagement failed\n", args.progname);
			return (1);
		}
	} else {
		fprintf (stderr, "%s: sleep mode is disabled\n", args.progname);
		return (1);
	}
	return (0);
}
开发者ID:Gems,项目名称:majormaco,代码行数:28,代码来源:sleepwatcher.c


示例2: IOMasterPort

int AoEProperties::configure_matching(void)
{
//	debugVerbose("AoEProperties::configure_matching\n");
	
	// Obtain ports for notifications (this will be used for all service matching notifications)
	kern_return_t kresult;
	mach_port_t MasterPort;
	kresult = IOMasterPort(MACH_PORT_NULL, &MasterPort);
	if ( kresult )
	{
		debugError("Could not get masterport. Error=%d\n", kresult);
		return false;
	}
	
	ms_NotificationPort = IONotificationPortCreate(MasterPort);
	
	ms_IOKitNotificationRunLoopSource = IONotificationPortGetRunLoopSource(ms_NotificationPort);
	CFRunLoopAddSource(CFRunLoopGetCurrent(), ms_IOKitNotificationRunLoopSource, kCFRunLoopDefaultMode);
	
	// SetUp Notification for matching to our device
	CFMutableDictionaryRef MatchingDict = IOServiceMatching(AOE_KEXT_NAME_Q);

	IOServiceAddMatchingNotification(ms_NotificationPort,
									 kIOMatchedNotification,
									 MatchingDict,
									 AoEProperties::matched_callback,
									 this,
									 &ms_MatchIt);
	
	// Call the callback immediately to check if our iterator already contains our device (ie. the device is already loaded)
	matched_callback(this, ms_MatchIt);
	
	return m_fMatched ? 0 : -1;
}
开发者ID:ecashin,项目名称:aoe-osx,代码行数:34,代码来源:AoEProperties.cpp


示例3: DASessionCreate

/**
 * Use the DiskArbitration Daemon to inform us of media changes
 */
void MonitorThreadDarwin::run(void)
{
    CFDictionaryRef match     = kDADiskDescriptionMatchVolumeMountable;
    DASessionRef    daSession = DASessionCreate(kCFAllocatorDefault);

    IOMasterPort(MACH_PORT_NULL, &sMasterPort);

    DARegisterDiskAppearedCallback(daSession, match,
                                   diskAppearedCallback, this);
    DARegisterDiskDisappearedCallback(daSession, match,
                                      diskDisappearedCallback, this);
    DARegisterDiskDescriptionChangedCallback(daSession, match,
                                             kDADiskDescriptionWatchVolumeName,
                                             diskChangedCallback, this);

    DASessionScheduleWithRunLoop(daSession,
                                 CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);


    // Nice and simple, as long as our monitor is valid and active, 
    // loop and let daSession check the devices.
    while (m_Monitor && m_Monitor->IsActive())        
    {
        // Run the run loop for interval (milliseconds) - this will
        // handle any disk arbitration appeared/dissappeared events
        CFRunLoopRunInMode(kCFRunLoopDefaultMode,
                           (float) m_Interval / 1000.0f, false );
    }

    DAUnregisterCallback(daSession, (void(*))diskChangedCallback,     this);
    DAUnregisterCallback(daSession, (void(*))diskDisappearedCallback, this);
    DAUnregisterCallback(daSession, (void(*))diskAppearedCallback,    this);
    CFRelease(daSession);
}
开发者ID:royboy626,项目名称:mythtv,代码行数:37,代码来源:mediamonitor-darwin.cpp


示例4: 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


示例5: main

int main(int argc, char **argv)
{
    mach_port_t		masterPort;
    kern_return_t	status;
    int			arg;

    // Parse args

    if( argc < 2 ) {
	printf("%s ClassName...\n", argv[0]);
	exit(0);
    }

    // Obtain the I/O Kit communication handle.

    status = IOMasterPort(bootstrap_port, &masterPort);
    assert(status == KERN_SUCCESS);

    for( arg = 1; arg < argc; arg++ ) {
	printf("terminate %s...",  argv[arg]);
        status = IOCatalogueTerminate( masterPort, 0, argv[arg] );
        printf("(%08x)\n", status);
    }

    exit(0);	
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:26,代码来源:termclass.c


示例6: 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


示例7: 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


示例8: FindModems

static kern_return_t
FindModems(io_iterator_t *matchingServices)
{
    kern_return_t           kernResult;
    mach_port_t             masterPort;
    CFMutableDictionaryRef  classesToMatch;

    kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);
    if (KERN_SUCCESS != kernResult)
    {
        /* printf("IOMasterPort returned %d\n", kernResult); */
        goto exit;
    }

    classesToMatch = IOServiceMatching(kIOSerialBSDServiceValue);
    if (classesToMatch != NULL)
    {
        CFDictionarySetValue(classesToMatch,
                             CFSTR(kIOSerialBSDTypeKey),
                             CFSTR(kIOSerialBSDModemType));
    }

    kernResult = IOServiceGetMatchingServices(masterPort, classesToMatch, matchingServices);
    if (KERN_SUCCESS != kernResult)
    {
        /* printf("IOServiceGetMatchingServices returned %d\n", kernResult); */
        goto exit;
    }

exit:
    return kernResult;
}
开发者ID:achiang,项目名称:wader,代码行数:32,代码来源:_osxserialports.c


示例9: 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


示例10: fetch_raw_smbios

bool fetch_raw_smbios(unsigned char** data, unsigned int* length)
{
  CFDataRef               value = NULL;
  io_object_t             device;
  io_iterator_t           objectIterator;
  CFMutableDictionaryRef  properties = NULL;
  mach_port_t             master_port;
  bool                    result = false;
  
  if (kIOReturnSuccess == IOMasterPort(MACH_PORT_NULL, &master_port)) {
    if (kIOReturnSuccess == IOServiceGetMatchingServices(master_port, IOServiceMatching("AppleSMBIOS"), &objectIterator)) {
      while ((device = IOIteratorNext(objectIterator))) {
        if (kIOReturnSuccess == IORegistryEntryCreateCFProperties(device, &properties, kCFAllocatorDefault, kNilOptions)) {
          if (CFDictionaryGetValueIfPresent(properties, CFSTR("SMBIOS"), (const void **)&value)) {
            *length = CFDataGetLength(value);
            *data = new uint8[*length];
            memcpy(*data, (uint8 *)CFDataGetBytePtr(value), *length);
            result = true;
            break;
          }
          CFRelease(properties);
        }
        IOObjectRelease(device);
      }
      IOObjectRelease(objectIterator);
    }
    mach_port_deallocate(mach_task_self(), master_port);
  }
  return result;
}
开发者ID:untgames,项目名称:funner,代码行数:30,代码来源:smbios.cpp


示例11: IN_GetIOHandle

/*
===============
IN_GetIOHandle
===============
*/
static io_connect_t IN_GetIOHandle( void )  // mac os x mouse accel hack
{
	io_connect_t  iohandle = MACH_PORT_NULL;
	kern_return_t status;
	io_service_t  iohidsystem = MACH_PORT_NULL;
	mach_port_t   masterport;

	status = IOMasterPort( MACH_PORT_NULL, &masterport );

	if ( status != KERN_SUCCESS )
	{
		return 0;
	}

	iohidsystem = IORegistryEntryFromPath( masterport, kIOServicePlane ":/IOResources/IOHIDSystem" );

	if ( !iohidsystem )
	{
		return 0;
	}

	status = IOServiceOpen( iohidsystem, mach_task_self(), kIOHIDParamConnectType, &iohandle );
	IOObjectRelease( iohidsystem );

	return iohandle;
}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:31,代码来源:sdl_input.c


示例12: FindEjectableCDMedia

kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator )
{
    kern_return_t       kernResult;
    mach_port_t     masterPort;
    CFMutableDictionaryRef  classesToMatch;

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

    classesToMatch = IOServiceMatching( kIOCDMediaClass );
    if ( classesToMatch == NULL ) {
        printf( "IOServiceMatching returned a NULL dictionary.\n" );
    } else {
    CFDictionarySetValue( classesToMatch, CFSTR( kIOMediaEjectableKey ), kCFBooleanTrue );
    }
    kernResult = IOServiceGetMatchingServices( masterPort, classesToMatch, mediaIterator );
    if ( KERN_SUCCESS != kernResult )
    {
        printf( "IOServiceGetMatchingServices returned %d\n", kernResult );
    }

    return kernResult;
}
开发者ID:h16o2u9u,项目名称:rtoss,代码行数:25,代码来源:block-raw-posix.c


示例13: 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


示例14: main

int main(int argc, char **argv)
{
  kern_return_t       result;
  
  result = IOMasterPort(bootstrap_port, &masterPort);
  if (result != KERN_SUCCESS) {
    errx(1, "Error getting the IOMaster port: %s",
         mach_error_string(result));
  }
  
  gPlatform = IORegistryEntryFromPath(masterPort, "IODeviceTree:/efi/platform");
  if (gPlatform == 0) {
    errx(1, "EFI is not supported on this system");
  }
  
  CFTypeRef data;
  result = GetOFVariable("Settings", &data);
  if (result != KERN_SUCCESS) {
    errx(1, "Clover absent or too old : %s",
         mach_error_string(result));
  }
  
  PrintConfig(data);
  CFRelease(data);
  
  IOObjectRelease(gPlatform);
  
  return 0;
}
开发者ID:huaqli,项目名称:clover,代码行数:29,代码来源:clover-genconfig.c


示例15: NXOpenEventStatus

/* Open and Close */
NXEventHandle NXOpenEventStatus(void)
{
    NXEventHandle 		handle = MACH_PORT_NULL;
    register kern_return_t	kr;
    io_service_t		service = MACH_PORT_NULL;
    mach_port_t			masterPort;

    do {

	kr = IOMasterPort( MACH_PORT_NULL, &masterPort );
	if( kr != KERN_SUCCESS)
	    break;

        service = IORegistryEntryFromPath( masterPort,
                    kIOServicePlane ":/IOResources/IOHIDSystem" );
	if( !service)
	    break;

        kr = IOServiceOpen( service,
			mach_task_self(),
			kIOHIDParamConnectType,
			&handle);

        IOObjectRelease( service );

    } while( false );

    return( handle );
}
开发者ID:wzw19890321,项目名称:IOKitUser,代码行数:30,代码来源:IOEventStatusAPI.c


示例16: suplibDarwinOpenService

/**
 * Opens the IOKit service, instantiating org_virtualbox_SupDrvClient.
 *
 * @returns VBox status code.
 */
static int suplibDarwinOpenService(PSUPLIBDATA pThis)
{
    /*
     * Open the IOKit client first - The first step is finding the service.
     */
    mach_port_t MasterPort;
    kern_return_t kr = IOMasterPort(MACH_PORT_NULL, &MasterPort);
    if (kr != kIOReturnSuccess)
    {
        LogRel(("IOMasterPort -> %d\n", kr));
        return VERR_GENERAL_FAILURE;
    }

    CFDictionaryRef ClassToMatch = IOServiceMatching(IOCLASS_NAME);
    if (!ClassToMatch)
    {
        LogRel(("IOServiceMatching(\"%s\") failed.\n", IOCLASS_NAME));
        return VERR_GENERAL_FAILURE;
    }

    /* Create an io_iterator_t for all instances of our drivers class that exist in the IORegistry. */
    io_iterator_t Iterator;
    kr = IOServiceGetMatchingServices(MasterPort, ClassToMatch, &Iterator);
    if (kr != kIOReturnSuccess)
    {
        LogRel(("IOServiceGetMatchingServices returned %d\n", kr));
        return VERR_GENERAL_FAILURE;
    }

    /* Get the first item in the iterator and release it. */
    io_service_t ServiceObject = IOIteratorNext(Iterator);
    IOObjectRelease(Iterator);
    if (!ServiceObject)
    {
        LogRel(("SUP: Couldn't find any matches. The kernel module is probably not loaded.\n"));
        return VERR_VM_DRIVER_NOT_INSTALLED;
    }

    /*
     * Open the service.
     *
     * This will cause the user client class in SUPDrv-darwin.cpp to be
     * instantiated and create a session for this process.
     */
    io_connect_t Connection = NULL;
    kr = IOServiceOpen(ServiceObject, mach_task_self(), SUP_DARWIN_IOSERVICE_COOKIE, &Connection);
    IOObjectRelease(ServiceObject);
    if (kr != kIOReturnSuccess)
    {
        LogRel(("SUP: IOServiceOpen returned %d. Driver open failed.\n", kr));
        pThis->uConnection = 0;
        return VERR_VM_DRIVER_OPEN_ERROR;
    }

    AssertCompile(sizeof(pThis->uConnection) >= sizeof(Connection));
    pThis->uConnection = Connection;
    return VINF_SUCCESS;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:63,代码来源:SUPLib-darwin.cpp


示例17: main

int main (int argc, const char * argv[])
{
    kern_return_t			err;
    CFMutableDictionaryRef 	matchingDictionary = 0;		// requires <IOKit/IOKitLib.h>
    SInt32					idVendor = 1351;
    SInt32					idProduct = 8193;
    CFNumberRef				numberRef;
    io_iterator_t			iterator = 0;
    io_service_t			usbDeviceRef;
    
    err = IOMasterPort(MACH_PORT_NULL, &masterPort);				
    if (err)
    {
        printf("USBSimpleExample: could not create master port, err = %08x\n", err);
        return err;
    }
    matchingDictionary = IOServiceMatching(kIOUSBDeviceClassName);	// requires <IOKit/usb/IOUSBLib.h>
    if (!matchingDictionary)
    {
        printf("USBSimpleExample: could not create matching dictionary\n");
        return -1;
    }
    numberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &idVendor);
    if (!numberRef)
    {
        printf("USBSimpleExample: could not create CFNumberRef for vendor\n");
        return -1;
    }
    CFDictionaryAddValue(matchingDictionary, CFSTR(kUSBVendorID), numberRef);
    CFRelease(numberRef);
    numberRef = 0;
    numberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &idProduct);
    if (!numberRef)
    {
        printf("USBSimpleExample: could not create CFNumberRef for product\n");
        return -1;
    }
    CFDictionaryAddValue(matchingDictionary, CFSTR(kUSBProductID), numberRef);
    CFRelease(numberRef);
    numberRef = 0;
    
    err = IOServiceGetMatchingServices(masterPort, matchingDictionary, &iterator);
    matchingDictionary = 0;			// this was consumed by the above call
    
    while ( (usbDeviceRef = IOIteratorNext(iterator)) )
    {
		printf("Found device %p\n", (void*)usbDeviceRef);
		dealWithDevice(usbDeviceRef);
		IOObjectRelease(usbDeviceRef);			// no longer need this reference
    }
    
    IOObjectRelease(iterator);
    iterator = 0;
    
    mach_port_deallocate(mach_task_self(), masterPort);
    return 0;
}
开发者ID:a-page,项目名称:IOUSBFamily,代码行数:57,代码来源:main.c


示例18: resetBaseband

void resetBaseband() {
    LOG(LOGLEVEL_INFO, "Resetting baseband...\n");
    mach_port_t masterPort;
    kern_return_t result = IOMasterPort(MACH_PORT_NULL, &masterPort);
    CFMutableDictionaryRef matchingDict = IOServiceMatching("AppleBaseband");
    io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
    io_connect_t conn;
    result = IOServiceOpen(service, mach_task_self(), 0, &conn);
    result = IOConnectCallScalarMethod(conn, 0, 0, 0, 0, 0);
    IOServiceClose(conn);
}
开发者ID:Alioune18,项目名称:iphone-elite,代码行数:11,代码来源:baseband.c


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


示例20: OpenDataPort

int OpenDataPort(char *DriverClassName, io_connect_t *DataPort)
{
    kern_return_t	kernResult;
    mach_port_t		masterPort;
    io_service_t	serviceObject;
    io_connect_t	dataPort;
    io_iterator_t 	iterator;
    CFDictionaryRef	classToMatch;
	
	
    kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);
	
    if (kernResult != KERN_SUCCESS)
    {
        syslog(LOG_ERR, "OpenDataPort: IOMasterPort Failed. %d\n", kernResult);
        return kernResult;
    }
	
    classToMatch = IOServiceMatching(DriverClassName);
	
    if (classToMatch == NULL)
    {
        syslog(LOG_ERR, "OpenDataPort: IOServiceMatching returned a NULL dictionary.");
        return -1;
    }
	
    kernResult = IOServiceGetMatchingServices(masterPort, classToMatch, &iterator);
	
    if (kernResult != KERN_SUCCESS)
    {
        syslog(LOG_ERR, "OpenDataPort: IOServiceGetMatchingServices Failed %d\n", kernResult);
        return kernResult;
    }
	
    serviceObject = IOIteratorNext(iterator);
    IOObjectRelease(iterator);
    if (!serviceObject)
    {
        syslog(LOG_ERR, "OpenDataPort: Couldn't find any matches.");
        return kernResult;
    }
	
    kernResult = IOServiceOpen(serviceObject, mach_task_self(), 0, &dataPort);
    IOObjectRelease(serviceObject);
    if (kernResult != KERN_SUCCESS)
    {
        syslog(LOG_ERR, "OpenDataPort: IOServiceOpen Failed %d\n", kernResult);
        return kernResult;
    }
	
    *DataPort = dataPort;
	
    return 0;
}
开发者ID:dansdrivers,项目名称:ndas4mac,代码行数:54,代码来源:NDASIOConnect.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ IONIL函数代码示例发布时间:2022-05-30
下一篇:
C++ IOMalloc函数代码示例发布时间: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