diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-12-24 22:11:44 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:47:42 -0500 |
commit | ebfbb2a7abe33e47af48d69164c37f4c24b7f8ed (patch) | |
tree | 259c6b4bd5c79ed9112a07cc7e671775813c8f59 /source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm | |
parent | e791dd73b98308b949f4ecfb91b5c87183b5de76 (diff) | |
download | samba-ebfbb2a7abe33e47af48d69164c37f4c24b7f8ed.tar.gz samba-ebfbb2a7abe33e47af48d69164c37f4c24b7f8ed.tar.bz2 samba-ebfbb2a7abe33e47af48d69164c37f4c24b7f8ed.zip |
r12463: Rename 'Samba' namespace to 'Samba4'
(This used to be commit f25358270d44a5642adbb85ecaa50b2e5730d7f0)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm new file mode 100644 index 0000000000..83f9034c7c --- /dev/null +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm @@ -0,0 +1,102 @@ +################################################### +# client calls generator +# Copyright tridge@samba.org 2003 +# released under the GNU GPL + +package Parse::Pidl::Samba4::NDR::Client; + +use vars qw($VERSION); +$VERSION = '0.01'; + +use strict; + +my($res); + +##################################################################### +# parse a function +sub ParseFunction($$) +{ + my ($interface, $fn) = @_; + 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 (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "NTSTATUS") { + $res .= "\tif (NT_STATUS_IS_OK(status)) status = r->out.result;\n"; + } + $res .= +" + return status; +} +"; +} + +my %done; + +##################################################################### +# parse the interface definitions +sub ParseInterface($) +{ + my($interface) = shift; + $res .= "/* $interface->{NAME} - client functions generated by pidl */\n\n"; + + foreach my $fn (@{$interface->{FUNCTIONS}}) { + next if not defined($fn->{OPNUM}); + next if defined($done{$fn->{NAME}}); + ParseFunction($interface, $fn); + $done{$fn->{NAME}} = 1; + } + + return $res; +} + +sub Parse($$) +{ + my($ndr) = shift; + my($filename) = shift; + + my $h_filename = $filename; + $res = ""; + + if ($h_filename =~ /(.*)\.c/) { + $h_filename = "$1.h"; + } + + $res .= "/* client functions auto-generated by pidl */\n"; + $res .= "\n"; + $res .= "#include \"includes.h\"\n"; + $res .= "#include \"$h_filename\"\n"; + $res .= "\n"; + + foreach my $x (@{$ndr}) { + ($x->{TYPE} eq "INTERFACE") && ParseInterface($x); + } + + return $res; +} + +1; |