pidl: merge multiple 'genpad' implementations into one.
[Samba.git] / pidl / lib / Parse / Pidl / Samba3 / Template.pm
blob4750cef00f2f66c58adfa794a90de709b8e07e9a
1 ###################################################
2 # server template function generator
3 # Copyright tridge@samba.org 2003
4 # released under the GNU GPL
6 package Parse::Pidl::Samba3::Template;
8 use vars qw($VERSION);
9 $VERSION = '0.01';
11 use Parse::Pidl::Util qw(genpad);
13 use strict;
15 my($res);
17 #####################################################################
18 # produce boilerplate code for a interface
19 sub Template($)
21 my($interface) = shift;
22 my($data) = $interface->{DATA};
23 my $name = $interface->{NAME};
25 $res .=
26 "/*
27 Unix SMB/CIFS implementation.
29 endpoint server for the $name pipe
31 Copyright (C) YOUR NAME HERE YEAR
33 This program is free software; you can redistribute it and/or modify
34 it under the terms of the GNU General Public License as published by
35 the Free Software Foundation; either version 3 of the License, or
36 (at your option) any later version.
38 This program is distributed in the hope that it will be useful,
39 but WITHOUT ANY WARRANTY; without even the implied warranty of
40 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 GNU General Public License for more details.
43 You should have received a copy of the GNU General Public License
44 along with this program. If not, see <http://www.gnu.org/licenses/>.
47 #include \"includes.h\"
48 #include \"ntdomain.h\"
49 #include \"../librpc/gen_ndr/srv_$name.h\"
53 foreach my $d (@{$data}) {
54 if ($d->{TYPE} eq "FUNCTION") {
55 my $fname = $d->{NAME};
56 my $pad = genpad("$d->{RETURN_TYPE} _$fname");
57 $res .=
59 /****************************************************************
60 _$fname
61 ****************************************************************/
63 $d->{RETURN_TYPE} _$fname(struct pipes_struct *p,
64 $pad"."struct $fname *r)
68 $res .= "\tp->fault_state = DCERPC_FAULT_OP_RNG_ERROR;\n";
69 if ($d->{RETURN_TYPE} eq "NTSTATUS") {
70 $res .= "\treturn NT_STATUS_NOT_IMPLEMENTED;\n";
71 } elsif ($d->{RETURN_TYPE} eq "WERROR") {
72 $res .= "\treturn WERR_NOT_SUPPORTED;\n";
75 $res .= "}
83 #####################################################################
84 # parse a parsed IDL structure back into an IDL file
85 sub Parse($)
87 my($idl) = shift;
88 $res = "";
89 foreach my $x (@{$idl}) {
90 ($x->{TYPE} eq "INTERFACE") &&
91 Template($x);
93 return $res;