summaryrefslogtreecommitdiff
path: root/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
diff options
context:
space:
mode:
authorJörg Mayer <jmayer@loplof.de>2005-12-26 00:47:24 +0000
committerJörg Mayer <jmayer@loplof.de>2005-12-26 00:47:24 +0000
commit2eb39a1bdceb86496275eb08e6d4b2c231170e0b (patch)
tree25260b209000c9930b09dd312bc669b40145bde2 /tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
parent6ea1842885cd7965b7dba3864ac6a08c6ebcb1f7 (diff)
downloadwireshark-2eb39a1bdceb86496275eb08e6d4b2c231170e0b.tar.gz
Update from samba tree revision 12430 to 12487
============================ Samba log start ============ ------------------------------------------------------------------------ r12462 | jelmer | 2005-12-24 22:57:51 +0100 (Sat, 24 Dec 2005) | 2 lines Hide oo magic from callers of the parser ------------------------------------------------------------------------ r12463 | jelmer | 2005-12-24 23:11:44 +0100 (Sat, 24 Dec 2005) | 2 lines Rename 'Samba' namespace to 'Samba4' ------------------------------------------------------------------------ r12464 | jelmer | 2005-12-25 00:32:50 +0100 (Sun, 25 Dec 2005) | 4 lines Add simple IDL parsing tests for pidl using the standard perl testing framework (Test::Simple, distributed with perl itself). Run these tests from 'make test' ------------------------------------------------------------------------ r12465 | jelmer | 2005-12-25 02:33:35 +0100 (Sun, 25 Dec 2005) | 3 lines Merge Parse::Pidl::Samba4::NDR::Header into Parse::Pidl::Samba4::NDR::Parser. Small optimization to avoid including NDR headers multiple times ------------------------------------------------------------------------ r12470 | jelmer | 2005-12-25 04:04:13 +0100 (Sun, 25 Dec 2005) | 3 lines Add helper module for pidl tests Convert other pidl tests to use Test::More and run them from 'make test' ------------------------------------------------------------------------ r12480 | jelmer | 2005-12-25 15:11:59 +0100 (Sun, 25 Dec 2005) | 2 lines Extend testsuite ------------------------------------------------------------------------ r12481 | jelmer | 2005-12-25 15:59:21 +0100 (Sun, 25 Dec 2005) | 4 lines Move parser-specific utility functions to idl.yp, remove some unused functions Allow the use of non-typedef structs and unions when declaring variables. Allow the use of the 'signed' and 'unsigned' qualifiers for integer types ------------------------------------------------------------------------ r12482 | jelmer | 2005-12-25 15:59:39 +0100 (Sun, 25 Dec 2005) | 2 lines Add some more tests ------------------------------------------------------------------------ r12483 | jelmer | 2005-12-25 16:19:55 +0100 (Sun, 25 Dec 2005) | 2 lines Remove --tdr-header option (merged into --tdr-parser) ------------------------------------------------------------------------ r12484 | jelmer | 2005-12-25 18:12:52 +0100 (Sun, 25 Dec 2005) | 2 lines Initial work on supporting non-typedeffed types ------------------------------------------------------------------------ ============================ Samba log end ============== svn path=/trunk/; revision=16896
Diffstat (limited to 'tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm')
-rw-r--r--tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm102
1 files changed, 102 insertions, 0 deletions
diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
new file mode 100644
index 0000000000..83f9034c7c
--- /dev/null
+++ b/tools/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;