s3-nterr: make nt_err_desc static const.
[nivanova/samba-autobuild/.git] / source3 / libsmb / nterr.c
index 5fa9ade3a5c67eb924ed58a9e4a3d08581208314..f228f992a7075929f04d0bc146875cc6110865d7 100644 (file)
@@ -1,18 +1,18 @@
-/* 
+/*
  *  Unix SMB/CIFS implementation.
  *  RPC Pipe client / server routines
  *  Copyright (C) Luke Kenneth Casson Leighton 1997-2001.
- *  
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
@@ -539,7 +539,7 @@ static const nt_err_code_struct nt_errs[] =
        { "NT_STATUS_DS_NO_MORE_RIDS", NT_STATUS_DS_NO_MORE_RIDS },
        { "NT_STATUS_NOT_A_REPARSE_POINT", NT_STATUS_NOT_A_REPARSE_POINT },
        { "NT_STATUS_DOWNGRADE_DETECTED", NT_STATUS_DOWNGRADE_DETECTED },
-        { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES },
+       { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES },
        { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES },
        { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED },
        { "STATUS_NO_MORE_FILES", STATUS_NO_MORE_FILES },
@@ -565,7 +565,7 @@ static const nt_err_code_struct nt_errs[] =
 
 /* These need sorting..... */
 
-nt_err_code_struct nt_err_desc[] =
+static const nt_err_code_struct nt_err_desc[] =
 {
        { N_("Success"),                                NT_STATUS_OK },
        { N_("Undetermined error"),             NT_STATUS_UNSUCCESSFUL },
@@ -630,7 +630,7 @@ nt_err_code_struct nt_err_desc[] =
        { N_("Logon session collision"),                NT_STATUS_LOGON_SESSION_COLLISION },
        { N_("Invalid logon type"),             NT_STATUS_INVALID_LOGON_TYPE },
        { N_("Cancelled"),                              NT_STATUS_CANCELLED },
-       { N_("Invalid computer name"),          NT_STATUS_INVALID_COMPUTER_NAME },      
+       { N_("Invalid computer name"),          NT_STATUS_INVALID_COMPUTER_NAME },
        { N_("Logon server conflict"),          NT_STATUS_LOGON_SERVER_CONFLICT },
        { N_("Time difference at domain controller"), NT_STATUS_TIME_DIFFERENCE_AT_DC },
        { N_("Pipe broken"),                    NT_STATUS_PIPE_BROKEN },
@@ -656,7 +656,7 @@ nt_err_code_struct nt_err_desc[] =
        { N_("User session deleted"),           NT_STATUS_USER_SESSION_DELETED },
        { N_("Insufficient server resources"),  NT_STATUS_INSUFF_SERVER_RESOURCES },
        { N_("Insufficient logon information"),         NT_STATUS_INSUFFICIENT_LOGON_INFO },
-       
+
        { N_("License quota exceeded"),                 NT_STATUS_LICENSE_QUOTA_EXCEEDED },
        { N_("No more files"),                  STATUS_NO_MORE_FILES },
 
@@ -669,12 +669,12 @@ nt_err_code_struct nt_err_desc[] =
 
 const char *nt_errstr(NTSTATUS nt_code)
 {
-        int idx = 0;
+       int idx = 0;
        char *result;
 
 #ifdef HAVE_LDAP
-        if (NT_STATUS_IS_LDAP(nt_code)) {
-                return ldap_err2string(NT_STATUS_LDAP_CODE(nt_code));
+       if (NT_STATUS_IS_LDAP(nt_code)) {
+               return ldap_err2string(NT_STATUS_LDAP_CODE(nt_code));
        }
 #endif
 
@@ -685,7 +685,7 @@ const char *nt_errstr(NTSTATUS 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;
+                       return nt_errs[idx].nt_errstr;
                }
                idx++;
        }
@@ -699,20 +699,20 @@ const char *nt_errstr(NTSTATUS nt_code)
 /************************************************************************
  Print friendler version fo NT error code
  ***********************************************************************/
+
 const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
 {
-        int idx = 0;
+       int idx = 0;
 
        while (nt_err_desc[idx].nt_errstr != NULL) {
                if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
-                        return nt_err_desc[idx].nt_errstr;
+                       return nt_err_desc[idx].nt_errstr;
                }
                idx++;
        }
-       
+
        /* fall back to NT_STATUS_XXX string */
-       
+
        return nt_errstr(nt_code);
 }
 
@@ -723,12 +723,12 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
 const char *get_nt_error_c_code(NTSTATUS nt_code)
 {
        char *result;
-        int idx = 0;
+       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;
+               if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
+                   NT_STATUS_V(nt_code)) {
+                       return nt_errs[idx].nt_errstr;
                }
                idx++;
        }
@@ -745,11 +745,11 @@ const char *get_nt_error_c_code(NTSTATUS nt_code)
 
 NTSTATUS nt_status_string_to_code(const char *nt_status_str)
 {
-        int idx = 0;
+       int idx = 0;
 
        while (nt_errs[idx].nt_errstr != NULL) {
                if (strcmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) {
-                        return nt_errs[idx].nt_errcode;
+                       return nt_errs[idx].nt_errcode;
                }
                idx++;
        }
@@ -759,8 +759,8 @@ NTSTATUS nt_status_string_to_code(const char *nt_status_str)
 /**
  * Squash an NT_STATUS in line with security requirements.
  * In an attempt to avoid giving the whole game away when users
- * are authenticating, NT replaces both NT_STATUS_NO_SUCH_USER and 
- * NT_STATUS_WRONG_PASSWORD with NT_STATUS_LOGON_FAILURE in certain situations 
+ * are authenticating, NT replaces both NT_STATUS_NO_SUCH_USER and
+ * NT_STATUS_WRONG_PASSWORD with NT_STATUS_LOGON_FAILURE in certain situations
  * (session setups in particular).
  *
  * @param nt_status NTSTATUS input for squashing.
@@ -770,15 +770,15 @@ NTSTATUS nt_status_string_to_code(const char *nt_status_str)
 NTSTATUS nt_status_squash(NTSTATUS nt_status)
 {
        if NT_STATUS_IS_OK(nt_status) {
-               return nt_status;               
+               return nt_status;
        } else if NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_SUCH_USER) {
                /* Match WinXP and don't give the game away */
                return NT_STATUS_LOGON_FAILURE;
-               
+
        } else if NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD) {
                /* Match WinXP and don't give the game away */
                return NT_STATUS_LOGON_FAILURE;
        } else {
                return nt_status;
-       }  
+       }
 }