From c2cdb4ad5c9398ef0d3310613107999f8d33c7ce Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 25 Feb 2009 17:43:07 +1100 Subject: Work around ndr_unpack failing on structures with relative pointers. This disgusting hack works around the fact that ndr_pull_struct_blob_all will always fail on structures with relative pointers. So, map ndr_unpack to ndr_pull_struct_blob_all only if we don't have any relative pointers in this structure. Andrew Bartlett --- pidl/lib/Parse/Pidl/Samba4/Python.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'pidl/lib') diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 48785f5b0a..6099fe5cae 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -275,7 +275,24 @@ sub PythonStruct($$$$$$) $self->pidl("if (!PyArg_ParseTuple(args, \"s#:__ndr_unpack__\", &blob.data, &blob.length))"); $self->pidl("\treturn NULL;"); $self->pidl(""); - $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);"); + + # This disgusting hack works around the fact that ndr_pull_struct_blob_all will always fail on structures with relative pointers. + # So, map ndr_unpack to ndr_pull_struct_blob_all only if we don't have any relative pointers in this + my $got_relative = 0; + if ($#{$d->{ELEMENTS}} > -1) { + foreach my $e (@{$d->{ELEMENTS}}) { + my $l = $e->{LEVELS}[0]; + if ($l->{TYPE} eq "POINTER" and ($l->{POINTER_TYPE} eq "relative")) { + $got_relative = 1; + last; + } + } + } + if ($got_relative == 0) { + $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);"); + } else { + $self->pidl("err = ndr_pull_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);"); + } $self->pidl("if (err != NDR_ERR_SUCCESS) {"); $self->indent; $self->pidl("PyErr_SetNdrError(err);"); -- cgit From fc3ffedcfe173900d65f6fa7db3a3cf2608f9f68 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 25 Feb 2009 15:05:43 +0100 Subject: Don't define _GNU_SOURCE if it's already defined on the command-line. --- pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pidl/lib') diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index af6885f67a..0e4a7e2289 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -2548,7 +2548,9 @@ sub GenerateIncludes($) if (is_intree()) { $self->pidl("#include \"includes.h\""); } else { + $self->pidl("#ifndef _GNU_SOURCE"); $self->pidl("#define _GNU_SOURCE"); + $self->pidl("#endif"); $self->pidl("#include "); $self->pidl("#include "); $self->pidl("#include "); -- cgit From f71db89256b65c3700eadaf44b2727623eb831fa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 25 Feb 2009 15:21:36 +0100 Subject: Include header with NTSTATUS, as some IDL files use it. --- pidl/lib/Parse/Pidl/Samba4/Header.pm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pidl/lib') diff --git a/pidl/lib/Parse/Pidl/Samba4/Header.pm b/pidl/lib/Parse/Pidl/Samba4/Header.pm index 0411466c82..5315957946 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -407,6 +407,9 @@ sub Parse($) } pidl "#include \n"; pidl "\n"; + # FIXME: Include this only if NTSTATUS was actually used + pidl choose_header("libcli/util/ntstatus.h", "core/ntstatus.h") . "\n"; + pidl "\n"; foreach (@{$ndr}) { ($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_); -- cgit From d7c7b31bbaf110446ea835b66845ab6f0ee09231 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 25 Feb 2009 16:54:35 +0100 Subject: Only define _GNU_SOURCE if it's not defined yet. --- pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pidl/lib') diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm index f8209be654..f2a96a3037 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm @@ -131,7 +131,9 @@ sub Parse($$$$) if (is_intree()) { $res .= "#include \"includes.h\"\n"; } else { + $res .= "#ifndef _GNU_SOURCE\n"; $res .= "#define _GNU_SOURCE\n"; + $res .= "#endif\n"; $res .= "#include \n"; $res .= "#include \n"; $res .= "#include \n"; -- cgit