1*5e3eaea3SApple OSS Distributions // 2*5e3eaea3SApple OSS Distributions // Result.h 3*5e3eaea3SApple OSS Distributions // CoreEntitlements 4*5e3eaea3SApple OSS Distributions // 5*5e3eaea3SApple OSS Distributions 6*5e3eaea3SApple OSS Distributions #ifndef CORE_ENTITLEMENTS_RESULT_H 7*5e3eaea3SApple OSS Distributions #define CORE_ENTITLEMENTS_RESULT_H 8*5e3eaea3SApple OSS Distributions 9*5e3eaea3SApple OSS Distributions #ifndef _CE_INDIRECT 10*5e3eaea3SApple OSS Distributions #error "Please include <CoreEntitlements/CoreEntitlements.h> instead of this file" 11*5e3eaea3SApple OSS Distributions #endif 12*5e3eaea3SApple OSS Distributions 13*5e3eaea3SApple OSS Distributions #include <sys/cdefs.h> 14*5e3eaea3SApple OSS Distributions __ptrcheck_abi_assume_single(); 15*5e3eaea3SApple OSS Distributions 16*5e3eaea3SApple OSS Distributions #include <CoreEntitlements/Errors.h> 17*5e3eaea3SApple OSS Distributions #include <stdint.h> 18*5e3eaea3SApple OSS Distributions 19*5e3eaea3SApple OSS Distributions /*! 20*5e3eaea3SApple OSS Distributions * @function CEErrorPassThrough 21*5e3eaea3SApple OSS Distributions * Returns its argument. Convenient breakpoint location for when anything raises an error. 22*5e3eaea3SApple OSS Distributions */ CEErrorPassThrough(CEError_t E)23*5e3eaea3SApple OSS Distributionsstatic inline CEError_t CEErrorPassThrough(CEError_t E) { 24*5e3eaea3SApple OSS Distributions return E; 25*5e3eaea3SApple OSS Distributions } 26*5e3eaea3SApple OSS Distributions 27*5e3eaea3SApple OSS Distributions /*! 28*5e3eaea3SApple OSS Distributions * @function CE_CHECK 29*5e3eaea3SApple OSS Distributions * Checks if the passed in return value from one of CoreEntitlements function is an error, and if so returns that error in the current function 30*5e3eaea3SApple OSS Distributions */ 31*5e3eaea3SApple OSS Distributions #define CE_CHECK(ret) do { CEError_t _ce_error = ret; if (_ce_error != kCENoError) {return CEErrorPassThrough(_ce_error);} } while(0) 32*5e3eaea3SApple OSS Distributions 33*5e3eaea3SApple OSS Distributions /*! 34*5e3eaea3SApple OSS Distributions * @function CE_THROW 35*5e3eaea3SApple OSS Distributions * Macro to "throw" (return) one of the CEErrors 36*5e3eaea3SApple OSS Distributions */ 37*5e3eaea3SApple OSS Distributions #define CE_THROW(err) return CEErrorPassThrough(err) 38*5e3eaea3SApple OSS Distributions 39*5e3eaea3SApple OSS Distributions /*! 40*5e3eaea3SApple OSS Distributions * @function CE_OK 41*5e3eaea3SApple OSS Distributions * Returns a true if the passed in value corresponds to kCENoError 42*5e3eaea3SApple OSS Distributions */ 43*5e3eaea3SApple OSS Distributions #define CE_OK(ret) ((ret) == kCENoError) 44*5e3eaea3SApple OSS Distributions 45*5e3eaea3SApple OSS Distributions #endif 46