From 348fa3f9f663fc83ee8d9442366a3b36a82a2724 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 6 Mar 2005 12:33:44 +0000 Subject: r5669: Couple of minor clearifications, simplifications. (This used to be commit 09a9222b600d58271f42ee0870e0c933d2e105d0) --- source4/build/pidl/README | 6 ++-- source4/build/pidl/client.pm | 70 ---------------------------------------- source4/build/pidl/ndr_client.pm | 70 ++++++++++++++++++++++++++++++++++++++++ source4/build/pidl/ndr_header.pm | 11 +++---- source4/build/pidl/pidl.pl | 8 ++--- 5 files changed, 81 insertions(+), 84 deletions(-) delete mode 100644 source4/build/pidl/client.pm create mode 100644 source4/build/pidl/ndr_client.pm (limited to 'source4') diff --git a/source4/build/pidl/README b/source4/build/pidl/README index 4b675ce210..e087888840 100644 --- a/source4/build/pidl/README +++ b/source4/build/pidl/README @@ -18,12 +18,12 @@ dump.pm - Converts the parse tree back to an IDL file validator.pm - Validates the parse tree -- DCE/RPC+NDR -- -client.pm - Generates client call functions in C +ndr_client.pm - Generates client call functions in C using the NDR parser eparser.pm - Generates a parser for the ethereal network sniffer by applying regexes to the output of parser.pm swig.pm - Generates SWIG interface files (.i) -header.pm - Generates a header file with structures -parser.pm - Generates pull/push functions for parsing +ndr_header.pm - Generates a header file with structures +ndr.pm - Generates pull/push functions for parsing NDR server.pm - Generates server side implementation in C template.pm - Generates stubs in C for server implementation diff --git a/source4/build/pidl/client.pm b/source4/build/pidl/client.pm deleted file mode 100644 index 1be895208f..0000000000 --- a/source4/build/pidl/client.pm +++ /dev/null @@ -1,70 +0,0 @@ -################################################### -# client calls generator -# Copyright tridge@samba.org 2003 -# released under the GNU GPL - -package IdlClient; - -use strict; - -my($res); - -##################################################################### -# parse a function -sub ParseFunction($$) -{ - my $interface = shift; - my $fn = shift; - my $name = $fn->{NAME}; - my $uname = uc $name; - - $res .= " -struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r) -{ - if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) { - NDR_PRINT_IN_DEBUG($name, r); - } - - return dcerpc_ndr_request_send(p, NULL, &dcerpc_table_$interface->{NAME}, DCERPC_$uname, mem_ctx, r); -} - -NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r) -{ - struct rpc_request *req; - NTSTATUS status; - - req = dcerpc_$name\_send(p, mem_ctx, r); - if (req == NULL) return NT_STATUS_NO_MEMORY; - - status = dcerpc_ndr_request_recv(req); - - if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { - NDR_PRINT_OUT_DEBUG($name, r); - } -"; - if ($fn->{RETURN_TYPE} eq "NTSTATUS") { - $res .= "\tif (NT_STATUS_IS_OK(status)) status = r->out.result;\n"; - } - $res .= -" - return status; -} -"; -} - - -##################################################################### -# parse the interface definitions -sub ParseInterface($) -{ - my($interface) = shift; - my($data) = $interface->{DATA}; - $res = "/* Client functions generated by pidl */\n\n"; - foreach my $d (@{$data}) { - ($d->{TYPE} eq "FUNCTION") && - ParseFunction($interface, $d); - } - return $res; -} - -1; diff --git a/source4/build/pidl/ndr_client.pm b/source4/build/pidl/ndr_client.pm new file mode 100644 index 0000000000..e5d4cc1569 --- /dev/null +++ b/source4/build/pidl/ndr_client.pm @@ -0,0 +1,70 @@ +################################################### +# client calls generator +# Copyright tridge@samba.org 2003 +# released under the GNU GPL + +package NdrClient; + +use strict; + +my($res); + +##################################################################### +# parse a function +sub ParseFunction($$) +{ + my $interface = shift; + my $fn = shift; + my $name = $fn->{NAME}; + my $uname = uc $name; + + $res .= " +struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r) +{ + if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) { + NDR_PRINT_IN_DEBUG($name, r); + } + + return dcerpc_ndr_request_send(p, NULL, &dcerpc_table_$interface->{NAME}, DCERPC_$uname, mem_ctx, r); +} + +NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r) +{ + struct rpc_request *req; + NTSTATUS status; + + req = dcerpc_$name\_send(p, mem_ctx, r); + if (req == NULL) return NT_STATUS_NO_MEMORY; + + status = dcerpc_ndr_request_recv(req); + + if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { + NDR_PRINT_OUT_DEBUG($name, r); + } +"; + if ($fn->{RETURN_TYPE} eq "NTSTATUS") { + $res .= "\tif (NT_STATUS_IS_OK(status)) status = r->out.result;\n"; + } + $res .= +" + return status; +} +"; +} + + +##################################################################### +# parse the interface definitions +sub ParseInterface($) +{ + my($interface) = shift; + my($data) = $interface->{DATA}; + $res = "/* Client functions generated by pidl */\n\n"; + foreach my $d (@{$data}) { + ($d->{TYPE} eq "FUNCTION") && + ParseFunction($interface, $d); + } + return $res; +} + +1; diff --git a/source4/build/pidl/ndr_header.pm b/source4/build/pidl/ndr_header.pm index c928ee1db3..3e673466e0 100644 --- a/source4/build/pidl/ndr_header.pm +++ b/source4/build/pidl/ndr_header.pm @@ -61,15 +61,12 @@ sub HeaderElement($) HeaderType($element, $element->{TYPE}, ""); pidl " "; if ($element->{POINTERS} && $element->{TYPE} ne "string") { - my($n) = $element->{POINTERS}; - for (my($i)=$n; $i > 0; $i--) { + for (my($i)=$element->{POINTERS}; $i > 0; $i--) { pidl "*"; } - } - if (defined $element->{ARRAY_LEN} && - !util::is_constant($element->{ARRAY_LEN}) && - !$element->{POINTERS}) { - # conformant arrays are ugly! I choose to implement them with + } elsif (NdrParser::is_surrounding_array($element) || + defined $element->{ARRAY_LEN} && !util::is_constant($element->{ARRAY_LEN})) { + # surrounding arrays are ugly! I choose to implement them with # pointers instead of the [1] method pidl "*"; } diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl index f7b213dcb0..6bbb2ec78c 100755 --- a/source4/build/pidl/pidl.pl +++ b/source4/build/pidl/pidl.pl @@ -15,10 +15,10 @@ use Getopt::Long; use File::Basename; use idl; use dump; +use ndr_client; use ndr_header; use ndr; use server; -use client; use dcom_proxy; use dcom_stub; use com_header; @@ -75,9 +75,9 @@ sub ShowHelp() --output OUTNAME put output in OUTNAME.* --parse parse a idl file to a .pidl file --dump dump a pidl file back to idl - --header create a C header file + --header create a C NDR header file --parser create a C NDR parser - --client create a C client + --client create a C NDR client --server create server boilerplate --template print a template for a pipe --eparser create an ethereal parser @@ -213,7 +213,7 @@ sub process_file($) $res .= "#include \"$h_filename\"\n\n"; foreach my $x (@{$pidl}) { - $res .= IdlClient::ParseInterface($x); + $res .= NdrClient::ParseInterface($x); } util::FileSave($client, $res); -- cgit