pyldb: avoid segfault when adding an element with no name
[kai/samba-autobuild/.git] / pidl / pidl
index b7dcc2a43cc2e020bd7deded1fa63d40caa85547..7883414478179c80eb03505bd7f2fa0528c8f054 100755 (executable)
--- a/pidl/pidl
+++ b/pidl/pidl
@@ -21,28 +21,28 @@ pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-id
 
 =head1 DESCRIPTION
 
 
 =head1 DESCRIPTION
 
-pidl is an IDL compiler written in Perl that aims to be somewhat 
-compatible with the midl compiler. IDL is short for 
+pidl is an IDL compiler written in Perl that aims to be somewhat
+compatible with the midl compiler. IDL is short for
 "Interface Definition Language".
 
 "Interface Definition Language".
 
-pidl can generate stubs for DCE/RPC server code, DCE/RPC 
+pidl can generate stubs for DCE/RPC server code, DCE/RPC
 client code and Wireshark dissectors for DCE/RPC traffic.
 
 client code and Wireshark dissectors for DCE/RPC traffic.
 
-IDL compilers like pidl take a description 
-of an interface as their input and use it to generate C 
-(though support for other languages may be added later) code that 
-can use these interfaces, pretty print data sent 
-using these interfaces, or even generate Wireshark 
-dissectors that can parse data sent over the 
-wire by these interfaces. 
+IDL compilers like pidl take a description
+of an interface as their input and use it to generate C
+(though support for other languages may be added later) code that
+can use these interfaces, pretty print data sent
+using these interfaces, or even generate Wireshark
+dissectors that can parse data sent over the
+wire by these interfaces.
 
 
-pidl takes IDL files in the same format as is used by midl, 
+pidl takes IDL files in the same format as is used by midl,
 converts it to a .pidl file (which contains pidl's internal representation of the interface) and can then generate whatever output you need.
 converts it to a .pidl file (which contains pidl's internal representation of the interface) and can then generate whatever output you need.
-.pidl files should be used for debugging purposes only. Write your 
+.pidl files should be used for debugging purposes only. Write your
 interface definitions in .idl format.
 
 interface definitions in .idl format.
 
-The goal of pidl is to implement a IDL compiler that can be used 
-while developing the RPC subsystem in Samba (for 
+The goal of pidl is to implement a IDL compiler that can be used
+while developing the RPC subsystem in Samba (for
 both marshalling/unmarshalling and debugging purposes).
 
 =head1 OPTIONS
 both marshalling/unmarshalling and debugging purposes).
 
 =head1 OPTIONS
@@ -56,20 +56,20 @@ Show list of available options.
 =item I<--version>
 
 Show pidl version
 =item I<--version>
 
 Show pidl version
-               
+
 =item I<--outputdir OUTNAME>
 
 =item I<--outputdir OUTNAME>
 
-Write output files to the specified directory.  Defaults to the current 
+Write output files to the specified directory.  Defaults to the current
 directory.
 
 =item I<--includedir DIR>
 
 directory.
 
 =item I<--includedir DIR>
 
-Add DIR to the search path used by the preprocessor. This option can be 
+Add DIR to the search path used by the preprocessor. This option can be
 specified multiple times.
 specified multiple times.
-               
+
 =item I<--parse-idl-tree>
 
 =item I<--parse-idl-tree>
 
-Read internal tree structure from input files rather 
+Read internal tree structure from input files rather
 than assuming they contain IDL.
 
 =item I<--dump-idl>
 than assuming they contain IDL.
 
 =item I<--dump-idl>
@@ -82,14 +82,14 @@ Generate a C header file for the specified interface. Filename defaults to OUTNA
 
 =item I<--ndr-parser>
 
 
 =item I<--ndr-parser>
 
-Generate a C file and C header containing NDR parsers. The filename for 
-the parser defaults to ndr_OUTNAME.c. The header filename will be the 
+Generate a C file and C header containing NDR parsers. The filename for
+the parser defaults to ndr_OUTNAME.c. The header filename will be the
 parser filename with the extension changed from .c to .h.
 
 =item I<--tdr-parser>
 
 parser filename with the extension changed from .c to .h.
 
 =item I<--tdr-parser>
 
-Generate a C file and C header containing TDR parsers. The filename for 
-the parser defaults to tdr_OUTNAME.c. The header filename will be the 
+Generate a C file and C header containing TDR parsers. The filename for
+the parser defaults to tdr_OUTNAME.c. The header filename will be the
 parser filename with the extension changed from .c to .h.
 
 =item I<--typelib>
 parser filename with the extension changed from .c to .h.
 
 =item I<--typelib>
@@ -98,51 +98,51 @@ Write type information to the specified file.
 
 =item I<--server>
 
 
 =item I<--server>
 
-Generate boilerplate for the RPC server that implements 
+Generate boilerplate for the RPC server that implements
 the interface. Filename defaults to ndr_OUTNAME_s.c.
 
 =item I<--template>
 
 the interface. Filename defaults to ndr_OUTNAME_s.c.
 
 =item I<--template>
 
-Generate stubs for a RPC server that implements the interface. Output will 
+Generate stubs for a RPC server that implements the interface. Output will
 be written to stdout.
 
 =item I<--ws-parser>
 
 Generate an Wireshark dissector (in C) and header file. The dissector filename
 be written to stdout.
 
 =item I<--ws-parser>
 
 Generate an Wireshark dissector (in C) and header file. The dissector filename
-defaults to packet-dcerpc-OUTNAME.c while the header filename defaults to 
+defaults to packet-dcerpc-OUTNAME.c while the header filename defaults to
 packet-dcerpc-OUTNAME.h.
 packet-dcerpc-OUTNAME.h.
-       
-Pidl will read additional data from an Wireshark conformance file if present. 
-Such a file should have the same location as the IDL file but with the 
+
+Pidl will read additional data from an Wireshark conformance file if present.
+Such a file should have the same location as the IDL file but with the
 extension I<cnf> rather than I<idl>. See L<Parse::Pidl::Wireshark::Conformance>
 for details on the format of this file.
 
 =item I<--diff>
 
 extension I<cnf> rather than I<idl>. See L<Parse::Pidl::Wireshark::Conformance>
 for details on the format of this file.
 
 =item I<--diff>
 
-Parse an IDL file,  generate a new IDL file based on the internal data 
-structures and see if there are any differences with the original IDL file. 
+Parse an IDL file,  generate a new IDL file based on the internal data
+structures and see if there are any differences with the original IDL file.
 Useful for debugging pidl.
 
 =item I<--dump-idl-tree>
 
 Useful for debugging pidl.
 
 =item I<--dump-idl-tree>
 
-Tell pidl to dump the internal tree representation of an IDL 
+Tell pidl to dump the internal tree representation of an IDL
 file the to disk. Useful for debugging pidl.
 
 =item I<--dump-ndr-tree>
 
 file the to disk. Useful for debugging pidl.
 
 =item I<--dump-ndr-tree>
 
-Tell pidl to dump the internal NDR information tree it generated 
+Tell pidl to dump the internal NDR information tree it generated
 from the IDL file to disk.  Useful for debugging pidl.
 
 =item I<--samba3-ndr-client>
 
 from the IDL file to disk.  Useful for debugging pidl.
 
 =item I<--samba3-ndr-client>
 
-Generate client calls for Samba3, to be placed in rpc_client/. Instead of 
-calling out to the code in Samba3's rpc_parse/, this will call out to 
+Generate client calls for Samba3, to be placed in rpc_client/. Instead of
+calling out to the code in Samba3's rpc_parse/, this will call out to
 Samba4's NDR code instead.
 
 =item I<--samba3-ndr-server>
 
 Samba4's NDR code instead.
 
 =item I<--samba3-ndr-server>
 
-Generate server calls for Samba3, to be placed in rpc_server/. Instead of 
-calling out to the code in Samba3's rpc_parse/, this will call out to 
+Generate server calls for Samba3, to be placed in rpc_server/. Instead of
+calling out to the code in Samba3's rpc_parse/, this will call out to
 Samba4's NDR code instead.
 
 =back
 Samba4's NDR code instead.
 
 =back
@@ -151,29 +151,29 @@ Samba4's NDR code instead.
 
 IDL files are always preprocessed using the C preprocessor.
 
 
 IDL files are always preprocessed using the C preprocessor.
 
-Pretty much everything in an interface (the interface itself, functions, 
-parameters) can have attributes (or properties whatever name you give them). 
-Attributes always prepend the element they apply to and are surrounded 
-by square brackets ([]). Multiple attributes are separated by comma's; 
-arguments to attributes are specified between parentheses. 
+Pretty much everything in an interface (the interface itself, functions,
+parameters) can have attributes (or properties whatever name you give them).
+Attributes always prepend the element they apply to and are surrounded
+by square brackets ([]). Multiple attributes are separated by comma's;
+arguments to attributes are specified between parentheses.
 
 
-See the section COMPATIBILITY for the list of attributes that 
+See the section COMPATIBILITY for the list of attributes that
 pidl supports.
 
 C-style comments can be used.
 pidl supports.
 
 C-style comments can be used.
-       
+
 =head2 CONFORMANT ARRAYS
 
 A conformant array is one with that ends in [*] or []. The strange
 =head2 CONFORMANT ARRAYS
 
 A conformant array is one with that ends in [*] or []. The strange
-things about conformant arrays are that they can only appear as the last 
-element of a structure (unless there is a pointer to the conformant array, 
-of course) and the array size appears before the structure itself on the wire. 
+things about conformant arrays are that they can only appear as the last
+element of a structure (unless there is a pointer to the conformant array,
+of course) and the array size appears before the structure itself on the wire.
 
 So, in this example:
 
        typedef struct {
                long abc;
 
 So, in this example:
 
        typedef struct {
                long abc;
-               long count;     
+               long count;
                long foo;
                [size_is(count)] long s[*];
        } Struct1;
                long foo;
                [size_is(count)] long s[*];
        } Struct1;
@@ -193,16 +193,16 @@ midl.exe would write the above array as the following C header:
 
    typedef struct {
                long abc;
 
    typedef struct {
                long abc;
-               long count;     
+               long count;
                long foo;
                long s[1];
        } Struct1;
 
 pidl takes a different approach, and writes it like this:
 
                long foo;
                long s[1];
        } Struct1;
 
 pidl takes a different approach, and writes it like this:
 
-    typedef struct {
+       typedef struct {
                long abc;
                long abc;
-               long count;     
+               long count;
                long foo;
                long *s;
        } Struct1;
                long foo;
                long *s;
        } Struct1;
@@ -213,7 +213,7 @@ A varying array looks like this:
 
        typedef struct {
                long abc;
 
        typedef struct {
                long abc;
-               long count;     
+               long count;
                long foo;
                [size_is(count)] long *s;
        } Struct1;
                long foo;
                [size_is(count)] long *s;
        } Struct1;
@@ -226,9 +226,9 @@ This will look like this on the wire:
 
 A fixed array looks like this:
 
 
 A fixed array looks like this:
 
-    typedef struct {
-           long s[10];
-    } Struct1;
+       typedef struct {
+               long s[10];
+       } Struct1;
 
 The NDR representation looks just like 10 separate long
 declarations. The array size is not encoded on the wire.
 
 The NDR representation looks just like 10 separate long
 declarations. The array size is not encoded on the wire.
@@ -236,28 +236,28 @@ declarations. The array size is not encoded on the wire.
 pidl also supports "inline" arrays, which are not part of the IDL/NDR
 standard. These are declared like this:
 
 pidl also supports "inline" arrays, which are not part of the IDL/NDR
 standard. These are declared like this:
 
-    typedef struct {
-           uint32 foo;
-           uint32 count;
-           uint32 bar;
-           long s[count];
-    } Struct1;
+       typedef struct {
+               uint32 foo;
+               uint32 count;
+               uint32 bar;
+               long s[count];
+       } Struct1;
 
 This appears like this:
 
        [foo] [count] [bar] [s...]
 
 Fixed arrays are an extension added to support some of the strange
 
 This appears like this:
 
        [foo] [count] [bar] [s...]
 
 Fixed arrays are an extension added to support some of the strange
-embedded structures in security descriptors and spoolss. 
+embedded structures in security descriptors and spoolss.
 
 
-This section is by no means complete. See the OpenGroup and MSDN 
+This section is by no means complete. See the OpenGroup and MSDN
        documentation for additional information.
 
 =head1 COMPATIBILITY WITH MIDL
 
 =head2 Missing features in pidl
 
        documentation for additional information.
 
 =head1 COMPATIBILITY WITH MIDL
 
 =head2 Missing features in pidl
 
-The following MIDL features are not (yet) implemented in pidl 
+The following MIDL features are not (yet) implemented in pidl
 or are implemented with an incompatible interface:
 
 =over
 or are implemented with an incompatible interface:
 
 =over
@@ -266,7 +266,7 @@ or are implemented with an incompatible interface:
 
 Asynchronous communication
 
 
 Asynchronous communication
 
-=item * 
+=item *
 
 Typelibs (.tlb files)
 
 
 Typelibs (.tlb files)
 
@@ -278,9 +278,9 @@ Datagram support (ncadg_*)
 
 =head2 Supported attributes and statements
 
 
 =head2 Supported attributes and statements
 
-in, out, ref, length_is, switch_is, size_is, uuid, case, default, string, 
-unique, ptr, pointer_default, v1_enum, object, helpstring, range, local, 
-call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as, 
+in, out, ref, length_is, switch_is, size_is, uuid, case, default, string,
+unique, ptr, pointer_default, v1_enum, object, helpstring, range, local,
+call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as,
 transmit_as, import, include, cpp_quote.
 
 =head2 PIDL Specific properties
 transmit_as, import, include, cpp_quote.
 
 =head2 PIDL Specific properties
@@ -294,7 +294,7 @@ forces the generated pull/push functions to be non-static. This allows
 you to declare types that can be used between modules. If you don't
 specify [public] then pull/push functions for other than top-level
 functions are declared static.
 you to declare types that can be used between modules. If you don't
 specify [public] then pull/push functions for other than top-level
 functions are declared static.
-                               
+
 =item noprint
 
 The [noprint] property is a pidl extension that allows you to specify
 =item noprint
 
 The [noprint] property is a pidl extension that allows you to specify
@@ -324,16 +324,16 @@ complex structures.
 =item subcontext(length)
 
 Specifies that a size of I<length>
 =item subcontext(length)
 
 Specifies that a size of I<length>
-bytes should be read, followed by a blob of that size, 
+bytes should be read, followed by a blob of that size,
 which will be parsed as NDR.
 
 which will be parsed as NDR.
 
-subcontext() is deprecated now, and should not be used in new code. 
+subcontext() is deprecated now, and should not be used in new code.
 Instead, use represent_as() or transmit_as().
 
 =item flag
 
 Instead, use represent_as() or transmit_as().
 
 =item flag
 
-Specify boolean options, mostly used for 
-low-level NDR options. Several options 
+Specify boolean options, mostly used for
+low-level NDR options. Several options
 can be specified using the | character.
 Note that flags are inherited by substructures!
 
 can be specified using the | character.
 Note that flags are inherited by substructures!
 
@@ -346,30 +346,30 @@ spoolss structures.
 
 =item charset(name)
 
 
 =item charset(name)
 
-Specify that the array or string uses the specified 
-charset. If this attribute is specified, pidl will 
-take care of converting the character data from this format 
+Specify that the array or string uses the specified
+charset. If this attribute is specified, pidl will
+take care of converting the character data from this format
 to the host format. Commonly used values are UCS2, DOS and UTF8.
 
 =back
 
 =head2 Unsupported MIDL properties or statements
 
 to the host format. Commonly used values are UCS2, DOS and UTF8.
 
 =back
 
 =head2 Unsupported MIDL properties or statements
 
-aggregatable, appobject, async_uuid, bindable, control, 
-defaultbind, defaultcollelem, defaultvalue, defaultvtable, dispinterface, 
-displaybind, dual, entry, first_is, helpcontext, helpfile, helpstringcontext, 
-helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib, 
-includelib, last_is, lcid, licensed, max_is, module, 
-ms_union, no_injected_text, nonbrowsable, noncreatable, nonextensible, odl, 
-oleautomation, optional, pragma, propget, propputref, propput, readonly, 
-requestedit, restricted, retval, source, uidefault, 
-usesgetlasterror, vararg, vi_progid, wire_marshal. 
+aggregatable, appobject, async_uuid, bindable, control,
+defaultbind, defaultcollelem, defaultvalue, defaultvtable, dispinterface,
+displaybind, dual, entry, first_is, helpcontext, helpfile, helpstringcontext,
+helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib,
+includelib, last_is, lcid, licensed, max_is, module,
+ms_union, no_injected_text, nonbrowsable, noncreatable, nonextensible, odl,
+oleautomation, optional, pragma, propget, propputref, propput, readonly,
+requestedit, restricted, retval, source, uidefault,
+usesgetlasterror, vararg, vi_progid, wire_marshal.
 
 =head1 EXAMPLES
 
        # Generating an Wireshark parser
        $ ./pidl --ws-parser -- atsvc.idl
 
 =head1 EXAMPLES
 
        # Generating an Wireshark parser
        $ ./pidl --ws-parser -- atsvc.idl
-       
+
        # Generating a TDR parser and header
        $ ./pidl --tdr-parser --header -- regf.idl
 
        # Generating a TDR parser and header
        $ ./pidl --tdr-parser --header -- regf.idl
 
@@ -381,23 +381,23 @@ usesgetlasterror, vararg, vi_progid, wire_marshal.
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<http://msdn.microsoft.com/library/en-us/rpc/rpc/field_attributes.asp>,
-L<http://wiki.wireshark.org/DCE/RPC>, 
-L<http://www.samba.org/>,
+L<https://msdn.microsoft.com/en-us/library/windows/desktop/aa373864%28v=vs.85%29.aspx>
+L<https://wiki.wireshark.org/DCE/RPC>,
+L<https://www.samba.org/>,
 L<yapp(1)>
 
 =head1 LICENSE
 
 L<yapp(1)>
 
 =head1 LICENSE
 
-pidl is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
+pidl is licensed under the GNU General Public License L<https://www.gnu.org/licenses/gpl.html>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
-pidl was written by Andrew Tridgell, Stefan Metzmacher, Tim Potter and Jelmer 
+pidl was written by Andrew Tridgell, Stefan Metzmacher, Tim Potter and Jelmer
 Vernooij. The current maintainer is Jelmer Vernooij.
 
 Vernooij. The current maintainer is Jelmer Vernooij.
 
-This manpage was written by Jelmer Vernooij, partially based on the original 
-pidl README by Andrew Tridgell. 
-       
+This manpage was written by Jelmer Vernooij, partially based on the original
+pidl README by Andrew Tridgell.
+
 =cut
 
 
 =cut
 
 
@@ -432,30 +432,30 @@ sub LoadStructure($)
 # read a file into a string
 sub FileLoad($)
 {
 # read a file into a string
 sub FileLoad($)
 {
-    my($filename) = shift;
-    local(*INPUTFILE);
-    open(INPUTFILE, $filename) || return undef;
-    my($saved_delim) = $/;
-    undef $/;
-    my($data) = <INPUTFILE>;
-    close(INPUTFILE);
-    $/ = $saved_delim;
-    return $data;
+       my($filename) = shift;
+       local(*INPUTFILE);
+       open(INPUTFILE, $filename) || return undef;
+       my($saved_delim) = $/;
+       undef $/;
+       my($data) = <INPUTFILE>;
+       close(INPUTFILE);
+       $/ = $saved_delim;
+       return $data;
 }
 
 #####################################################################
 # write a string into a file
 sub FileSave($$)
 {
 }
 
 #####################################################################
 # write a string into a file
 sub FileSave($$)
 {
-    my($filename) = shift;
-    my($v) = shift;
-    local(*FILE);
-    open(FILE, ">$filename") || die "can't open $filename";    
-    print FILE $v;
-    close(FILE);
+       my($filename) = shift;
+       my($v) = shift;
+       local(*FILE);
+       open(FILE, ">$filename") || die "can't open $filename";
+       print FILE $v;
+       close(FILE);
 }
 
 }
 
-my(@opt_incdirs) = (); 
+my(@opt_incdirs) = ();
 my($opt_help) = 0;
 my($opt_version) = 0;
 my($opt_parse_idl_tree) = 0;
 my($opt_help) = 0;
 my($opt_version) = 0;
 my($opt_parse_idl_tree) = 0;
@@ -469,6 +469,7 @@ my($opt_samba3_parser);
 my($opt_samba3_server);
 my($opt_samba3_ndr_client);
 my($opt_samba3_ndr_server);
 my($opt_samba3_server);
 my($opt_samba3_ndr_client);
 my($opt_samba3_ndr_server);
+my($opt_samba3_template) = 0;
 my($opt_template) = 0;
 my($opt_client);
 my($opt_typelib);
 my($opt_template) = 0;
 my($opt_client);
 my($opt_typelib);
@@ -525,65 +526,67 @@ Samba 4 output:
  --com-header[=OUTFILE]  create header for COM [com_BASENAME.h]
 
 Samba 3 output:
  --com-header[=OUTFILE]  create header for COM [com_BASENAME.h]
 
 Samba 3 output:
- --samba3-ndr-client[=OUTF] create client calls for Samba3 
+ --samba3-ndr-client[=OUTF] create client calls for Samba3
                             using Samba4's NDR code [cli_BASENAME.c]
                             using Samba4's NDR code [cli_BASENAME.c]
- --samba3-ndr-server[=OUTF] create server call wrapper for Samba3 
+ --samba3-ndr-server[=OUTF] create server call wrapper for Samba3
                             using Samba4's NDR code [srv_BASENAME.c]
                             using Samba4's NDR code [srv_BASENAME.c]
+ --samba3-template          print a template for a pipe
 
 Wireshark parsers:
  --ws-parser[=OUTFILE]  create Wireshark parser and header
 \n";
 
 Wireshark parsers:
  --ws-parser[=OUTFILE]  create Wireshark parser and header
 \n";
-    exit(0);
+       exit(0);
 }
 
 #########################################
 # Display version
 sub ShowVersion()
 {
 }
 
 #########################################
 # Display version
 sub ShowVersion()
 {
-    print "perl IDL version $VERSION\n";
+       print "perl IDL version $VERSION\n";
 }
 
 # main program
 my $result = GetOptions (
 }
 
 # main program
 my $result = GetOptions (
-           'help|h|?' => \$opt_help, 
-            'version' => \$opt_version,
-           'outputdir=s' => \$opt_outputdir,
-           'dump-idl' => \$opt_dump_idl,
+               'help|h|?' => \$opt_help,
+               'version' => \$opt_version,
+               'outputdir=s' => \$opt_outputdir,
+               'dump-idl' => \$opt_dump_idl,
                'dump-idl-tree:s' => \$opt_dump_idl_tree,
                'parse-idl-tree' => \$opt_parse_idl_tree,
                'dump-ndr-tree:s' => \$opt_dump_ndr_tree,
                'samba3-ndr-client:s' => \$opt_samba3_ndr_client,
                'samba3-ndr-server:s' => \$opt_samba3_ndr_server,
                'dump-idl-tree:s' => \$opt_dump_idl_tree,
                'parse-idl-tree' => \$opt_parse_idl_tree,
                'dump-ndr-tree:s' => \$opt_dump_ndr_tree,
                'samba3-ndr-client:s' => \$opt_samba3_ndr_client,
                'samba3-ndr-server:s' => \$opt_samba3_ndr_server,
+               'samba3-template' => \$opt_samba3_template,
                'header:s' => \$opt_header,
                'header:s' => \$opt_header,
-           'server:s' => \$opt_server,
+               'server:s' => \$opt_server,
                'typelib:s' => \$opt_typelib,
                'typelib:s' => \$opt_typelib,
-           'tdr-parser:s' => \$opt_tdr_parser,
-           'template' => \$opt_template,
-           'ndr-parser:s' => \$opt_ndr_parser,
-           'client:s' => \$opt_client,
-           'ws-parser:s' => \$opt_ws_parser,
+               'tdr-parser:s' => \$opt_tdr_parser,
+               'template' => \$opt_template,
+               'ndr-parser:s' => \$opt_ndr_parser,
+               'client:s' => \$opt_client,
+               'ws-parser:s' => \$opt_ws_parser,
                'python' => \$opt_python,
                'python' => \$opt_python,
-           'diff' => \$opt_diff,
-        'dcom-proxy:s' => \$opt_dcom_proxy,
+               'diff' => \$opt_diff,
+               'dcom-proxy:s' => \$opt_dcom_proxy,
                'com-header:s' => \$opt_com_header,
                'com-header:s' => \$opt_com_header,
-           'quiet' => \$opt_quiet,
+               'quiet' => \$opt_quiet,
                'verbose' => \$opt_verbose,
                'verbose' => \$opt_verbose,
-           'warn-compat' => \$opt_warn_compat,
+               'warn-compat' => \$opt_warn_compat,
                'includedir=s@' => \@opt_incdirs
                'includedir=s@' => \@opt_incdirs
-           );
+               );
 
 if (not $result) {
        exit(1);
 }
 
 if ($opt_help) {
 
 if (not $result) {
        exit(1);
 }
 
 if ($opt_help) {
-    ShowHelp();
-    exit(0);
+       ShowHelp();
+       exit(0);
 }
 
 if ($opt_version) {
 }
 
 if ($opt_version) {
-    ShowVersion();
-    exit(0);
+       ShowVersion();
+       exit(0);
 }
 
 sub process_file($)
 }
 
 sub process_file($)
