1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

libclu/util: Move get_friendly_nt_error_msg() in common.

Andrew Bartlett

Signed-off-by: Andrew Tridgell <tridge@samba.org>
This commit is contained in:
Andrew Bartlett 2011-06-16 13:00:09 +10:00
parent d2bc45e7ff
commit 1233ba7bf3
4 changed files with 52 additions and 40 deletions

View File

@ -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);
}

View File

@ -628,6 +628,15 @@ typedef uint32_t NTSTATUS;
* this means we need a torture test */
#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.
*****************************************************************************/

View File

@ -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);
}

View File

@ -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);
}