diff options
author | Günther Deschner <gd@samba.org> | 2008-01-09 10:56:07 -0600 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-01-09 05:03:01 -0600 |
commit | e6968df1e57e1c09bee21019fc1eec15e7a06005 (patch) | |
tree | 1d7bc8a4249a4d83b99f3ea456a4f05e60665d81 /source4/pidl/lib | |
parent | 4d58fc88cbba394faa83b493ec79344935a497f8 (diff) | |
download | samba-e6968df1e57e1c09bee21019fc1eec15e7a06005.tar.gz samba-e6968df1e57e1c09bee21019fc1eec15e7a06005.tar.bz2 samba-e6968df1e57e1c09bee21019fc1eec15e7a06005.zip |
r26698: Prettify samba3 client code a little more.
Guenther
(This used to be commit 6ac36d6a4b83b9ef794a2022c4d46ed0b69758e9)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm index 01b77c0c9f..b7372a802a 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm @@ -2,6 +2,7 @@ # Samba3 client generator for IDL structures # on top of Samba4 style NDR functions # Copyright jelmer@samba.org 2005-2006 +# Copyright gd@samba.org 2008 # released under the GNU GPL package Parse::Pidl::Samba3::ClientNDR; @@ -27,6 +28,15 @@ sub pidl($$) { my ($self,$txt) = @_; $self->{res} .= $txt ? "$self->{tabs}$txt\n sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; } sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); } +sub genpad($) +{ + my ($s) = @_; + my $nt = int((length($s)+1)/8); + my $lt = ($nt*8)-1; + my $ns = (length($s)-$lt); + return "\t"x($nt)." "x($ns); +} + sub new($) { my ($class) = shift; @@ -38,20 +48,23 @@ sub ParseFunction($$$) { my ($self, $if, $fn) = @_; - my $inargs = ""; - my $defargs = ""; + my $fn_args = ""; my $uif = uc($if); my $ufn = "NDR_".uc($fn->{NAME}); + my $fn_str = "NTSTATUS rpccli_$fn->{NAME}"; + my $pad = genpad($fn_str); + + $fn_args .= "struct rpc_pipe_client *cli,\n" . $pad . "TALLOC_CTX *mem_ctx"; foreach (@{$fn->{ELEMENTS}}) { - $defargs .= ", " . DeclLong($_); + $fn_args .= ",\n" . $pad . DeclLong($_); } if (defined($fn->{RETURN_TYPE}) && ($fn->{RETURN_TYPE} eq "WERROR")) { - $defargs .= ", WERROR *werror"; + $fn_args .= ",\n" . $pad . "WERROR *werror"; } - $self->fn_declare("NTSTATUS rpccli_$fn->{NAME}(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx$defargs)"); + $self->fn_declare("$fn_str($fn_args)"); $self->pidl("{"); $self->indent; $self->pidl("struct $fn->{NAME} r;"); @@ -62,7 +75,7 @@ sub ParseFunction($$$) foreach (@{$fn->{ELEMENTS}}) { if (grep(/in/, @{$_->{DIRECTION}})) { $self->pidl("r.in.$_->{NAME} = $_->{NAME};"); - } + } } $self->pidl(""); @@ -72,7 +85,12 @@ sub ParseFunction($$$) $self->deindent; $self->pidl("}"); $self->pidl(""); - $self->pidl("status = cli_do_rpc_ndr(cli, mem_ctx, PI_$uif, &ndr_table_$if, $ufn, &r);"); + $self->pidl("status = cli_do_rpc_ndr(cli,"); + $self->pidl("\t\t\tmem_ctx,"); + $self->pidl("\t\t\tPI_$uif,"); + $self->pidl("\t\t\t&ndr_table_$if,"); + $self->pidl("\t\t\t$ufn,"); + $self->pidl("\t\t\t&r);"); $self->pidl(""); $self->pidl("if (!NT_STATUS_IS_OK(status)) {"); |