@@ -653,28 +656,28 @@ sub process_file($)
        $pidl = Parse::Pidl::ODL::ODL2IDL($pidl, dirname($idl_file), \@opt_incdirs);
 
        if (defined($opt_ws_parser)) {
        $pidl = Parse::Pidl::ODL::ODL2IDL($pidl, dirname($idl_file), \@opt_incdirs);
 
        if (defined($opt_ws_parser)) {
-         require Parse::Pidl::Wireshark::NDR;
+               require Parse::Pidl::Wireshark::NDR;
 
 
-         my $cnffile = $idl_file;
-         $cnffile =~ s/\.idl$/\.cnf/;
+               my $cnffile = $idl_file;
+               $cnffile =~ s/\.idl$/\.cnf/;
 
 
-         my $generator = new Parse::Pidl::Wireshark::NDR();
-         $generator->Initialize($cnffile);
+               my $generator = new Parse::Pidl::Wireshark::NDR();
+               $generator->Initialize($cnffile);
        }
 
 
        if (defined($opt_ws_parser) or
        }
 
 
        if (defined($opt_ws_parser) or
-           defined($opt_client) or
-           defined($opt_server) or 
-           defined($opt_header) or
-           defined($opt_ndr_parser) or
-           defined($opt_python) or 
-           defined($opt_dump_ndr_tree) or
-           defined($opt_samba3_header) or 
-           defined($opt_samba3_parser) or 
-           defined($opt_samba3_server) or 
-           defined($opt_samba3_ndr_client) or
-           defined($opt_samba3_ndr_server)) {
+               defined($opt_client) or
+               defined($opt_server) or
+               defined($opt_header) or
+               defined($opt_ndr_parser) or
+               defined($opt_python) or
+               defined($opt_dump_ndr_tree) or
+               defined($opt_samba3_header) or
+               defined($opt_samba3_parser) or
+               defined($opt_samba3_server) or
+               defined($opt_samba3_ndr_client) or
+               defined($opt_samba3_ndr_server)) {
                require Parse::Pidl::NDR;
                $ndr = Parse::Pidl::NDR::Parse($pidl);
        }
                require Parse::Pidl::NDR;
                $ndr = Parse::Pidl::NDR::Parse($pidl);
        }
