mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
Add get_friendly_werror_msg().
Guenther
(This used to be commit b1ad3def98
)
This commit is contained in:
@ -21,12 +21,16 @@
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
typedef const struct
|
||||
{
|
||||
typedef const struct {
|
||||
const char *dos_errstr;
|
||||
WERROR werror;
|
||||
} werror_code_struct;
|
||||
|
||||
typedef const struct {
|
||||
WERROR werror;
|
||||
const char *friendly_errstr;
|
||||
} werror_str_struct;
|
||||
|
||||
werror_code_struct dos_errs[] =
|
||||
{
|
||||
{ "WERR_OK", WERR_OK },
|
||||
@ -92,6 +96,22 @@ werror_code_struct dos_errs[] =
|
||||
{ NULL, W_ERROR(0) }
|
||||
};
|
||||
|
||||
werror_str_struct dos_err_strs[] = {
|
||||
{ WERR_OK, "Success" },
|
||||
{ WERR_ACCESS_DENIED, "Access is denied" },
|
||||
{ WERR_INVALID_PARAM, "Invalid parameter" },
|
||||
{ WERR_NOT_SUPPORTED, "Not supported" },
|
||||
{ WERR_BAD_PASSWORD, "A bad password was supplied" },
|
||||
{ WERR_NOMEM, "Out of memory" },
|
||||
{ WERR_NO_LOGON_SERVERS, "No logon servers found" },
|
||||
{ WERR_NO_SUCH_LOGON_SESSION, "No such logon session" },
|
||||
{ WERR_DOMAIN_CONTROLLER_NOT_FOUND, "A domain controller could not be found" },
|
||||
{ WERR_SETUP_NOT_JOINED, "Join failed" },
|
||||
{ WERR_SETUP_ALREADY_JOINED, "Machine is already joined" },
|
||||
{ WERR_SETUP_DOMAIN_CONTROLLER, "Machine is a Domain Controller" },
|
||||
{ WERR_LOGON_FAILURE, "Invalid logon credentials" },
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
Returns a DOS error message. not amazingly helpful, but better than a number.
|
||||
*****************************************************************************/
|
||||
@ -114,6 +134,24 @@ const char *dos_errstr(WERROR werror)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Get friendly error string for WERRORs
|
||||
*****************************************************************************/
|
||||
|
||||
const char *get_friendly_werror_msg(WERROR werror)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dos_err_strs); i++) {
|
||||
if (W_ERROR_V(dos_err_strs[i].werror) ==
|
||||
W_ERROR_V(werror)) {
|
||||
return dos_err_strs[i].friendly_errstr;
|
||||
}
|
||||
}
|
||||
|
||||
return dos_errstr(werror);
|
||||
}
|
||||
|
||||
/* compat function for samba4 */
|
||||
const char *win_errstr(WERROR werror)
|
||||
{
|
||||
|
Reference in New Issue
Block a user