这篇教程C++ CFUUIDGetUUIDBytes函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CFUUIDGetUUIDBytes函数的典型用法代码示例。如果您正苦于以下问题:C++ CFUUIDGetUUIDBytes函数的具体用法?C++ CFUUIDGetUUIDBytes怎么用?C++ CFUUIDGetUUIDBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CFUUIDGetUUIDBytes函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CreateDeviceInterfaceUsingOldMethodvoid CreateDeviceInterfaceUsingOldMethod(io_object_t scsiDevice, IOSCSIDeviceInterface ***interface){ io_name_t className; IOCFPlugInInterface **plugInInterface = NULL; HRESULT plugInResult = S_OK; kern_return_t kr = kIOReturnSuccess; SInt32 score = 0; // Get the object's class name just to display it kr = IOObjectGetClass(scsiDevice, className); if (kr != kIOReturnSuccess) { fprintf(stderr, "Failed to get class name. (0x%08x)/n", kr); } else { fprintf(stderr, "Found device class /"%s/" using old method./n", className); // Create the base interface of type IOCFPlugInInterface. // This object will be used to create the SCSI device interface object. kr = IOCreatePlugInInterfaceForService( scsiDevice, kIOSCSIUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); if (kr != kIOReturnSuccess) { fprintf(stderr, "Couldn't create a plugin interface for the io_service_t. (0x%08x)/n", kr); } else { // Query the base plugin interface for an instance of the specific SCSI device interface // object. plugInResult = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOSCSIDeviceInterfaceID), (LPVOID *) interface); if (plugInResult != S_OK) { fprintf(stderr, "Couldn't create SCSI device interface. (%ld)/n", plugInResult); } // We're now finished with the instance of IOCFPlugInInterface. IODestroyPlugInInterface(plugInInterface); } }}
开发者ID:fruitsamples,项目名称:SCSIOldAndNew,代码行数:42,
示例2: iterate_devicesstatic void iterate_devices(void* context, io_iterator_t iterator){ io_service_t device; while((device = IOIteratorNext(iterator)) != 0){ // Get the plugin interface for the device IOCFPlugInInterface** plugin; SInt32 score; kern_return_t err = IOCreatePlugInInterfaceForService(device, kIOHIDDeviceTypeID, kIOCFPlugInInterfaceID, &plugin, &score); if(err != kIOReturnSuccess){ ckb_err("Failed to create device plugin: %x/n", err); continue; } // Get the device interface hid_dev_t handle; err = (*plugin)->QueryInterface(plugin, CFUUIDGetUUIDBytes(kIOHIDDeviceDeviceInterfaceID), (LPVOID*)&handle); if(err != kIOReturnSuccess){ ckb_err("QueryInterface failed: %x/n", err); continue; } // Plugin is no longer needed IODestroyPlugInInterface(plugin); // Seize the device handle euid_guard_start; err = (*handle)->open(handle, kIOHIDOptionsTypeSeizeDevice); euid_guard_stop; if(err != kIOReturnSuccess){ ckb_err("Failed to seize device: %x/n", err); continue; } // Connect it io_object_t* rm_notify = 0; usbdevice* kb = usbadd(handle, &rm_notify); if(kb) // If successful, register for removal notification IOServiceAddInterestNotification(notify, device, kIOGeneralInterest, remove_device, kb, rm_notify); else { // Otherwise, release it now (*handle)->close(handle, kIOHIDOptionsTypeNone); remove_device(0, device, kIOMessageServiceIsTerminated, 0); } }}
开发者ID:akosipc,项目名称:ckb,代码行数:41,
示例3: CreateRemoteIsochPortIOReturnCreateRemoteIsochPort( IOFireWireLibNubRef nub, IOFireWireLibRemoteIsochPortRef* outPort ){ cout << i << "+CreateRemoteIsochPort/n" ; IOFireWireLibRemoteIsochPortRef port ; port = (**nub).CreateRemoteIsochPort( nub, false, CFUUIDGetUUIDBytes( kIOFireWireRemoteIsochPortInterfaceID ) ) ; if (!port) return kIOReturnError ; (**port).SetGetSupportedHandler( port, & RemotePort_GetSupported ) ; (**port).SetAllocatePortHandler( port, & RemotePort_AllocatePort ) ; (**port).SetReleasePortHandler( port, & RemotePort_ReleasePort ) ; (**port).SetStartHandler( port, & RemotePort_Start ) ; (**port).SetStopHandler( port, & RemotePort_Stop ) ; *outPort = port ; return kIOReturnSuccess ;}
开发者ID:arnelh,项目名称:Examples,代码行数:21,
示例4: CFUUIDGetUUIDBytesHRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::QueryInterface(REFIID iid, LPVOID *ppv){ HRESULT result = E_NOINTERFACE; *ppv = nullptr; CFUUIDBytes unknown = CFUUIDGetUUIDBytes(IUnknownUUID); if (memcmp(&iid, &unknown, sizeof(REFIID)) == 0) { *ppv = this; AddRef(); result = S_OK; } else if (memcmp(&iid, &IID_IDeckLinkNotificationCallback, sizeof(REFIID)) == 0) { *ppv = (IDeckLinkNotificationCallback *)this; AddRef(); result = S_OK; } return result;}
开发者ID:AhmedAbdulSalam5,项目名称:obs-studio,代码行数:21,
示例5: CFUUIDGetUUIDBytes/////////////////////////////////////////////////////////////// Store the interface to the joystick/gamepad for future usage////////////////////////////////////////////////////////////int JoystickSupport::GetDeviceInterface(io_object_t *hidDevice, JoystickDevice &joystick){ IOCFPlugInInterface **plugInInterface; HRESULT plugInResult; SInt32 score = 0; IOReturn ioRes; if (IOCreatePlugInInterfaceForService(*hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score) == kIOReturnSuccess) { plugInResult = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID*)&(joystick.hidDeviceInterface)); if( plugInResult == S_OK ) { (*plugInInterface)->Release(plugInInterface); ioRes = (*(joystick.hidDeviceInterface))->open(joystick.hidDeviceInterface, 0); } } return ioRes;}
开发者ID:fu7mu4,项目名称:entonetics,代码行数:24,
示例6: openDeviceInterfaceunsigned long openDeviceInterface(UInt32 hidDevice, struct deviceRecord *deviceRec){ IOReturn result = 0; HRESULT plugInResult = 0; SInt32 score = 0; IOCFPlugInInterface **plugInInterface = NULL; if (!deviceRec->interface) { result = IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); if (kIOReturnSuccess == result) { // Call a method of the intermediate plug-in to create the device interface plugInResult = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **) &(deviceRec->interface)); if (verbose && plugInResult) printf("Can't get HID device info./n"); IODestroyPlugInInterface(plugInInterface); } else if (verbose) printf("Failed to create USB interface./n"); } if (deviceRec->interface) { result = (*(IOHIDDeviceInterface**) deviceRec->interface)->open(deviceRec->interface, 0); if (verbose && result) printf("Failed to open USB device interface./n"); } return result;}
开发者ID:Nimajamin,项目名称:pk2cmd,代码行数:38,
示例7: FWDevice_readQuadlet// Read a 32bit valuestatic VALUE FWDevice_readQuadlet(VALUE Self, VALUE StartAddr){ FWDevice *device; Data_Get_Struct(Self, FWDevice, device); IOCFPlugInInterface **cfPlugInInterface = NULL; SInt32 theScore; IOFireWireLibDeviceRef fwIntf; IOReturn result = IOCreatePlugInInterfaceForService(device->Device, kIOFireWireLibTypeID, kIOCFPlugInInterfaceID, &cfPlugInInterface, &theScore); (*cfPlugInInterface)->QueryInterface(cfPlugInInterface, CFUUIDGetUUIDBytes(kIOFireWireDeviceInterfaceID), (void **) &fwIntf); assert((*fwIntf)->InterfaceIsInited(fwIntf)); VALUE ret; if((*fwIntf)->Open(fwIntf) == 0) { // Set destination adress. Note that the upper 48 bits identify // the device on the bus and the address set by the operating system. uint64_t startaddr = rb_num2ull(StartAddr); FWAddress fwaddr; fwaddr.nodeID = 0; fwaddr.addressHi = startaddr >> 32; fwaddr.addressLo = startaddr & 0xffffffffL; // do the actual read UInt32 val = 0; result = (*fwIntf)->ReadQuadlet(fwIntf, device->Device, &fwaddr, &val, false, 0); ret = rb_hash_new(); rb_hash_aset(ret, ID2SYM(rb_intern("value")), INT2FIX(val)); rb_hash_aset(ret, ID2SYM(rb_intern("resultcode")), INT2FIX(result)); }
开发者ID:iZsh,项目名称:rubyfw,代码行数:38,
示例8: InitUserID// Generate a unique user ID. We're using a GUID form,// but not jumping through hoops to make it cryptographically// secure. We just want it to distinguish unique users.static nsresultInitUserID(nsACString& aUserID){ nsID id; // copied shamelessly from nsUUIDGenerator.cpp#if defined(XP_WIN) HRESULT hr = CoCreateGuid((GUID*)&id); if (NS_FAILED(hr)) return NS_ERROR_FAILURE;#elif defined(XP_MACOSX) CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); if (!uuid) return NS_ERROR_FAILURE; CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid); memcpy(&id, &bytes, sizeof(nsID)); CFRelease(uuid);#else // UNIX or some such thing id.m0 = random(); id.m1 = random(); id.m2 = random(); *reinterpret_cast<PRUint32*>(&id.m3[0]) = random(); *reinterpret_cast<PRUint32*>(&id.m3[4]) = random();#endif char* id_cstr = id.ToString(); NS_ENSURE_TRUE(id_cstr, NS_ERROR_OUT_OF_MEMORY); nsDependentCString id_str(id_cstr); aUserID = Substring(id_str, 1, id_str.Length()-2); PR_Free(id_cstr); return NS_OK;}
开发者ID:fortunto2,项目名称:celtx,代码行数:39,
示例9: get_default_namestatic krb5_error_code KRB5_CALLCONVget_default_name(krb5_context context, const krb5_cc_ops *ops, const char *cachename, char **str){ CFUUIDRef uuid = NULL; CFUUIDBytes bytes; uuid = HeimCredCopyDefaultCredential(kHEIMTypeKerberos, NULL); if (uuid == NULL) { return _krb5_expand_default_cc_name(context, cachename, str); } bytes = CFUUIDGetUUIDBytes(uuid); char uuidstr[37]; uuid_unparse((void *)&bytes, uuidstr); CFRELEASE_NULL(uuid); asprintf(str, "%s:%s", ops->prefix, uuidstr); return 0;}
开发者ID:aosm,项目名称:Heimdal,代码行数:24,
示例10: wxLogSysError//.........这里部分代码省略......... } if ( IORegistryEntryCreateCFProperties ( pObject, &pDictionary, kCFAllocatorDefault, kNilOptions ) != KERN_SUCCESS ) { wxLogDebug(wxT("IORegistryEntryCreateCFProperties failed")); } // // Now we get the attributes of each "product" in the iterator // //Get [product] name CFStringRef cfsProduct = (CFStringRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey)); m_szProductName = wxCFStringRef( wxCFRetain(cfsProduct) ).AsString(); //Get the Product ID Key CFNumberRef cfnProductId = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductIDKey)); if (cfnProductId) { CFNumberGetValue(cfnProductId, kCFNumberIntType, &m_nProductId); } //Get the Vendor ID Key CFNumberRef cfnVendorId = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDVendorIDKey)); if (cfnVendorId) { CFNumberGetValue(cfnVendorId, kCFNumberIntType, &m_nManufacturerId); } // // End attribute getting // //Create the interface (good grief - long function names!) SInt32 nScore; IOCFPlugInInterface** ppPlugin; if(IOCreatePlugInInterfaceForService(pObject, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &ppPlugin, &nScore) != kIOReturnSuccess) { wxLogSysError(wxT("Could not create HID Interface for product")); return false; } //Now, the final thing we can check before we fall back to asserts //(because the dtor only checks if the device is ok, so if anything //fails from now on the dtor will delete the device anyway, so we can't break from this). //Get the HID interface from the plugin to the mach port if((*ppPlugin)->QueryInterface(ppPlugin, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void**) &m_ppDevice) != S_OK) { wxLogSysError(wxT("Could not get device interface from HID interface")); return false; } //release the plugin (*ppPlugin)->Release(ppPlugin); //open the HID interface... if ( (*m_ppDevice)->open(m_ppDevice, 0) != S_OK ) { wxLogDebug(wxT("HID device: open failed")); } // //Now the hard part - in order to scan things we need "cookies" // CFArrayRef cfaCookies = (CFArrayRef)CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDElementKey)); BuildCookies(cfaCookies); //cleanup CFRelease(pDictionary); IOObjectRelease(pObject); //iterator cleanup IOObjectRelease(pIterator); return true; } //iterator cleanup IOObjectRelease(pIterator); return false; //no device}//end Create()
开发者ID:erwincoumans,项目名称:wxWidgets,代码行数:101,
示例11: darwinHIDKeyboardCacheCreateEntry/** * Creates a keyboard cache entry. * * @returns true if the entry was created successfully, otherwise false. * @param pKeyboardEntry Pointer to the entry. * @param KeyboardDevice The keyboard device to create the entry for. * */static bool darwinHIDKeyboardCacheCreateEntry(struct KeyboardCacheData *pKeyboardEntry, io_object_t KeyboardDevice){ unsigned long cRefs = 0; memset(pKeyboardEntry, 0, sizeof(*pKeyboardEntry)); /* * Query the HIDDeviceInterface for this HID (keyboard) object. */ SInt32 Score = 0; IOCFPlugInInterface **ppPlugInInterface = NULL; IOReturn rc = IOCreatePlugInInterfaceForService(KeyboardDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &ppPlugInInterface, &Score); if (rc == kIOReturnSuccess) { IOHIDDeviceInterface **ppHidDeviceInterface = NULL; HRESULT hrc = (*ppPlugInInterface)->QueryInterface(ppPlugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID *)&ppHidDeviceInterface); cRefs = (*ppPlugInInterface)->Release(ppPlugInInterface); MY_CHECK_CREFS(cRefs); ppPlugInInterface = NULL; if (hrc == S_OK) { rc = (*ppHidDeviceInterface)->open(ppHidDeviceInterface, 0); if (rc == kIOReturnSuccess) { /* * create a removal callback. */ /** @todo */ /* * Create the queue so we can insert elements while searching the properties. */ IOHIDQueueInterface **ppHidQueueInterface = (*ppHidDeviceInterface)->allocQueue(ppHidDeviceInterface); if (ppHidQueueInterface) { rc = (*ppHidQueueInterface)->create(ppHidQueueInterface, 0, 32); if (rc != kIOReturnSuccess) { AssertMsgFailed(("rc=%d/n", rc)); cRefs = (*ppHidQueueInterface)->Release(ppHidQueueInterface); MY_CHECK_CREFS(cRefs); ppHidQueueInterface = NULL; } } else AssertFailed(); pKeyboardEntry->ppHidQueueInterface = ppHidQueueInterface; /* * Brute force getting of attributes. */ /** @todo read up on how to do this in a less resource intensive way! Suggestions are welcome! */ CFMutableDictionaryRef PropertiesRef = 0; kern_return_t krc = IORegistryEntryCreateCFProperties(KeyboardDevice, &PropertiesRef, kCFAllocatorDefault, kNilOptions); if (krc == KERN_SUCCESS) { darwinBruteForcePropertySearch(PropertiesRef, pKeyboardEntry); CFRelease(PropertiesRef); } else AssertMsgFailed(("krc=%#x/n", krc)); if (ppHidQueueInterface) { /* * Now install our queue callback. */ CFRunLoopSourceRef RunLoopSrcRef = NULL; rc = (*ppHidQueueInterface)->createAsyncEventSource(ppHidQueueInterface, &RunLoopSrcRef); if (rc == kIOReturnSuccess) { CFRunLoopRef RunLoopRef = (CFRunLoopRef)GetCFRunLoopFromEventLoop(GetMainEventLoop()); CFRunLoopAddSource(RunLoopRef, RunLoopSrcRef, kCFRunLoopDefaultMode); } /* * Now install our queue callback. */ rc = (*ppHidQueueInterface)->setEventCallout(ppHidQueueInterface, darwinQueueCallback, ppHidQueueInterface, pKeyboardEntry); if (rc != kIOReturnSuccess) AssertMsgFailed(("rc=%d/n", rc)); } /* * Complete the new keyboard cache entry. */ pKeyboardEntry->ppHidDeviceInterface = ppHidDeviceInterface; pKeyboardEntry->ppHidQueueInterface = ppHidQueueInterface; return true; }//.........这里部分代码省略.........
开发者ID:VirtualMonitor,项目名称:VirtualMonitor,代码行数:101,
示例12: platform_update_device_listforensic1394_result platform_update_device_list(forensic1394_bus *bus){ CFMutableDictionaryRef matchingDict; io_iterator_t iterator; io_object_t currdev; IOReturn iret; forensic1394_result fret = FORENSIC1394_RESULT_SUCCESS; // We need to get the systems local device node to update the CSR matchingDict = IOServiceMatching("IOFireWireDevice"); iret = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &iterator); require_assertion(iret == kIOReturnSuccess, cleanupMatchingServices, fret, FORENSIC1394_RESULT_OTHER_ERROR); while ((currdev = IOIteratorNext(iterator))) { IOCFPlugInInterface **plugIn; SInt32 theScore; UInt32 generation; UInt16 nodeid; // Allocate memory for a forensic1394 device forensic1394_dev *fdev = malloc(sizeof(forensic1394_dev)); // And for the platform specific structure fdev->pdev = malloc(sizeof(platform_dev)); // Copy over the device IO object to the structure fdev->pdev->dev = currdev; // Get an plug-in interface to the device IOCreatePlugInInterfaceForService(currdev, kIOFireWireLibTypeID, kIOCFPlugInInterfaceID, &plugIn, &theScore); // Ensure we got an interface require_assertion(plugIn, cleanupPlugIn, fret, FORENSIC1394_RESULT_OTHER_ERROR); // Use this to get an interface to the firewire device (*plugIn)->QueryInterface(plugIn, CFUUIDGetUUIDBytes(kIOFireWireDeviceInterfaceID_v9), (void **) &fdev->pdev->devIntrf); // Ensure the interface is inited require_assertion((*fdev->pdev->devIntrf)->InterfaceIsInited(fdev->pdev->devIntrf), cleanupDevIntrf, fret, FORENSIC1394_RESULT_OTHER_ERROR); // Save the bus the device is attached to fdev->bus = bus; // The device is not open fdev->is_open = 0; // Copy the ROM copy_device_csr(currdev, fdev->rom); // Parse the ROM to extract useful fragments common_parse_csr(fdev); // Get the bus generation (*fdev->pdev->devIntrf)->GetBusGeneration(fdev->pdev->devIntrf, &generation); // Get the node ID (*fdev->pdev->devIntrf)->GetRemoteNodeID(fdev->pdev->devIntrf, generation, &nodeid); fdev->generation = generation; fdev->node_id = nodeid; // Add this new device to the device list fdev->next = bus->dev_link; bus->dev_link = fdev; bus->ndev++; // Continue; everything from here on in is damage control continue; cleanupDevIntrf: // Release the device interface (*fdev->pdev->devIntrf)->Release(fdev->pdev->devIntrf); cleanupPlugIn: // Release the plug-in interface IODestroyPlugInInterface(plugIn); // Release the IO object IOObjectRelease(fdev->pdev->dev); // Release the partially allocated device free(fdev->pdev); free(fdev);//.........这里部分代码省略.........
开发者ID:WorkIdea,项目名称:libforensic1394,代码行数:101,
示例13: IOCreatePlugInInterfaceForServicekern_return_tIOCreatePlugInInterfaceForService(io_service_t service, CFUUIDRef pluginType, CFUUIDRef interfaceType, IOCFPlugInInterface *** theInterface, SInt32 * theScore){ CFDictionaryRef plist = 0; CFArrayRef plists; CFArrayRef factories; CFMutableArrayRef candidates; CFMutableArrayRef scores; CFIndex index; CFIndex insert; CFUUIDRef factoryID; kern_return_t kr; SInt32 score; IOCFPlugInInterface ** interface; Boolean haveOne; kr = IOFindPlugIns( service, pluginType, &factories, &plists ); if( KERN_SUCCESS != kr) { if (factories) CFRelease(factories); if (plists) CFRelease(plists); return( kr ); } if ((KERN_SUCCESS != kr) || (factories == NULL) || (0 == CFArrayGetCount(factories))) {// printf("No factories for type/n"); if (factories) CFRelease(factories); if (plists) CFRelease(plists); return( kIOReturnUnsupported ); } candidates = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL); scores = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL); // allocate and Probe all if (candidates && scores) { CFIndex numfactories = CFArrayGetCount(factories); for ( index = 0; index < numfactories; index++ ) { IUnknownVTbl ** iunknown; factoryID = (CFUUIDRef) CFArrayGetValueAtIndex(factories, index); iunknown = (IUnknownVTbl **) CFPlugInInstanceCreate(NULL, factoryID, pluginType); if (!iunknown) { // printf("Failed to create instance (link error?)/n"); continue; } (*iunknown)->QueryInterface(iunknown, CFUUIDGetUUIDBytes(interfaceType), (LPVOID *)&interface); // Now we are done with IUnknown interface (*iunknown)->Release(iunknown); if (!interface) { // printf("Failed to get interface./n"); continue; } if (plists) plist = (CFDictionaryRef) CFArrayGetValueAtIndex( plists, index ); score = 0; // from property table kr = (*interface)->Probe(interface, plist, service, &score); if (kIOReturnSuccess == kr) { CFIndex numscores = CFArrayGetCount(scores); for (insert = 0; insert < numscores; insert++) { if (score > (SInt32) ((intptr_t) CFArrayGetValueAtIndex(scores, insert))) break; } CFArrayInsertValueAtIndex(candidates, insert, (void *) interface); CFArrayInsertValueAtIndex(scores, insert, (void *) (intptr_t) score); } else (*interface)->Release(interface); } } // Start in score order CFIndex candidatecount = CFArrayGetCount(candidates); for (haveOne = false, index = 0; index < candidatecount; index++) { Boolean freeIt; if (plists) plist = (CFDictionaryRef) CFArrayGetValueAtIndex(plists, index ); interface = (IOCFPlugInInterface **) CFArrayGetValueAtIndex(candidates, index ); if (!haveOne) { haveOne = (kIOReturnSuccess == (*interface)->Start(interface, plist, service)); freeIt = !haveOne; if (haveOne) { *theInterface = interface; *theScore = (SInt32) (intptr_t) CFArrayGetValueAtIndex(scores, index ); } } else//.........这里部分代码省略.........
开发者ID:StrongZhu,项目名称:IOKitUser,代码行数:101,
示例14: UPSDeviceAddedvoid UPSDeviceAdded(void *refCon, io_iterator_t iterator){ io_object_t upsDevice = MACH_PORT_NULL; UPSDataRef upsDataRef = NULL; CFDictionaryRef upsProperties = NULL; CFDictionaryRef upsEvent = NULL; CFSetRef upsCapabilites = NULL; CFRunLoopSourceRef upsEventSource = NULL; CFRunLoopTimerRef upsEventTimer = NULL; CFTypeRef typeRef = NULL; IOCFPlugInInterface ** plugInInterface = NULL; IOUPSPlugInInterface_v140 ** upsPlugInInterface = NULL; HRESULT result = S_FALSE; IOReturn kr; SInt32 score; while ( (upsDevice = IOIteratorNext(iterator)) ) { // Create the CF plugin for this device kr = IOCreatePlugInInterfaceForService(upsDevice, kIOUPSPlugInTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); if ( kr != kIOReturnSuccess ) goto UPSDEVICEADDED_NONPLUGIN_CLEANUP; // Grab the new v140 interface result = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUPSPlugInInterfaceID_v140), (LPVOID)&upsPlugInInterface); if ( ( result == S_OK ) && upsPlugInInterface ) { kr = (*upsPlugInInterface)->createAsyncEventSource(upsPlugInInterface, &typeRef); if ((kr != kIOReturnSuccess) || !typeRef) goto UPSDEVICEADDED_FAIL; if ( CFGetTypeID(typeRef) == CFRunLoopTimerGetTypeID() ) { upsEventTimer = (CFRunLoopTimerRef)typeRef; CFRunLoopAddTimer(CFRunLoopGetCurrent(), upsEventTimer, kCFRunLoopDefaultMode); } else if ( CFGetTypeID(typeRef) == CFRunLoopSourceGetTypeID() ) { upsEventSource = (CFRunLoopSourceRef)typeRef; CFRunLoopAddSource(CFRunLoopGetCurrent(), upsEventSource, kCFRunLoopDefaultMode); } } // Couldn't grab the new interface. Fallback on the old. else { result = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUPSPlugInInterfaceID), (LPVOID)&upsPlugInInterface); } // Got the interface if ( ( result == S_OK ) && upsPlugInInterface ) { kr = (*upsPlugInInterface)->getProperties(upsPlugInInterface, &upsProperties); if (kr != kIOReturnSuccess) goto UPSDEVICEADDED_FAIL; upsDataRef = GetPrivateData(upsProperties); if ( !upsDataRef ) goto UPSDEVICEADDED_FAIL; upsDataRef->upsPlugInInterface = (IOUPSPlugInInterface **)upsPlugInInterface; upsDataRef->upsEventSource = upsEventSource; upsDataRef->upsEventTimer = upsEventTimer; upsDataRef->isPresent = true; kr = (*upsPlugInInterface)->getCapabilities(upsPlugInInterface, &upsCapabilites); if (kr != kIOReturnSuccess) goto UPSDEVICEADDED_FAIL; kr = CreatePowerManagerUPSEntry(upsDataRef, upsProperties, upsCapabilites); if (kr != kIOReturnSuccess) goto UPSDEVICEADDED_FAIL; kr = (*upsPlugInInterface)->getEvent(upsPlugInInterface, &upsEvent); if (kr != kIOReturnSuccess) goto UPSDEVICEADDED_FAIL; ProcessUPSEvent(upsDataRef, upsEvent); (*upsPlugInInterface)->setEventCallback(upsPlugInInterface, UPSEventCallback, NULL, upsDataRef); IOServiceAddInterestNotification( gNotifyPort, // notifyPort upsDevice, // service kIOGeneralInterest, // interestType DeviceNotification, // callback upsDataRef, // refCon &(upsDataRef->notification) // notification ); //.........这里部分代码省略.........
开发者ID:hashier,项目名称:caffeinate_fix,代码行数:101,
示例15: try_device/** Try out the given device and see if there's a match. Returns 0 on * success, -1 on failure. */static int try_device(io_service_t device, usb_handle *handle) { kern_return_t kr; IOCFPlugInInterface **plugin = NULL; IOUSBDeviceInterface500** dev = NULL; SInt32 score; HRESULT result; UInt8 serialIndex; UInt32 locationId; // Create an intermediate plugin. kr = IOCreatePlugInInterfaceForService(device, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin, &score); if ((kr != 0) || (plugin == NULL)) { goto error; } // Now create the device interface. result = (*plugin)->QueryInterface(plugin, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID500), (LPVOID*)&dev); if ((result != 0) || (dev == NULL)) { ERR("Couldn't create a device interface (%08x)/n", (int) result); goto error; } /* * We don't need the intermediate interface after the device interface * is created. */ IODestroyPlugInInterface(plugin); // So, we have a device, finally. Grab its vitals. kr = (*dev)->GetDeviceVendor(dev, &handle->info.dev_vendor); if (kr != 0) { ERR("GetDeviceVendor"); goto error; } kr = (*dev)->GetDeviceProduct(dev, &handle->info.dev_product); if (kr != 0) { ERR("GetDeviceProduct"); goto error; } kr = (*dev)->GetDeviceClass(dev, &handle->info.dev_class); if (kr != 0) { ERR("GetDeviceClass"); goto error; } kr = (*dev)->GetDeviceSubClass(dev, &handle->info.dev_subclass); if (kr != 0) { ERR("GetDeviceSubClass"); goto error; } kr = (*dev)->GetDeviceProtocol(dev, &handle->info.dev_protocol); if (kr != 0) { ERR("GetDeviceProtocol"); goto error; } kr = (*dev)->GetLocationID(dev, &locationId); if (kr != 0) { ERR("GetLocationId"); goto error; } snprintf(handle->info.device_path, sizeof(handle->info.device_path), "usb:%" PRIu32 "X", (unsigned int)locationId); kr = (*dev)->USBGetSerialNumberStringIndex(dev, &serialIndex); if (serialIndex > 0) { IOUSBDevRequest req; UInt16 buffer[256]; req.bmRequestType = USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice); req.bRequest = kUSBRqGetDescriptor; req.wValue = (kUSBStringDesc << 8) | serialIndex; //language ID (en-us) for serial number string req.wIndex = 0x0409; req.pData = buffer; req.wLength = sizeof(buffer); kr = (*dev)->DeviceRequest(dev, &req); if (kr == kIOReturnSuccess && req.wLenDone > 0) { int i, count; // skip first word, and copy the rest to the serial string, changing shorts to bytes. count = (req.wLenDone - 1) / 2; for (i = 0; i < count; i++) handle->info.serial_number[i] = buffer[i + 1]; handle->info.serial_number[i] = 0; }//.........这里部分代码省略.........
开发者ID:MoKee,项目名称:android_system_core,代码行数:101,
示例16: AndroidInterfaceAddedstatic voidAndroidInterfaceAdded(void *refCon, io_iterator_t iterator){ kern_return_t kr; io_service_t usbDevice; io_service_t usbInterface; IOCFPlugInInterface **plugInInterface = NULL; IOUSBInterfaceInterface220 **iface = NULL; IOUSBDeviceInterface197 **dev = NULL; HRESULT result; SInt32 score; UInt32 locationId; UInt16 vendor; UInt16 product; UInt8 serialIndex; char serial[256]; char devpathBuf[64]; char *devpath = NULL; while ((usbInterface = IOIteratorNext(iterator))) { //* Create an intermediate interface plugin kr = IOCreatePlugInInterfaceForService(usbInterface, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); IOObjectRelease(usbInterface); if ((kIOReturnSuccess != kr) || (!plugInInterface)) { DBG("ERR: Unable to create an interface plug-in (%08x)/n", kr); continue; } //* This gets us the interface object result = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID), (LPVOID*) &iface); //* We only needed the plugin to get the interface, so discard it (*plugInInterface)->Release(plugInInterface); if (result || !iface) { DBG("ERR: Couldn't query the interface (%08x)/n", (int) result); continue; } //* this gets us an ioservice, with which we will find the actual //* device; after getting a plugin, and querying the interface, of //* course. //* Gotta love OS X kr = (*iface)->GetDevice(iface, &usbDevice); if (kIOReturnSuccess != kr || !usbDevice) { DBG("ERR: Couldn't grab device from interface (%08x)/n", kr); continue; } plugInInterface = NULL; score = 0; //* create an intermediate device plugin kr = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); //* only needed this to find the plugin (void)IOObjectRelease(usbDevice); if ((kIOReturnSuccess != kr) || (!plugInInterface)) { DBG("ERR: Unable to create a device plug-in (%08x)/n", kr); continue; } result = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID*) &dev); //* only needed this to query the plugin (*plugInInterface)->Release(plugInInterface); if (result || !dev) { DBG("ERR: Couldn't create a device interface (%08x)/n", (int) result); continue; } //* Now after all that, we actually have a ref to the device and //* the interface that matched our criteria kr = (*dev)->GetDeviceVendor(dev, &vendor); kr = (*dev)->GetDeviceProduct(dev, &product); kr = (*dev)->GetLocationID(dev, &locationId); if (kr == 0) { snprintf(devpathBuf, sizeof(devpathBuf), "usb:%lX", locationId); devpath = devpathBuf; } kr = (*dev)->USBGetSerialNumberStringIndex(dev, &serialIndex); if (serialIndex > 0) { IOUSBDevRequest req; UInt16 buffer[256]; UInt16 languages[128]; memset(languages, 0, sizeof(languages)); req.bmRequestType = USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice); req.bRequest = kUSBRqGetDescriptor; req.wValue = (kUSBStringDesc << 8) | 0; req.wIndex = 0;//.........这里部分代码省略.........
开发者ID:Ugryumych,项目名称:r2d2b2g,代码行数:101,
示例17: DeviceAdded//.........这里部分代码省略......... if(serialNumberAsCFString) { Boolean result; char serialNumber[MAXPATHLEN]; // Convert from a CFString to a C (NUL-terminated) result = CFStringGetCString( serialNumberAsCFString, serialNumber, sizeof(serialNumber), kCFStringEncodingUTF8 ); if(result) { deviceItem->deviceParams.serialNumber = serialNumber; } CFRelease(serialNumberAsCFString); } // Now, get the locationID of this device. In order to do this, we need to create an IOUSBDeviceInterface // for our device. This will create the necessary connections between our userland application and the // kernel object for the USB Device. kr = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); if((kIOReturnSuccess != kr) || !plugInInterface) { fprintf(stderr, "IOCreatePlugInInterfaceForService returned 0x%08x./n", kr); continue; } stDeviceListItem *deviceListItem = new stDeviceListItem(); // Use the plugin interface to retrieve the device interface. res = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID*) &deviceListItem->deviceInterface); // Now done with the plugin interface. (*plugInInterface)->Release(plugInInterface); if(res || deviceListItem->deviceInterface == NULL) { fprintf(stderr, "QueryInterface returned %d./n", (int) res); continue; } // Now that we have the IOUSBDeviceInterface, we can call the routines in IOUSBLib.h. // In this case, fetch the locationID. The locationID uniquely identifies the device // and will remain the same, even across reboots, so long as the bus topology doesn't change. kr = (*deviceListItem->deviceInterface)->GetLocationID(deviceListItem->deviceInterface, &locationID); if(KERN_SUCCESS != kr) { fprintf(stderr, "GetLocationID returned 0x%08x./n", kr); continue; } std::stringstream sstream; sstream << std::hex << locationID; deviceItem->deviceParams.locationId = sstream.str(); kr = (*deviceListItem->deviceInterface)->GetDeviceAddress(deviceListItem->deviceInterface, &addr); if(KERN_SUCCESS != kr) { fprintf(stderr, "GetDeviceAddress returned 0x%08x./n", kr); continue; } deviceItem->deviceParams.deviceAddress = addr; kr = (*deviceListItem->deviceInterface)->GetDeviceVendor(deviceListItem->deviceInterface, &vendorId); if(KERN_SUCCESS != kr) {
开发者ID:apla,项目名称:node-usb-detection,代码行数:67,
示例18: interfaceInteractionvoid interfaceInteraction(IOUSBInterfaceInterface300*** intfPtr, io_service_t Ref){ IOCFPlugInInterface **iodev; SInt32 score; IOReturn err; UInt8 interfaceClass, direction, number, transfertype, interval; UInt8 interfaceSubClass, interfaceNumEndpoints, interfaceNumber; UInt16 maxPacketSize; int pipeRef = 1; char *message; err = IOCreatePlugInInterfaceForService(Ref, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID, &iodev, &score); IO_ERR(3, "openInterface: Create Plugin Interface for usbInterface", err); //query plugin for device interface err = (*iodev)->QueryInterface(iodev, CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID300), (LPVOID)intfPtr); IO_ERR(3, "openInterface: Query Plugin for Device Interface", err); err = (**intfPtr)->GetInterfaceNumber(*intfPtr, &interfaceNumber); IO_ERR(3, "openInterface: Get Interface Number", err); //NSLog(@"Interface Number: %d", interfaceNumber); //err = (**intfPtr)->GetPipeStatus(*intfPtr); //ERR(self.usbDebug, "openInterface: Pipe Status", err); err = (**intfPtr)->USBInterfaceOpen(*intfPtr); IO_ERR(3, "openInterface: Open Interface port", err); err = (**intfPtr)->GetInterfaceClass(*intfPtr, &interfaceClass); err = (**intfPtr)->GetInterfaceSubClass(*intfPtr, &interfaceSubClass); //NSLog(@"OpenInterface: interface Class:%d Interface Sub Class:%d", interfaceClass, interfaceSubClass); err = (**intfPtr)->GetNumEndpoints(*intfPtr, &interfaceNumEndpoints); //NSLog(@"OpenInterface: Number of Endpoints is:%d", interfaceNumEndpoints); for(pipeRef = 1; pipeRef <= interfaceNumEndpoints; pipeRef++) { err = (**intfPtr)->GetPipeProperties(*intfPtr, pipeRef, &direction, &number, &transfertype, &maxPacketSize, &interval); IO_ERR(3, "openInterface: Get Pipe Properties",err); printf("Pipe Reference number:%d, ", pipeRef); switch (direction) { case kUSBOut: message = "out"; break; case kUSBIn: message = "in"; break; case kUSBNone: message = "none"; break; case kUSBAnyDirn: message = "any"; break; default: message = "???"; break; } printf("direction:%s, ", message); switch (transfertype) { case kUSBControl: message = "control"; break; case kUSBIsoc: message = "isoc"; break; case kUSBBulk: message = "bulk"; break; case kUSBInterrupt: message = "interrupt"; break; case kUSBAnyType: message = "any"; break; default: message = "???"; break; } printf("transfer type:%s, Pipe Number:%d maxPacketSize:%d, Intervals:%d/n", message, number, maxPacketSize,interval); if (transfertype == kUSBBulk && direction == kUSBIn) { //alarmInPipeRef = number; }else if (transfertype == kUSBBulk && direction == kUSBOut) { //alarmOutPipeRef = number; } } (*iodev)->Release(iodev); }
开发者ID:poppe34,项目名称:MAC-Zigbee-GUI,代码行数:96,
示例19: ipod_scsi_inquiryint ipod_scsi_inquiry(struct ipod_t* ipod, int page_code, unsigned char* buf, int bufsize){ /* OS X doesn't allow to simply send out a SCSI inquiry request but * requires registering an interface handler first. * Currently this is done on each inquiry request which is somewhat * inefficient but the current ipodpatcher API doesn't really fit here. * Based on the documentation in Apple's document * "SCSI Architecture Model Device Interface Guide". * * WARNING: this code currently doesn't take the selected device into * account. It simply looks for an Ipod on the system and uses * the first match. */ (void)ipod; int result = 0; /* first, create a dictionary to match the device. This is needed to get the * service. */ CFMutableDictionaryRef match_dict; match_dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, NULL); if(match_dict == NULL) return -1; /* set value to match. In case of the Ipod this is "iPodUserClientDevice". */ CFMutableDictionaryRef sub_dict; sub_dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, NULL); CFDictionarySetValue(sub_dict, CFSTR(kIOPropertySCSITaskDeviceCategory), CFSTR("iPodUserClientDevice")); CFDictionarySetValue(match_dict, CFSTR(kIOPropertyMatchKey), sub_dict); if(sub_dict == NULL) return -1; /* get an iterator for searching for the service. */ kern_return_t kr; io_iterator_t iterator = IO_OBJECT_NULL; /* get matching services from IO registry. Consumes one reference to * the dictionary, so no need to release that. */ kr = IOServiceGetMatchingServices(kIOMasterPortDefault, match_dict, &iterator); if(!iterator | (kr != kIOReturnSuccess)) return -1; /* get interface and obtain exclusive access */ SInt32 score; HRESULT herr; kern_return_t err; IOCFPlugInInterface **plugin_interface = NULL; SCSITaskDeviceInterface **interface = NULL; io_service_t device = IO_OBJECT_NULL; device = IOIteratorNext(iterator); err = IOCreatePlugInInterfaceForService(device, kIOSCSITaskDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin_interface, &score); if(err != noErr) { return -1; } /* query the plugin interface for task interface */ herr = (*plugin_interface)->QueryInterface(plugin_interface, CFUUIDGetUUIDBytes(kIOSCSITaskDeviceInterfaceID), (LPVOID*)&interface); if(herr != S_OK) { IODestroyPlugInInterface(plugin_interface); return -1; } err = (*interface)->ObtainExclusiveAccess(interface); if(err != noErr) { (*interface)->Release(interface); IODestroyPlugInInterface(plugin_interface); return -1; } /* do the inquiry */ SCSITaskInterface **task = NULL; task = (*interface)->CreateSCSITask(interface); if(task != NULL) { kern_return_t err; SCSITaskStatus task_status; IOVirtualRange* range; SCSI_Sense_Data sense_data; SCSICommandDescriptorBlock cdb; UInt64 transfer_count = 0; memset(buf, 0, bufsize); /* allocate virtual range for buffer. */ range = (IOVirtualRange*) malloc(sizeof(IOVirtualRange)); memset(&sense_data, 0, sizeof(sense_data)); memset(cdb, 0, sizeof(cdb)); /* set up range. address is buffer address, length is request size. */ range->address = (IOVirtualAddress)buf; range->length = bufsize; /* setup CDB */ cdb[0] = 0x12; /* inquiry */ cdb[1] = 1; cdb[2] = page_code; cdb[4] = bufsize; /* set cdb in task *///.........这里部分代码省略.........
开发者ID:BurntBrunch,项目名称:rockbox-fft,代码行数:101,
示例20: BulkTestDeviceAddedvoid BulkTestDeviceAdded(void *refCon, io_iterator_t iterator){ kern_return_t kr; io_service_t usbDevice; IOCFPlugInInterface **plugInInterface=NULL; IOUSBDeviceInterface245 **dev=NULL; HRESULT res; SInt32 score; UInt16 vendor; UInt16 product; UInt16 release; while ( (usbDevice = IOIteratorNext(iterator)) ) { printf("Bulk test device added./n"); kr = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); kr = IOObjectRelease(usbDevice); // done with the device object now that I have the plugin if ((kIOReturnSuccess != kr) || !plugInInterface) { printf("unable to create a plugin (%08x)/n", kr); continue; } // I have the device plugin, I need the device interface res = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID245), (LPVOID)&dev); IODestroyPlugInInterface(plugInInterface); // done with this if (res || !dev) { printf("couldn't create a device interface (%08x)/n", (int) res); continue; } // technically should check these kr values kr = (*dev)->GetDeviceVendor(dev, &vendor); kr = (*dev)->GetDeviceProduct(dev, &product); kr = (*dev)->GetDeviceReleaseNumber(dev, &release); if ((vendor != kOurVendorID) || (product != kOurProductIDBulkTest) || (release != 1)) { // We should never get here because the matching criteria we specified above // will return just those devices with our vendor and product IDs printf("found device i didn't want (vendor = %d, product = %d)/n", vendor, product); (*dev)->Release(dev); continue; } // need to open the device in order to change its state kr = (*dev)->USBDeviceOpen(dev); if (kIOReturnSuccess != kr) { printf("unable to open device: %08x/n", kr); (*dev)->Release(dev); continue; } kr = ConfigureAnchorDevice(dev); if (kIOReturnSuccess != kr) { printf("unable to configure device: %08x/n", kr); (*dev)->USBDeviceClose(dev); (*dev)->Release(dev); continue; } kr = FindInterfaces(dev); if (kIOReturnSuccess != kr) { printf("unable to find interfaces on device: %08x/n", kr); (*dev)->USBDeviceClose(dev); (*dev)->Release(dev); continue; } #ifndef USE_ASYNC_IO kr = (*dev)->USBDeviceClose(dev); kr = (*dev)->Release(dev);#endif }}
开发者ID:aosm,项目名称:IOUSBFamily,代码行数:78,
示例21: drives_availabledrives_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,
示例22: GetSerialDevices//.........这里部分代码省略......... modemFound = true; kernResult = KERN_SUCCESS; uv_mutex_lock(&list_mutex); io_service_t device = GetUsbDevice(modemService); if (device) { CFStringRef manufacturerAsCFString = (CFStringRef) IORegistryEntryCreateCFProperty(device, CFSTR(kUSBVendorString), kCFAllocatorDefault, 0); if (manufacturerAsCFString) { Boolean result; char manufacturer[MAXPATHLEN]; // Convert from a CFString to a C (NUL-terminated) result = CFStringGetCString(manufacturerAsCFString, manufacturer, sizeof(manufacturer), kCFStringEncodingUTF8); if (result) { snprintf(serialDevice->manufacturer, sizeof(serialDevice->manufacturer), "%s", manufacturer); } CFRelease(manufacturerAsCFString); } CFStringRef serialNumberAsCFString = (CFStringRef) IORegistryEntrySearchCFProperty(device, kIOServicePlane, CFSTR(kUSBSerialNumberString), kCFAllocatorDefault, kIORegistryIterateRecursively); if (serialNumberAsCFString) { Boolean result; char serialNumber[MAXPATHLEN]; // Convert from a CFString to a C (NUL-terminated) result = CFStringGetCString(serialNumberAsCFString, serialNumber, sizeof(serialNumber), kCFStringEncodingUTF8); if (result) { snprintf(serialDevice->serialNumber, sizeof(serialDevice->serialNumber), "%s", serialNumber); } CFRelease(serialNumberAsCFString); } IOCFPlugInInterface **plugInInterface = NULL; SInt32 score; HRESULT res; IOUSBDeviceInterface **deviceInterface = NULL; kernResult = IOCreatePlugInInterfaceForService(device, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); if ((kIOReturnSuccess != kernResult) || !plugInInterface) { continue; } // Use the plugin interface to retrieve the device interface. res = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), reinterpret_cast<LPVOID*> (&deviceInterface)); // Now done with the plugin interface. (*plugInInterface)->Release(plugInInterface); if (res || deviceInterface == NULL) { continue; } // Extract the desired Information ExtractUsbInformation(serialDevice, deviceInterface); // Release the Interface (*deviceInterface)->Release(deviceInterface); // Release the device (void) IOObjectRelease(device); } uv_mutex_unlock(&list_mutex); } } // Release the io_service_t now that we are done with it. (void) IOObjectRelease(modemService); } IOObjectRelease(serialPortIterator); // Release the iterator. return devices;}
开发者ID:blafuente,项目名称:RaspberryPiCapstone,代码行数:101,
|