diff options
author | Tim Potter <tpot@samba.org> | 2005-08-08 00:24:05 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:31:30 -0500 |
commit | 16cc2aa58ebd56e117112d1856051f71a79976e8 (patch) | |
tree | 381328536d6034dce3c6b73a2f9ea0e3680bfc4d | |
parent | febfcd33ec150bcb815fd950afe407d14264f263 (diff) | |
download | samba-16cc2aa58ebd56e117112d1856051f71a79976e8.tar.gz samba-16cc2aa58ebd56e117112d1856051f71a79976e8.tar.bz2 samba-16cc2aa58ebd56e117112d1856051f71a79976e8.zip |
r9205: Generate more stub code for smb_raw ejs functions.
(This used to be commit 3407490121344f34c69eeaf838de6ce9c4c7b1fc)
-rwxr-xr-x | source4/script/build_smb_interfaces.pl | 109 |
1 files changed, 65 insertions, 44 deletions
diff --git a/source4/script/build_smb_interfaces.pl b/source4/script/build_smb_interfaces.pl index e06f05b25d..990151b2c8 100755 --- a/source4/script/build_smb_interfaces.pl +++ b/source4/script/build_smb_interfaces.pl @@ -57,6 +57,9 @@ sub flatten_structs($) { # Generate implementation # +my $basename = basename($file, ".h"); +stat "libcli/gen_raw" || mkdir("libcli/gen_raw") || die("mkdir"); + open(FILE, ">libcli/gen_raw/ejs_${basename}.c"); print FILE "/* EJS wrapper functions auto-generated by build_smb_interfaces.pl */\n\n"; @@ -74,9 +77,38 @@ foreach my $s (@newheader) { # Top level struct - print FILE "static NTSTATUS ejs_$s->{TYPE_DEFINED}(int eid, int argc, struct MprVar **argv)\n"; + print FILE "static int ejs_$s->{TYPE_DEFINED}(int eid, int argc, struct MprVar **argv)\n"; print FILE "{\n"; - print FILE "\treturn NT_STATUS_OK;\n"; + print FILE "\tstruct $s->{TYPE_DEFINED} params;\n"; + print FILE "\tstruct smbcli_tree *tree;\n"; + print FILE "\tNTSTATUS result;\n\n"; + + print FILE "\tif (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) {\n"; + print FILE "\t\tejsSetErrorMsg(eid, \"invalid arguments\");\n"; + print FILE "\t\treturn -1;\n"; + print FILE "\t}\n\n"; + + foreach my $field (@{$s->{FIELDS}}) { + next if $field->{NAME} eq "out"; + print FILE "\t// pull params.$field->{NAME}\n"; + } + + my $fn = $s->{TYPE_DEFINED}; + $fn =~ s/^smb_/smb_raw_/; + + print FILE "\n\tresult = $fn(tree, ¶ms);\n\n"; + + foreach my $field (@{$s->{FIELDS}}) { + next if $field->{NAME} eq "in"; + print FILE "\t// push params.$field->{NAME}\n"; + } + + print FILE "\n\tmpr_Return(eid, mprNTSTATUS(result));\n\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 "}\n\n"; } else { @@ -85,9 +117,38 @@ foreach my $s (@newheader) { foreach my $arm (@{$s->{FIELDS}}) { - print FILE "static NTSTATUS ejs_$s->{TYPE_DEFINED}_$arm->{NAME}(int eid, int argc, struct MprVar **argv)\n"; + print FILE "static int ejs_$s->{TYPE_DEFINED}_$arm->{NAME}(int eid, int argc, struct MprVar **argv)\n"; print FILE "{\n"; - print FILE "\treturn NT_STATUS_OK;\n"; + print FILE "\tunion $s->{TYPE_DEFINED} params;\n"; + print FILE "\tstruct smbcli_tree *tree;\n"; + print FILE "\tNTSTATUS result;\n\n"; + + print FILE "\tif (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) {\n"; + print FILE "\t\tejsSetErrorMsg(eid, \"invalid arguments\");\n"; + print FILE "\t\treturn -1;\n"; + print FILE "\t}\n\n"; + + foreach my $field (@{$arm->{FIELDS}}) { + next if $field->{NAME} eq "out"; + print FILE "\t// pull params.$arm->{NAME}.$field->{NAME}\n"; + } + + my $fn = $s->{TYPE_DEFINED}; + $fn =~ s/^smb_/smb_raw_/; + + print FILE "\n\tresult = $fn(tree, ¶ms);\n\n"; + + foreach my $field (@{$arm->{FIELDS}}) { + next if $field->{NAME} eq "in"; + print FILE "\t// push params.$arm->{NAME}.$field->{NAME}\n"; + } + + print FILE "\n\tmpr_Return(eid, mprNTSTATUS(result));\n\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 "}\n\n"; } } @@ -119,43 +180,3 @@ print FILE "}\n"; close(FILE); exit; - -foreach my $x (@{$header}) { - next, if $x->{STRUCT_NAME} eq ""; - - $raw_name = $x->{STRUCT_NAME}; - $raw_name =~ s/smb_/smb_raw_/; - - 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} params;\n"; - print FILE "\tstruct smbcli_tree *tree;\n"; - print FILE "\tNTSTATUS result;\n\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 "}\n\n"; -} - |