tags:

views:

335

answers:

1

I need to get the output of ioreg in Mac OS X for further processing, however the tree like structure it uses is difficult to parse? Is there any way to get the output in XML or something easier to parse (like system_profiler)?

+-o Root  <class IORegistryEntry, retain 12>
  | {
  |   ...
  | }
  | 
  +-o MacBookPro5,1  <class IOPlatformExpertDevice, registered, matched, active, busy 0, retain 25>
    | {
    |   ...
    | }
    | 
    +-o AppleACPIPlatformExpert  <class AppleACPIPlatformExpert, registered, matched, active, busy 0, retain 51>
    | | {
    | |   ...
+1  A: 

A long road can be to grab the source code to ioreg and modify it...

http://www.opensource.apple.com/darwinsource/10.5.6/IOKitTools-76/ioreg.tproj/

Download:

Change the #include <IOKit/IOKitLibPrivate.h> to #include "IOKitLibPrivate.h" so you can compile when both files is in same directory, then compile with

cc -o ioreg ioreg.c -framework Foundation -framework IOKit -lcurses
epatel