svn commit: samba r2204 - in branches/SAMBA_4_0/source/librpc: idl ndr

tridge at samba.org tridge at samba.org
Fri Sep 3 12:10:35 GMT 2004


Author: tridge
Date: 2004-09-03 12:10:34 +0000 (Fri, 03 Sep 2004)
New Revision: 2204

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/librpc&rev=2204&nolog=1

Log:
added [flag(RELATIVE_CURRENT)] to change [relative] pointer behaviour
for this struct and all sub-structures to be like spoolss relative
pointers (where offset is relative to current position).

volker will test this for me :)





Modified:
   branches/SAMBA_4_0/source/librpc/idl/idl_types.h
   branches/SAMBA_4_0/source/librpc/ndr/libndr.h
   branches/SAMBA_4_0/source/librpc/ndr/ndr.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/idl/idl_types.h
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/idl_types.h	2004-09-03 09:17:32 UTC (rev 2203)
+++ branches/SAMBA_4_0/source/librpc/idl/idl_types.h	2004-09-03 12:10:34 UTC (rev 2204)
@@ -80,5 +80,7 @@
 */
 #define NDR_PAHEX LIBNDR_PRINT_ARRAY_HEX
 
+/* this enables spoolss style relative ptrs */
+#define RELATIVE_CURRENT LIBNDR_FLAG_RELATIVE_CURRENT
 
 #define bool8 uint8

Modified: branches/SAMBA_4_0/source/librpc/ndr/libndr.h
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/libndr.h	2004-09-03 09:17:32 UTC (rev 2203)
+++ branches/SAMBA_4_0/source/librpc/ndr/libndr.h	2004-09-03 12:10:34 UTC (rev 2204)
@@ -115,7 +115,11 @@
 /* used to check if alignment padding is zero */
 #define LIBNDR_FLAG_PAD_CHECK     (1<<18)
 
+/* used to indicate spoolss style relative pointers (relative to current
+   offset, not base) */
+#define LIBNDR_FLAG_RELATIVE_CURRENT  (1<<19)
 
+
 /* useful macro for debugging */
 #define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p)
 #define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_union_fn_t)ndr_print_ ##type, #p, level, p)

Modified: branches/SAMBA_4_0/source/librpc/ndr/ndr.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/ndr.c	2004-09-03 09:17:32 UTC (rev 2203)
+++ branches/SAMBA_4_0/source/librpc/ndr/ndr.c	2004-09-03 12:10:34 UTC (rev 2204)
@@ -639,11 +639,11 @@
 		return NT_STATUS_OK;
 	}
 	ndr_pull_save(ndr, &save);
-        /* the old way of handling relative pointers appears to be
-	   wrong, and there doesn't seem to be anything relying on it,
-	   but I am keeping the code around in case I missed a
-	   critical use for it (tridge, august 2004) */
-	NDR_CHECK(ndr_pull_set_offset(ndr, ofs));
+	if (ndr->flags & LIBNDR_FLAG_RELATIVE_CURRENT) {
+		NDR_CHECK(ndr_pull_set_offset(ndr, ofs + ndr->offset - 4));
+	} else {
+		NDR_CHECK(ndr_pull_set_offset(ndr, ofs));
+	}
 	NDR_CHECK(ndr_pull_subcontext(ndr, ndr2, ndr->data_size - ndr->offset));
 	/* strings must be allocated by the backend functions */
 	if (ndr->flags & LIBNDR_STRING_FLAGS) {
@@ -748,7 +748,11 @@
 	if (ndr->offset == 0) {
 		return NT_STATUS_INTERNAL_ERROR;
 	}
-	NDR_CHECK(ndr_push_uint32(ndr, save.offset));
+	if (ndr->flags & LIBNDR_FLAG_RELATIVE_CURRENT) {
+		NDR_CHECK(ndr_push_uint32(ndr, save.offset - ndr->offset));
+	} else {
+		NDR_CHECK(ndr_push_uint32(ndr, save.offset));
+	}
 	ndr_push_restore(ndr, &save);
 	return NT_STATUS_OK;
 }



More information about the samba-cvs mailing list