@@ -708,8 +711,8 @@ sub process_file($)
 
        if (defined($opt_python)) {
                require Parse::Pidl::Samba4::Python;
 
        if (defined($opt_python)) {
                require Parse::Pidl::Samba4::Python;
-               my $generator = new Parse::Pidl::Samba4::Python(); 
-               my ($prsr) = $generator->Parse($basename, $ndr, 
+               my $generator = new Parse::Pidl::Samba4::Python();
+               my ($prsr) = $generator->Parse($basename, $ndr,
                                        "$outputdir/ndr_$basename\_c.h", $h_filename);
                FileSave("$outputdir/py_$basename.c", $prsr);
        }
                                        "$outputdir/ndr_$basename\_c.h", $h_filename);
                FileSave("$outputdir/py_$basename.c", $prsr);
        }
@@ -732,17 +735,17 @@ sub process_file($)
        }
 
        if (defined($opt_ws_parser)) {
        }
 
        if (defined($opt_ws_parser)) {
-         require Parse::Pidl::Wireshark::NDR;
-         my($eparser) = ($opt_ws_parser or "$outputdir/packet-dcerpc-$basename.c");
-         my $eheader = $eparser;
-         $eheader =~ s/\.c$/\.h/;
-         my $cnffile = $idl_file;
-         $cnffile =~ s/\.idl$/\.cnf/;
-
-         my $generator = new Parse::Pidl::Wireshark::NDR();
-         my ($dp, $dh) = $generator->Parse($ndr, $idl_file, $eheader, $cnffile);
-         FileSave($eparser, $dp) if defined($dp);
-         FileSave($eheader, $dh) if defined($dh);
+               require Parse::Pidl::Wireshark::NDR;
+               my($eparser) = ($opt_ws_parser or "$outputdir/packet-dcerpc-$basename.c");
+               my $eheader = $eparser;
+               $eheader =~ s/\.c$/\.h/;
+               my $cnffile = $idl_file;
+               $cnffile =~ s/\.idl$/\.cnf/;
+
+               my $generator = new Parse::Pidl::Wireshark::NDR();
+               my ($dp, $dh) = $generator->Parse($ndr, $idl_file, $eheader, $cnffile);
+               FileSave($eparser, $dp) if defined($dp);
+               FileSave($eheader, $dh) if defined($dh);
        }
 
        if (defined($opt_tdr_parser)) {
        }
 
        if (defined($opt_tdr_parser)) {
@@ -767,6 +770,11 @@ sub process_file($)
                print Parse::Pidl::Samba4::Template::Parse($pidl);
        }
 
                print Parse::Pidl::Samba4::Template::Parse($pidl);
        }
 
+       if ($opt_samba3_template) {
+               require Parse::Pidl::Samba3::Template;
+               print Parse::Pidl::Samba3::Template::Parse($pidl);
+       }
+
        if (defined($opt_samba3_ndr_client)) {
                my $client = ($opt_samba3_ndr_client or "$outputdir/cli_$basename.c");
                my $header = $client; $header =~ s/\.c$/\.h/;
        if (defined($opt_samba3_ndr_client)) {
                my $client = ($opt_samba3_ndr_client or "$outputdir/cli_$basename.c");
                my $header = $client; $header =~ s/\.c$/\.h/;