diff options
Diffstat (limited to 'source3/librpc/ndr/libndr.h')
-rw-r--r-- | source3/librpc/ndr/libndr.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/source3/librpc/ndr/libndr.h b/source3/librpc/ndr/libndr.h index 518b4a5a37..6341e20b65 100644 --- a/source3/librpc/ndr/libndr.h +++ b/source3/librpc/ndr/libndr.h @@ -160,6 +160,7 @@ struct ndr_print { #define NDR_BE(ndr) (((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN) enum ndr_err_code { + NDR_ERR_SUCCESS = 0, NDR_ERR_ARRAY_SIZE, NDR_ERR_BAD_SWITCH, NDR_ERR_OFFSET, @@ -179,6 +180,14 @@ enum ndr_err_code { NDR_ERR_UNREAD_BYTES }; +#define NDR_ERR_CODE_IS_SUCCESS(x) (x == NDR_ERR_SUCCESS) + +#define NDR_ERR_HAVE_NO_MEMORY(x) do { \ + if (NULL == (x)) { \ + return NDR_ERR_ALLOC; \ + } \ +} while (0) + enum ndr_compression_alg { NDR_COMPRESSION_MSZIP = 2, NDR_COMPRESSION_XPRESS = 3 @@ -231,11 +240,13 @@ enum ndr_compression_alg { /* these are used to make the error checking on each element in libndr less tedious, hopefully making the code more readable */ -#define NDR_CHECK(call) do { NTSTATUS _status; \ - _status = call; \ - if (!NT_STATUS_IS_OK(_status)) \ - return _status; \ - } while (0) +#define NDR_CHECK(call) do { \ + enum ndr_err_code _status; \ + _status = call; \ + if (!NDR_ERR_CODE_IS_SUCCESS(_status)) { \ + return _status; \ + } \ +} while (0) #define NDR_PULL_GET_MEM_CTX(ndr) (ndr->current_mem_ctx) @@ -281,8 +292,8 @@ enum ndr_compression_alg { } while (0) /* these are used when generic fn pointers are needed for ndr push/pull fns */ -typedef NTSTATUS (*ndr_push_flags_fn_t)(struct ndr_push *, int ndr_flags, const void *); -typedef NTSTATUS (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *); +typedef enum ndr_err_code (*ndr_push_flags_fn_t)(struct ndr_push *, int ndr_flags, const void *); +typedef enum ndr_err_code (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *); typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, const void *); typedef void (*ndr_print_function_t)(struct ndr_print *, const char *, int, const void *); |