繁体   English   中英

是否有可能以更容易解析的格式获得 ioreg 的 output?

[英]Is it possible to get the output of ioreg in a more easily parse-able format?

我需要在 Mac OS X 中获取ioreg的 output 以进行进一步处理,但是它使用的树状结构很难解析? 有什么方法可以在 XML 中获得 output 或更容易解析的东西(如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>
    | | {
    | |   ...

路漫漫其修远兮,可将源码抓取到ioreg并修改...

https://opensource.apple.com/source/IOKitTools/IOKitTools-108/ioreg.tproj/

下载:

#include <IOKit/IOKitLibPrivate.h>#include <IOKit/IOKitKeysPrivate.h >更改为#include "IOKitLibPrivate.h"#include "IOKitKeysPrivate.h"以便在两个文件位于同一目录时进行编译,然后编译

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM