Remove use of global_loadparm during initialization of gensec.
[sfrench/samba-autobuild/.git] / source4 / libcli / util / errormap.c
index 711f02a626429782f4186c329ea40cb481b2de07..4260c0dd7dfee3eb31b3e02c69ab0db3b0787d24 100644 (file)
@@ -20,6 +20,8 @@
  */
 
 #include "includes.h"
+#include "param/param.h"
+#include "librpc/ndr/libndr.h"
 
 /* This map was extracted by the ERRMAPEXTRACT smbtorture command. 
    The setup was a Samba HEAD (2002-01-03) PDC and an Win2k member 
@@ -1155,19 +1157,19 @@ static const struct {
        {NT_STATUS(0x80000025), W_ERROR(0x962)},
        {NT_STATUS(0x80000288), W_ERROR(0x48d)},
        {NT_STATUS(0x80000289), W_ERROR(0x48e)},
-       {NT_STATUS_OK, WERR_OK}};
-
+       {NT_STATUS_OK, WERR_OK}
+};
 
 /*
   check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code
 */
-BOOL ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2)
+bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2)
 {
        /* when we negotiate nt status support, we don't want to consider
           the mapping of dos codes, as we want to catch the cases where
           a forced dos code is needed
        */
-       if (lp_nt_status_support()) {
+       if (lp_nt_status_support(global_loadparm)) {
                return NT_STATUS_V(status1) == NT_STATUS_V(status2);
        }
 
@@ -1374,3 +1376,28 @@ NTSTATUS map_nt_error_from_unix(int unix_error)
        /* Default return */
        return NT_STATUS_UNSUCCESSFUL;
 }
+
+NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err)
+{
+       switch (ndr_err) {
+       case NDR_ERR_SUCCESS:
+               return NT_STATUS_OK;
+       case NDR_ERR_BUFSIZE:
+               return NT_STATUS_BUFFER_TOO_SMALL;
+       case NDR_ERR_TOKEN:
+               return NT_STATUS_INTERNAL_ERROR;
+       case NDR_ERR_ALLOC:
+               return NT_STATUS_NO_MEMORY;
+       case NDR_ERR_ARRAY_SIZE:
+               return NT_STATUS_ARRAY_BOUNDS_EXCEEDED;
+       case NDR_ERR_INVALID_POINTER:
+               return NT_STATUS_INVALID_PARAMETER_MIX;
+       case NDR_ERR_UNREAD_BYTES:
+               return NT_STATUS_PORT_MESSAGE_TOO_LONG;
+       default:
+               break;
+       }
+
+       /* we should map all error codes to different status codes */
+       return NT_STATUS_INVALID_PARAMETER;
+}