Prettify samba3 client code a little more.
authorgd <gd@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Wed, 9 Jan 2008 10:56:07 +0000 (10:56 +0000)
committergd <gd@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Wed, 9 Jan 2008 10:56:07 +0000 (10:56 +0000)
Guenther

git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_4_0@26698 0c0555d6-39d7-0310-84fc-f1cc0bd64818

source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm

index 01b77c0c9fd6c0e15b545d858ab7950190fa78f0..b7372a802aaa81b0833f096ce038c77847e770c6 100644 (file)
@@ -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)) {");