summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-11-18 20:53:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:58 -0500
commita0fa682faa309bda812008ea3a084cf54f65310b (patch)
tree5841de49e8c7c212a9ac97cd82c06e7b4d9591c3 /source4/build/pidl
parentbe01250d1a5ef9611164e5ca741e07255f770b4d (diff)
downloadsamba-a0fa682faa309bda812008ea3a084cf54f65310b.tar.gz
samba-a0fa682faa309bda812008ea3a084cf54f65310b.tar.bz2
samba-a0fa682faa309bda812008ea3a084cf54f65310b.zip
r3861: - Put ndr and rpc client code in seperate files
- Add some const (This used to be commit a00bda88e1b6abdc36e5aa8c2a35f64855f67c96)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/client.pm12
-rw-r--r--source4/build/pidl/header.pm2
-rw-r--r--source4/build/pidl/parser.pm19
-rwxr-xr-xsource4/build/pidl/pidl.pl29
-rw-r--r--source4/build/pidl/proxy.pm36
5 files changed, 68 insertions, 30 deletions
diff --git a/source4/build/pidl/client.pm b/source4/build/pidl/client.pm
index 015ac05223..43808ce3fb 100644
--- a/source4/build/pidl/client.pm
+++ b/source4/build/pidl/client.pm
@@ -21,15 +21,11 @@ sub ParseFunction($$)
$res .= "
struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
{
-
- if (p->flags & DCERPC_DEBUG_PRINT_IN) {
- NDR_PRINT_IN_DEBUG($name, r);
+ if (p->flags & DCERPC_DEBUG_PRINT_IN) {
+ NDR_PRINT_IN_DEBUG($name, r);
}
-
- return dcerpc_ndr_request_send(p, NULL, DCERPC_$uname, mem_ctx,
- (ndr_push_flags_fn_t) ndr_push_$name,
- (ndr_pull_flags_fn_t) ndr_pull_$name,
- r, sizeof(*r));
+
+ return dcerpc_ndr_request_table_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)
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index 188fdd4f72..5dda18d1b5 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -195,7 +195,7 @@ sub HeaderTypedefProto($)
}
if (needed::is_needed("ndr_size_$d->{NAME}")) {
- $res .= "size_t ndr_size_$d->{NAME}(int , struct $d->{NAME} *, int );\n";
+ $res .= "size_t ndr_size_$d->{NAME}(int , const struct $d->{NAME} *, int );\n";
}
}
if ($d->{DATA}{TYPE} eq "UNION") {
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index 5be538b2cf..cec983724d 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -8,8 +8,6 @@
package IdlParser;
use strict;
-use client;
-use proxy;
use needed;
# the list of needed functions
@@ -853,7 +851,7 @@ sub ParseStructNdrSize($)
my $static = fn_prefix($t);
my $sizevar;
- pidl $static . "size_t ndr_size_$t->{NAME}(int ret, struct $t->{NAME} *r, int flags)\n";
+ pidl $static . "size_t ndr_size_$t->{NAME}(int ret, const struct $t->{NAME} *r, int flags)\n";
pidl "{\n";
if (util::has_property($t->{DATA}, "flag")) {
@@ -1062,7 +1060,7 @@ sub ParseUnionNdrSize($)
my $t = shift;
my $static = fn_prefix($t);
- pidl $static . "size_t ndr_size_$t->{NAME}(int ret, union $t->{NAME} *data, uint16 level, int flags)\n";
+ pidl $static . "size_t ndr_size_$t->{NAME}(int ret, const union $t->{NAME} *data, uint16 level, int flags)\n";
pidl "{\n";
if (util::has_property($t->{DATA}, "flag")) {
pidl "\tflags = flags | " . $t->{DATA}->{PROPERTIES}->{flag} . ";\n";
@@ -1599,13 +1597,6 @@ sub RegistrationFunction($$)
pidl "\tif (NT_STATUS_IS_ERR(status)) {\n";
pidl "\t\treturn status;\n";
pidl "\t}\n\n";
-
- if (util::has_property($interface, "object")) {
- pidl "\tstatus = dcom_$interface->{NAME}_init();\n";
- pidl "\tif (NT_STATUS_IS_ERR(status)) {\n";
- pidl "\t\treturn status;\n";
- pidl "\t}\n\n";
- }
}
pidl "\treturn status;\n";
pidl "}\n\n";
@@ -1633,12 +1624,6 @@ sub Parse($$)
if ($x->{TYPE} eq "INTERFACE") {
needed::BuildNeeded($x);
ParseInterface($x);
-
- if (util::has_property($x, "object")) {
- pidl IdlProxy::ParseInterface($x);
- } else {
- pidl IdlClient::ParseInterface($x);
- }
}
}
diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl
index bb7f1f8ed6..8388bcfd4c 100755
--- a/source4/build/pidl/pidl.pl
+++ b/source4/build/pidl/pidl.pl
@@ -17,6 +17,8 @@ use idl;
use dump;
use header;
use server;
+use client;
+use proxy;
use stub;
use parser;
use eparser;
@@ -31,6 +33,7 @@ my($opt_dump) = 0;
my($opt_diff) = 0;
my($opt_header) = 0;
my($opt_template) = 0;
+my($opt_client) = 0;
my($opt_server) = 0;
my($opt_parser) = 0;
my($opt_eparser) = 0;
@@ -68,6 +71,7 @@ sub ShowHelp()
--dump dump a pidl file back to idl
--header create a C header file
--parser create a C parser
+ --client create a C client
--server create server boilerplate
--template print a template for a pipe
--eparser create an ethereal parser
@@ -88,6 +92,7 @@ GetOptions (
'server' => \$opt_server,
'template' => \$opt_template,
'parser' => \$opt_parser,
+ 'client' => \$opt_client,
'eparser' => \$opt_eparser,
'diff' => \$opt_diff,
'keep' => \$opt_keep,
@@ -138,6 +143,30 @@ sub process_file($)
util::FileSave($header, IdlHeader::Parse($pidl));
}
+ if ($opt_client) {
+ my ($client) = util::ChangeExtension($output, "_c.c");
+ my $res = "";
+ my $h_filename = util::ChangeExtension($output, ".h");
+ my $need_dcom_register = 0;
+
+ $res .= "#include \"includes.h\"\n";
+ $res .= "#include \"$h_filename\"\n\n";
+
+ foreach my $x (@{$pidl}) {
+ if (util::has_property($x, "object")) {
+ $res .= IdlProxy::ParseInterface($x);
+ $need_dcom_register = 1;
+ } else {
+ $res .= IdlClient::ParseInterface($x);
+ }
+ }
+
+ if ($need_dcom_register) {
+ $res .= IdlProxy::RegistrationFunction($pidl, $basename);
+ }
+ util::FileSave($client, $res);
+ }
+
if ($opt_server) {
my($server) = util::ChangeExtension($output, "_s.c");
my $res = "";
diff --git a/source4/build/pidl/proxy.pm b/source4/build/pidl/proxy.pm
index f8991ce9fe..bf3990da47 100644
--- a/source4/build/pidl/proxy.pm
+++ b/source4/build/pidl/proxy.pm
@@ -105,10 +105,7 @@ static struct rpc_request *dcom_proxy_$interface->{NAME}_$name\_send(struct dcom
NDR_PRINT_IN_DEBUG($name, r);
}
- return dcerpc_ndr_request_send(p, &d->ipid, DCERPC_$uname, mem_ctx,
- (ndr_push_flags_fn_t) ndr_push_$name,
- (ndr_pull_flags_fn_t) ndr_pull_$name,
- r, sizeof(*r));
+ return dcerpc_ndr_request_table_send(p, &d->ipid, &dcerpc_table_$interface->{NAME}, DCERPC_$uname, mem_ctx, r);
}
static NTSTATUS dcom_proxy_$interface->{NAME}_$name(struct dcom_interface_p *d, TALLOC_CTX *mem_ctx, struct $name *r)
@@ -163,4 +160,35 @@ sub ParseInterface($)
ParseRegFunc($interface);
}
+sub RegistrationFunction($$)
+{
+ my $idl = shift;
+ my $basename = shift;
+
+ my $res = "NTSTATUS dcom_$basename\_init(void)\n";
+ $res .= "{\n";
+ $res .="\tNTSTATUS status = NT_STATUS_OK;\n";
+ foreach my $interface (@{$idl}) {
+ next if $interface->{TYPE} ne "INTERFACE";
+ next if not util::has_property($interface, "object");
+
+ my $data = $interface->{INHERITED_DATA};
+ my $count = 0;
+ foreach my $d (@{$data}) {
+ if ($d->{TYPE} eq "FUNCTION") { $count++; }
+ }
+
+ next if ($count == 0);
+
+ $res .= "\tstatus = dcom_$interface->{NAME}_init();\n";
+ $res .= "\tif (NT_STATUS_IS_ERR(status)) {\n";
+ $res .= "\t\treturn status;\n";
+ $res .= "\t}\n\n";
+ }
+ $res .= "\treturn status;\n";
+ $res .= "}\n\n";
+
+ return $res;
+}
+
1;