diff options
author | Tim Potter <tpot@samba.org> | 2004-04-25 22:58:18 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:34 -0500 |
commit | 3dce6f1e23eb9b902c3b9b46214dc5ef2d6b8920 (patch) | |
tree | 036acd0d40bd94d95c288ccf06be3eb830b0b110 /source4/build/pidl/clientfns.pm | |
parent | f3d3b3c8091ad4540c330c07662540440affb96e (diff) | |
download | samba-3dce6f1e23eb9b902c3b9b46214dc5ef2d6b8920.tar.gz samba-3dce6f1e23eb9b902c3b9b46214dc5ef2d6b8920.tar.bz2 samba-3dce6f1e23eb9b902c3b9b46214dc5ef2d6b8920.zip |
r356: Start of auto-generated client functions. Tridge can you take a look
and tell me what you think? Output does not compile yet.
(This used to be commit 65692c9a9301329ad93628778e3d8f9188a67059)
Diffstat (limited to 'source4/build/pidl/clientfns.pm')
-rw-r--r-- | source4/build/pidl/clientfns.pm | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/source4/build/pidl/clientfns.pm b/source4/build/pidl/clientfns.pm new file mode 100644 index 0000000000..9f5f0ea883 --- /dev/null +++ b/source4/build/pidl/clientfns.pm @@ -0,0 +1,127 @@ +################################################### +# clientfs boilerplate generator +# Copyright tpot@samba.org 2004 +# released under the GNU GPL + +package IdlClientFns; + +use strict; + +my($res); + +sub pidl($) +{ + $res .= shift; +} + +use Data::Dumper; + +##################################################################### +# produce boilerplate code for a interface +sub Boilerplate_ClientFns($) +{ + my($interface) = shift; + my($data) = $interface->{DATA}; + my $name = $interface->{NAME}; + + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { + + pidl "/*\n"; + pidl Dumper($d); + pidl "\n*/\n\n"; + + pidl "$d->{RETURN_TYPE} $d->{NAME}(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx"; + + my $count = 0, my $i = 0; + + foreach my $a (@{$d->{DATA}}) { + $count++; + } + + pidl ", ", if $count > 0; + + foreach my $a (@{$d->{DATA}}) { + + pidl "/* ["; + if ($a->{PROPERTIES}->{in}) { + pidl "in"; + if ($a->{PROPERTIES}->{out} or + $a->{PROPERTIES}->{ref}) { + pidl ","; + } + } + if ($a->{PROPERTIES}->{out}) { + pidl "out"; + if ($a->{PROPERTIES}->{ref}) { + pidl ","; + } + } + if ($a->{PROPERTIES}->{ref}) { + pidl "ref"; + } + pidl "] */ "; + + pidl "struct ", if $a->{TYPE} eq "policy_handle"; + + pidl "$a->{TYPE} "; + if ($a->{PROPERTIES}->{out}) { + pidl "*"; + } + + if (!$a->{PROPERTIES}->{ref}) { + pidl "*", if $a->{POINTERS}; + } + + pidl "$a->{NAME}"; + + $i++; + + pidl ", ", if $i < $count; + } + pidl ")\n"; + pidl "{\n"; + + pidl "\tstruct $d->{NAME} r;\n"; + pidl "\tNTSTATUS status;\n"; + pidl "\n"; + + foreach $a (@{$d->{DATA}}) { + if ($a->{PROPERTIES}->{in}) { + pidl "\tr.in.$a->{NAME} = $a->{NAME};\n"; + } + if ($a->{PROPERTIES}->{out}) { + pidl "\tr.out.$a->{NAME} = $a->{NAME};\n"; + } + } + pidl "\n"; + + pidl "\tstatus = dcerpc_$d->{NAME}(p, mem_ctx, &r);\n"; + pidl "\n"; + + pidl "\treturn NT_STATUS_OK;\n"; + + pidl "}\n\n"; + } + } +} + +##################################################################### +# parse a parsed IDL structure back into an IDL file +sub Parse($) +{ + my($idl) = shift; + $res = "/* dcerpc client functions generated by pidl */\n\n"; + + $res .= "#include \"includes.h\"\n\n"; + + foreach my $x (@{$idl}) { + if ($x->{TYPE} eq "INTERFACE") { + Boilerplate_ClientFns($x); + } + } + + return $res; +} + +1; |