r25538: Revert r25533
authorVolker Lendecke <vlendec@samba.org>
Fri, 5 Oct 2007 22:06:24 +0000 (22:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:31:12 +0000 (12:31 -0500)
(This used to be commit 1e02208c43cb27ca4b43d268a7f0324f2a9b2cfd)

source3/libsmb/nterr.c
source3/torture/torture.c

index 774e50e700b9cce158e9b72021037fdc5a223321..d88e650c9cbdda5bb3cb0147ac6ef14f5efd1f0f 100644 (file)
@@ -647,6 +647,7 @@ nt_err_code_struct nt_err_desc[] =
 
 const char *nt_errstr(NTSTATUS nt_code)
 {
+        static pstring msg;
         int idx = 0;
 
 #ifdef HAVE_LDAP
@@ -655,6 +656,8 @@ const char *nt_errstr(NTSTATUS nt_code)
        }
 #endif
 
+       slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code));
+
        while (nt_errs[idx].nt_errstr != NULL) {
                if (NT_STATUS_EQUAL(nt_errs[idx].nt_errcode, nt_code)) {
                         return nt_errs[idx].nt_errstr;
@@ -662,8 +665,7 @@ const char *nt_errstr(NTSTATUS nt_code)
                idx++;
        }
 
-       return talloc_asprintf(talloc_tos(), "NT code 0x%08x",
-                              NT_STATUS_V(nt_code));
+        return msg;
 }
 
 /************************************************************************
@@ -686,6 +688,28 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
        return nt_errstr(nt_code);
 }
 
+/*****************************************************************************
+ Returns an NT_STATUS constant as a string for inclusion in autogen C code.
+ *****************************************************************************/
+
+const char *get_nt_error_c_code(NTSTATUS nt_code)
+{
+        static pstring out;
+        int idx = 0;
+
+       while (nt_errs[idx].nt_errstr != NULL) {
+               if (NT_STATUS_V(nt_errs[idx].nt_errcode) == 
+                    NT_STATUS_V(nt_code)) {
+                        return nt_errs[idx].nt_errstr;
+               }
+               idx++;
+       }
+
+       slprintf(out, sizeof(out), "NT_STATUS(0x%08x)", NT_STATUS_V(nt_code));
+
+        return out;
+}
+
 /*****************************************************************************
  Returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)
  *****************************************************************************/
index e48448e5dadf2ebe21cb75cf1638c47d9b7c04df..6d0fc546ab4acfb8abe118ece5ea0a5d99bf19bf 100644 (file)
@@ -4768,14 +4768,14 @@ static BOOL run_error_map_extract(int dummy) {
 
                if (NT_STATUS_V(nt_status) != error) { 
                        printf("/*\t{ This NT error code was 'sqashed'\n\t from %s to %s \n\t during the session setup }\n*/\n", 
-                              nt_errstr(NT_STATUS(error)),
-                              nt_errstr(nt_status));
+                              get_nt_error_c_code(NT_STATUS(error)), 
+                              get_nt_error_c_code(nt_status));
                }
                
                printf("\t{%s,\t%s,\t%s},\n", 
                       smb_dos_err_class(errclass), 
                       smb_dos_err_name(errclass, errnum), 
-                      nt_errstr(NT_STATUS(error)));
+                      get_nt_error_c_code(NT_STATUS(error)));
        }
        return True;
 }