1 ###################################################
2 # Samba3 server generator for IDL structures
3 # on top of Samba4 style NDR functions
4 # Copyright jelmer@samba.org 2005-2006
5 # released under the GNU GPL
7 package Parse::Pidl::Samba3::ServerNDR;
10 use Parse::Pidl::Typelist qw(hasType getType mapType scalar_is_reference);
11 use Parse::Pidl::Util qw(has_property ParseExpr is_constant);
12 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred);
13 use Parse::Pidl::Samba4 qw(DeclLong);
15 use vars qw($VERSION);
21 sub indent() { $tabs.="\t"; }
22 sub deindent() { $tabs = substr($tabs, 1); }
23 sub pidl($) { $res .= $tabs.(shift)."\n"; }
24 sub pidl_hdr($) { $res_hdr .= (shift)."\n"; }
25 sub fatal($$) { my ($e,$s) = @_; die("$e->{ORIGINAL}->{FILE}:$e->{ORIGINAL}->{LINE}: $s\n"); }
26 sub warning($$) { my ($e,$s) = @_; warn("$e->{ORIGINAL}->{FILE}:$e->{ORIGINAL}->{LINE}: $s\n"); }
27 sub fn_declare($) { my ($n) = @_; pidl $n; pidl_hdr "$n;"; }
33 pidl "static BOOL api_$fn->{NAME}(pipes_struct *p)";
46 my $uif = uc($if->{NAME});
48 pidl_hdr "#ifndef __SRV_$uif\__";
49 pidl_hdr "#define __SRV_$uif\__";
50 ParseFunction($if, $_) foreach (@{$if->{FUNCTIONS}});
54 pidl "static struct api_struct api_$if->{NAME}_cmds[] = ";
58 foreach (@{$if->{FUNCTIONS}}) {
59 pidl "{\"" . uc($_->{NAME}) . "\", DCERPC_" . uc($_->{NAME}) . ", api_$_->{NAME}},";
67 pidl_hdr "void $if->{NAME}_get_pipe_fns(struct api_struct **fns, int *n_fns);";
68 pidl "void $if->{NAME}_get_pipe_fns(struct api_struct **fns, int *n_fns)";
71 pidl "*fns = api_$if->{NAME}_cmds;";
72 pidl "*n_fns = sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct);";
77 pidl_hdr "NTSTATUS rpc_netdfs_init(void);";
78 pidl "NTSTATUS rpc_netdfs_init(void)";
80 pidl "\treturn rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, \"$if->{NAME}\", \"$if->{NAME}\", api_$if->{NAME}_cmds, sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct));";
83 pidl_hdr "#endif /* __SRV_$uif\__ */";
88 my($ndr,$header,$ndr_header) = @_;
94 pidl " * Unix SMB/CIFS implementation.";
95 pidl " * server auto-generated by pidl. DO NOT MODIFY!";
98 pidl "#include \"includes.h\"";
99 pidl "#include \"$header\"";
100 pidl_hdr "#include \"$ndr_header\"";
104 ParseInterface($_) if ($_->{TYPE} eq "INTERFACE");
107 return ($res, $res_hdr);