gpt4 book ai didi

macos - 是否有可能以更易于解析的格式获取 ioreg 的输出?

转载 作者:行者123 更新时间:2023-12-04 00:59:31 25 4
gpt4 key购买 nike

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

关于macos - 是否有可能以更易于解析的格式获取 ioreg 的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/587693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com