svn commit: samba r19859 - in branches/SAMBA_4_0/source: librpc/ndr
pidl/tests
jelmer at samba.org
jelmer at samba.org
Thu Nov 23 16:02:21 GMT 2006
Author: jelmer
Date: 2006-11-23 16:02:20 +0000 (Thu, 23 Nov 2006)
New Revision: 19859
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19859
Log:
Reuse referrent ids when pushing full pointers (still need to
avoid pushing the referred object twice) and add test for full pointers.
Added:
branches/SAMBA_4_0/source/pidl/tests/ndr_fullptr.pl
Modified:
branches/SAMBA_4_0/source/librpc/ndr/libndr.h
branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c
branches/SAMBA_4_0/source/pidl/tests/Util.pm
Changeset:
Modified: branches/SAMBA_4_0/source/librpc/ndr/libndr.h
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/libndr.h 2006-11-23 15:51:20 UTC (rev 19858)
+++ branches/SAMBA_4_0/source/librpc/ndr/libndr.h 2006-11-23 16:02:20 UTC (rev 19859)
@@ -88,6 +88,7 @@
struct ndr_token_list *switch_list;
struct ndr_token_list *relative_list;
struct ndr_token_list *nbt_string_list;
+ struct ndr_token_list *full_ptr_list;
/* this is used to ensure we generate unique reference IDs */
uint32_t ptr_count;
Modified: branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c 2006-11-23 15:51:20 UTC (rev 19858)
+++ branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c 2006-11-23 16:02:20 UTC (rev 19859)
@@ -485,8 +485,13 @@
{
uint32_t ptr = 0;
if (p) {
- ndr->ptr_count++;
- ptr = ndr->ptr_count;
+ /* Check if the pointer already exists and has an id */
+ ptr = ndr_token_peek(&ndr->full_ptr_list, p);
+ if (ptr == 0) {
+ ndr->ptr_count++;
+ ptr = ndr->ptr_count;
+ ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr);
+ }
}
return ndr_push_uint32(ndr, NDR_SCALARS, ptr);
}
Modified: branches/SAMBA_4_0/source/pidl/tests/Util.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/Util.pm 2006-11-23 15:51:20 UTC (rev 19858)
+++ branches/SAMBA_4_0/source/pidl/tests/Util.pm 2006-11-23 16:02:20 UTC (rev 19859)
@@ -35,7 +35,7 @@
SKIP: {
skip "no samba environment available, skipping compilation", 3
- if (system("pkg-config --exists dcerpc ndr") != 0);
+ if (system("pkg-config --exists ndr") != 0);
my $test_data_prefix = $ENV{TEST_DATA_PREFIX};
@@ -46,7 +46,7 @@
$outfile = "test-$name";
}
- my $cflags = `pkg-config --libs --cflags dcerpc ndr`;
+ my $cflags = `pkg-config --libs --cflags ndr`;
open CC, "|cc -x c - -o $outfile $cflags";
print CC "#define uint_t unsigned int\n";
Added: branches/SAMBA_4_0/source/pidl/tests/ndr_fullptr.pl
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/ndr_fullptr.pl 2006-11-23 15:51:20 UTC (rev 19858)
+++ branches/SAMBA_4_0/source/pidl/tests/ndr_fullptr.pl 2006-11-23 16:02:20 UTC (rev 19859)
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+# Simple tests for unique pointers
+# (C) 2006 Jelmer Vernooij <jelmer at samba.org>.
+# Published under the GNU General Public License.
+use strict;
+
+use Test::More tests => 1 * 8;
+use FindBin qw($RealBin);
+use lib "$RealBin/../lib";
+use lib "$RealBin";
+use Util qw(test_samba4_ndr);
+
+test_samba4_ndr("fullptr-push-dup",
+'
+ [public] uint16 echo_TestFull([in,ptr] uint32 *x, [in,ptr] uint32 *y);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ uint32_t v = 13;
+ struct echo_TestRef r;
+ r.in.x = &v;
+ r.in.y = &v;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) {
+ fprintf(stderr, "push failed\n");
+ return 1;
+ }
+
+ if (ndr->offset != 12) {
+ fprintf(stderr, "Offset(%d) != 12\n", ndr->offset);
+ return 2;
+ }
+
+ if (ndr->data[0] != ndr->data[8] ||
+ ndr->data[1] != ndr->data[9] ||
+ ndr->data[2] != ndr->data[10] ||
+ ndr->data[3] != ndr->data[11]) {
+ fprintf(stderr, "Data incorrect\n");
+ return 3;
+ }
+');
Property changes on: branches/SAMBA_4_0/source/pidl/tests/ndr_fullptr.pl
___________________________________________________________________
Name: svn:executable
+ *
More information about the samba-cvs
mailing list