00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _NT_STATUS_H
00023 #define _NT_STATUS_H
00024
00025
00026
00027 #ifdef _SPLINT_
00028 #undef HAVE_IMMEDIATE_STRUCTURES
00029 #endif
00030
00031
00032
00033
00034
00035
00036
00037 #if defined(HAVE_IMMEDIATE_STRUCTURES)
00038 typedef struct {uint32 v;} NTSTATUS;
00039 #define NT_STATUS(x) ((NTSTATUS) { x })
00040 #define NT_STATUS_V(x) ((x).v)
00041 #else
00042 typedef uint32 NTSTATUS;
00043 #define NT_STATUS(x) (x)
00044 #define NT_STATUS_V(x) (x)
00045 #endif
00046
00047 #if defined(HAVE_IMMEDIATE_STRUCTURES)
00048 typedef struct {uint32 w;} WERROR;
00049 #define W_ERROR(x) ((WERROR) { x })
00050 #define W_ERROR_V(x) ((x).w)
00051 #else
00052 typedef uint32 WERROR;
00053 #define W_ERROR(x) (x)
00054 #define W_ERROR_V(x) (x)
00055 #endif
00056
00057 #define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
00058 #define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
00059 #define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
00060 #define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
00061 #define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y))
00062
00063 #define NT_STATUS_HAVE_NO_MEMORY(x) do { \
00064 if (!(x)) {\
00065 return NT_STATUS_NO_MEMORY;\
00066 }\
00067 } while (0)
00068
00069 #define NT_STATUS_NOT_OK_RETURN(x) do { \
00070 if (!NT_STATUS_IS_OK(x)) {\
00071 return x;\
00072 }\
00073 } while (0)
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 #define NT_STATUS_TYPE(status) ((NT_STATUS_V(status) & 0xFF000000) >> 24)
00085
00086 #define NT_STATUS_TYPE_DOS 0xF1
00087 #define NT_STATUS_TYPE_LDAP 0xF2
00088
00089
00090
00091
00092 #define NT_STATUS_DOS_MASK (NT_STATUS_TYPE_DOS << 24)
00093 #define NT_STATUS_DOS(class, code) NT_STATUS(NT_STATUS_DOS_MASK | ((class)<<16) | code)
00094 #define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == NT_STATUS_DOS_MASK)
00095 #define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
00096 #define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
00097
00098
00099 #define NT_STATUS_LDAP_MASK (NT_STATUS_TYPE_LDAP << 24)
00100 #define NT_STATUS_LDAP(code) NT_STATUS(NT_STATUS_LDAP_MASK | code)
00101 #define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == NT_STATUS_LDAP_MASK)
00102 #define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000)
00103
00104 #endif