mirror of
https://github.com/samba-team/samba.git
synced 2025-03-12 20:58:37 +03:00
r9099: Start generating code to pull/push fields. Generate functions to call
the smb_raw_foo() calls. (This used to be commit 39dfabe66d1a377ed5a473db0309ca97adf24e7a)
This commit is contained in:
parent
1b42035bd9
commit
daaf771498
@ -4,6 +4,8 @@
|
||||
#
|
||||
|
||||
use File::Basename;
|
||||
use Data::Dumper;
|
||||
|
||||
my $file = shift;
|
||||
my $basename = basename($file, ".h");
|
||||
|
||||
@ -11,9 +13,6 @@ require smb_interfaces;
|
||||
my $parser = new smb_interfaces;
|
||||
$header = $parser->parse($file);
|
||||
|
||||
use Data::Dumper;
|
||||
#print Dumper($header);
|
||||
|
||||
# Create header
|
||||
|
||||
open(FILE, ">ejs_${basename}.h");
|
||||
@ -38,28 +37,6 @@ sub prototypes_for($)
|
||||
print FILE "NTSTATUS ejs_pull_$name(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
|
||||
}
|
||||
|
||||
sub pushpull_for($)
|
||||
{
|
||||
my $obj = shift;
|
||||
my $name = struct_name($obj);
|
||||
|
||||
print FILE "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const uint32_t *r)\n";
|
||||
print FILE "{\n";
|
||||
|
||||
print FILE "\tNDR_CHECK(ejs_push_struct_start(ejs, &v, \"output\"));\n";
|
||||
|
||||
print FILE "\n\treturn NT_STATUS_OK;\n";
|
||||
print FILE "}\n\n";
|
||||
|
||||
print FILE "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const uint32_t *r)\n";
|
||||
print FILE "{\n";
|
||||
|
||||
print FILE "\tNDR_CHECK(ejs_pull_struct_start(ejs, &v, \"input\"));\n";
|
||||
|
||||
print FILE "\treturn NT_STATUS_OK;\n";
|
||||
print FILE "}\n\n";
|
||||
}
|
||||
|
||||
foreach my $x (@{$header}) {
|
||||
|
||||
# Prototypes for top level structures and unions
|
||||
@ -89,21 +66,58 @@ print FILE "/* EJS wrapper functions auto-generated by build_smb_interfaces.pl *
|
||||
|
||||
# Top level push/pull functions
|
||||
|
||||
sub print_field($$) {
|
||||
my $f = shift;
|
||||
my $suffix = shift;
|
||||
|
||||
if ($f->{TYPE} eq "char" and $f->{POINTERS} == 1) {
|
||||
$type = "string";
|
||||
}
|
||||
|
||||
if ($f->{TYPE} =~ /_t$/) {
|
||||
$type = $f->{TYPE};
|
||||
$type =~ s/_t$//;
|
||||
}
|
||||
|
||||
foreach my $x (@{$f->{NAME}}) {
|
||||
print FILE "\tNDR_CHECK(ejs_pull_$type(ejs, v, \"$x\", &r->$suffix.$x));\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $x (@{$header}) {
|
||||
|
||||
next, if $x->{STRUCT_NAME} eq "";
|
||||
|
||||
# Pull in to struct.in
|
||||
|
||||
print FILE "static NTSTATUS ejs_pull_$x->{STRUCT_NAME}(struct ejs_rpc *ejs, struct MprVar *v, struct $x->{STRUCT_NAME} *r)\n";
|
||||
print FILE "{\n";
|
||||
print FILE "\tNDR_CHECK(ejs_pull_struct_start(ejs, &v, \"input\"));\n";
|
||||
print FILE "\treturn NT_STATUS_OK;\n";
|
||||
|
||||
foreach my $e (@{$x->{DATA}}) {
|
||||
next, if $e->{NAME}[0] ne 'in';
|
||||
foreach my $f (@{$e->{DATA}}) {
|
||||
print_field($f, "in");
|
||||
}
|
||||
}
|
||||
|
||||
print FILE "\n\treturn NT_STATUS_OK;\n";
|
||||
print FILE "}\n\n";
|
||||
|
||||
# Push from struct.out
|
||||
|
||||
print FILE "static NTSTATUS ejs_push_$x->{STRUCT_NAME}(struct ejs_rpc *ejs, struct MprVar *v, const struct $x->{STRUCT_NAME} *r)\n\n";
|
||||
print FILE "{\n";
|
||||
print FILE "\tNDR_CHECK(ejs_push_struct_start(ejs, &v, \"output\"));\n";
|
||||
|
||||
print FILE "\treturn NT_STATUS_OK;\n";
|
||||
foreach my $e (@{$x->{DATA}}) {
|
||||
next, if $e->{NAME}[0] ne 'out';
|
||||
foreach my $f (@{$e->{DATA}}) {
|
||||
print_field($f, "out");
|
||||
}
|
||||
}
|
||||
|
||||
print FILE "\n\treturn NT_STATUS_OK;\n";
|
||||
print FILE "}\n\n";
|
||||
}
|
||||
|
||||
@ -117,12 +131,34 @@ foreach my $x (@{$header}) {
|
||||
|
||||
print FILE "static int ejs_$x->{STRUCT_NAME}(int eid, int argc, struct MprVar **argv)\n";
|
||||
print FILE "{\n";
|
||||
print FILE "\tstruct $x->{STRUCT_NAME} parms;\n\n";
|
||||
print FILE "\tstruct $x->{STRUCT_NAME} parms;\n";
|
||||
print FILE "\tstruct smbcli_tree *tree;\n";
|
||||
print FILE "\tNTSTATUS result;\n\n";
|
||||
|
||||
print FILE "\t$raw_name(tree, ¶ms);\n";
|
||||
$output = << "__HERE__";
|
||||
if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) {
|
||||
ejsSetErrorMsg(eid, "invalid arguments");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tree = mprGetThisPtr(eid, "tree");
|
||||
|
||||
if (!tree) {
|
||||
ejsSetErrorMsg(eid, "invalid tree");
|
||||
return -1;
|
||||
}
|
||||
|
||||
__HERE__
|
||||
|
||||
print FILE $output;
|
||||
print FILE "\tresult = $raw_name(tree, ¶ms);\n\n";
|
||||
|
||||
print FILE "\tmpr_Return(eid, mprNTSTATUS(status));\n";
|
||||
print FILE "\tif (NT_STATUS_EQUAL(status, NT_STATUS_INTERNAL_ERROR)) {\n";
|
||||
print FILE "\t\treturn -1;\n";
|
||||
print FILE "\t}\n\n";
|
||||
print FILE "\treturn 0;\n";
|
||||
|
||||
print FILE "\tejsSetErrorMsg(eid, \"Not implemented\");\n";
|
||||
print FILE "\treturn -1;\n";
|
||||
print FILE "}\n\n";
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user