From 586a69d17322afa45cb83877fa3679a8ac09efed Mon Sep 17 00:00:00 2001 From: Muntashir Al-Islam Date: Sun, 11 Nov 2018 22:33:32 +0600 Subject: [PATCH] Bump version to 1.8 --- DPCIManager.xcodeproj/project.pbxproj | 16 +- DPCIManager/AppDelegate.h | 1 + DPCIManager/DPCIManager-Info.plist | 17 -- DPCIManager/Hardware.m | 1 - DPCIManager/en.lproj/MainMenu.xib | 8 +- README.md | 2 +- ddcli/lib/DDCliApplication.h | 2 +- dspci/DataTypeHandler.m | 321 +++++++++++++++++++++++++- dspci/dspci.h | 2 +- dspci/dspci.m | 17 +- 10 files changed, 343 insertions(+), 44 deletions(-) diff --git a/DPCIManager.xcodeproj/project.pbxproj b/DPCIManager.xcodeproj/project.pbxproj index 3f8e3f8..626a021 100644 --- a/DPCIManager.xcodeproj/project.pbxproj +++ b/DPCIManager.xcodeproj/project.pbxproj @@ -408,7 +408,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; CURRENT_MARKETING_VERSION = 1.6; - CURRENT_PROJECT_VERSION = 286; + CURRENT_PROJECT_VERSION = 287; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -458,7 +458,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; CURRENT_MARKETING_VERSION = 1.6; - CURRENT_PROJECT_VERSION = 286; + CURRENT_PROJECT_VERSION = 287; DEBUG_INFORMATION_FORMAT = dwarf; DEPLOYMENT_POSTPROCESSING = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -480,10 +480,11 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; + CURRENT_MARKETING_VERSION = 1.8; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "DPCIManager/DPCIManager-Prefix.pch"; INFOPLIST_FILE = "DPCIManager/DPCIManager-Info.plist"; - PRODUCT_BUNDLE_IDENTIFIER = "net.sourceforge.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_BUNDLE_IDENTIFIER = io.github.muntashirakon.DPCIManager; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -493,10 +494,11 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; + CURRENT_MARKETING_VERSION = 1.8; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "DPCIManager/DPCIManager-Prefix.pch"; INFOPLIST_FILE = "DPCIManager/DPCIManager-Info.plist"; - PRODUCT_BUNDLE_IDENTIFIER = "net.sourceforge.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_BUNDLE_IDENTIFIER = io.github.muntashirakon.DPCIManager; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -538,6 +540,7 @@ buildSettings = { CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_EMPTY_BODY = YES; + CURRENT_MARKETING_VERSION = 1.8; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "DPCIManager/DPCIManager-Prefix.pch"; INFOPLIST_FILE = "$(SRCROOT)/DPCIManager/DPCIManager-Info.plist"; @@ -548,7 +551,7 @@ __pci_ids, pci.ids, ); - PRODUCT_BUNDLE_IDENTIFIER = "net.sourceforge.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_BUNDLE_IDENTIFIER = io.github.muntashirakon.dspci; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -558,6 +561,7 @@ buildSettings = { CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_EMPTY_BODY = YES; + CURRENT_MARKETING_VERSION = 1.8; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "DPCIManager/DPCIManager-Prefix.pch"; INFOPLIST_FILE = "$(SRCROOT)/DPCIManager/DPCIManager-Info.plist"; @@ -568,7 +572,7 @@ __pci_ids, pci.ids, ); - PRODUCT_BUNDLE_IDENTIFIER = "net.sourceforge.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_BUNDLE_IDENTIFIER = io.github.muntashirakon.dspci; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/DPCIManager/AppDelegate.h b/DPCIManager/AppDelegate.h index 319468c..e500051 100644 --- a/DPCIManager/AppDelegate.h +++ b/DPCIManager/AppDelegate.h @@ -41,6 +41,7 @@ typedef struct { -(IBAction)repair:(id)sender; -(IBAction)rebuild:(id)sender; -(IBAction)install:(id)sender; +-(IBAction)fetchvBIOS:(id)sender; -(void)logTask:(NSData *)data; @end diff --git a/DPCIManager/DPCIManager-Info.plist b/DPCIManager/DPCIManager-Info.plist index c56242c..15c0ea9 100644 --- a/DPCIManager/DPCIManager-Info.plist +++ b/DPCIManager/DPCIManager-Info.plist @@ -26,23 +26,6 @@ public.app-category.utilities LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - NSExceptionDomains - - sourceforge.net - - NSIncludesSubdomains - - NSTemporaryExceptionAllowsInsecureHTTPLoads - - NSTemporaryExceptionMinimumTLSVersion - TLSv1.1 - - - NSHumanReadableCopyright Licensed under GPLv3, full text at http://www.gnu.org/licenses/gpl-3.0.txt NSMainNibFile diff --git a/DPCIManager/Hardware.m b/DPCIManager/Hardware.m index c1a7aae..f9e7aff 100644 --- a/DPCIManager/Hardware.m +++ b/DPCIManager/Hardware.m @@ -13,7 +13,6 @@ #import #import #define kPCIFormat @"0x%04lX%04lX" -#define kDirectHWIdentifier @"com.coresystems.driver.DirectHW" #define kOSBundleStarted @"OSBundleStarted" @implementation AppDelegate (HardwareAdditions) diff --git a/DPCIManager/en.lproj/MainMenu.xib b/DPCIManager/en.lproj/MainMenu.xib index 84cd37d..4f74dbe 100644 --- a/DPCIManager/en.lproj/MainMenu.xib +++ b/DPCIManager/en.lproj/MainMenu.xib @@ -1055,7 +1055,7 @@ - + @@ -1063,7 +1063,7 @@ - + @@ -1137,6 +1137,7 @@ + @@ -1210,7 +1211,7 @@ - + @@ -1324,6 +1325,7 @@ + diff --git a/README.md b/README.md index bcda5ce..fea1fcf 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ As of version `1.7`, you can see usage by running: dspci --help ``` -#### JSON Schema +#### JSON Schema for default JSON output For `1.6`, see [old schema](https://github.com/MuntashirAkon/DPCIManager/blob/e302cd9ce6f62d90d5da627cccc14cb088696444/README.md#json-schema). An output contains an array of objects which have the following attributes. diff --git a/ddcli/lib/DDCliApplication.h b/ddcli/lib/DDCliApplication.h index 238d623..4830d5a 100755 --- a/ddcli/lib/DDCliApplication.h +++ b/ddcli/lib/DDCliApplication.h @@ -141,7 +141,7 @@ int DDCliAppRunWithClass(Class delegateClass); * class is used as the delegate class, so be sure to only include a single * class that implements this protocol per application. */ -int DDCliAppRunWithDefaultClass(); +int DDCliAppRunWithDefaultClass(void); /** @} */ diff --git a/dspci/DataTypeHandler.m b/dspci/DataTypeHandler.m index 70593dd..eda5df6 100644 --- a/dspci/DataTypeHandler.m +++ b/dspci/DataTypeHandler.m @@ -70,6 +70,18 @@ - (int) handleDataType: (NSString *)dataType { [self printAudioList]; //printf("%s\n", [[self listAudio] bv_jsonStringWithPrettyPrint:true].UTF8String); break; + case DT_LIST_GPU_INT: + case DT_LIST_GPU_ID_INT: + [self printGPUList]; + break; + case DT_LIST_NETWORK_INT: + case DT_LIST_NETWORK_ID_INT: + [self printNetworkList]; + break; + case DT_LIST_CONNECTED_INT: + case DT_LIST_CONNECTED_ID_INT: + [self printConnectedList]; + break; default: @throw [DDCliParseException parseExceptionWithReason:[NSString stringWithFormat:@"Invalid data type.\nUse `%@ --listDataTypes` to get a list of possible data types.", DDCliApp] exitCode:EX_DATAERR]; } @@ -223,16 +235,20 @@ - (NSArray *) listAudio { [[NSRegularExpression regularExpressionWithPattern:@"Codec ID: 0x([0-9a-f]{8})(?:\n.*){3}Revision: 0x([0-9a-f]{2})\n.*Stepping: 0x([0-9a-f]{2})" options:0 error:nil] enumerateMatchesInString:dump options:0 range:NSMakeRange(0, dump.length) usingBlock:^void(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop){ long codecid = strHexDec([dump substringWithRange:[result rangeAtIndex:1]]), revision = strHexDec([dump substringWithRange:[result rangeAtIndex:2]]) << 8 | strHexDec([dump substringWithRange:[result rangeAtIndex:3]]); - char *codecname = NULL; + NSString *CodecID = [self insertColonInID:codecid]; + NSString *CodecName = nil; for(int n = 0; gCodecList[n].name; n++) - if (HDA_DEV_MATCH(gCodecList[n].id, codecid) && revision >= gCodecList[n].rev) { codecname = gCodecList[n].name; break; } - if (codecname == NULL) codecname = !codecid ? "NULL Codec" : "Unknown Codec"; + if (HDA_DEV_MATCH(gCodecList[n].id, codecid) && revision >= gCodecList[n].rev) { + CodecName = [NSString stringWithUTF8String:gCodecList[n].name]; + break; + } + if (CodecName == nil) CodecName = !codecid ? @"NULL Codec" : @"Unknown Codec"; [hda addObject:@{ @"DeviceID" : [NSString stringWithFormat:kPCIFormat, audio.vendor.integerValue, audio.device.integerValue], @"SubdeviceID" : [NSString stringWithFormat:kPCIFormat, audio.subVendor.integerValue, audio.subDevice.integerValue], - @"CodecID" : [NSString stringWithFormat:@"%08lX", codecid], + @"CodecID" : CodecID, @"Revision" : [NSString stringWithFormat:@"%04lX", revision], - @"Model" : [NSString stringWithUTF8String:codecname] + @"Model" : CodecName } ]; }]; @@ -259,11 +275,9 @@ - (NSArray *) listAudio { while ((child = IOIteratorNext(itChild))){ long codecid = [[pciDevice grabNumber:CFSTR("IOHDACodecVendorID") forService:child] longValue] & 0xFFFFFFFF, revision = [[pciDevice grabNumber:CFSTR("IOHDACodecRevisionID") forService:child] longValue] & 0xFFFF; - NSMutableString *CodecID = [NSMutableString stringWithFormat:@"%08lX", codecid]; - [CodecID insertString:@":" atIndex:4]; + NSString *CodecID = [self insertColonInID:codecid]; // NSLog(@"%@", [pciDevice grabNumber:CFSTR("IOHDACodecVendorID") forService:child].stringValue); NSString *CodecName = nil; - NSString *hda_gfx = [pciDevice grabString:CFSTR("hda-gfx") forService:parent]; for(int n = 0; gCodecList[n].name; n++) if (HDA_DEV_MATCH(gCodecList[n].id, codecid)) { CodecName = [NSString stringWithUTF8String:gCodecList[n].name]; @@ -275,7 +289,7 @@ - (NSArray *) listAudio { @"SubdeviceID" : [NSString stringWithFormat:kPCIFormat, audio.subVendor.integerValue, audio.subDevice.integerValue], @"CodecID" : CodecID, @"LayoutID" : [pciDevice grabNumber:CFSTR("layout-id") forService:parent], - @"hda-gfx" : [hda_gfx substringToIndex:[hda_gfx length]-1], + @"hda-gfx" : [self removeNullChar:[pciDevice grabString:CFSTR("hda-gfx") forService:parent]], @"Revision" : [NSString stringWithFormat:@"%04lX", revision], @"Model" : CodecName } @@ -316,4 +330,293 @@ - (NSArray *) listAudio { return [temp copy]; } +- (void) printGPUList { + NSArray *GPUs = [self listGraphics]; + NSMutableArray *GPUList = [NSMutableArray array]; + for(NSDictionary *GPU in GPUs){ + [GPUList addObject:[self getGPUInfo:dataType GPU:GPU]]; + } + // Print + if(printJSON) printf("%s\n", [GPUList bv_jsonStringWithPrettyPrint:true].UTF8String); + else printf("%s\n", [GPUList componentsJoinedByString:@"\n"].UTF8String); +} + +- (id) getGPUInfo: (unsigned) dataType GPU: (NSDictionary *)GPU { + switch(dataType) { + case DT_LIST_GPU_INT: + return GPU; + case DT_LIST_GPU_ID_INT: + return [GPU valueForKey:@"DeviceID"]; + } + return nil; +} + +- (NSArray *) listGraphics { + NSMutableArray *temp = [NSMutableArray array]; + io_iterator_t itThis; + io_service_t service; + io_service_t parent; + io_name_t name; + if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("AtiFbStub"), &itThis) == KERN_SUCCESS) { + NSMutableDictionary *card; + int ports = 0; + unsigned long long old; + unsigned long long new; + service = 1; + while(service) { + service = IOIteratorNext(itThis); + if (!card && !service) break; + IORegistryEntryGetParentEntry(service, kIOServicePlane, &parent); + IORegistryEntryGetRegistryEntryID(parent, &new); + if (card && new!=old){ + [card setObject:@(ports) forKey:@"ports"]; + [temp addObject:[card copy]]; + card = nil; + ports = 0; + } + if (!card && service) { + IORegistryEntryGetRegistryEntryID(parent, &old); + IORegistryEntryGetName(service, name); + card = [@{ + @"DeviceID" : [NSString stringWithFormat:kPCIFormat, [pciDevice grabNumber:CFSTR("vendor-id") forService:parent].longValue,[pciDevice grabNumber:CFSTR("device-id") forService:parent].longValue], + @"SubdeviceID" : [NSString stringWithFormat:kPCIFormat, [pciDevice grabNumber:CFSTR("subsystem-vendor-id") forService:parent].longValue,[pciDevice grabNumber:CFSTR("subsystem-id") forService:parent].longValue], + @"Revision" : [NSString stringWithFormat:@"%04lX", [pciDevice grabNumber:CFSTR("revision-id") forService:parent].longValue], + @"Model" : [pciDevice grabString:CFSTR("model") forService:parent], + // @"Ports" : + @"ig-platform-id" : @(name), + @"hda-gfx" : [self removeNullChar:[pciDevice grabString:CFSTR("hda-gfx") forService:parent]] + } mutableCopy]; + } + ports++; + IOObjectRelease(parent); + IOObjectRelease(service); + } + IOObjectRelease(itThis); + } + if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IONDRVDevice"), &itThis) == KERN_SUCCESS){ + NSMutableDictionary *card; + int ports = 0; + unsigned long long old; + unsigned long long new; + service = 1; + while(service) { + service = IOIteratorNext(itThis); + if (!card && !service) break; + IORegistryEntryGetParentEntry(service, kIOServicePlane, &parent); + IORegistryEntryGetRegistryEntryID(parent, &new); + if (card && new != old){ + [card setObject:@(ports) forKey:@"ports"]; + [temp addObject:[card copy]]; + card = nil; + ports = 0; + } + if (!card && service) { + io_service_t child; + IORegistryEntryGetChildEntry(service, kIOServicePlane, &child); + IORegistryEntryGetRegistryEntryID(parent, &old); + IORegistryEntryGetName(child, name); + card = [@{ + @"DeviceID" : [NSString stringWithFormat:kPCIFormat, [pciDevice grabNumber:CFSTR("vendor-id") forService:parent].longValue,[pciDevice grabNumber:CFSTR("device-id") forService:parent].longValue], + @"SubdeviceID" : [NSString stringWithFormat:kPCIFormat, [pciDevice grabNumber:CFSTR("subsystem-vendor-id") forService:parent].longValue,[pciDevice grabNumber:CFSTR("subsystem-id") forService:parent].longValue], + @"Revision" : [NSString stringWithFormat:@"%04lX", [pciDevice grabNumber:CFSTR("revision-id") forService:parent].longValue], + @"Model" : [pciDevice grabString:CFSTR("model") forService:parent], + // @"Ports" : + @"ig-platform-id" : @(name), + @"hda-gfx" : [self removeNullChar:[pciDevice grabString:CFSTR("hda-gfx") forService:parent]] + } mutableCopy]; + IOObjectRelease(child); + } + ports++; + IOObjectRelease(parent); + IOObjectRelease(service); + } + IOObjectRelease(itThis); + } + if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("AppleIntelFramebuffer"), &itThis) == KERN_SUCCESS){ + NSMutableDictionary *card; + int ports = 0; + unsigned long long old; + unsigned long long new; + service = 1; + while(service) { + service = IOIteratorNext(itThis); + if (!card && !service) break; + IORegistryEntryGetParentEntry(service, kIOServicePlane, &parent); + IORegistryEntryGetRegistryEntryID(parent, &new); + if (card && new!=old){ + [card setObject:@(ports) forKey:@"Ports"]; + [temp addObject:[card copy]]; + card = nil; + ports = 0; + } + if (!card && service) { + io_service_t child; + IORegistryEntryGetChildEntry(parent, kIOServicePlane, &child); + IORegistryEntryGetRegistryEntryID(parent, &old); + NSUInteger framebuffer = [[pciDevice grabNumber:CFSTR("AAPL,ig-platform-id") forService:parent] longValue]; + if (framebuffer) sprintf(name, "0x%08lX", framebuffer); + else IORegistryEntryGetName(child, name); + card = [@{ + @"DeviceID" : [NSString stringWithFormat:kPCIFormat, [pciDevice grabNumber:CFSTR("vendor-id") forService:parent].longValue,[pciDevice grabNumber:CFSTR("device-id") forService:parent].longValue], + @"SubdeviceID" : [NSString stringWithFormat:kPCIFormat, [pciDevice grabNumber:CFSTR("subsystem-vendor-id") forService:parent].longValue,[pciDevice grabNumber:CFSTR("subsystem-id") forService:parent].longValue], + @"Revision" : [NSString stringWithFormat:@"%04lX", [pciDevice grabNumber:CFSTR("revision-id") forService:parent].longValue], + @"Model" : [pciDevice grabString:CFSTR("model") forService:parent], + // @"Ports" : + @"ig-platform-id" : @(name), + @"hda-gfx" : [self removeNullChar:[pciDevice grabString:CFSTR("hda-gfx") forService:parent]] + } mutableCopy]; + IOObjectRelease(child); + } + ports++; + IOObjectRelease(parent); + IOObjectRelease(service); + } + IOObjectRelease(itThis); + } + return [temp copy]; +} + +- (void) printNetworkList { + NSArray *NetworkInterfaces = [self listNetwork]; + NSMutableArray *NetworkInterfaceList = [NSMutableArray array]; + for(NSDictionary *NetworkInterface in NetworkInterfaces){ + [NetworkInterfaceList addObject:[self getNetworkInfo:dataType NetworkInt:NetworkInterface]]; + } + // Print + if(printJSON) printf("%s\n", [NetworkInterfaceList bv_jsonStringWithPrettyPrint:true].UTF8String); + else printf("%s\n", [NetworkInterfaceList componentsJoinedByString:@"\n"].UTF8String); +} + +- (id) getNetworkInfo: (unsigned) dataType NetworkInt: (NSDictionary *)NetworkInt { + switch(dataType) { + case DT_LIST_NETWORK_INT: + return NetworkInt; + case DT_LIST_NETWORK_ID_INT: + return [NetworkInt valueForKey:@"DeviceID"]; + } + return nil; +} + +- (NSArray *) listNetwork { + NSMutableArray *temp = [NSMutableArray array]; + io_iterator_t itThis; + if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IONetworkInterface"), &itThis) == KERN_SUCCESS) { + io_service_t service; + while((service = IOIteratorNext(itThis))){ + io_service_t parent; + io_service_t device; + IORegistryEntryGetParentEntry(service, kIOServicePlane, &parent); + IORegistryEntryGetParentEntry(parent, kIOServicePlane, &device); + NSString *DeviceID; + if (![pciDevice isPCI:device]) { + // Not a PCI device + io_service_t device2; + IORegistryEntryGetParentEntry(device, kIOServicePlane, &device2); + IOObjectRelease(device); + device = 0; + if (![pciDevice isPCI:device2]) IOObjectRelease(device2); + else device = device2; + DeviceID = [NSString stringWithFormat:kPCIFormat, [pciDevice grabNumber:CFSTR("idProduct") forService:parent].longValue, [pciDevice grabNumber:CFSTR("idVendor") forService:parent].longValue]; + } else { + DeviceID = [self insertColonInStrID:[[pciDevice grabString:CFSTR("IOPCIMatch") forService:parent] substringFromIndex:2]]; + } + NSString *model; + io_name_t name; + if (!(model = [pciDevice grabString:CFSTR("IOModel") forService:parent]).length) { + IORegistryEntryGetName(parent, name); + model = [NSString stringWithUTF8String:name]; + } + IOObjectRelease(parent); + IORegistryEntryGetName(service, name);//FIXME: better PCI detection + [temp addObject:@{ + @"Model" : model, + @"BSD" : @(name), + @"BuiltIn": [pciDevice grabNumber:CFSTR("IOBuiltin") forService:service], + @"DeviceID" : DeviceID + } + ]; + if (device) IOObjectRelease(device); + IOObjectRelease(service); + } + IOObjectRelease(itThis); + } + return [temp copy]; +} + +- (void) printConnectedList { + NSArray *ConnectedDevices = [self listConnected]; + NSMutableArray *ConnectedDeviceList = [NSMutableArray array]; + for(NSDictionary *ConnectedDevice in ConnectedDevices){ + [ConnectedDeviceList addObject:[self getConnectedInfo:dataType Connected:ConnectedDevice]]; + } + // Print + if(printJSON) printf("%s\n", [ConnectedDeviceList bv_jsonStringWithPrettyPrint:true].UTF8String); + else printf("%s\n", [ConnectedDeviceList componentsJoinedByString:@"\n"].UTF8String); +} + +- (id) getConnectedInfo: (unsigned) dataType Connected: (NSDictionary *)Connected { + switch(dataType) { + case DT_LIST_CONNECTED_INT: + return Connected; + case DT_LIST_CONNECTED_ID_INT: + return [Connected valueForKey:@"DeviceID"]; + } + return nil; +} + +- (NSArray *) listConnected { + NSMutableArray *temp = [NSMutableArray array]; + io_iterator_t itThis; + if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IOUSBDevice"), &itThis) == KERN_SUCCESS) { + io_service_t service; + while((service = IOIteratorNext(itThis))){ + NSString *DeviceID; + DeviceID = [NSString stringWithFormat:kPCIFormat, [pciDevice grabNumber:CFSTR("idProduct") forService:service].longValue, [pciDevice grabNumber:CFSTR("idVendor") forService:service].longValue]; + io_name_t name; + IORegistryEntryGetName(service, name); + [temp addObject:@{ + @"ProductName" : [pciDevice grabString:CFSTR("USB Product Name") forService:service], + @"VendorName" : [pciDevice grabString:CFSTR("USB Vendor Name") forService:service], + @"Name" : @(name), + @"BuiltIn": [pciDevice grabNumber:CFSTR("Built-In") forService:service], + @"DeviceID" : DeviceID, + @"PortNumber": [pciDevice grabNumber:CFSTR("PortNum") forService:service], + } + ]; + IOObjectRelease(service); + } + IOObjectRelease(itThis); + } + return [temp copy]; +} + + +/** + * Insert colon in device id to format it like this: `VendorID:DeviceID` + * + * @param int_id The given integer + 8 @return A string containing the desired format + */ +- (NSString *) insertColonInID: (long) int_id { + NSMutableString *ID = [NSMutableString stringWithFormat:@"%08lX", int_id]; + [ID insertString:@":" atIndex:4]; + return [ID copy]; +} + +- (NSString *) insertColonInStrID: (NSString *) str_id { + NSMutableString *ID = [NSMutableString stringWithString:str_id]; + [ID insertString:@":" atIndex:4]; + return [ID copy]; +} + +/** + * Some "Data" fields have NULL character at the end, so have to remove it + * + * @param str The given string containing NULL character + * @return A string without the NULL character + */ +- (NSString *) removeNullChar: (NSString *) str { + return [str substringToIndex:[str length]-1]; +} + @end diff --git a/dspci/dspci.h b/dspci/dspci.h index 8d6f851..2674e90 100644 --- a/dspci/dspci.h +++ b/dspci/dspci.h @@ -9,7 +9,7 @@ #define dspci_h #import "DDCommandLineInterface.h" -#define CURRENT_MARKETING_VERSION "1.6" +#define CURRENT_MARKETING_VERSION "1.8" @interface DSPCI : NSObject { diff --git a/dspci/dspci.m b/dspci/dspci.m index 14e5ddc..615e145 100644 --- a/dspci/dspci.m +++ b/dspci/dspci.m @@ -40,10 +40,17 @@ - (void) printVersion { - (void) listDataTypes { printf("Available data types:\n" - " DTListPCIID List only PCI IDs\n" - " DTListAudio List audio related info\n" - " DTListAudioID List audio device IDs\n" - " DTListAudioCodecID List audio codec IDs\n" + " DTListPCIID List only PCI IDs\n" + " DTListAudio List audio related info\n" + " DTListAudioID List audio device IDs\n" + " DTListAudioCodecID List audio codec IDs\n" + " DTListAudioCodecIDWithRevision List audio codec IDs\n" + " DTListGPU List GPU related info\n" + " DTListGPUID List GPU only IDs\n" + " DTListNetwork List network devices\n" + " DTListNetworkID List network device IDs\n" + " DTListConnected List connected devices via USB\n" + " DTListConnectedID List connected device IDs via USB\n" "\n" "By default, all the PCI device info will be printed.\n"); } @@ -52,7 +59,7 @@ - (void) application: (DDCliApplication *) app willParseOptions: (DDGetoptLongPa DDGetoptOption optionTable[] = { // Long Short Argument options {"listDataTypes", 'l', DDGetoptNoArgument}, - {"json", 0, DDGetoptNoArgument}, + {"json", 'j', DDGetoptNoArgument}, {"version", 0, DDGetoptNoArgument}, {"help", 'h', DDGetoptNoArgument}, {"", 0, 0},