Re: Getting processor description from sysctl
Re: Getting processor description from sysctl
- Subject: Re: Getting processor description from sysctl
- From: Philip Aker <email@hidden>
- Date: Wed, 14 May 2008 23:26:51 -0700
On 08-05-14, at 21:41, Mike wrote:
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
Maybe:
system_profiler -xml SPHardwareDataType
In C, not from a shell script.
/* sysprof.c */
#include <CoreFoundation/CoreFoundation.h>
#include <Tcl/tcl.h>
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;
}
// :-)
Philip Aker
echo email@hidden@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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden