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