• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: hw.cpufamily vs ASP vs machine.h
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hw.cpufamily vs ASP vs machine.h


  • Subject: Re: hw.cpufamily vs ASP vs machine.h
  • From: Steve Checkoway <email@hidden>
  • Date: Sun, 16 Dec 2007 19:47:30 -0800


On Dec 15, 2007, at 3:04 PM, David M. Cotter wrote:

Invoke the system_profiler tool and parse its output; use something like "system_profiler -xml SPHardwareDataType".

i am unable to find any API called "system_profiler()" that I can call from my C++ (carbon) program.


Something like the following?

#include <CoreFoundation/CoreFoundation.h>
#include <stdio.h>

CFPropertyListRef system_profiler()
{
	FILE *fp = popen( "system_profiler -xml", "r" );
	CFMutableDataRef dataRef = CFDataCreateMutable( NULL, 0 );
	CFPropertyListRef listRef;
	char buf[1024];
	size_t size;

while( (size = fread(buf, sizeof(buf), 1, fp)) )
CFDataAppendBytes( dataRef, (const UInt8*)buf, size );
pclose( fp );
listRef = CFPropertyListCreateFromXMLData( NULL, dataRef, kCFPropertyListImmutable, NULL );
CFRelease( dataRef );
return listRef;
}


Perhaps add some error checking on the return of popen(); maybe an ferror() before pclose().

--
Steve Checkoway

    "Anyone who says that the solution is to educate the users
    hasn't ever met an actual user." -- Bruce Schneier




Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >Re: hw.cpufamily vs ASP vs machine.h (From: "David M. Cotter" <email@hidden>)

  • Prev by Date: Re: hw.cpufamily vs ASP vs machine.h
  • Next by Date: Unable to read DHCP offer packet
  • Previous by thread: Re: hw.cpufamily vs ASP vs machine.h
  • Next by thread: Unable to read DHCP offer packet
  • Index(es):
    • Date
    • Thread