diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-16 13:00:09 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-17 17:08:59 +1000 |
commit | 1233ba7bf3d2dfd9a84eb52d601e589411c55185 (patch) | |
tree | 7288be923353c2b884fc6120b6ead219843b2faa | |
parent | d2bc45e7ffb4e8d47878a6fc53c5f5c90dfd2114 (diff) | |
download | samba-1233ba7bf3d2dfd9a84eb52d601e589411c55185.tar.gz samba-1233ba7bf3d2dfd9a84eb52d601e589411c55185.tar.bz2 samba-1233ba7bf3d2dfd9a84eb52d601e589411c55185.zip |
libclu/util: Move get_friendly_nt_error_msg() in common.
Andrew Bartlett
Signed-off-by: Andrew Tridgell <tridge@samba.org>
-rw-r--r-- | libcli/util/nterr.c | 43 | ||||
-rw-r--r-- | libcli/util/ntstatus.h | 9 | ||||
-rw-r--r-- | source3/libsmb/nterr.c | 20 | ||||
-rw-r--r-- | source4/libcli/util/nterr.c | 20 |
4 files changed, 52 insertions, 40 deletions
diff --git a/libcli/util/nterr.c b/libcli/util/nterr.c index 5f31c3c0c2..1e84e81878 100644 --- a/libcli/util/nterr.c +++ b/libcli/util/nterr.c @@ -906,3 +906,46 @@ NTSTATUS nt_status_squash(NTSTATUS nt_status) return nt_status; } } + +/***************************************************************************** + Returns an NT error message. not amazingly helpful, but better than a number. + + This version is const, and so neither allocates memory nor uses a + static variable for unknown errors. + *****************************************************************************/ + +const char *nt_errstr_const(NTSTATUS nt_code) +{ + static char msg[40]; + 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++; + } + + return "unknown NT_STATUS error"; +} + +/************************************************************************ + Print friendler version fo NT error code + ***********************************************************************/ + +const char *get_friendly_nt_error_msg(NTSTATUS nt_code) +{ + 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; + } + idx++; + } + + /* fall back to NT_STATUS_XXX string */ + + return nt_errstr_const(nt_code); +} diff --git a/libcli/util/ntstatus.h b/libcli/util/ntstatus.h index 13ce733ca3..2f1635093b 100644 --- a/libcli/util/ntstatus.h +++ b/libcli/util/ntstatus.h @@ -629,6 +629,15 @@ typedef uint32_t NTSTATUS; #define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL /***************************************************************************** + Returns an NT error message. not amazingly helpful, but better than a number. + + This version is const, and so neither allocates memory nor uses a + static variable for unknown errors. + *****************************************************************************/ + +const char *nt_errstr_const(NTSTATUS nt_code); + +/***************************************************************************** returns an NT error message. not amazingly helpful, but better than a number. *****************************************************************************/ const char *nt_errstr(NTSTATUS nt_code); diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c index 7d0b3d08fd..a4a388303d 100644 --- a/source3/libsmb/nterr.c +++ b/source3/libsmb/nterr.c @@ -55,23 +55,3 @@ const char *nt_errstr(NTSTATUS nt_code) return result; } -/************************************************************************ - Print friendler version fo NT error code - ***********************************************************************/ - -const char *get_friendly_nt_error_msg(NTSTATUS nt_code) -{ - 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; - } - idx++; - } - - /* fall back to NT_STATUS_XXX string */ - - return nt_errstr(nt_code); -} - diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index ea8c0fcd35..1532b5b787 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -52,23 +52,3 @@ const char *nt_errstr(NTSTATUS nt_code) return msg; } - -/************************************************************************ - Print friendler version fo NT error code - ***********************************************************************/ - -const char *get_friendly_nt_error_msg(NTSTATUS nt_code) -{ - 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; - } - idx++; - } - - /* fall back to NT_STATUS_XXX string */ - - return nt_errstr(nt_code); -} |