Re: Getting processor description from sysctl
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On 08-05-14, at 21:41, Mike wrote: Maybe: system_profiler -xml SPHardwareDataType /* sysprof.c */ #include <CoreFoundation/CoreFoundation.h> #include <Tcl/tcl.h> // :-) Philip Aker echo astwta@lvpc.dslh@nl | tr a-z@. p-za-o.@ Sent from my SE/30 _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... System Profiler provides the processor name, so there must be a way to get it. For example on the MacBook it reports: Processor Name: Intel Core 2 Duo In C, not from a shell script. int main( int argc, char *argv[] ) { #pragma unused( argc, argv ) int err = noErr; Tcl_Interp *interp = Tcl_CreateInterp(); Tcl_Obj *cmd = Tcl_NewStringObj( "exec /usr/sbin/system_profiler -xml SPHardwareDataType", -1 ); if( Tcl_EvalObj( interp, cmd ) == TCL_OK ) { int length = 0; unsigned char *bytes = Tcl_GetByteArrayFromObj( Tcl_GetObjResult( interp ), &length ); CFDataRef data = CFDataCreate( kCFAllocatorDefault, bytes, length ); if( data != NULL ) { CFArrayRef array = CFPropertyListCreateFromXMLData( kCFAllocatorDefault, data, kCFPropertyListMutableContainersAndLeaves, NULL ); if( array != NULL ) { CFDictionaryRef dict = (CFDictionaryRef)CFArrayGetValueAtIndex( array, 0 ); CFArrayRef items = CFDictionaryGetValue( dict, CFSTR( "_items" ) ); CFDictionaryRef details = CFArrayGetValueAtIndex( items, 0 ); CFStringRef cpu_type = CFDictionaryGetValue( details, CFSTR( "cpu_type" ) ); CFShow( cpu_type ); CFRelease( array ); } CFRelease( data ); } } return err; } This email sent to site_archiver@lists.apple.com
participants (1)
-
Philip Aker