1 ###################################################
2 # client calls generator
3 # Copyright tridge@samba.org 2003
4 # Copyright jelmer@samba.org 2005-2006
5 # released under the GNU GPL
7 package Parse::Pidl::Samba4::NDR::Client;
9 use Parse::Pidl::Samba4 qw(choose_header is_intree);
11 use vars qw($VERSION);
18 #####################################################################
22 my ($interface, $fn) = @_;
23 my $name = $fn->{NAME};
26 $res_hdr .= "\nstruct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r);
27 NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r);
31 struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
33 if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) {
34 NDR_PRINT_IN_DEBUG($name, r);
37 return dcerpc_ndr_request_send(p, NULL, &ndr_table_$interface->{NAME}, NDR_$uname, mem_ctx, r);
40 NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
42 struct rpc_request *req;
45 req = dcerpc_$name\_send(p, mem_ctx, r);
46 if (req == NULL) return NT_STATUS_NO_MEMORY;
48 status = dcerpc_ndr_request_recv(req);
50 if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) {
51 NDR_PRINT_OUT_DEBUG($name, r);
55 if (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "NTSTATUS") {
56 $res .= "\tif (NT_STATUS_IS_OK(status)) status = r->out.result;\n";
67 #####################################################################
68 # parse the interface definitions
71 my($interface) = shift;
73 $res_hdr .= "#ifndef _HEADER_RPC_$interface->{NAME}\n";
74 $res_hdr .= "#define _HEADER_RPC_$interface->{NAME}\n\n";
76 if (defined $interface->{PROPERTIES}->{uuid}) {
77 $res_hdr .= "extern const struct ndr_interface_table ndr_table_$interface->{NAME};\n";
80 $res .= "/* $interface->{NAME} - client functions generated by pidl */\n\n";
82 foreach my $fn (@{$interface->{FUNCTIONS}}) {
83 next if not defined($fn->{OPNUM});
84 next if defined($done{$fn->{NAME}});
85 ParseFunction($interface, $fn);
86 $done{$fn->{NAME}} = 1;
89 $res_hdr .= "#endif /* _HEADER_RPC_$interface->{NAME} */\n";
96 my($ndr,$header,$ndr_header,$client_header) = @_;
101 $res .= "/* client functions auto-generated by pidl */\n";
104 $res .= "#include \"includes.h\"\n";
106 $res .= "#define _GNU_SOURCE\n";
107 $res .= "#include <stdio.h>\n";
108 $res .= "#include <stdbool.h>\n";
109 $res .= "#include <stdlib.h>\n";
110 $res .= "#include <stdint.h>\n";
111 $res .= "#include <stdarg.h>\n";
112 $res .= "#include <core/ntstatus.h>\n";
114 $res .= "#include \"$ndr_header\"\n";
115 $res .= "#include \"$client_header\"\n";
118 $res_hdr .= choose_header("librpc/rpc/dcerpc.h", "dcerpc.h")."\n";
119 $res_hdr .= "#include \"$header\"\n";
121 foreach my $x (@{$ndr}) {
122 ($x->{TYPE} eq "INTERFACE") && ParseInterface($x);
125 return ($res,$res_hdr);