libcli/util/hresult: add generated hresult_errstr() function.
authorGünther Deschner <gd@samba.org>
Fri, 6 Mar 2015 16:44:19 +0000 (17:44 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 13 Mar 2015 22:58:07 +0000 (23:58 +0100)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
libcli/util/hresult.c
libcli/util/hresult.h

index d8d25087647165d22de7b92987b852d866680264..1b3a8f2b690e543c78d0b6b4d9bb0f8597c99445 100644 (file)
@@ -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;
+};
index aa89cd5602231a675c4946500d48de530e7b370e..18941a574a3aa8375a75aa7fd92f3302fc1c30a8 100644 (file)
@@ -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)