1 ###################################################
2 # Samba3 NDR server generator for IDL structures
3 # Copyright jelmer@samba.org 2005
4 # released under the GNU GPL
6 package Parse::Pidl::Samba3::Server;
9 use Parse::Pidl::Typelist qw(hasType getType mapType);
10 use Parse::Pidl::Util qw(has_property ParseExpr);
11 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred);
16 sub indent() { $tabs.="\t"; }
17 sub deindent() { $tabs = substr($tabs, 1); }
18 sub pidl($) { $res .= $tabs.(shift)."\n"; }
20 use vars qw($VERSION);
27 pidl "/******************************************************************";
28 pidl " api_$fn->{NAME}";
29 pidl " *****************************************************************/";
31 pidl "static BOOL api_$fn->{NAME}(pipes_struct *p)";
34 pidl uc("$if->{NAME}_q_$fn->{NAME}") . " q_u;";
35 pidl uc("$if->{NAME}_r_$fn->{NAME}") . " r_u;";
36 pidl "prs_struct *data = &p->in_data.data;";
37 pidl "prs_struct *rdata = &p->out_data.rdata;";
39 pidl "ZERO_STRUCT(q_u);";
40 pidl "ZERO_STRUCT(r_u);";
42 pidl "if (!$if->{NAME}_io_q_$fn->{NAME}(\"\", &q_u, data, 0))";
43 pidl "\treturn False;";
45 if ($fn->{RETURN_TYPE}) {
46 pidl "r_u.status = _$fn->{NAME}(p, &q_u, &r_u);";
48 pidl "_$fn->{NAME}(p, &q_u, &r_u);";
51 pidl "if (!$if->{NAME}_io_r_$fn->{NAME}(\"\", &r_u, rdata, 0))";
52 pidl "\treturn False;";
63 ParseFunction($if, $_) foreach (@{$if->{FUNCTIONS}});
67 pidl "static struct api_struct api_$if->{NAME}_cmds[] = ";
70 foreach (@{$if->{FUNCTIONS}}) {
71 pidl "{\"" . uc($_->{NAME}) . "\", " . uc($_->{NAME}) . ", api_$_->{NAME}},";
78 pidl "void $if->{NAME}_get_pipe_fns(struct api_struct **fns, int *n_fns)";
81 pidl "*fns = api_$if->{NAME}_cmds;";
82 pidl "*n_fns = sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct);";
88 pidl "NTSTATUS rpc_$if->{NAME}_init(void)";
91 pidl "return 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));";
98 my($ndr,$filename) = @_;
104 pidl " * Unix SMB/CIFS implementation.";
105 pidl " * server auto-generated by pidl. DO NOT MODIFY!";
108 pidl "#include \"includes.h\"";
109 pidl "#include \"nterr.h\"";
111 pidl "#undef DBGC_CLASS";
112 pidl "#define DBGC_CLASS DBGC_RPC";
116 ParseInterface($_) if ($_->{TYPE} eq "INTERFACE");