Skip to content

Commit

Permalink
libcli/util/hresult: add generated hresult_errstr() function.
Browse files Browse the repository at this point in the history
Guenther

Signed-off-by: Günther Deschner <[email protected]>
Reviewed-by: Stefan Metzmacher <[email protected]>
  • Loading branch information
gd committed Mar 13, 2015
1 parent 5cf1545 commit 533cfb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libcli/util/hresult.c
Original file line number Diff line number Diff line change
Expand Up @@ -14685,3 +14685,17 @@ const char *hresult_errstr_const(HRESULT err_code)
}
return result;
};

const char *hresult_errstr(HRESULT err_code)
{
static char msg[20];
int i;

for (i = 0; i < ARRAY_SIZE(hresult_errs); i++) {
if (HRES_IS_EQUAL(err_code, hresult_errs[i].error_code)) {
return hresult_errs[i].error_str;
}
}
snprintf(msg, sizeof(msg), "HRES code 0x%08x", HRES_ERROR_V(err_code));
return msg;
};
2 changes: 2 additions & 0 deletions libcli/util/hresult.h
Original file line number Diff line number Diff line change
Expand Up @@ -2971,6 +2971,8 @@ typedef uint32_t HRESULT;

const char *hresult_errstr_const(HRESULT err_code);

const char *hresult_errstr(HRESULT err_code);

#define FACILITY_WIN32 0x0007
#define WIN32_FROM_HRESULT(x) (HRES_ERROR_V(x) == 0 ? HRES_ERROR_V(x) : ~((FACILITY_WIN32 << 16) | 0x80000000) & HRES_ERROR_V(x))
#define HRESULT_IS_LIKELY_WERR(x) ((HRES_ERROR_V(x) & 0xFFFF0000) == 0x80070000)
Expand Down

0 comments on commit 533cfb6

Please sign in to comment.