r1083: Generate prototypes for structs and unions marked "public" in the idl.
authorTim Potter <tpot@samba.org>
Tue, 8 Jun 2004 12:33:47 +0000 (12:33 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:56:37 +0000 (12:56 -0500)
Delete various hacks to work around not doing this before.
(This used to be commit 5c3c3d3e72d8dd5d995a5bc5b2c7d7217b7c0432)

source4/build/pidl/eparser.pm
source4/build/pidl/packet-dcerpc-eparser.c
source4/build/pidl/packet-dcerpc-eparser.h
source4/build/pidl/pidl.pl

index fb8d0e39ca88f33fc90269cd7df146396d30d1b5..fd2f721f36e6c56067f371352cd85895c7b18d9a 100644 (file)
@@ -785,7 +785,7 @@ sub ParseInterface($)
        my($data) = $interface->{DATA};
 
        foreach my $d (@{$data}) {
-               if ($d->{TYPE} eq "TYPEDEF") {
+               if ($d->{TYPE} eq "TYPEDEF") {
                    $structs{$d->{NAME}} = $d;
            }
        }
@@ -827,8 +827,6 @@ sub NeededFunction($)
                    'ft'   => type2ft($e->{TYPE}),
                    'base' => type2base($e->{TYPE})
                    };
-               $needed{"proto_$e->{TYPE}"} = 1,
-                   if !util::is_builtin_type($e->{TYPE});
                $e->{PARENT} = $fn;
        }
 }
@@ -851,9 +849,6 @@ sub NeededTypedef($)
                    'base' => type2base($e->{TYPE})
                    };
 
-               $needed{"proto_$e->{TYPE}"} = 1,
-               if !util::is_builtin_type($e->{TYPE});
-
                        $e->{PARENT} = $t->{DATA};
                        if ($needed{"pull_$t->{NAME}"}) {
                                $needed{"pull_$e->{TYPE}"} = 1;
@@ -861,11 +856,9 @@ sub NeededTypedef($)
                }
        }
        if ($t->{DATA}->{TYPE} eq "UNION") {
-               $needed{"proto_$t->{NAME}"} = "union";
                for my $e (@{$t->{DATA}->{DATA}}) {
                        $e->{PARENT} = $t->{DATA};
                        if ($e->{TYPE} eq "UNION_ELEMENT") {
-                           $needed{"proto_$e->{DATA}->{TYPE}"} = 1;
                                if ($needed{"pull_$t->{NAME}"}) {
                                        $needed{"pull_$e->{DATA}->{TYPE}"} = 1;
                                }
@@ -901,6 +894,36 @@ sub ModuleHeader($)
     $if_endpoints = $h->{PROPERTIES}->{endpoints};
 }
 
+sub ParseHeader($$)
+{
+       my($idl) = shift;
+       my($filename) = shift;
+
+       open(OUT, ">$filename") || die "can't open $filename";    
+
+       pidl "/* parser auto-generated by pidl */\n\n";
+
+       foreach my $x (@{$idl}) {
+           if ($x->{TYPE} eq "INTERFACE") { 
+               foreach my $d (@{$x->{DATA}}) {
+                   if ($d->{TYPE} eq "TYPEDEF" and 
+                       util::has_property($d->{DATA}, "public")) {
+                       
+                       if ($d->{DATA}{TYPE} eq "STRUCT") { 
+                           pidl "void ndr_pull_$d->{NAME}(struct e_ndr_pull *ndr, int ndr_flags);\n";
+                       }
+
+                       if ($d->{DATA}{TYPE} eq "UNION") {
+                           pidl "void ndr_pull_$d->{NAME}(struct e_ndr_pull *ndr, int ndr_flags, int level);\n";
+                       }
+                   }
+               }
+           }
+       }
+
+       close(OUT);
+}
+
 #####################################################################
 # parse a parsed IDL structure back into an IDL file
 sub Parse($$)
@@ -944,19 +967,6 @@ sub Parse($$)
                            pidl "static int $y = -1;\n", if $y =~ /^hf_/;
                        }
 
-                       # Function prototypes
-
-                       foreach my $x (keys(%needed)) {
-                           next, if !($x =~ /^proto_/);
-                           my $name = $x;
-                           $name =~ s/^proto_//;
-                           pidl "void ndr_pull_$name(struct e_ndr_pull *ndr, int ndr_flags";
-
-                           pidl ", int level", if $needed{$x} eq "union";
-
-                           pidl ");\n";
-                       }
-       
                ParseInterface($x);
                }
        }
index ae559e878a6e34d8cf6e41b27b6ccb216f1a22f8..8b828da38eada2bb8fa69e6004a8a21cc4489dca 100644 (file)
@@ -162,16 +162,3 @@ void ndr_pull_subcontext_header(struct e_ndr_pull *ndr,
                                struct e_ndr_pull *ndr2)
 {
 }
-
-void ndr_pull_lsa_SidArray(struct e_ndr_pull *ndr, int ndr_flags)
-{
-}
-
-void ndr_pull_samr_LogonHours(struct e_ndr_pull *ndr, int ndr_flags)
-{
-}
-
-void ndr_pull_samr_Password(struct e_ndr_pull *ndr, int ndr_flags)
-{
-}
-
index e8b89e66006111bc6329a0450adc153258918ad2..5c26a40b3d1f0e939c6b8e84f32a9708af2fee9e 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _packet_dcerpc_eparser_h
+#define _packet_dcerpc_eparser_h
+
 #define NDR_SCALARS 1
 #define NDR_BUFFERS 2
 
@@ -45,6 +48,8 @@ struct ndr_ofs_list {
        struct ndr_ofs_list *next;
 };
 
+#include "packet-dcerpc-proto.h"
+
 /* Create a ndr_pull structure from data stored in a tvb at a given offset. */
 
 struct e_ndr_pull *ndr_pull_init(tvbuff_t *tvb, int offset, packet_info *pinfo,
@@ -75,6 +80,4 @@ void ndr_pull_string(struct e_ndr_pull *e_ndr, int hf);
 void ndr_pull_dom_sid2(struct e_ndr_pull *e_ndr, int hf);
 void ndr_pull_security_descriptor(struct e_ndr_pull *e_ndr, int hf);
 
-void ndr_pull_lsa_SidArray(struct e_ndr_pull *ndr, int ndr_flags);
-void ndr_pull_samr_LogonHours(struct e_ndr_pull *ndr, int ndr_flags);
-void ndr_pull_samr_Password(struct e_ndr_pull *ndr, int ndr_flags);
+#endif /* _packet_dcerpc_eparser_h */
index 1c122932ba48c94a6a72c6cd64f499c466790af8..cebd545297ab07a15bc62de454857607838e01a9 100755 (executable)
@@ -146,6 +146,12 @@ sub process_file($)
        if ($opt_eparser) {
                my($parser) = dirname($output) . "/packet-dcerpc-$basename.c";
                IdlEParser::Parse($pidl, $parser);
+               $parser = dirname($output) . "/packet-dcerpc-proto-$basename.h";
+               IdlEParser::ParseHeader($pidl, $parser);
+               my($header) = dirname($output) . "/packet-dcerpc-proto.h";
+               open(OUT, ">>$header") || die "can't open $header";
+               print OUT "#include \"packet-dcerpc-proto-$basename.h\"\n";
+               close(OUT);
        }
 
        if ($opt_diff) {