summaryrefslogtreecommitdiff
path: root/librpc/ndr/ndr.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-01-26 17:31:22 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-01-26 17:31:22 +0100
commit79255cec6a75cd96b05a42845ff39040d1a1dfbf (patch)
treef29c9f14dd14ce8c42cada2796ea3f8677f95fd6 /librpc/ndr/ndr.c
parent5baac15781779a3ebfa3807299e5329809835370 (diff)
downloadsamba-79255cec6a75cd96b05a42845ff39040d1a1dfbf.tar.gz
Add function for mapping NDR error codes to strings.
Diffstat (limited to 'librpc/ndr/ndr.c')
-rw-r--r--librpc/ndr/ndr.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index 22b9fccbb53..2341f51faa0 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -1122,3 +1122,38 @@ _PUBLIC_ enum ndr_err_code ndr_pull_relative_ptr2(struct ndr_pull *ndr, const vo
NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, p, &rel_offset));
return ndr_pull_set_offset(ndr, rel_offset);
}
+
+const static struct {
+ enum ndr_err_code err;
+ const char *string;
+} ndr_err_code_strings[] = {
+ { NDR_ERR_SUCCESS, "Success" },
+ { NDR_ERR_ARRAY_SIZE, "Bad Array Size" },
+ { NDR_ERR_BAD_SWITCH, "Bad Switch" },
+ { NDR_ERR_OFFSET, "Offset Error" },
+ { NDR_ERR_RELATIVE, "Relative Pointer Error" },
+ { NDR_ERR_CHARCNV, "Character Conversion Error" },
+ { NDR_ERR_LENGTH, "Length Error" },
+ { NDR_ERR_SUBCONTEXT, "Subcontext Error" },
+ { NDR_ERR_COMPRESSION, "Compression Error" },
+ { NDR_ERR_STRING, "String Error" },
+ { NDR_ERR_VALIDATE, "Validate Error" },
+ { NDR_ERR_BUFSIZE, "Buffer Size Error" },
+ { NDR_ERR_ALLOC, "Allocation Error" },
+ { NDR_ERR_RANGE, "Range Error" },
+ { NDR_ERR_TOKEN, "Token Error" },
+ { NDR_ERR_IPV4ADDRESS, "IPv4 Address Error" },
+ { NDR_ERR_INVALID_POINTER, "Invalid Pointer" },
+ { NDR_ERR_UNREAD_BYTES, "Unread Bytes" },
+ { 0, NULL }
+};
+
+_PUBLIC_ const char *ndr_map_error2string(enum ndr_err_code ndr_err)
+{
+ int i;
+ for (i = 0; ndr_err_code_strings[i].string != NULL; i++) {
+ if (ndr_err_code_strings[i].err == ndr_err)
+ return ndr_err_code_strings[i].string;
+ }
+ return "Unknown error";
+}