~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to pidl/lib/Parse/Pidl/Samba4/Template.pm

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###################################################
 
2
# server template function generator
 
3
# Copyright tridge@samba.org 2003
 
4
# released under the GNU GPL
 
5
 
 
6
package Parse::Pidl::Samba4::Template;
 
7
 
 
8
use vars qw($VERSION);
 
9
$VERSION = '0.01';
 
10
 
 
11
use strict;
 
12
 
 
13
my($res);
 
14
 
 
15
#####################################################################
 
16
# produce boilerplate code for a interface
 
17
sub Template($)
 
18
{
 
19
        my($interface) = shift;
 
20
        my($data) = $interface->{DATA};
 
21
        my $name = $interface->{NAME};
 
22
 
 
23
        $res .= 
 
24
"/* 
 
25
   Unix SMB/CIFS implementation.
 
26
 
 
27
   endpoint server for the $name pipe
 
28
 
 
29
   Copyright (C) YOUR NAME HERE YEAR
 
30
   
 
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.
 
35
   
 
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.
 
40
   
 
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/>.
 
43
*/
 
44
 
 
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\"
 
49
 
 
50
";
 
51
 
 
52
        foreach my $d (@{$data}) {
 
53
                if ($d->{TYPE} eq "FUNCTION") {
 
54
                        my $fname = $d->{NAME};
 
55
                        $res .=
 
56
"
 
57
/* 
 
58
  $fname 
 
59
*/
 
60
static $d->{RETURN_TYPE} dcesrv_$fname(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
 
61
                       struct $fname *r)
 
62
{
 
63
";
 
64
 
 
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";
 
69
        }
 
70
 
 
71
        $res .= "}
 
72
 
 
73
";
 
74
                }
 
75
        }
 
76
 
 
77
        $res .= 
 
78
"
 
79
/* include the generated boilerplate */
 
80
#include \"librpc/gen_ndr/ndr_$name\_s.c\"
 
81
"
 
82
}
 
83
 
 
84
 
 
85
#####################################################################
 
86
# parse a parsed IDL structure back into an IDL file
 
87
sub Parse($)
 
88
{
 
89
        my($idl) = shift;
 
90
        $res = "";
 
91
        foreach my $x (@{$idl}) {
 
92
                ($x->{TYPE} eq "INTERFACE") && 
 
93
                    Template($x);
 
94
        }
 
95
        return $res;
 
96
}
 
97
 
 
98
1;