#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_misc.h"
+/**
+ build a NDR blob from a GUID
+*/
+_PUBLIC_ NTSTATUS GUID_to_ndr_blob(const struct GUID *guid, TALLOC_CTX *mem_ctx, DATA_BLOB *b)
+{
+ enum ndr_err_code ndr_err;
+ ndr_err = ndr_push_struct_blob(b, mem_ctx, guid,
+ (ndr_push_flags_fn_t)ndr_push_GUID);
+ return ndr_map_error2ntstatus(ndr_err);
+}
+
/**
build a GUID from a NDR data blob
mem_ctx = talloc_new(NULL);
NT_STATUS_HAVE_NO_MEMORY(mem_ctx);
- ndr_err = ndr_pull_struct_blob_all(b, mem_ctx, NULL, guid,
+ ndr_err = ndr_pull_struct_blob_all(b, mem_ctx, guid,
(ndr_pull_flags_fn_t)ndr_pull_GUID);
talloc_free(mem_ctx);
return ndr_map_error2ntstatus(ndr_err);
_PUBLIC_ int GUID_compare(const struct GUID *u1, const struct GUID *u2)
{
if (u1->time_low != u2->time_low) {
- return u1->time_low - u2->time_low;
+ return u1->time_low > u2->time_low ? 1 : -1;
}
if (u1->time_mid != u2->time_mid) {
- return u1->time_mid - u2->time_mid;
+ return u1->time_mid > u2->time_mid ? 1 : -1;
}
if (u1->time_hi_and_version != u2->time_hi_and_version) {
- return u1->time_hi_and_version - u2->time_hi_and_version;
+ return u1->time_hi_and_version > u2->time_hi_and_version ? 1 : -1;
}
if (u1->clock_seq[0] != u2->clock_seq[0]) {
- return u1->clock_seq[0] - u2->clock_seq[0];
+ return u1->clock_seq[0] > u2->clock_seq[0] ? 1 : -1;
}
if (u1->clock_seq[1] != u2->clock_seq[1]) {
- return u1->clock_seq[1] - u2->clock_seq[1];
+ return u1->clock_seq[1] > u2->clock_seq[1] ? 1 : -1;
}
return memcmp(u1->node, u2->node, 6);
{
char *ret;
DATA_BLOB guid_blob;
- enum ndr_err_code ndr_err;
TALLOC_CTX *tmp_mem;
+ NTSTATUS status;
tmp_mem = talloc_new(mem_ctx);
if (!tmp_mem) {
return NULL;
}
- ndr_err = ndr_push_struct_blob(&guid_blob, tmp_mem,
- NULL,
- guid,
- (ndr_push_flags_fn_t)ndr_push_GUID);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ status = GUID_to_ndr_blob(guid, tmp_mem, &guid_blob);
+ if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_mem);
return NULL;
}