| 1 |
################################################### |
| 2 |
# server template function generator |
| 3 |
# Copyright [email protected] 2003 |
| 4 |
# released under the GNU GPL |
| 5 |
|
| 6 |
package Parse::Pidl::Samba3::Template; |
| 7 |
|
| 8 |
use vars qw($VERSION); |
| 9 |
$VERSION = '0.01'; |
| 10 |
|
| 11 |
use Parse::Pidl::Util qw(genpad); |
| 12 |
|
| 13 |
use strict; |
| 14 |
use warnings; |
| 15 |
|
| 16 |
my($res); |
| 17 |
|
| 18 |
##################################################################### |
| 19 |
# produce boilerplate code for a interface |
| 20 |
sub Template($) |
| 21 |
{ |
| 22 |
my($interface) = shift; |
| 23 |
my($data) = $interface->{DATA}; |
| 24 |
my $name = $interface->{NAME}; |
| 25 |
|
| 26 |
$res .= |
| 27 |
"/* |
| 28 |
Unix SMB/CIFS implementation. |
| 29 |
|
| 30 |
endpoint server for the $name pipe |
| 31 |
|
| 32 |
Copyright (C) YOUR NAME HERE YEAR |
| 33 |
|
| 34 |
This program is free software; you can redistribute it and/or modify |
| 35 |
it under the terms of the GNU General Public License as published by |
| 36 |
the Free Software Foundation; either version 3 of the License, or |
| 37 |
(at your option) any later version. |
| 38 |
|
| 39 |
This program is distributed in the hope that it will be useful, |
| 40 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 41 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 42 |
GNU General Public License for more details. |
| 43 |
|
| 44 |
You should have received a copy of the GNU General Public License |
| 45 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 46 |
*/ |
| 47 |
|
| 48 |
#include \"includes.h\" |
| 49 |
#include \"ntdomain.h\" |
| 50 |
#include \"librpc/gen_ndr/ndr_$name.h\" |
| 51 |
#include \"librpc/gen_ndr/ndr_$name\_scompat.h\" |
| 52 |
|
| 53 |
"; |
| 54 |
|
| 55 |
foreach my $d (@{$data}) { |
| 56 |
if ($d->{TYPE} eq "FUNCTION") { |
| 57 |
my $fname = $d->{NAME}; |
| 58 |
my $pad = genpad("$d->{RETURN_TYPE} _$fname"); |
| 59 |
$res .= |
| 60 |
" |
| 61 |
/**************************************************************** |
| 62 |
_$fname |
| 63 |
****************************************************************/ |
| 64 |
|
| 65 |
$d->{RETURN_TYPE} _$fname(struct pipes_struct *p, |
| 66 |
$pad"."struct $fname *r) |
| 67 |
{ |
| 68 |
"; |
| 69 |
|
| 70 |
$res .= "\tp->fault_state = DCERPC_FAULT_OP_RNG_ERROR;\n"; |
| 71 |
if ($d->{RETURN_TYPE} eq "NTSTATUS") { |
| 72 |
$res .= "\treturn NT_STATUS_NOT_IMPLEMENTED;\n"; |
| 73 |
} elsif ($d->{RETURN_TYPE} eq "WERROR") { |
| 74 |
$res .= "\treturn WERR_NOT_SUPPORTED;\n"; |
| 75 |
} elsif ($d->{RETURN_TYPE} eq "HRESULT") { |
| 76 |
$res .= "\treturn HRES_ERROR_NOT_SUPPORTED;\n"; |
| 77 |
} elsif ($d->{RETURN_TYPE} eq "int") { |
| 78 |
$res .= "\treturn ENOTSUP;\n"; |
| 79 |
} |
| 80 |
|
| 81 |
$res .= "} |
| 82 |
|
| 83 |
"; |
| 84 |
} |
| 85 |
} |
| 86 |
$res .= |
| 87 |
"/* include the generated boilerplate */ |
| 88 |
#include \"librpc/gen_ndr/ndr_$name\_scompat.c\"\ |
| 89 |
"; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
##################################################################### |
| 94 |
# parse a parsed IDL structure back into an IDL file |
| 95 |
sub Parse($) |
| 96 |
{ |
| 97 |
my($idl) = shift; |
| 98 |
$res = ""; |
| 99 |
foreach my $x (@{$idl}) { |
| 100 |
($x->{TYPE} eq "INTERFACE") && |
| 101 |
Template($x); |
| 102 |
} |
| 103 |
return $res; |
| 104 |
} |
| 105 |
|
| 106 |
1; |