summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-03-15 14:33:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:11:04 -0500
commita81a2c22a2a3684bcf3df441e9186ae414639db3 (patch)
tree29586ed169351b260ceb311374f3b96805781cee /source4/build/pidl
parentebc34d215780e33eb1b1fa377c5f76f425df35f1 (diff)
downloadsamba-a81a2c22a2a3684bcf3df441e9186ae414639db3.tar.gz
samba-a81a2c22a2a3684bcf3df441e9186ae414639db3.tar.bz2
samba-a81a2c22a2a3684bcf3df441e9186ae414639db3.zip
r5797: - add idl property [subcontext_size()]
this can be used like this [subcontext_size(28),subcontext(0)] dom_sid sid; this descripes a fixed 28 byte buffer which contains a dom_sid, and the rest of the buffer is padded with zero bytes if the dom_sid doesn't need all 28 byte in it's ndr encoding. - only push and pull the subcontext when we are in the NDR_SCALARS section (tridge, jelmer: I hope this is correct for all cases...!?:-) metze (This used to be commit 483bb1418fd5c70c418142ade80c1e286adfa05a)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/ndr.pm48
-rw-r--r--source4/build/pidl/validator.pm4
2 files changed, 35 insertions, 17 deletions
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index 0d021f8daa..fde9f05d2f 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -600,12 +600,12 @@ sub ParseArrayPull($$$$)
}
}
-sub ParseSubcontextPushStart($)
+sub ParseSubcontextPushStart($$)
{
my $e = shift;
- my $sub_size = util::has_property($e, "subcontext");
+ my $ndr_flags = shift;
- pidl "{";
+ pidl "if (($ndr_flags) & NDR_SCALARS) {";
indent;
pidl "struct ndr_push *_ndr_$e->{NAME};";
pidl "";
@@ -620,34 +620,48 @@ sub ParseSubcontextPushStart($)
sub ParseSubcontextPushEnd($)
{
my $e = shift;
- my $sub_size = util::has_property($e, "subcontext");
- pidl "NDR_CHECK(ndr_push_subcontext_header(ndr, $sub_size, _ndr_$e->{NAME}));";
+ my $header_size = util::has_property($e, "subcontext");
+ my $size_is = util::has_property($e, "subcontext_size");
+
+ if (not defined($size_is)) {
+ $size_is = "-1";
+ }
+
+ pidl "NDR_CHECK(ndr_push_subcontext_header(ndr, $header_size, $size_is, _ndr_$e->{NAME}));";
pidl "NDR_CHECK(ndr_push_bytes(ndr, _ndr_$e->{NAME}->data, _ndr_$e->{NAME}->offset));";
deindent;
pidl "}";
}
-sub ParseSubcontextPullStart($)
+sub ParseSubcontextPullStart($$)
{
my $e = shift;
- my $sub_size = util::has_property($e, "subcontext");
+ my $ndr_flags = shift;
+ my $header_size = util::has_property($e, "subcontext");
+ my $size_is = util::has_property($e, "subcontext_size");
- pidl "{";
+ if (not defined($size_is)) {
+ $size_is = "-1";
+ }
+
+ pidl "if (($ndr_flags) & NDR_SCALARS) {";
indent;
pidl "struct ndr_pull *_ndr_$e->{NAME};";
pidl "NDR_ALLOC(ndr, _ndr_$e->{NAME});";
- pidl "NDR_CHECK(ndr_pull_subcontext_header(ndr, $sub_size, _ndr_$e->{NAME}));";
-
+ pidl "NDR_CHECK(ndr_pull_subcontext_header(ndr, $header_size, $size_is, _ndr_$e->{NAME}));";
return "_ndr_$e->{NAME}";
}
sub ParseSubcontextPullEnd($)
{
my $e = shift;
- my $sub_size = util::has_property($e, "subcontext");
+ my $header_size = util::has_property($e, "subcontext");
+ my $size_is = util::has_property($e, "subcontext_size");
my $advance;
- if ($sub_size) {
+ if (defined ($size_is)) {
+ $advance = "$size_is";
+ } elsif ($header_size) {
$advance = "_ndr_$e->{NAME}->data_size";
} else {
$advance = "_ndr_$e->{NAME}->offset";
@@ -676,7 +690,7 @@ sub ParseElementPushScalar($$$)
}
if (defined $sub_size and $e->{POINTERS} == 0) {
- $ndr = ParseSubcontextPushStart($e);
+ $ndr = ParseSubcontextPushStart($e, "NDR_SCALARS");
}
if (need_wire_pointer($e)) {
@@ -819,7 +833,7 @@ sub ParseElementPullScalar($$$)
start_flags($e);
if (defined $sub_size && $e->{POINTERS} == 0) {
- $ndr = ParseSubcontextPullStart($e);
+ $ndr = ParseSubcontextPullStart($e, $ndr_flags);
$ndr_flags = "NDR_SCALARS|NDR_BUFFERS";
}
@@ -909,10 +923,10 @@ sub ParseElementPushBuffer($$)
}
if (defined $sub_size) {
- $ndr = ParseSubcontextPushStart($e);
+ $ndr = ParseSubcontextPushStart($e, $ndr_flags);
$ndr_flags = "NDR_SCALARS|NDR_BUFFERS";
}
-
+
if (util::array_size($e)) {
ParseArrayPush($e, $ndr, "r->", $ndr_flags);
} else {
@@ -972,7 +986,7 @@ sub ParseElementPullBuffer($$)
}
if (defined $sub_size) {
- $ndr = ParseSubcontextPullStart($e);
+ $ndr = ParseSubcontextPullStart($e, $ndr_flags);
$ndr_flags = "NDR_SCALARS|NDR_BUFFERS";
}
diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm
index e8a42c6031..5e1f1e1660 100644
--- a/source4/build/pidl/validator.pm
+++ b/source4/build/pidl/validator.pm
@@ -72,6 +72,10 @@ sub ValidElement($)
fatal(el_name($e) . " : length_is() on non-array element");
}
+ if (defined (util::has_property($e, "subcontext_size")) and not defined(util::has_property($e, "subcontext"))) {
+ fatal(el_name($e) . " : subcontext_size() on non-subcontext element");
+ }
+
if (!$e->{POINTERS} && (
util::has_property($e, "ptr") or
util::has_property($e, "unique") or