mirror of
https://github.com/samba-team/samba.git
synced 2025-11-08 16:23:49 +03:00
-
108 lines
2.1 KiB
Perl
108 lines
2.1 KiB
Perl
|
|
|
|
###################################################
|
|
# server boilerplate generator
|
|
# Copyright tridge@samba.org 2003
|
|
# released under the GNU GPL
|
|
|
|
package IdlServer;
|
|
|
|
use strict;
|
|
|
|
my($res);
|
|
|
|
sub pidl($)
|
|
{
|
|
$res .= shift;
|
|
}
|
|
|
|
#####################################################################
|
|
# produce boilerplate code for a interface
|
|
sub Boilerplate($)
|
|
{
|
|
my($interface) = shift;
|
|
my($data) = $interface->{DATA};
|
|
my $count = 0;
|
|
my $name = $interface->{NAME};
|
|
my $uname = uc $name;
|
|
|
|
foreach my $d (@{$data}) {
|
|
if ($d->{TYPE} eq "FUNCTION") { $count++; }
|
|
}
|
|
|
|
if ($count == 0) {
|
|
return;
|
|
}
|
|
|
|
pidl "static const dcesrv_dispatch_fn_t dispatch_table[] = {\n";
|
|
foreach my $d (@{$data}) {
|
|
if ($d->{TYPE} eq "FUNCTION") {
|
|
pidl "\t(dcesrv_dispatch_fn_t)$d->{NAME},\n";
|
|
}
|
|
}
|
|
pidl "\tNULL};\n\n";
|
|
|
|
pidl "
|
|
static BOOL op_query_endpoint(const struct dcesrv_endpoint *ep)
|
|
{
|
|
return dcesrv_table_query(&dcerpc_table_$name, ep);
|
|
}
|
|
|
|
static BOOL op_set_interface(struct dcesrv_state *dce,
|
|
const char *uuid, uint32 if_version)
|
|
{
|
|
return dcesrv_set_interface(dce, uuid, if_version,
|
|
&dcerpc_table_$name, dispatch_table);
|
|
}
|
|
|
|
static NTSTATUS op_connect(struct dcesrv_state *dce)
|
|
{
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
static void op_disconnect(struct dcesrv_state *dce)
|
|
{
|
|
/* nothing to do */
|
|
}
|
|
|
|
static int op_lookup_endpoints(TALLOC_CTX *mem_ctx, struct dcesrv_ep_iface **e)
|
|
{
|
|
return dcesrv_lookup_endpoints(&dcerpc_table_$name, mem_ctx, e);
|
|
}
|
|
|
|
static const struct dcesrv_endpoint_ops $name\_ops = {
|
|
op_query_endpoint,
|
|
op_set_interface,
|
|
op_connect,
|
|
op_disconnect,
|
|
op_lookup_endpoints
|
|
};
|
|
|
|
void rpc_$name\_init(void *v)
|
|
{
|
|
struct dcesrv_context *dce = v;
|
|
if (!dcesrv_endpoint_register(dce, &$name\_ops,
|
|
&dcerpc_table_$name)) {
|
|
DEBUG(1,(\"Failed to register rpcecho endpoint\\n\"));
|
|
}
|
|
}
|
|
";
|
|
}
|
|
|
|
|
|
#####################################################################
|
|
# parse a parsed IDL structure back into an IDL file
|
|
sub Parse($)
|
|
{
|
|
my($idl) = shift;
|
|
$res = "/* dcerpc server boilerplate generated by pidl */\n\n";
|
|
foreach my $x (@{$idl}) {
|
|
($x->{TYPE} eq "INTERFACE") &&
|
|
Boilerplate($x);
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
1;
|
|
|