summaryrefslogtreecommitdiff
path: root/source4/script/build_smb_interfaces.pl
blob: cc3a35298723264494c05403cc532158608c06e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
#
# Create ejs interfaces for structures in a C header file
#

use File::Basename;
my $file = shift;
my $basename = basename($file, ".h");

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");

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";

foreach my $x (@{$header}) {
    print FILE "NTSTATUS ejs_push_$x->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
    print FILE "NTSTATUS ejs_pull_$x->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
}

print FILE "#endif\n";

close(FILE);

# Create file

open(FILE, ">ejs_${basename}.c");

print FILE "/* EJS wrapper functions auto-generated by build_smb_interfaces.pl */\n\n";

# Top level functions

foreach my $x (@{$header}) {
    print FILE "NTSTATUS ejs_push_$x->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *)\n";
    print FILEq "{\n";
    print FILE "\treturn NT_STATUS_OK;\n";
    print FILE "}\n\n";
    print FILE "NTSTATUS ejs_pull_$x->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *)\n";
    print FILE "{\n";
    print FILE "\treturn NT_STATUS_OK;\n";
    print FILE "}\n\n";
}

close(FILE);