Initial source import
[drsuapi_dissector.git] / pidl / lib / Parse / Pidl / Samba4 / Template.pm
bloba35fc7d2eb0a9634a45fb68ed37ca8e963ac2239
1 ###################################################
2 # server template function generator
3 # Copyright tridge@samba.org 2003
4 # released under the GNU GPL
6 package Parse::Pidl::Samba4::Template;
8 use vars qw($VERSION);
9 $VERSION = '0.01';
11 use strict;
13 my($res);
15 #####################################################################
16 # produce boilerplate code for a interface
17 sub Template($)
19 my($interface) = shift;
20 my($data) = $interface->{DATA};
21 my $name = $interface->{NAME};
23 $res .=
24 "/*
25 Unix SMB/CIFS implementation.
27 endpoint server for the $name pipe
29 Copyright (C) YOUR NAME HERE YEAR
31 This program is free software; you can redistribute it and/or modify
32 it under the terms of the GNU General Public License as published by
33 the Free Software Foundation; either version 3 of the License, or
34 (at your option) any later version.
36 This program is distributed in the hope that it will be useful,
37 but WITHOUT ANY WARRANTY; without even the implied warranty of
38 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 GNU General Public License for more details.
41 You should have received a copy of the GNU General Public License
42 along with this program. If not, see <http://www.gnu.org/licenses/>.
45 #include \"includes.h\"
46 #include \"rpc_server/dcerpc_server.h\"
47 #include \"librpc/gen_ndr/ndr_$name.h\"
48 #include \"rpc_server/common/common.h\"
52 foreach my $d (@{$data}) {
53 if ($d->{TYPE} eq "FUNCTION") {
54 my $fname = $d->{NAME};
55 $res .=
57 /*
58 $fname
60 static $d->{RETURN_TYPE} dcesrv_$fname(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
61 struct $fname *r)
65 if ($d->{RETURN_TYPE} eq "void") {
66 $res .= "\tDCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR);\n";
67 } else {
68 $res .= "\tDCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);\n";
71 $res .= "}
77 $res .=
79 /* include the generated boilerplate */
80 #include \"librpc/gen_ndr/ndr_$name\_s.c\"
85 #####################################################################
86 # parse a parsed IDL structure back into an IDL file
87 sub Parse($)
89 my($idl) = shift;
90 $res = "";
91 foreach my $x (@{$idl}) {
92 ($x->{TYPE} eq "INTERFACE") &&
93 Template($x);
95 return $res;