summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/pidl/MANIFEST1
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm78
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/EJSHeader.pm77
-rwxr-xr-xsource4/pidl/pidl7
-rw-r--r--source4/scripting/ejs/ejsrpc.h17
-rw-r--r--source4/scripting/ejs/smbcalls.c1
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c37
7 files changed, 75 insertions, 143 deletions
diff --git a/source4/pidl/MANIFEST b/source4/pidl/MANIFEST
index e0619d41f0..1d6cfc98dc 100644
--- a/source4/pidl/MANIFEST
+++ b/source4/pidl/MANIFEST
@@ -13,7 +13,6 @@ lib/Parse/Pidl/Samba4/NDR/Client.pm
lib/Parse/Pidl/Samba4/COM/Header.pm
lib/Parse/Pidl/Samba4/COM/Stub.pm
lib/Parse/Pidl/Samba4/COM/Proxy.pm
-lib/Parse/Pidl/Samba4/EJSHeader.pm
lib/Parse/Pidl/Samba4/Header.pm
lib/Parse/Pidl/Samba4/SWIG.pm
lib/Parse/Pidl/Samba4/TDR.pm
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm b/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm
index 8c576c44f9..d5e1405c30 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm
@@ -13,10 +13,18 @@ use Parse::Pidl::Util qw(has_property);
use vars qw($VERSION);
$VERSION = '0.01';
-my($res);
+my $res;
+my $res_hdr;
+
my %constants;
my $tabs = "";
+
+sub pidl_hdr ($)
+{
+ $res_hdr .= shift;
+}
+
sub pidl($)
{
my $d = shift;
@@ -110,12 +118,16 @@ sub get_value_of($)
#####################################################################
# work out is a parse function should be declared static or not
-sub fn_prefix($)
+sub fn_declare($$)
{
- my $fn = shift;
+ my ($fn,$decl) = @_;
- return "" if (has_property($fn, "public"));
- return "static ";
+ if (has_property($fn, "public")) {
+ pidl_hdr "$decl;\n";
+ pidl "$decl";
+ } else {
+ pidl "static $decl";
+ }
}
###########################
@@ -251,8 +263,8 @@ sub EjsStructPull($$)
my $name = shift;
my $d = shift;
my $env = GenerateStructEnv($d);
- pidl fn_prefix($d);
- pidl "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, struct $name *r)\n{";
+ fn_declare($d, "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, struct $name *r)");
+ pidl "{";
indent;
pidl "NDR_CHECK(ejs_pull_struct_start(ejs, &v, name));";
foreach my $e (@{$d->{ELEMENTS}}) {
@@ -271,8 +283,8 @@ sub EjsUnionPull($$)
my $d = shift;
my $have_default = 0;
my $env = GenerateStructEnv($d);
- pidl fn_prefix($d);
- pidl "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, union $name *r)\n{";
+ fn_declare($d, "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, union $name *r)");
+ pidl "{";
indent;
pidl "NDR_CHECK(ejs_pull_struct_start(ejs, &v, name));";
pidl "switch (ejs->switch_var) {";
@@ -327,8 +339,8 @@ sub EjsEnumPull($$)
my $name = shift;
my $d = shift;
EjsEnumConstant($d);
- pidl fn_prefix($d);
- pidl "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, enum $name *r)\n{";
+ fn_declare($d, "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, enum $name *r)");
+ pidl "{";
indent;
pidl "unsigned e;";
pidl "NDR_CHECK(ejs_pull_enum(ejs, v, name, &e));";
@@ -346,8 +358,8 @@ sub EjsBitmapPull($$)
my $d = shift;
my $type_fn = $d->{BASE_TYPE};
my($type_decl) = Parse::Pidl::Typelist::mapType($d->{BASE_TYPE});
- pidl fn_prefix($d);
- pidl "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, $type_decl *r)\n{";
+ fn_declare($d, "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, $type_decl *r)");
+ pidl "{";
indent;
pidl "return ejs_pull_$type_fn(ejs, v, name, r);";
deindent;
@@ -529,8 +541,8 @@ sub EjsStructPush($$)
my $name = shift;
my $d = shift;
my $env = GenerateStructEnv($d);
- pidl fn_prefix($d);
- pidl "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const struct $name *r)\n{";
+ fn_declare($d, "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const struct $name *r)");
+ pidl "{";
indent;
pidl "NDR_CHECK(ejs_push_struct_start(ejs, &v, name));";
foreach my $e (@{$d->{ELEMENTS}}) {
@@ -549,8 +561,8 @@ sub EjsUnionPush($$)
my $d = shift;
my $have_default = 0;
my $env = GenerateStructEnv($d);
- pidl fn_prefix($d);
- pidl "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const union $name *r)\n{";
+ fn_declare($d, "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const union $name *r)");
+ pidl "{";
indent;
pidl "NDR_CHECK(ejs_push_struct_start(ejs, &v, name));";
pidl "switch (ejs->switch_var) {";
@@ -587,8 +599,8 @@ sub EjsEnumPush($$)
my $name = shift;
my $d = shift;
EjsEnumConstant($d);
- pidl fn_prefix($d);
- pidl "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const enum $name *r)\n{";
+ fn_declare($d, "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const enum $name *r)");
+ pidl "{";
indent;
pidl "unsigned e = *r;";
pidl "NDR_CHECK(ejs_push_enum(ejs, v, name, &e));";
@@ -613,8 +625,8 @@ sub EjsBitmapPush($$)
$constants{$bname} = $v;
}
}
- pidl fn_prefix($d);
- pidl "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const $type_decl *r)\n{";
+ fn_declare($d, "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const $type_decl *r)");
+ pidl "{";
indent;
pidl "return ejs_push_$type_fn(ejs, v, name, r);";
deindent;
@@ -628,6 +640,7 @@ sub EjsTypedefPush($)
{
my $d = shift;
return if (has_property($d, "noejs"));
+
if ($d->{DATA}->{TYPE} eq 'STRUCT') {
EjsStructPush($d->{NAME}, $d->{DATA});
} elsif ($d->{DATA}->{TYPE} eq 'UNION') {
@@ -706,6 +719,17 @@ sub EjsInterface($$)
%constants = ();
+ pidl_hdr "#ifndef _HEADER_EJS_$interface->{NAME}\n";
+ pidl_hdr "#define _HEADER_EJS_$interface->{NAME}\n\n";
+
+ if (has_property($interface, "depends")) {
+ foreach (split / /, $interface->{PROPERTIES}->{depends}) {
+ pidl_hdr "#include \"librpc/gen_ndr/ndr_$_\_ejs\.h\"\n";
+ }
+ }
+
+ pidl_hdr "\n";
+
foreach my $d (@{$interface->{TYPES}}) {
($needed->{"push_$d->{NAME}"}) && EjsTypedefPush($d);
($needed->{"pull_$d->{NAME}"}) && EjsTypedefPull($d);
@@ -748,9 +772,13 @@ sub EjsInterface($$)
pidl "NTSTATUS ejs_init_$name(void)";
pidl "{";
indent;
- pidl "return smbcalls_register_ejs(\"$name\_init\", ejs_$name\_init);";
+ pidl "ejsDefineCFunction(-1, \"$name\_init\", ejs_$name\_init, NULL, MPR_VAR_SCRIPT_HANDLE);";
+ pidl "return NT_STATUS_OK;";
deindent;
pidl "}";
+
+ pidl_hdr "\n";
+ pidl_hdr "#endif /* _HEADER_EJS_$interface->{NAME} */\n";
}
#####################################################################
@@ -762,6 +790,10 @@ sub Parse($$)
my $ejs_hdr = $hdr;
$ejs_hdr =~ s/.h$/_ejs.h/;
$res = "";
+ $res_hdr = "";
+
+ pidl_hdr "/* header auto-generated by pidl */\n\n";
+
pidl "
/* EJS wrapper functions auto-generated by pidl */
#include \"includes.h\"
@@ -784,7 +816,7 @@ sub Parse($$)
($x->{TYPE} eq "INTERFACE") && EjsInterface($x, \%needed);
}
- return $res;
+ return ($res_hdr, $res);
}
sub NeededFunction($$)
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/EJSHeader.pm b/source4/pidl/lib/Parse/Pidl/Samba4/EJSHeader.pm
deleted file mode 100644
index eae7ddce5f..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/EJSHeader.pm
+++ /dev/null
@@ -1,77 +0,0 @@
-###################################################
-# create C header files for an EJS mapping functions
-# Copyright tridge@samba.org 2005
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::EJSHeader;
-
-use strict;
-use Parse::Pidl::Typelist;
-use Parse::Pidl::Util qw(has_property);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-my($res);
-
-sub pidl ($)
-{
- $res .= shift;
-}
-
-#####################################################################
-# prototype a typedef
-sub HeaderTypedefProto($)
-{
- my $d = shift;
- my $name = $d->{NAME};
-
- return unless has_property($d, "public");
-
- my $type_decl = Parse::Pidl::Typelist::mapType($name);
-
- pidl "NTSTATUS ejs_push_$d->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const $type_decl *);\n";
- pidl "NTSTATUS ejs_pull_$d->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, $type_decl *);\n";
-}
-
-#####################################################################
-# parse the interface definitions
-sub HeaderInterface($)
-{
- my($interface) = shift;
-
- my $count = 0;
-
- pidl "#ifndef _HEADER_EJS_$interface->{NAME}\n";
- pidl "#define _HEADER_EJS_$interface->{NAME}\n\n";
-
- if (defined $interface->{PROPERTIES}->{depends}) {
- my @d = split / /, $interface->{PROPERTIES}->{depends};
- foreach my $i (@d) {
- pidl "#include \"librpc/gen_ndr/ndr_$i\_ejs\.h\"\n";
- }
- }
-
- pidl "\n";
-
- HeaderTypedefProto($_) foreach (@{$interface->{TYPES}});
-
- pidl "\n";
- pidl "#endif /* _HEADER_EJS_$interface->{NAME} */\n";
-}
-
-#####################################################################
-# parse a parsed IDL into a C header
-sub Parse($)
-{
- my($idl) = shift;
-
- $res = "";
- pidl "/* header auto-generated by pidl */\n\n";
- foreach my $x (@{$idl}) {
- ($x->{TYPE} eq "INTERFACE") && HeaderInterface($x);
- }
- return $res;
-}
-
-1;
diff --git a/source4/pidl/pidl b/source4/pidl/pidl
index d1b8c4480b..dcf5850774 100755
--- a/source4/pidl/pidl
+++ b/source4/pidl/pidl
@@ -675,10 +675,9 @@ sub process_file($)
if (defined($opt_ejs)) {
require Parse::Pidl::Samba4::EJS;
- require Parse::Pidl::Samba4::EJSHeader;
- FileSave("$outputdir/ndr_$basename\_ejs.c", Parse::Pidl::Samba4::EJS::Parse($ndr, $h_filename));
-
- FileSave("$outputdir/ndr_$basename\_ejs.h", Parse::Pidl::Samba4::EJSHeader::Parse($ndr));
+ my ($hdr,$prsr) = Parse::Pidl::Samba4::EJS::Parse($ndr, $h_filename);
+ FileSave("$outputdir/ndr_$basename\_ejs.c", $prsr);
+ FileSave("$outputdir/ndr_$basename\_ejs.h", $hdr);
}
if (defined($opt_server)) {
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index a790beb804..d710ff375c 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -115,6 +115,23 @@ NTSTATUS ejs_push_array_uint8(struct ejs_rpc *ejs,
struct MprVar *v, const char *name,
const uint8_t *r, uint32_t length);
+NTSTATUS ejs_pull_GUID(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, struct GUID *r);
+NTSTATUS ejs_push_GUID(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const struct GUID *r);
+
+struct lsa_String;
+NTSTATUS ejs_pull_lsa_String(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, struct lsa_String *r);
+NTSTATUS ejs_push_lsa_String(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const struct lsa_String *r);
+
+struct winreg_String;
+NTSTATUS ejs_pull_winreg_String(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, struct winreg_String *r);
+NTSTATUS ejs_push_winreg_String(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const struct winreg_String *r);
+
#define EJS_ALLOC_SIZE(ejs, s, size) do { \
(s) = talloc_size(ejs, size); \
if (!(s)) return ejs_panic(ejs, "out of memory"); \
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index ee999402a5..3e96f8bef2 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -124,7 +124,6 @@ void smb_setup_ejs_functions(void)
smb_setup_ejs_ldb();
smb_setup_ejs_nbt();
smb_setup_ejs_cli();
- smb_setup_ejs_rpc();
smb_setup_ejs_auth();
smb_setup_ejs_options();
smb_setup_ejs_nss();
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index c71a475a92..6d2d411957 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -363,43 +363,6 @@ done:
return 0;
}
-/* a list of registered ejs rpc modules */
-static struct ejs_register {
- struct ejs_register *next, *prev;
- const char *name;
- MprCFunction fn;
-} *ejs_registered;
-
-/*
- register a generated ejs module
-*/
- NTSTATUS smbcalls_register_ejs(const char *name, MprCFunction fn)
-{
- struct ejs_register *r;
- void *ctx = ejs_registered;
- if (ctx == NULL) {
- ctx = talloc_autofree_context();
- }
- r = talloc(ctx, struct ejs_register);
- NT_STATUS_HAVE_NO_MEMORY(r);
- r->name = name;
- r->fn = fn;
- DLIST_ADD(ejs_registered, r);
- return NT_STATUS_OK;
-}
-
-/*
- setup C functions that be called from ejs
-*/
-void smb_setup_ejs_rpc(void)
-{
- struct ejs_register *r;
-
- for (r=ejs_registered;r;r=r->next) {
- ejsDefineCFunction(-1, r->name, r->fn, NULL, MPR_VAR_SCRIPT_HANDLE);
- }
-}
-
/*
hook called by generated RPC interfaces at the end of their init routines
used to add generic operations on the pipe