include/nt_status.h

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    SMB parameters and setup, plus a whole lot more.
00004    
00005    Copyright (C) Andrew Tridgell              2001
00006    
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011    
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016    
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 
00022 #ifndef _NT_STATUS_H
00023 #define _NT_STATUS_H
00024 
00025 /* The Splint code analysis tool doesn't like immediate structures. */
00026 
00027 #ifdef _SPLINT_                      /* http://www.splint.org */
00028 #undef HAVE_IMMEDIATE_STRUCTURES
00029 #endif
00030 
00031 /* the following rather strange looking definitions of NTSTATUS and WERROR
00032    and there in order to catch common coding errors where different error types
00033    are mixed up. This is especially important as we slowly convert Samba
00034    from using BOOL for internal functions 
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 /* The top byte in an NTSTATUS code is used as a type field.
00076  * Windows only uses value 0xC0 as an indicator for an NT error
00077  * and 0x00 for success.
00078  * So we can use the type field to store other types of error codes
00079  * inside the three lower bytes. 
00080  * NB: The system error codes (errno) are not integrated via a type of
00081  *     their own but are mapped to genuine NT error codes via 
00082  *     map_nt_error_from_unix() */
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 /* this defines special NTSTATUS codes to represent DOS errors.  I
00090    have chosen this macro to produce status codes in the invalid
00091    NTSTATUS range */
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 /* define ldap error codes as NTSTATUS codes */
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

Sambaに対してSat Aug 29 21:22:54 2009に生成されました。  doxygen 1.4.7