summaryrefslogtreecommitdiff
path: root/source4/script
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-08-07 19:22:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:29 -0500
commit3824a0caa8c95b75e7d98340a5c9eb8d40c0b38d (patch)
tree395b515ea9f2884d3b2130e2c92c1677dd6baba8 /source4/script
parentd8a490ab1bff8e62e76e34b7a16eb27a74b30f66 (diff)
downloadsamba-3824a0caa8c95b75e7d98340a5c9eb8d40c0b38d.tar.gz
samba-3824a0caa8c95b75e7d98340a5c9eb8d40c0b38d.tar.bz2
samba-3824a0caa8c95b75e7d98340a5c9eb8d40c0b38d.zip
r9191: Generate headers for nested structures that need pushing or pulling.
(This used to be commit c56a530d3ba31a603d1a5615bdd2a0788cf1f967)
Diffstat (limited to 'source4/script')
-rwxr-xr-xsource4/script/build_smb_interfaces.pl72
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");