diff options
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/script/build_smb_interfaces.pl | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/source4/script/build_smb_interfaces.pl b/source4/script/build_smb_interfaces.pl index 192a7d7094..63cc25080c 100755 --- a/source4/script/build_smb_interfaces.pl +++ b/source4/script/build_smb_interfaces.pl @@ -46,7 +46,8 @@ sub flatten_names($) { foreach my $elt (@{$obj->{DATA}}) { foreach my $name (@{$elt->{NAME}}) { $obj->{FIELDS}{$name} = $elt; - delete $obj->{FIELDS}{$name}{NAME}; + $obj->{FIELDS}{$name}{NAME} = $name; + $obj->{FIELDS}{$name}{PARENT} = $obj; } } @@ -63,42 +64,13 @@ foreach my $s (@{$header}) { # For each parsed structure flatten_names($s); } -print Dumper($header); - -exit; - -foreach my $s (@{$header}) { # For each parsed structure - print Dumper($s); - my $newdata; - foreach my $e (@{$s->{DATA}}) { # For each element in structure - foreach my $n (@{$e->{NAME}}) { # For each field in element - - my $newdata2; - foreach my $e2 (@{$e->{DATA}}) { - foreach my $n2 (@{$e2->{NAME}}) { - my $d = $e2; - $d->{NAME} = $n2; - push(@{$newdata2}, $d); - } - } - - push(@{$newdata}, {"NAME" => $n, "DATA" => $newdata2}); - } - } - my $newstruct = $s; - $newstruct->{DATA} = $newdata; - push(@{$newheader}, $newstruct); -} - -print Dumper($newheader); -exit 0; - +# +# Generate header +# my $basename = basename($file, ".h"); stat "libcli/gen_raw" || mkdir("libcli/gen_raw") || die("mkdir"); -# Create header - open(FILE, ">libcli/gen_raw/ejs_${basename}.h"); print FILE "/* header auto-generated by build_smb_interfaces.pl */\n\n"; @@ -106,6 +78,36 @@ print FILE "/* header auto-generated by build_smb_interfaces.pl */\n\n"; print FILE "#ifndef _ejs_${basename}_h\n"; print FILE "#define _ejs_${basename}_h\n\n"; + +# Generate a push/pull prototype for every top level structure, as +# well as every non-anonymous nested structure (i.e TYPE_NAME element +# is undefined. + +foreach my $s (@{$header}) { + + # Top level + + print FILE "NTSTATUS ejs_push_$s->{TYPE_NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n"; + print FILE "NTSTATUS ejs_pull_$s->{TYPE_NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n"; + + sub header_for($$) { + my $prefix = shift; + my $obj = shift; + + return if !($obj->{TYPE} eq "struct" or $obj->{TYPE} eq "union"); + return if ($obj->{NAME} eq "in" or $obj->{NAME} eq "out"); + + print FILE "NTSTATUS ejs_push_${prefix}_$obj->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n"; + print FILE "NTSTATUS ejs_pull_${prefix}_$obj->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n"; + + foreach my $key (%{$obj->{FIELDS}}) { + header_for("${prefix}.$obj->{TYPE_NAME}", $obj->{FIELDS}{$key}); + } + } +} + +exit; + sub struct_name($) { my $obj = shift; @@ -161,7 +163,9 @@ print FILE "#endif\n"; close(FILE); -# Create file +# +# Generate implementation +# open(FILE, ">libcli/gen_raw/ejs_${basename}.c"); |