g_lock: Use dbwrap_do_locked in g_lock_lock_retry
[Samba.git] / libcli / util / ntstatus.h
blobe24d6eb98439e2465482caaccfd0aef3225ae0d0
1 /*
2 Unix SMB/CIFS implementation.
3 NT error code constants
4 Copyright (C) Andrew Tridgell 1992-2000
5 Copyright (C) John H Terpstra 1996-2000
6 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
7 Copyright (C) Paul Ashton 1998-2000
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef _NTSTATUS_H
24 #define _NTSTATUS_H
26 #include "libcli/util/ntstatus_gen.h"
28 /* the following rather strange looking definitions of NTSTATUS
29 are there in order to catch common coding errors where different error types
30 are mixed up. This is especially important as we slowly convert Samba
31 from using bool for internal functions
34 #if defined(HAVE_IMMEDIATE_STRUCTURES)
35 typedef struct {uint32_t v;} NTSTATUS;
36 #define NT_STATUS(x) ((NTSTATUS) { x })
37 #define NT_STATUS_V(x) ((x).v)
38 #else
39 typedef uint32_t NTSTATUS;
40 #define NT_STATUS(x) (x)
41 #define NT_STATUS_V(x) (x)
42 #endif
44 /* Win32 status codes. */
45 #define ERROR_INVALID_PARAMETER NT_STATUS(0x0057)
46 #define ERROR_INSUFFICIENT_BUFFER NT_STATUS(0x007a)
47 #define ERROR_INVALID_DATATYPE NT_STATUS(0x070c)
48 #define NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS NT_STATUS(0x2071)
49 #define NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION NT_STATUS(0x2177)
50 #define NT_STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP NT_STATUS(0xC05D0000)
52 /* Other error codes that aren't in the list we use */
53 #define NT_STATUS_OK NT_STATUS_SUCCESS
55 #define STATUS_MORE_ENTRIES NT_STATUS_MORE_ENTRIES
56 #define STATUS_BUFFER_OVERFLOW NT_STATUS_BUFFER_OVERFLOW
57 #define STATUS_NO_MORE_FILES NT_STATUS_NO_MORE_FILES
58 #define STATUS_NO_MORE_EAS NT_STATUS_NO_MORE_EAS
59 #define STATUS_INVALID_EA_NAME NT_STATUS_INVALID_EA_NAME
60 #define STATUS_INVALID_EA_FLAG NT_STATUS_INVALID_EA_FLAG
61 #define STATUS_SOME_UNMAPPED NT_STATUS_SOME_NOT_MAPPED
62 #define STATUS_NOTIFY_CLEANUP NT_STATUS_NOTIFY_CLEANUP
63 #define STATUS_NOTIFY_ENUM_DIR NT_STATUS_NOTIFY_ENUM_DIR
64 #define STATUS_PENDING NT_STATUS_PENDING
65 #define STATUS_STOPPED_ON_SYMLINK NT_STATUS_STOPPED_ON_SYMLINK
66 #define STATUS_EA_LIST_INCONSISTENT NT_STATUS_EA_LIST_INCONSISTENT
67 #define NT_STATUS_INACCESSIBLE_SYSTEM_SHORTCUT NT_STATUS(0x8000002d)
69 #define NT_STATUS_ABIOS_NOT_PRESENT NT_STATUS(0xC0000000 | 0x010f)
70 #define NT_STATUS_ABIOS_LID_NOT_EXIST NT_STATUS(0xC0000000 | 0x0110)
71 #define NT_STATUS_ABIOS_LID_ALREADY_OWNED NT_STATUS(0xC0000000 | 0x0111)
72 #define NT_STATUS_ABIOS_NOT_LID_OWNER NT_STATUS(0xC0000000 | 0x0112)
73 #define NT_STATUS_ABIOS_INVALID_COMMAND NT_STATUS(0xC0000000 | 0x0113)
74 #define NT_STATUS_ABIOS_INVALID_LID NT_STATUS(0xC0000000 | 0x0114)
75 #define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x0115)
76 #define NT_STATUS_ABIOS_INVALID_SELECTOR NT_STATUS(0xC0000000 | 0x0116)
78 #define NT_STATUS_HANDLE_NOT_WAITABLE NT_STATUS(0xC0000000 | 0x0036)
79 #define NT_STATUS_DEVICE_POWER_FAILURE NT_STATUS(0xC0000000 | 0x009e)
80 #define NT_STATUS_VHD_SHARED NT_STATUS(0xC05CFF0A)
81 #define NT_STATUS_SMB_BAD_CLUSTER_DIALECT NT_STATUS(0xC05D0001)
82 #define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE)
85 --------------
86 / \
87 / REST \
88 / IN \
89 / PEACE \
90 / \
91 | NT_STATUS_NOPROBLEMO |
92 | |
93 | |
94 | 4 September |
95 | |
96 | 2001 |
97 *| * * * | *
98 _________)/\\_//(\/(/\)/\//\/\///|_)_______
101 /* I use NT_STATUS_FOOBAR when I have no idea what error code to use -
102 * this means we need a torture test */
103 #define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL
105 /*****************************************************************************
106 Returns an NT error message. not amazingly helpful, but better than a number.
108 This version is const, and so neither allocates memory nor uses a
109 static variable for unknown errors.
110 *****************************************************************************/
112 const char *nt_errstr_const(NTSTATUS nt_code);
114 /*****************************************************************************
115 returns an NT error message. not amazingly helpful, but better than a number.
116 *****************************************************************************/
117 const char *nt_errstr(NTSTATUS nt_code);
119 /************************************************************************
120 Print friendler version fo NT error code
121 ***********************************************************************/
122 const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
124 /*****************************************************************************
125 returns an NT_STATUS constant as a string for inclusion in autogen C code
126 *****************************************************************************/
127 const char *get_nt_error_c_code(void *mem_ctx, NTSTATUS nt_code);
129 /*****************************************************************************
130 returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)
131 *****************************************************************************/
132 NTSTATUS nt_status_string_to_code(const char *nt_status_str);
134 /* we need these here for openchange */
135 #ifndef likely
136 #define likely(x) (x)
137 #endif
138 #ifndef unlikely
139 #define unlikely(x) (x)
140 #endif
142 #define NT_STATUS_IS_OK(x) (likely(NT_STATUS_V(x) == 0))
143 #define NT_STATUS_IS_ERR(x) (unlikely((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000))
144 #define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
147 * These macros (with the embedded return) are considered poor coding
148 * style per README.Coding
150 * Please do not use them in new code, and do not rely on them in
151 * projects external to Samba as they will go away at some point.
154 #define NT_STATUS_HAVE_NO_MEMORY(x) do { \
155 if (unlikely(!(x))) { \
156 return NT_STATUS_NO_MEMORY;\
158 } while (0)
160 /* This varient is for when you want to free a local
161 temporary memory context in the error path */
162 #define NT_STATUS_HAVE_NO_MEMORY_AND_FREE(x, ctx) do { \
163 if (!(x)) {\
164 talloc_free(ctx); \
165 return NT_STATUS_NO_MEMORY;\
167 } while (0)
169 #define NT_STATUS_IS_OK_RETURN(x) do { \
170 if (NT_STATUS_IS_OK(x)) {\
171 return x;\
173 } while (0)
175 #define NT_STATUS_NOT_OK_RETURN(x) do { \
176 if (!NT_STATUS_IS_OK(x)) {\
177 return x;\
179 } while (0)
181 #define NT_STATUS_NOT_OK_RETURN_AND_FREE(x, ctx) do { \
182 if (!NT_STATUS_IS_OK(x)) {\
183 talloc_free(ctx); \
184 return x;\
186 } while (0)
188 #define NT_STATUS_IS_ERR_RETURN(x) do { \
189 if (NT_STATUS_IS_ERR(x)) {\
190 return x;\
192 } while (0)
194 #define NT_STATUS_NOT_ERR_RETURN(x) do { \
195 if (!NT_STATUS_IS_ERR(x)) {\
196 return x;\
198 } while (0)
200 /* this defines special NTSTATUS codes to represent DOS errors. I
201 have chosen this macro to produce status codes in the invalid
202 NTSTATUS range */
203 #define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code)
204 #define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000)
205 #define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
206 #define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
208 /* define ldap error codes as NTSTATUS codes */
209 #define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code)
210 #define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000)
211 #define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000)
213 #define NT_STATUS_IS_RPC(status) \
214 (((NT_STATUS_V(status) & 0xFFFF) == 0xC0020000) || \
215 ((NT_STATUS_V(status) & 0xFFFF) == 0xC0030000))
217 #endif /* _NTSTATUS_H */