Last active
June 21, 2017 15:15
-
-
Save MLKrisJohnson/eb5e1cb623694372676c938be82c9bb4 to your computer and use it in GitHub Desktop.
Objective-C++ program to decode an IOReturn/kern_return_t value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Decodes an IOReturn/kern_return_t value. | |
// See https://developer.apple.com/library/content/qa/qa1075/_index.html for details | |
#include <iostream> | |
#include <iomanip> | |
#include <mach/error.h> | |
using std::cout; | |
using std::cerr; | |
using std::endl; | |
using std::hex; | |
using std::dec; | |
using std::stol; | |
using std::showbase; | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
if (argc > 1) { | |
for (int i = 1; i < argc; ++i) { | |
auto err = stol(argv[1], 0, 0); | |
cout << showbase | |
<< hex << err | |
<< dec << "(" << err <<")" | |
<< hex | |
<< ": system=" << err_get_system(err) | |
<< "; subsystem=" << err_get_sub(err) | |
<< "; code=" << err_get_code(err) | |
<< endl; | |
} | |
} | |
else { | |
cerr << "usage: " << argv[0] << "CODE..."; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment