Changeset 988 for vendor/current/pidl


Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/pidl
Files:
1 added
24 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/pidl/README

    r414 r988  
    11Introduction:
    22=============
    3 This directory contains the source code of the pidl (Perl IDL) 
    4 compiler for Samba 4. 
     3This directory contains the source code of the pidl (Perl IDL)
     4compiler for Samba 4.
    55
    66The main sources for pidl are available using Git as part of
    7 the combined Samba 3 / Samba 4 tree. Use:
     7the Samba source tree. Use:
    88git clone git://git.samba.org/samba.git
    99
    10 Pidl works by building a parse tree from a .pidl file (a simple 
    11 dump of it's internal parse tree) or a .idl file 
    12 (a file format mostly like the IDL file format midl uses). 
    13 The IDL file parser is in idl.yp (a yacc file converted to 
     10Pidl works by building a parse tree from a .pidl file (a simple
     11dump of it's internal parse tree) or a .idl file
     12(a file format mostly like the IDL file format midl uses).
     13The IDL file parser is in idl.yp (a yacc file converted to
    1414perl code by yapp)
    15 
    16 After a parse tree is present, pidl will call one of it's backends
    17 (which one depends on the options given on the command-line). Here is
    18 a list of current backends:
    1915
    2016Standalone installation:
    2117========================
    22 Run Makefile.PL to generate the Makefile. 
     18Run Makefile.PL to generate the Makefile.
    2319
    2420Then run "make install" (as root) to install.
     
    2622Internals overview:
    2723===================
     24
     25After a parse tree is present, pidl will call one of it's backends
     26(which one depends on the options given on the command-line). Here is
     27a list of current backends:
    2828
    2929-- Generic --
     
    5656
    5757Tips for hacking on pidl:
    58  - Look at the pidl's parse tree by using the --keep option and looking
    59    at the generated .pidl file.
    60  - The various backends have a lot in common, if you don't understand how one 
    61    implements something, look at the others
     58 - Inspect pidl's parse tree by using the --keep option and looking at the
     59   generated .pidl file.
     60 - The various backends have a lot in common, if you don't understand how one
     61   implements something, look at the others.
    6262 - See pidl(1) and the documentation on midl
    63  - See 'info bison' and yapp(1) for information on the file format of idl.yp
     63 - See 'info bison' and yapp(1) for information on the file format of idl.yp
     64 - Run the tests (all in tests/)
  • vendor/current/pidl/TODO

    r414 r988  
    1515- --explain-ndr option that dumps out parse tree ?
    1616
    17 - seperate tables for NDR and DCE/RPC
     17- separate tables for NDR and DCE/RPC
    1818 - maybe no tables for NDR at all? we only need them for ndrdump
    1919   and that can use dlsym()
  • vendor/current/pidl/lib/Parse/Pidl/Dump.pm

    r414 r988  
    4040
    4141    foreach my $d ($props) {
    42         foreach my $k (keys %{$d}) {
     42        foreach my $k (sort(keys %{$d})) {
    4343            if ($k eq "in") {
    4444                $res .= "[in] ";
     
    245245
    246246    $res .= "[\n";
    247     foreach my $k (keys %{$data}) {
     247    foreach my $k (sort(keys %{$data})) {
    248248            $first || ($res .= ",\n"); $first = 0;
    249249            $res .= "$k($data->{$k})";
  • vendor/current/pidl/lib/Parse/Pidl/NDR.pm

    r860 r988  
    950950        my ($e) = @_;
    951951
     952        if (property_matches($e, "flag", ".*STR_NULLTERM.*")) {
     953                return 1;
     954        }
     955        if (exists($e->{LEVELS}) and $e->{LEVELS}->[0]->{TYPE} eq "ARRAY" and
     956                ($e->{LEVELS}->[0]->{IS_FIXED} or $e->{LEVELS}->[0]->{IS_INLINE}) and
     957                has_property($e, "charset"))
     958        {
     959                return 1;
     960        }
     961
    952962        foreach my $l (@{$e->{LEVELS}}) {
    953963                return 1 if ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED});
     964        }
     965        if (property_matches($e, "charset", ".*DOS.*")) {
     966                return 1;
    954967        }
    955968
  • vendor/current/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm

    r740 r988  
    1414use strict;
    1515use Parse::Pidl qw(fatal warning error);
    16 use Parse::Pidl::Util qw(has_property ParseExpr);
     16use Parse::Pidl::Util qw(has_property ParseExpr genpad);
    1717use Parse::Pidl::NDR qw(ContainsPipe);
    1818use Parse::Pidl::Typelist qw(mapTypeName);
     
    2929sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); }
    3030
    31 sub genpad($)
    32 {
    33         my ($s) = @_;
    34         my $nt = int((length($s)+1)/8);
    35         my $lt = ($nt*8)-1;
    36         my $ns = (length($s)-$lt);
    37         return "\t"x($nt)." "x($ns);
    38 }
    39 
    4031sub new($)
    4132{
     
    6051        my $ret = "";
    6152
    62         foreach my $d (keys %{$props}) {
     53        foreach my $d (sort(keys %{$props})) {
    6354                next if (grep(/^$d$/, @$ignores));
    6455                if($props->{$d} ne "1") {
  • vendor/current/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm

    r919 r988  
    1515use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
    1616use Parse::Pidl::Util qw(ParseExpr has_property is_constant);
    17 use Parse::Pidl::NDR qw(GetNextLevel);
     17use Parse::Pidl::NDR qw(GetNextLevel ContainsPipe);
    1818use Parse::Pidl::Samba4 qw(ElementStars DeclLong);
    1919use Parse::Pidl::Samba4::Header qw(GenerateFunctionOutEnv);
     
    2525my $res_hdr;
    2626my $tabs = "";
     27sub pidl_reset() { $res=""; $res_hdr="", $tabs=""; }
     28sub pidl_return() { my $s = $res; my $h = $res_hdr; pidl_reset(); return ($s, $h) }
    2729sub indent() { $tabs.="\t"; }
    2830sub deindent() { $tabs = substr($tabs, 1); }
     
    4951}
    5052
    51 sub AllocOutVar($$$$$)
    52 {
    53         my ($e, $mem_ctx, $name, $env, $fail) = @_;
     53sub AllocOutVar($$$$$$$)
     54{
     55        my ($e, $mem_ctx, $name, $env, $check, $cleanup, $return) = @_;
    5456
    5557        my $l = $e->{LEVELS}[0];
     
    8486        }
    8587
    86         pidl "if ($name == NULL) {";
    87         $fail->();
    88         pidl "}";
    89         pidl "";
    90 }
    91 
    92 sub CallWithStruct($$$$)
    93 {
    94         my ($pipes_struct, $mem_ctx, $fn, $fail) = @_;
     88        pidl "if (" . $check->($name) . ") {";
     89        indent;
     90        pidl $cleanup->($name) if defined($cleanup);
     91        pidl $return->($name) if defined($return);
     92        deindent;
     93        pidl "}";
     94        pidl "";
     95}
     96
     97sub CallWithStruct($$$$$$)
     98{
     99        my ($pipes_struct, $mem_ctx, $fn, $check, $cleanup, $return) = @_;
    95100        my $env = GenerateFunctionOutEnv($fn);
    96101        my $hasout = 0;
     
    101106        pidl "ZERO_STRUCT(r->out);" if ($hasout);
    102107
    103         my $proto = "_$fn->{NAME}(struct pipes_struct *p, struct $fn->{NAME} *r";
    104         my $ret = "_$fn->{NAME}($pipes_struct, r";
    105108        foreach (@{$fn->{ELEMENTS}}) {
    106109                my @dir = @{$_->{DIRECTION}};
     
    111114
    112115        foreach (@{$fn->{ELEMENTS}}) {
     116                next if ContainsPipe($_, $_->{LEVELS}[0]);
    113117                my @dir = @{$_->{DIRECTION}};
    114118                if (grep(/in/, @dir) and grep(/out/, @dir)) {
     
    116120                } elsif (grep(/out/, @dir) and not
    117121                                 has_property($_, "represent_as")) {
    118                         AllocOutVar($_, $mem_ctx, "r->out.$_->{NAME}", $env, $fail);
    119                 }
    120         }
    121         $ret .= ")";
    122         $proto .= ");";
     122                        AllocOutVar($_, $mem_ctx, "r->out.$_->{NAME}", $env,
     123                                    $check, $cleanup, $return);
     124                }
     125        }
     126
     127        my $proto = "_$fn->{NAME}(struct pipes_struct *p, struct $fn->{NAME} *r)";
     128        my $ret = "_$fn->{NAME}($pipes_struct, r)";
    123129
    124130        if ($fn->{RETURN_TYPE}) {
    125131                $ret = "r->out.result = $ret";
    126                 $proto = "$fn->{RETURN_TYPE} $proto";
     132                $proto = mapTypeName($fn->{RETURN_TYPE})." $proto";
    127133        } else {
    128134                $proto = "void $proto";
    129135        }
    130136
    131         pidl_hdr "$proto";
     137        pidl_hdr "$proto;";
    132138        pidl "$ret;";
    133139}
     
    176182        pidl "";
    177183
    178         CallWithStruct("p", "r", $fn,
    179         sub {
    180                         pidl "\ttalloc_free(r);";
    181                         pidl "\treturn false;";
     184        CallWithStruct("p", "r", $fn,
     185                sub ($) {
     186                        my ($name) = @_;
     187                        return "${name} == NULL";
     188                },
     189                sub ($) {
     190                        my ($name) = @_;
     191                        return "talloc_free(r);";
     192                },
     193                sub ($) {
     194                        my ($name) = @_;
     195                        return "return false;";
    182196                }
    183197        );
     
    286300        my($ndr,$header,$ndr_header) = @_;
    287301
    288         $res = "";
    289         $res_hdr = "";
     302        pidl_reset();
    290303
    291304        pidl "/*";
     
    304317        }
    305318
    306         return ($res, $res_hdr);
     319        return pidl_return();
    307320}
    308321
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/Header.pm

    r740 r988  
    3939        my $ret = "";
    4040
    41         foreach my $d (keys %{$props}) {
     41        foreach my $d (sort(keys %{$props})) {
    4242                next if (grep(/^$d$/, @$ignores));
    4343                if($props->{$d} ne "1") {
     
    143143                my $with_val = 0;
    144144                my $without_val = 0;
    145                 pidl " { __donnot_use_enum_$name=0x7FFFFFFF}\n";
     145                pidl " { __do_not_use_enum_$name=0x7FFFFFFF}\n";
    146146                foreach my $e (@{$enum->{ELEMENTS}}) {
    147147                        my $t = "$e";
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm

    r740 r988  
    1212
    1313use Parse::Pidl qw(fatal warning error);
    14 use Parse::Pidl::Util qw(has_property ParseExpr);
     14use Parse::Pidl::Util qw(has_property ParseExpr genpad);
    1515use Parse::Pidl::NDR qw(ContainsPipe);
    1616use Parse::Pidl::Typelist qw(mapTypeName);
     
    2929sub pidl_both($$) { my ($self, $txt) = @_; $self->{hdr} .= "$txt\n"; $self->{res_hdr} .= "$txt\n"; }
    3030sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); }
    31 
    32 sub genpad($)
    33 {
    34         my ($s) = @_;
    35         my $nt = int((length($s)+1)/8);
    36         my $lt = ($nt*8)-1;
    37         my $ns = (length($s)-$lt);
    38         return "\t"x($nt)." "x($ns);
    39 }
    4031
    4132sub new($)
     
    159150
    160151        $self->pidl("status = dcerpc_binding_handle_call_recv(subreq);");
    161         $self->pidl("if (!NT_STATUS_IS_OK(status)) {");
    162         $self->indent;
    163         $self->pidl("tevent_req_nterror(req, status);");
     152        $self->pidl("TALLOC_FREE(subreq);");
     153        $self->pidl("if (tevent_req_nterror(req, status)) {");
     154        $self->indent;
    164155        $self->pidl("return;");
    165156        $self->deindent;
     
    260251        my $ret = "";
    261252
    262         foreach my $d (keys %{$props}) {
     253        foreach my $d (sort(keys %{$props})) {
    263254                next if (grep(/^$d$/, @$ignores));
    264255                if($props->{$d} ne "1") {
     
    401392                }
    402393
     394                my $dest_ptr = "$o$e->{NAME}";
     395                my $elem_size = "sizeof(*$dest_ptr)";
     396                $self->pidl("if ($dest_ptr != $out_var) {");
     397                $self->indent;
    403398                if (has_property($e, "charset")) {
    404                         $self->pidl("memcpy(discard_const_p(uint8_t *, $o$e->{NAME}), $out_var, $copy_len_var * sizeof(*$o$e->{NAME}));");
    405                 } else {
    406                         $self->pidl("memcpy($o$e->{NAME}, $out_var, $copy_len_var * sizeof(*$o$e->{NAME}));");
    407                 }
     399                        $dest_ptr = "discard_const_p(uint8_t *, $dest_ptr)";
     400                }
     401                $self->pidl("memcpy($dest_ptr, $out_var, $copy_len_var * $elem_size);");
     402                $self->deindent;
     403                $self->pidl("}");
    408404
    409405                $self->deindent;
     
    564560        $self->pidl("status = dcerpc_$name\_r_recv(subreq, mem_ctx);");
    565561        $self->pidl("TALLOC_FREE(subreq);");
    566         $self->pidl("if (!NT_STATUS_IS_OK(status)) {");
    567         $self->indent;
    568         $self->pidl("tevent_req_nterror(req, status);");
     562        $self->pidl("if (tevent_req_nterror(req, status)) {");
     563        $self->indent;
    569564        $self->pidl("return;");
    570565        $self->deindent;
     
    693688        }
    694689        $self->pidl("");
     690
     691        $self->pidl("/* Out parameters */");
     692        foreach my $e (@{$fn->{ELEMENTS}}) {
     693                next unless grep(/out/, @{$e->{DIRECTION}});
     694
     695                $self->ParseCopyArgument($fn, $e, "r.out.", "_");
     696        }
     697        $self->pidl("");
     698
     699        if (defined($fn->{RETURN_TYPE})) {
     700                $self->pidl("/* Result */");
     701                $self->pidl("ZERO_STRUCT(r.out.result);");
     702                $self->pidl("");
     703        }
    695704
    696705        $self->pidl("status = dcerpc_$name\_r(h, mem_ctx, &r);");
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm

    r860 r988  
    199199                        $size = $length = "ndr_string_length($var_name, sizeof(*$var_name))";
    200200                }
     201                if (defined($l->{SIZE_IS})) {
     202                        $size = ParseExpr($l->{SIZE_IS}, $env, $e);
     203                }
     204                if (defined($l->{LENGTH_IS})) {
     205                        $length = ParseExpr($l->{LENGTH_IS}, $env, $e);
     206                }
    201207        } else {
    202208                $size = ParseExpr($l->{SIZE_IS}, $env, $e);
     
    256262                        }
    257263                }
    258                 warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully derefenced variable") if ($nump > length($ptr));
     264                warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully dereferenced variable") if ($nump > length($ptr));
    259265                return ($origvar);
    260266        }
     
    413419        }
    414420
    415         if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) {
     421        if ($l->{IS_CONFORMANT} and (defined($l->{SIZE_IS}) or not $l->{IS_ZERO_TERMINATED})) {
    416422                $self->defer("if ($var_name) {");
    417423                $self->defer_indent;
     
    425431        }
    426432
    427         if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) {
     433        if ($l->{IS_VARYING} and (defined($l->{LENGTH_IS}) or not $l->{IS_ZERO_TERMINATED})) {
    428434                $self->defer("if ($var_name) {");
    429435                $self->defer_indent;
     
    627633        }
    628634
    629         if ($l->{TYPE} eq "POINTER" and $deferred) {
     635        if ($l->{TYPE} eq "POINTER" and $l->{POINTER_TYPE} eq "ignore") {
     636                $self->pidl("/* [ignore] '$e->{NAME}' */");
     637        } elsif ($l->{TYPE} eq "POINTER" and $deferred) {
    630638                my $rel_var_name = $var_name;
    631639                if ($l->{POINTER_TYPE} ne "ref") {
     
    663671
    664672                if ((($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) and not $array_pointless) {
    665                         $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
     673                        $self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
    666674                        $self->indent;
    667675                        $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 0);
     
    671679
    672680                if ($deferred and ContainsDeferred($e, $l) and not $array_pointless) {
    673                         $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
     681                        $self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
    674682                        $self->indent;
    675683                        $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 0, 1);
     
    730738
    731739        if ($l->{POINTER_TYPE} eq "ref") {
    732                 $self->pidl("if ($var_name == NULL) {");
    733                 $self->indent;
    734                 $self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
    735                 $self->deindent;
    736                 $self->pidl("}");
     740                if ($l->{LEVEL_INDEX} > 0) {
     741                        $self->pidl("if ($var_name == NULL) {");
     742                        $self->indent;
     743                        $self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
     744                        $self->deindent;
     745                        $self->pidl("}");
     746                }
    737747                if ($l->{LEVEL} eq "EMBEDDED") {
    738                         $self->pidl("NDR_CHECK(ndr_push_ref_ptr(ndr));");
     748                        $self->pidl("NDR_CHECK(ndr_push_ref_ptr(ndr)); /* $var_name */");
    739749                }
    740750        } elsif ($l->{POINTER_TYPE} eq "relative") {
     
    746756        } elsif ($l->{POINTER_TYPE} eq "full") {
    747757                $self->pidl("NDR_CHECK(ndr_push_full_ptr($ndr, $var_name));");
     758        } elsif ($l->{POINTER_TYPE} eq "ignore") {
     759                # We don't want this pointer to appear on the wire at all
     760                $self->pidl("NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));");
    748761        } else {
    749762                die("Unhandled pointer type $l->{POINTER_TYPE}");
     
    805818
    806819        return if (has_property($e, "noprint"));
     820        my $cur_depth = 0;
     821        my $ignore_depth = 0xFFFF;
    807822
    808823        if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
     
    818833
    819834        foreach my $l (@{$e->{LEVELS}}) {
     835                $cur_depth += 1;
     836
     837                if ($cur_depth > $ignore_depth) {
     838                        next;
     839                }
     840
    820841                if ($l->{TYPE} eq "POINTER") {
    821842                        $self->pidl("ndr_print_ptr($ndr, \"$e->{NAME}\", $var_name);");
     843                        if ($l->{POINTER_TYPE} eq "ignore") {
     844                                $self->pidl("/* [ignore] '$e->{NAME}' */");
     845                                $ignore_depth = $cur_depth;
     846                                last;
     847                        }
    822848                        $self->pidl("$ndr->depth++;");
    823849                        if ($l->{POINTER_TYPE} ne "ref") {
     
    833859                        }
    834860                       
    835                         if ($l->{IS_ZERO_TERMINATED}) {
     861                        if ($l->{IS_ZERO_TERMINATED} and not defined($l->{LENGTH_IS})) {
    836862                                $length = "ndr_string_length($var_name, sizeof(*$var_name))";
    837863                        } else {
     
    852878                                $self->pidl("$ndr->print($ndr, \"\%s: ARRAY(\%d)\", \"$e->{NAME}\", (int)$length);");
    853879                                $self->pidl("$ndr->depth++;");
    854                                 $self->pidl("for ($counter=0;$counter<$length;$counter++) {");
     880                                $self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
    855881                                $self->indent;
    856882
     
    867893
    868894        foreach my $l (reverse @{$e->{LEVELS}}) {
     895                $cur_depth -= 1;
     896
     897                if ($cur_depth > $ignore_depth) {
     898                        next;
     899                }
     900
    869901                if ($l->{TYPE} eq "POINTER") {
     902                        if ($l->{POINTER_TYPE} eq "ignore") {
     903                                next;
     904                        }
     905
    870906                        if ($l->{POINTER_TYPE} ne "ref") {
    871907                                $self->deindent;
     
    10071043
    10081044        return undef unless ($l->{TYPE} eq "POINTER" or $l->{TYPE} eq "ARRAY");
     1045        return undef if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ignore"));
    10091046
    10101047        return undef unless ($l->{TYPE} ne "ARRAY" or ArrayDynamicallyAllocated($e,$l));
     
    11151152
    11161153        # add additional constructions
    1117         if ($l->{TYPE} eq "POINTER" and $deferred) {
     1154        if ($l->{TYPE} eq "POINTER" and $l->{POINTER_TYPE} eq "ignore") {
     1155                $self->pidl("/* [ignore] '$e->{NAME}' */");
     1156        } elsif ($l->{TYPE} eq "POINTER" and $deferred) {
    11181157                if ($l->{POINTER_TYPE} ne "ref") {
    11191158                        $self->pidl("if ($var_name) {");
     
    11351174
    11361175                if ($l->{POINTER_TYPE} ne "ref") {
    1137                         if ($l->{POINTER_TYPE} eq "relative") {
     1176                        if ($l->{POINTER_TYPE} eq "relative" or $l->{POINTER_TYPE} eq "relative_short") {
    11381177                                $self->pidl("if ($ndr->offset > $ndr->relative_highest_offset) {");
    11391178                                $self->indent;
     
    11671206                        }
    11681207
    1169                         $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
     1208                        $self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
    11701209                        $self->indent;
    11711210                        $self->ParseElementPullLevel($e, $nl, $ndr, $var_name, $env, 1, 0);
     
    11751214
    11761215                if ($deferred and ContainsDeferred($e, $l)) {
    1177                         $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
     1216                        $self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
    11781217                        $self->indent;
    11791218                        $self->ParseElementPullLevel($e,GetNextLevel($e,$l), $ndr, $var_name, $env, 0, 1);
     
    12561295        } elsif ($l->{POINTER_TYPE} eq "relative_short") {
    12571296                $self->pidl("NDR_CHECK(ndr_pull_relative_ptr_short($ndr, &_ptr_$e->{NAME}));");
     1297        } elsif ($l->{POINTER_TYPE} eq "ignore") {
     1298                #We want to consume the pointer bytes, but ignore the pointer value
     1299                $self->pidl("NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &_ptr_$e->{NAME}));");
     1300                $self->pidl("_ptr_$e->{NAME} = 0;");
    12581301        } else {
    12591302                die("Unhandled pointer type $l->{POINTER_TYPE}");
     
    12631306        $self->indent;
    12641307
    1265         # Don't do this for arrays, they're allocated at the actual level
    1266         # of the array
    1267         unless ($next_is_array or $next_is_string) {
    1268                 $self->pidl("NDR_PULL_ALLOC($ndr, $var_name);");
     1308        if ($l->{POINTER_TYPE} eq "ignore") {
     1309                # Don't do anything, we don't want to do the
     1310                # allocation, as we forced it to NULL just above, and
     1311                # we may not know the declared type anyway.
    12691312        } else {
    1270                 # FIXME: Yes, this is nasty.
    1271                 # We allocate an array twice
    1272                 # - once just to indicate that it's there,
    1273                 # - then the real allocation...
    1274                 $self->pidl("NDR_PULL_ALLOC($ndr, $var_name);");
     1313                # Don't do this for arrays, they're allocated at the actual level
     1314                # of the array
     1315                unless ($next_is_array or $next_is_string) {
     1316                       $self->pidl("NDR_PULL_ALLOC($ndr, $var_name);");
     1317                } else {
     1318                       # FIXME: Yes, this is nasty.
     1319                       # We allocate an array twice
     1320                       # - once just to indicate that it's there,
     1321                       # - then the real allocation...
     1322                       $self->pidl("NDR_PULL_ALLOC($ndr, $var_name);");
     1323                }
    12751324        }
    12761325
     
    12851334}
    12861335
     1336sub CheckRefPtrs($$$$)
     1337{
     1338        my ($self,$e,$ndr,$env) = @_;
     1339
     1340        return if ContainsPipe($e, $e->{LEVELS}[0]);
     1341        return if ($e->{LEVELS}[0]->{TYPE} ne "POINTER");
     1342        return if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref");
     1343
     1344        my $var_name = $env->{$e->{NAME}};
     1345        $var_name = append_prefix($e, $var_name);
     1346
     1347        $self->pidl("if ($var_name == NULL) {");
     1348        $self->indent;
     1349        $self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
     1350        $self->deindent;
     1351        $self->pidl("}");
     1352}
     1353
    12871354sub ParseStructPushPrimitives($$$$$)
    12881355{
    12891356        my ($self, $struct, $ndr, $varname, $env) = @_;
     1357
     1358        $self->CheckRefPtrs($_, $ndr, $env) foreach (@{$struct->{ELEMENTS}});
    12901359
    12911360        # see if the structure contains a conformant array. If it
     
    13071376                                        $size = "ndr_string_length($varname->$e->{NAME}, sizeof(*$varname->$e->{NAME}))";
    13081377                                }
     1378                                if (defined($e->{LEVELS}[0]->{SIZE_IS})) {
     1379                                        $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL});
     1380                                }
    13091381                        } else {
    13101382                                $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL});
     
    13571429        $self->start_flags($struct, $ndr);
    13581430
     1431        $self->pidl("NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);");
    13591432        $self->pidl("if (ndr_flags & NDR_SCALARS) {");
    13601433        $self->indent;
     
    16101683        foreach my $l (@{$e->{LEVELS}}) {
    16111684                my $mem_flags = $self->ParseMemCtxPullFlags($e, $l);
     1685
     1686                if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ignore")) {
     1687                        last;
     1688                }
     1689
    16121690                if (defined($mem_flags)) {
    1613                         $self->pidl("TALLOC_CTX *_mem_save_$e->{NAME}_$l->{LEVEL_INDEX};");
     1691                        $self->pidl("TALLOC_CTX *_mem_save_$e->{NAME}_$l->{LEVEL_INDEX} = NULL;");
    16141692                }
    16151693        }
     
    16741752        my $env = GenerateStructEnv($struct, $varname);
    16751753
     1754        $self->pidl("NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);");
    16761755        $self->pidl("if (ndr_flags & NDR_SCALARS) {");
    16771756        $self->indent;
     
    17781857                        }
    17791858                        $self->DeclareArrayVariables($el);
    1780                         $self->ParseElementPush($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
     1859                        my $el_env = {$el->{NAME} => "$varname->$el->{NAME}"};
     1860                        $self->CheckRefPtrs($el, $ndr, $el_env);
     1861                        $self->ParseElementPush($el, $ndr, $el_env, 1, 0);
    17811862                        $self->deindent;
    17821863                }
     
    18371918        $self->start_flags($e, $ndr);
    18381919
     1920        $self->pidl("NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);");
    18391921        $self->pidl("if (ndr_flags & NDR_SCALARS) {");
    18401922        $self->indent;
     
    20142096        $self->pidl("level = ndr_pull_get_switch_value($ndr, $varname);");
    20152097
     2098        $self->pidl("NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);");
    20162099        $self->pidl("if (ndr_flags & NDR_SCALARS) {");
    20172100        $self->indent;
     
    22962379        }
    22972380
     2381        $self->pidl("NDR_PUSH_CHECK_FN_FLAGS(ndr, flags);");
     2382
    22982383        $self->pidl("if (flags & NDR_IN) {");
    22992384        $self->indent;
     
    23022387
    23032388        EnvSubstituteValue($env, $fn);
     2389
     2390        foreach my $e (@{$fn->{ELEMENTS}}) {
     2391                if (grep(/in/,@{$e->{DIRECTION}})) {
     2392                        $self->CheckRefPtrs($e, $ndr, $env);
     2393                }
     2394        }
    23042395
    23052396        foreach my $e (@{$fn->{ELEMENTS}}) {
     
    23162407
    23172408        $env = GenerateFunctionOutEnv($fn);
     2409        EnvSubstituteValue($env, $fn);
     2410
     2411        foreach my $e (@{$fn->{ELEMENTS}}) {
     2412                if (grep(/out/,@{$e->{DIRECTION}})) {
     2413                        $self->CheckRefPtrs($e, $ndr, $env);
     2414                }
     2415        }
     2416
    23182417        foreach my $e (@{$fn->{ELEMENTS}}) {
    23192418                if (grep(/out/,@{$e->{DIRECTION}})) {
     
    23822481                $double_cases{"$e->{NAME}"} = 1;
    23832482        }
     2483
     2484        $self->pidl("NDR_PULL_CHECK_FN_FLAGS(ndr, flags);");
    23842485
    23852486        $self->pidl("if (flags & NDR_IN) {");
     
    27042805                my $name = uc $interface->{NAME};
    27052806                $self->pidl_hdr("#define NDR_$name\_UUID " .
    2706                 Parse::Pidl::Util::make_str(lc($interface->{PROPERTIES}->{uuid})));
    2707 
    2708                 if(!defined $interface->{PROPERTIES}->{version}) { $interface->{PROPERTIES}->{version} = "0.0"; }
    2709                 $self->pidl_hdr("#define NDR_$name\_VERSION $interface->{PROPERTIES}->{version}");
     2807                Parse::Pidl::Util::make_str(lc($interface->{UUID})));
     2808
     2809                $self->pidl_hdr("#define NDR_$name\_VERSION $interface->{VERSION}");
    27102810
    27112811                $self->pidl_hdr("#define NDR_$name\_NAME \"$interface->{NAME}\"");
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm

    r740 r988  
    7878        my $name = $interface->{NAME};
    7979        my $uname = uc $name;
    80         my $uuid = lc($interface->{PROPERTIES}->{uuid});
    81         my $if_version = $interface->{PROPERTIES}->{version};
     80        my $uuid = lc($interface->{UUID});
     81        my $if_version = $interface->{VERSION};
    8282
    8383        pidl "
     
    252252        }
    253253
    254         return false;   
    255 }
    256        
     254        return false;
     255}
     256
    257257NTSTATUS dcerpc_server_$name\_init(void)
    258258{
     
    290290        my $count = 0;
    291291
     292        $res .= "NTSTATUS dcerpc_server_$interface->{NAME}\_init(void);\n";
     293        $res .= "\n";
     294
    292295        if (!defined $interface->{PROPERTIES}->{uuid}) {
    293296                return $res;
     
    320323        $res .= "/* server functions auto-generated by pidl */\n";
    321324        $res .= "#include \"$header\"\n";
     325        $res .= "#include <util/debug.h>\n";
    322326        $res .= "\n";
    323327
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/Python.pm

    r740 r988  
    1111use strict;
    1212use Parse::Pidl qw(warning fatal error);
    13 use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias);
     13use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias bitmap_type_fn enum_type_fn);
    1414use Parse::Pidl::Util qw(has_property ParseExpr unmake_str);
    1515use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe is_charset_array);
     
    2323sub new($) {
    2424        my ($class) = @_;
    25         my $self = { res => "", res_hdr => "", tabs => "", constants => {},
     25        my $self = { res => "", res_hdr => "", tabs => "",
     26                                 constants => [], constants_uniq => {},
    2627                     module_methods => [], module_objects => [], ready_types => [],
    27                                  module_imports => {}, type_imports => {},
     28                                 module_imports => [], module_imports_uniq => {},
     29                                 type_imports => [], type_imports_uniq => {},
    2830                                 patch_type_calls => [], prereadycode => [],
    2931                                 postreadycode => []};
     
    9597        my ($self, $name, $type, $value) = @_;
    9698
    97         $self->{constants}->{$name} = [$type, $value];
     99        unless (defined $self->{constants_uniq}->{$name}) {
     100                my $h = {"key" => $name, "val" => [$type, $value]};
     101                push @{$self->{constants}}, $h;
     102                $self->{constants_uniq}->{$name} = $h;
     103        }
    98104}
    99105
     
    107113                $e =~ /^([A-Za-z0-9_]+)/;
    108114                my $cname = $1;
    109                
     115
    110116                $self->register_constant($cname, $d, $cname);
    111117        }
     
    201207                        $self->pidl("{");
    202208                        $self->indent;
    203                         $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(obj);");
     209                        $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(obj);");
    204210                        $self->pidl("PyObject *py_$e->{NAME};");
    205                         $self->ConvertObjectToPython("py_talloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}", "return NULL;");
     211                        $self->ConvertObjectToPython("pytalloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}", "return NULL;");
    206212                        $self->pidl("return py_$e->{NAME};");
    207213                        $self->deindent;
     
    212218                        $self->pidl("{");
    213219                        $self->indent;
    214                         $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
    215                         my $mem_ctx = "py_talloc_get_mem_ctx(py_obj)";
     220                        $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
     221                        my $mem_ctx = "pytalloc_get_mem_ctx(py_obj)";
    216222                        my $l = $e->{LEVELS}[0];
    217223                        my $nl = GetNextLevel($e, $l);
    218                         if ($l->{TYPE} eq "POINTER" and 
     224                        if ($l->{TYPE} eq "POINTER" and
    219225                                not ($nl->{TYPE} eq "ARRAY" and ($nl->{IS_FIXED} or is_charset_array($e, $nl))) and
    220226                                not ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE}))) {
    221                                 $self->pidl("talloc_unlink(py_talloc_get_mem_ctx(py_obj), $varname);");
     227                                $self->pidl("talloc_unlink($mem_ctx, discard_const($varname));");
    222228                        }
    223229                        $self->ConvertObjectFromPython($env, $mem_ctx, $e, "value", $varname, "return -1;");
     
    232238                $self->indent;
    233239                foreach my $e (@{$d->{ELEMENTS}}) {
    234                         $self->pidl("{ discard_const_p(char, \"$e->{NAME}\"), py_$name\_get_$e->{NAME}, py_$name\_set_$e->{NAME} },");
    235                 }
    236                 $self->pidl("{ NULL }");
     240                        $self->pidl("{");
     241                        $self->indent;
     242                        $self->pidl(".name = discard_const_p(char, \"$e->{NAME}\"),");
     243                        $self->pidl(".get = py_$name\_get_$e->{NAME},");
     244                        $self->pidl(".set = py_$name\_set_$e->{NAME},");
     245                        $self->pidl(".doc = discard_const_p(char, \"PIDL-generated element $e->{NAME}\")");
     246                        $self->deindent;
     247                        $self->pidl("},");
     248                }
     249                $self->pidl("{ .name = NULL }");
    237250                $self->deindent;
    238251                $self->pidl("};");
     
    243256        $self->pidl("{");
    244257        $self->indent;
    245         $self->pidl("return py_talloc_new($cname, type);");
     258        $self->pidl("return pytalloc_new($cname, type);");
    246259        $self->deindent;
    247260        $self->pidl("}");
     
    250263        my $py_methods = "NULL";
    251264
    252         # If the struct is not public there ndr_pull/ndr_push functions will 
     265        # If the struct is not public there ndr_pull/ndr_push functions will
    253266        # be static so not callable from here
    254267        if (has_property($d, "public")) {
     
    256269                $self->pidl("{");
    257270                $self->indent;
    258                 $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
     271                $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
     272                $self->pidl("PyObject *ret = NULL;");
    259273                $self->pidl("DATA_BLOB blob;");
    260274                $self->pidl("enum ndr_err_code err;");
    261                 $self->pidl("err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_$name);");
     275                $self->pidl("TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));");
     276                $self->pidl("if (tmp_ctx == NULL) {");
     277                $self->indent;
     278                $self->pidl("PyErr_SetNdrError(NDR_ERR_ALLOC);");
     279                $self->pidl("return NULL;");
     280                $self->deindent;
     281                $self->pidl("}");
     282                $self->pidl("err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_$name);");
    262283                $self->pidl("if (err != NDR_ERR_SUCCESS) {");
    263284                $self->indent;
     285                $self->pidl("TALLOC_FREE(tmp_ctx);");
    264286                $self->pidl("PyErr_SetNdrError(err);");
    265287                $self->pidl("return NULL;");
     
    267289                $self->pidl("}");
    268290                $self->pidl("");
    269                 $self->pidl("return PyString_FromStringAndSize((char *)blob.data, blob.length);");
    270                 $self->deindent;
    271                 $self->pidl("}");
    272                 $self->pidl("");
    273 
    274                 $self->pidl("static PyObject *py_$name\_ndr_unpack(PyObject *py_obj, PyObject *args)");
     291                $self->pidl("ret = PyString_FromStringAndSize((char *)blob.data, blob.length);");
     292                $self->pidl("TALLOC_FREE(tmp_ctx);");
     293                $self->pidl("return ret;");
     294                $self->deindent;
     295                $self->pidl("}");
     296                $self->pidl("");
     297
     298                $self->pidl("static PyObject *py_$name\_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)");
    275299                $self->pidl("{");
    276300                $self->indent;
    277                 $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
     301                $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
    278302                $self->pidl("DATA_BLOB blob;");
     303                $self->pidl("Py_ssize_t blob_length = 0;");
    279304                $self->pidl("enum ndr_err_code err;");
    280                 $self->pidl("if (!PyArg_ParseTuple(args, \"s#:__ndr_unpack__\", &blob.data, &blob.length))");
    281                 $self->pidl("\treturn NULL;");
    282                 $self->pidl("");
    283                 $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
     305                $self->pidl("const char * const kwnames[] = { \"data_blob\", \"allow_remaining\", NULL };");
     306                $self->pidl("PyObject *allow_remaining_obj = NULL;");
     307                $self->pidl("bool allow_remaining = false;");
     308                $self->pidl("");
     309                $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s#|O:__ndr_unpack__\",");
     310                $self->indent;
     311                $self->pidl("discard_const_p(char *, kwnames),");
     312                $self->pidl("&blob.data, &blob_length,");
     313                $self->pidl("&allow_remaining_obj)) {");
     314                $self->deindent;
     315                $self->indent;
     316                $self->pidl("return NULL;");
     317                $self->deindent;
     318                $self->pidl("}");
     319                $self->pidl("blob.length = blob_length;");
     320                $self->pidl("");
     321                $self->pidl("if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {");
     322                $self->indent;
     323                $self->pidl("allow_remaining = true;");
     324                $self->deindent;
     325                $self->pidl("}");
     326                $self->pidl("");
     327                $self->pidl("if (allow_remaining) {");
     328                $self->indent;
     329                $self->pidl("err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
     330                $self->deindent;
     331                $self->pidl("} else {");
     332                $self->indent;
     333                $self->pidl("err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
     334                $self->deindent;
     335                $self->pidl("}");
    284336                $self->pidl("if (err != NDR_ERR_SUCCESS) {");
    285337                $self->indent;
     
    297349                $self->pidl("{");
    298350                $self->indent;
    299                 $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
     351                $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
    300352                $self->pidl("PyObject *ret;");
    301353                $self->pidl("char *retstr;");
    302354                $self->pidl("");
    303                 $self->pidl("retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_$name, \"$name\", object);");
     355                $self->pidl("retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_$name, \"$name\", object);");
    304356                $self->pidl("ret = PyString_FromString(retstr);");
    305357                $self->pidl("talloc_free(retstr);");
     
    314366                $self->indent;
    315367                $self->pidl("{ \"__ndr_pack__\", (PyCFunction)py_$name\_ndr_pack, METH_NOARGS, \"S.ndr_pack(object) -> blob\\nNDR pack\" },");
    316                 $self->pidl("{ \"__ndr_unpack__\", (PyCFunction)py_$name\_ndr_unpack, METH_VARARGS, \"S.ndr_unpack(class, blob) -> None\\nNDR unpack\" },");
     368                $self->pidl("{ \"__ndr_unpack__\", (PyCFunction)py_$name\_ndr_unpack, METH_VARARGS|METH_KEYWORDS, \"S.ndr_unpack(class, blob, allow_remaining=False) -> None\\nNDR unpack\" },");
    317369                $self->pidl("{ \"__ndr_print__\", (PyCFunction)py_$name\_ndr_print, METH_VARARGS, \"S.ndr_print(object) -> None\\nNDR print\" },");
    318370                $self->pidl("{ NULL, NULL, 0, NULL }");
     
    322374        }
    323375
    324         $self->pidl_hdr("staticforward PyTypeObject $name\_Type;\n");
     376        $self->pidl_hdr("static PyTypeObject $name\_Type;\n");
    325377        $self->pidl("");
    326378        my $docstring = $self->DocString($d, $name);
     
    336388        $self->pidl(".tp_methods = $py_methods,");
    337389        $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
    338         $self->pidl(".tp_basicsize = sizeof(py_talloc_Object),");
    339390        $self->pidl(".tp_new = py_$name\_new,");
    340391        $self->deindent;
     
    343394        $self->pidl("");
    344395
    345         my $talloc_typename = $self->import_type_variable("talloc", "Object");
    346         $self->register_module_prereadycode(["$name\_Type.tp_base = $talloc_typename;", ""]);
     396        my $talloc_typename = $self->import_type_variable("talloc", "BaseObject");
     397        $self->register_module_prereadycode(["$name\_Type.tp_base = $talloc_typename;",
     398                                             "$name\_Type.tp_basicsize = pytalloc_BaseObject_size();",
     399                                             ""]);
    347400
    348401        return "&$typeobject";
     
    372425                foreach my $dir (@{$e->{DIRECTION}}) {
    373426                         my $main = get_metadata_var($e);
    374                          if ($main) { 
    375                                  $metadata_args->{$dir}->{$main} = $e->{NAME}; 
     427                         if ($main) {
     428                                 $metadata_args->{$dir}->{$main} = $e->{NAME};
    376429                         }
    377430                 }
     
    399452        foreach my $e (@{$fn->{ELEMENTS}}) {
    400453                next unless (grep(/out/,@{$e->{DIRECTION}}));
    401                 next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or 
     454                next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
    402455                         ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
    403456                $self->pidl("PyObject *py_$e->{NAME};");
     
    482535        foreach my $e (@{$fn->{ELEMENTS}}) {
    483536                next unless (grep(/in/,@{$e->{DIRECTION}}));
    484                 next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or 
     537                next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
    485538                                 ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
    486539                $self->pidl("PyObject *py_$e->{NAME};");
     
    612665        if ($actual_ctype->{TYPE} eq "UNION" and defined($actual_ctype->{ELEMENTS})) {
    613666                $self->pidl("PyObject *py_import_$d->{NAME}(TALLOC_CTX *mem_ctx, int level, " .mapTypeName($d) . " *in)");
     667                $self->pidl_hdr("PyObject *py_import_$d->{NAME}(TALLOC_CTX *mem_ctx, int level, " .mapTypeName($d) . " *in);\n");
    614668                $self->pidl("{");
    615669                $self->indent;
     
    620674
    621675                $self->pidl(mapTypeName($d) . " *py_export_$d->{NAME}(TALLOC_CTX *mem_ctx, int level, PyObject *in)");
     676                $self->pidl_hdr(mapTypeName($d) . " *py_export_$d->{NAME}(TALLOC_CTX *mem_ctx, int level, PyObject *in);\n");
    622677                $self->pidl("{");
    623678                $self->indent;
     
    658713
    659714        if (defined $interface->{PROPERTIES}->{uuid}) {
    660                 $self->pidl_hdr("staticforward PyTypeObject $interface->{NAME}_InterfaceType;\n");
     715                $self->pidl_hdr("static PyTypeObject $interface->{NAME}_InterfaceType;\n");
    661716                $self->pidl("");
    662717
     
    704759                $self->deindent;
    705760                $self->pidl("}");
    706        
    707                 $self->pidl("");
    708 
    709                 my $signature = 
     761
     762                $self->pidl("");
     763
     764                my $signature =
    710765"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> connection\\n\"
    711766\"\\n\"
     
    741796                $self->register_module_prereadycode(["$if_typename.tp_base = $dcerpc_typename;", ""]);
    742797                $self->register_module_postreadycode(["if (!PyInterface_AddNdrRpcMethods(&$if_typename, py_ndr_$interface->{NAME}\_methods))", "\treturn;", ""]);
     798
     799
     800                $self->pidl("static PyObject *syntax_$interface->{NAME}_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)");
     801                $self->pidl("{");
     802                $self->indent;
     803                $self->pidl("return py_dcerpc_syntax_init_helper(type, args, kwargs, &ndr_table_$interface->{NAME}.syntax_id);");
     804                $self->deindent;
     805                $self->pidl("}");
     806
     807                $self->pidl("");
     808
     809                my $signature = "\"abstract_syntax()\\n\"";
     810
     811                my $docstring = $self->DocString($interface, $interface->{NAME}."_syntax");
     812
     813                if ($docstring) {
     814                        $docstring = "$signature$docstring";
     815                } else {
     816                        $docstring = $signature;
     817                }
     818
     819                my $syntax_typename = "$interface->{NAME}_SyntaxType";
     820
     821                $self->pidl("static PyTypeObject $syntax_typename = {");
     822                $self->indent;
     823                $self->pidl("PyObject_HEAD_INIT(NULL) 0,");
     824                $self->pidl(".tp_name = \"$basename.$interface->{NAME}\",");
     825                $self->pidl(".tp_doc = $docstring,");
     826                $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
     827                $self->pidl(".tp_new = syntax_$interface->{NAME}_new,");
     828                $self->deindent;
     829                $self->pidl("};");
     830
     831                $self->pidl("");
     832
     833                $self->register_module_typeobject("abstract_syntax", "&$syntax_typename");
     834                my $ndr_typename = $self->import_type_variable("samba.dcerpc.misc", "ndr_syntax_id");
     835                $self->register_module_prereadycode(["$syntax_typename.tp_base = $ndr_typename;",
     836                                                     "$syntax_typename.tp_basicsize = pytalloc_BaseObject_size();",
     837                                                     ""]);
    743838        }
    744839
     
    778873        $var_name = "dep_$var_name";
    779874
    780         $self->{module_imports}->{$var_name} = $module_path;
    781 
     875        unless (defined $self->{module_imports_uniq}->{$var_name}) {
     876                my $h = { "key" => $var_name, "val" => $module_path};
     877                push @{$self->{module_imports}}, $h;
     878                $self->{module_imports_uniq}->{$var_name} = $h;
     879        }
    782880        return $var_name;
    783881}
     
    788886
    789887        $self->register_module_import($module);
    790         unless (defined($self->{type_imports}->{$name})) {
    791                 $self->{type_imports}->{$name} = $module;
     888        unless (defined $self->{type_imports_uniq}->{$name}) {
     889                my $h = { "key" => $name, "val" => $module};
     890                push @{$self->{type_imports}}, $h;
     891                $self->{type_imports_uniq}->{$name} = $h;
    792892        }
    793893        return "$name\_Type";
     
    797897{
    798898        my ($self, $orig_ctype) = @_;
    799         # FIXME: Have a global lookup table for types that look different on the 
     899        # FIXME: Have a global lookup table for types that look different on the
    800900        # wire than they are named in C?
    801         if ($orig_ctype->{NAME} eq "dom_sid2" or $orig_ctype->{NAME} eq "dom_sid28") {
     901        if ($orig_ctype->{NAME} eq "dom_sid2" or
     902            $orig_ctype->{NAME} eq "dom_sid28" or
     903            $orig_ctype->{NAME} eq "dom_sid0") {
    802904                $orig_ctype->{NAME} = "dom_sid";
    803905        }
     906        if ($orig_ctype->{NAME} eq "spoolss_security_descriptor") {
     907                $orig_ctype->{NAME} = "security_descriptor";
     908        }
     909
    804910        my $ctype = resolveType($orig_ctype);
    805911        unless (defined($ctype->{BASEFILE})) {
     
    868974        }
    869975
    870         if ($actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP") {
     976        # We need to cover ENUMs, BITMAPS and SCALAR values here, as
     977        # all could otherwise be assigned invalid integer values
     978        my $ctype_alias = "";
     979        my $uint_max = "";
     980        if ($actual_ctype->{TYPE} eq "ENUM") {
     981                # Importantly, ENUM values are unsigned in pidl, and
     982                # typically map to uint32
     983                $ctype_alias = enum_type_fn($actual_ctype);
     984        } elsif ($actual_ctype->{TYPE} eq "BITMAP") {
     985                $ctype_alias = bitmap_type_fn($actual_ctype);
     986        } elsif ($actual_ctype->{TYPE} eq "SCALAR") {
     987                $ctype_alias = expandAlias($actual_ctype->{NAME});
     988        }
     989
     990        # This is the unsigned Python Integer -> C integer validation
     991        # case.  The signed case is below.
     992        if ($ctype_alias  =~ /^(uint[0-9]*|hyper|udlong|udlongr
     993                                |NTTIME_hyper|NTTIME|NTTIME_1sec
     994                                |uid_t|gid_t)$/x) {
     995                $self->pidl("{");
     996                $self->indent;
     997                $self->pidl("const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof($target));");
    871998                $self->pidl("if (PyLong_Check($cvar)) {");
    872999                $self->indent;
    873                 $self->pidl("$target = PyLong_AsLongLong($cvar);");
     1000                $self->pidl("unsigned long long test_var;");
     1001                $self->pidl("test_var = PyLong_AsUnsignedLongLong($cvar);");
     1002                $self->pidl("if (PyErr_Occurred() != NULL) {");
     1003                $self->indent;
     1004                $self->pidl($fail);
     1005                $self->deindent;
     1006                $self->pidl("}");
     1007                $self->pidl("if (test_var > uint_max) {");
     1008                $self->indent;
     1009                $self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range 0 - %llu, got %llu\",\\");
     1010                $self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);");
     1011                $self->pidl($fail);
     1012                $self->deindent;
     1013                $self->pidl("}");
     1014                $self->pidl("$target = test_var;");
    8741015                $self->deindent;
    8751016                $self->pidl("} else if (PyInt_Check($cvar)) {");
    8761017                $self->indent;
    877                 $self->pidl("$target = PyInt_AsLong($cvar);");
     1018                $self->pidl("long test_var;");
     1019                $self->pidl("test_var = PyInt_AsLong($cvar);");
     1020                $self->pidl("if (test_var < 0 || test_var > uint_max) {");
     1021                $self->indent;
     1022                $self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range 0 - %llu, got %ld\",\\");
     1023                $self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);");
     1024                $self->pidl($fail);
     1025                $self->deindent;
     1026                $self->pidl("}");
     1027                $self->pidl("$target = test_var;");
    8781028                $self->deindent;
    8791029                $self->pidl("} else {");
     
    8841034                $self->deindent;
    8851035                $self->pidl("}");
     1036                $self->deindent;
     1037                $self->pidl("}");
    8861038                return;
    8871039        }
    888         if ($actual_ctype->{TYPE} eq "SCALAR" ) {
    889                 if (expandAlias($actual_ctype->{NAME}) =~ /^(u?int64|hyper|dlong|udlong|udlongr|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) {
    890                         $self->pidl("if (PyLong_Check($cvar)) {");
    891                         $self->indent;
    892                         $self->pidl("$target = PyLong_AsLongLong($cvar);");
    893                         $self->deindent;
    894                         $self->pidl("} else if (PyInt_Check($cvar)) {");
    895                         $self->indent;
    896                         $self->pidl("$target = PyInt_AsLong($cvar);");
    897                         $self->deindent;
    898                         $self->pidl("} else {");
    899                         $self->indent;
    900                         $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected type %s or %s\",\\");
    901                         $self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name);");
    902                         $self->pidl($fail);
    903                         $self->deindent;
    904                         $self->pidl("}");
    905                         return;
    906                 }
    907                 if (expandAlias($actual_ctype->{NAME}) =~ /^(char|u?int[0-9]*|time_t|uid_t|gid_t)$/) {
    908                         $self->pidl("PY_CHECK_TYPE(&PyInt_Type, $cvar, $fail);");
    909                         $self->pidl("$target = PyInt_AsLong($cvar);");
    910                         return;
    911                 }
     1040
     1041        # Confirm the signed python integer fits in the C type
     1042        # correctly.  It is subtly different from the unsigned case
     1043        # above, so while it looks like a duplicate, it is not
     1044        # actually a duplicate.
     1045        if ($ctype_alias  =~ /^(dlong|char|int[0-9]*|time_t)$/x) {
     1046                $self->pidl("{");
     1047                $self->indent;
     1048                $self->pidl("const long long int_max = ndr_sizeof2intmax(sizeof($target));");
     1049                $self->pidl("const long long int_min = -int_max - 1;");
     1050                $self->pidl("if (PyLong_Check($cvar)) {");
     1051                $self->indent;
     1052                $self->pidl("long long test_var;");
     1053                $self->pidl("test_var = PyLong_AsLongLong($cvar);");
     1054                $self->pidl("if (PyErr_Occurred() != NULL) {");
     1055                $self->indent;
     1056                $self->pidl($fail);
     1057                $self->deindent;
     1058                $self->pidl("}");
     1059                $self->pidl("if (test_var < int_min || test_var > int_max) {");
     1060                $self->indent;
     1061                $self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range %lld - %lld, got %lld\",\\");
     1062                $self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name, int_min, int_max, test_var);");
     1063                $self->pidl($fail);
     1064                $self->deindent;
     1065                $self->pidl("}");
     1066                $self->pidl("$target = test_var;");
     1067                $self->deindent;
     1068                $self->pidl("} else if (PyInt_Check($cvar)) {");
     1069                $self->indent;
     1070                $self->pidl("long test_var;");
     1071                $self->pidl("test_var = PyInt_AsLong($cvar);");
     1072                $self->pidl("if (test_var < int_min || test_var > int_max) {");
     1073                $self->indent;
     1074                $self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range %lld - %lld, got %ld\",\\");
     1075                $self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name, int_min, int_max, test_var);");
     1076                $self->pidl($fail);
     1077                $self->deindent;
     1078                $self->pidl("}");
     1079                $self->pidl("$target = test_var;");
     1080                $self->deindent;
     1081                $self->pidl("} else {");
     1082                $self->indent;
     1083                $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected type %s or %s\",\\");
     1084                $self->pidl("  PyInt_Type.tp_name, PyLong_Type.tp_name);");
     1085                $self->pidl($fail);
     1086                $self->deindent;
     1087                $self->pidl("}");
     1088                $self->deindent;
     1089                $self->pidl("}");
     1090                return;
    9121091        }
    9131092
     
    9201099                }
    9211100                $self->pidl("PY_CHECK_TYPE($ctype_name, $cvar, $fail);");
    922                 $self->pidl("if (talloc_reference($mem_ctx, py_talloc_get_mem_ctx($cvar)) == NULL) {");
     1101                $self->pidl("if (talloc_reference($mem_ctx, pytalloc_get_mem_ctx($cvar)) == NULL) {");
    9231102                $self->indent;
    9241103                $self->pidl("PyErr_NoMemory();");
     
    9261105                $self->deindent;
    9271106                $self->pidl("}");
    928                 $self->assign($target, "(".mapTypeName($ctype)." *)py_talloc_get_ptr($cvar)");
     1107                $self->assign($target, "(".mapTypeName($ctype)." *)pytalloc_get_ptr($cvar)");
    9291108                return;
    9301109        }
     
    9351114        }
    9361115
    937         if ($actual_ctype->{TYPE} eq "SCALAR" and 
     1116        if ($actual_ctype->{TYPE} eq "SCALAR" and
    9381117                ($actual_ctype->{NAME} eq "string" or $actual_ctype->{NAME} eq "nbt_string" or $actual_ctype->{NAME} eq "nbt_name" or $actual_ctype->{NAME} eq "wrepl_nbt_name")) {
    9391118                $self->pidl("$target = talloc_strdup($mem_ctx, PyString_AS_STRING($cvar));");
     
    9731152        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "WERROR") {
    9741153                $self->pidl("$target = W_ERROR(PyInt_AsLong($cvar));");
     1154                return;
     1155        }
     1156
     1157        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "HRESULT") {
     1158                $self->pidl("$target = HRES_ERROR(PyInt_AsLong($cvar));");
    9751159                return;
    9761160        }
     
    10601244                                $self->pidl("if (!$var_name) { $fail; }");
    10611245                                $self->pidl("talloc_set_name_const($var_name, \"ARRAY: $var_name\");");
     1246                        } else {
     1247                                $self->pidl("if (ARRAY_SIZE($var_name) != PyList_GET_SIZE($py_var)) {");
     1248                                $self->indent;
     1249                                $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected list of type %s, length %zu, got %zd\", Py_TYPE($py_var)->tp_name, ARRAY_SIZE($var_name),  PyList_GET_SIZE($py_var));");
     1250                                $self->pidl("$fail");
     1251                                $self->deindent;
     1252                                $self->pidl("}");
    10621253                        }
    10631254                        $self->pidl("for ($counter = 0; $counter < PyList_GET_SIZE($py_var); $counter++) {");
     
    11091300        $ctypename = expandAlias($ctypename);
    11101301
    1111         if ($ctypename =~ /^(u?int64|hyper|dlong|udlong|udlongr|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) {
    1112                 return "PyLong_FromLongLong($cvar)";
    1113         }
    1114 
    1115         if ($ctypename =~ /^(char|u?int[0-9]*|time_t|uid_t|gid_t)$/) {
     1302        if ($ctypename =~ /^(int64|dlong)$/) {
     1303                return "ndr_PyLong_FromLongLong($cvar)";
     1304        }
     1305
     1306        if ($ctypename =~ /^(uint64|hyper|NTTIME_hyper|NTTIME|NTTIME_1sec|udlong|udlongr|uid_t|gid_t)$/) {
     1307                return "ndr_PyLong_FromUnsignedLongLong($cvar)";
     1308        }
     1309
     1310        if ($ctypename =~ /^(char|int|int8|int16|int32|time_t)$/) {
    11161311                return "PyInt_FromLong($cvar)";
     1312        }
     1313
     1314        # Needed to ensure unsigned values in a 32 or 16 bit enum is
     1315        # cast correctly to a uint32_t, not sign extended to a a
     1316        # possibly 64 bit unsigned long.  (enums are signed in C,
     1317        # unsigned in NDR)
     1318        if ($ctypename =~ /^(uint32|uint3264)$/) {
     1319                return "ndr_PyLong_FromUnsignedLongLong((uint32_t)$cvar)";
     1320        }
     1321
     1322        if ($ctypename =~ /^(uint|uint8|uint16|uint1632)$/) {
     1323                return "PyInt_FromLong((uint16_t)$cvar)";
    11171324        }
    11181325
     
    11291336        }
    11301337
     1338        if ($ctypename eq "HRESULT") {
     1339                return "PyErr_FromHRESULT($cvar)";
     1340        }
     1341
    11311342        if (($ctypename eq "string" or $ctypename eq "nbt_string" or $ctypename eq "nbt_name" or $ctypename eq "wrepl_nbt_name")) {
    11321343                return "PyString_FromStringOrNULL($cvar)";
     
    11381349
    11391350        # Not yet supported
    1140         if ($ctypename eq "string_array") { return "PyCObject_FromTallocPtr($cvar)"; }
     1351        if ($ctypename eq "string_array") { return "pytalloc_CObject_FromTallocPtr($cvar)"; }
    11411352        if ($ctypename eq "ipv4address") { return "PyString_FromStringOrNULL($cvar)"; }
    11421353        if ($ctypename eq "ipv6address") { return "PyString_FromStringOrNULL($cvar)"; }
     
    11441355        if ($ctypename eq "dnsp_string") { return "PyString_FromStringOrNULL($cvar)"; }
    11451356        if ($ctypename eq "pointer") {
    1146                 return "PyCObject_FromTallocPtr($cvar)";
     1357                return "pytalloc_CObject_FromTallocPtr($cvar)";
    11471358        }
    11481359
     
    11611372        if ($actual_ctype->{TYPE} eq "TYPEDEF") {
    11621373                $actual_ctype = $actual_ctype->{DATA};
    1163         } 
    1164        
     1374        }
     1375
    11651376        if ($actual_ctype->{TYPE} eq "ENUM") {
    11661377                return $self->ConvertScalarToPython(Parse::Pidl::Typelist::enum_type_fn($actual_ctype), $cvar);
     
    11771388                        return "NULL"; # FIXME!
    11781389                }
    1179                 return "py_talloc_reference_ex($ctype_name, $mem_ctx, $cvar)";
     1390                return "pytalloc_reference_ex($ctype_name, $mem_ctx, $cvar)";
    11801391        }
    11811392
     
    12551466                        my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}";
    12561467                        $self->pidl("int $counter;");
    1257                         $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
     1468                        $self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
    12581469                        $self->indent;
    12591470                        my $member_var = "py_$e->{NAME}_$l->{LEVEL_INDEX}";
     
    13001511    $self->pidl_hdr("
    13011512/* Python wrapper functions auto-generated by pidl */
     1513#define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
    13021514#include <Python.h>
    13031515#include \"includes.h\"
     
    13081520#include \"$ndr_hdr\"
    13091521
     1522/*
     1523 * These functions are here to ensure they can be optomised out by
     1524 * the compiler based on the constant input values
     1525 */
     1526
     1527static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
     1528{
     1529        switch (var_size) {
     1530        case 8:
     1531                return UINT64_MAX;
     1532        case 4:
     1533                return UINT32_MAX;
     1534        case 2:
     1535                return UINT16_MAX;
     1536        case 1:
     1537                return UINT8_MAX;
     1538        }
     1539
     1540        return 0;
     1541}
     1542
     1543static inline long long ndr_sizeof2intmax(size_t var_size)
     1544{
     1545        switch (var_size) {
     1546        case 8:
     1547                return INT64_MAX;
     1548        case 4:
     1549                return INT32_MAX;
     1550        case 2:
     1551                return INT16_MAX;
     1552        case 1:
     1553                return INT8_MAX;
     1554        }
     1555
     1556        return 0;
     1557}
     1558
     1559static inline PyObject *ndr_PyLong_FromLongLong(long long v)
     1560{
     1561        if (v > LONG_MAX || v < LONG_MIN) {
     1562                return PyLong_FromLongLong(v);
     1563        } else {
     1564                return PyInt_FromLong(v);
     1565        }
     1566}
     1567
     1568static inline PyObject *ndr_PyLong_FromUnsignedLongLong(unsigned long long v)
     1569{
     1570        if (v > LONG_MAX) {
     1571                return PyLong_FromUnsignedLongLong(v);
     1572        } else {
     1573                return PyInt_FromLong(v);
     1574        }
     1575}
     1576
    13101577");
    13111578
     
    13141581            ($x->{TYPE} eq "INTERFACE") && $self->Interface($x, $basename);
    13151582        }
    1316        
     1583
    13171584        $self->pidl("static PyMethodDef $basename\_methods[] = {");
    13181585        $self->indent;
     
    13331600        $self->indent;
    13341601        $self->pidl("PyObject *m;");
    1335         foreach (keys %{$self->{module_imports}}) {
    1336                 $self->pidl("PyObject *$_;");
     1602        foreach my $h (@{$self->{module_imports}}) {
     1603                $self->pidl("PyObject *$h->{'key'};");
    13371604        }
    13381605        $self->pidl("");
    13391606
    1340         foreach (keys %{$self->{module_imports}}) {
    1341                 my $var_name = $_;
    1342                 my $module_path = $self->{module_imports}->{$var_name};
     1607        foreach my $h (@{$self->{module_imports}}) {
     1608                my $var_name = $h->{'key'};
     1609                my $module_path = $h->{'val'};
    13431610                $self->pidl("$var_name = PyImport_ImportModule(\"$module_path\");");
    13441611                $self->pidl("if ($var_name == NULL)");
     
    13471614        }
    13481615
    1349         foreach (keys %{$self->{type_imports}}) {
    1350                 my $type_var = "$_\_Type";
    1351                 my $module_path = $self->{type_imports}->{$_};
     1616        foreach my $h (@{$self->{type_imports}}) {
     1617                my $type_var = "$h->{'key'}\_Type";
     1618                my $module_path = $h->{'val'};
    13521619                $self->pidl_hdr("static PyTypeObject *$type_var;\n");
    1353                 my $pretty_name = PrettifyTypeName($_, $module_path);
     1620                my $pretty_name = PrettifyTypeName($h->{'key'}, $module_path);
    13541621                my $module_var = "dep_$module_path";
    13551622                $module_var =~ s/\./_/g;
     
    13821649        $self->pidl("\treturn;");
    13831650        $self->pidl("");
    1384         foreach my $name (keys %{$self->{constants}}) {
     1651        foreach my $h (@{$self->{constants}}) {
     1652                my $name = $h->{'key'};
    13851653                my $py_obj;
    1386                 my ($ctype, $cvar) = @{$self->{constants}->{$name}};
     1654                my ($ctype, $cvar) = @{$h->{'val'}};
    13871655                if ($cvar =~ /^[0-9]+$/ or $cvar =~ /^0x[0-9a-fA-F]+$/) {
    1388                         $py_obj = "PyInt_FromLong($cvar)";
     1656                        $py_obj = "ndr_PyLong_FromUnsignedLongLong($cvar)";
    13891657                } elsif ($cvar =~ /^".*"$/) {
    13901658                        $py_obj = "PyString_FromString($cvar)";
  • vendor/current/pidl/lib/Parse/Pidl/Samba4/Template.pm

    r414 r988  
    88use vars qw($VERSION);
    99$VERSION = '0.01';
     10
     11use Parse::Pidl::Util qw(genpad);
    1012
    1113use strict;
     
    2123        my $name = $interface->{NAME};
    2224
    23         $res .= 
    24 "/* 
     25        $res .=
     26"/*
    2527   Unix SMB/CIFS implementation.
    2628
     
    2830
    2931   Copyright (C) YOUR NAME HERE YEAR
    30    
     32
    3133   This program is free software; you can redistribute it and/or modify
    3234   it under the terms of the GNU General Public License as published by
    3335   the Free Software Foundation; either version 3 of the License, or
    3436   (at your option) any later version.
    35    
     37
    3638   This program is distributed in the hope that it will be useful,
    3739   but WITHOUT ANY WARRANTY; without even the implied warranty of
    3840   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3941   GNU General Public License for more details.
    40    
     42
    4143   You should have received a copy of the GNU General Public License
    4244   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    5355                if ($d->{TYPE} eq "FUNCTION") {
    5456                        my $fname = $d->{NAME};
     57                        my $pad = genpad("static $d->{RETURN_TYPE} dcesrv_$fname");
    5558                        $res .=
    5659"
    57 /* 
    58   $fname 
     60/*
     61  $fname
    5962*/
    60 static $d->{RETURN_TYPE} dcesrv_$fname(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    61                        struct $fname *r)
     63
     64static $d->{RETURN_TYPE} dcesrv_$fname(struct dcesrv_call_state *dce_call,
     65$pad"."TALLOC_CTX *mem_ctx,
     66$pad"."struct $fname *r)
    6267{
    6368";
     
    7580        }
    7681
    77         $res .= 
     82        $res .=
    7883"
    7984/* include the generated boilerplate */
     
    9095        $res = "";
    9196        foreach my $x (@{$idl}) {
    92                 ($x->{TYPE} eq "INTERFACE") && 
     97                ($x->{TYPE} eq "INTERFACE") &&
    9398                    Template($x);
    9499        }
  • vendor/current/pidl/lib/Parse/Pidl/Typelist.pm

    r740 r988  
    6161        "NTTIME_hyper"  => "NTTIME",
    6262        "WERROR"        => "WERROR",
     63        "HRESULT"       => "HRESULT",
    6364        "NTSTATUS"      => "NTSTATUS",
    6465        "COMRESULT" => "COMRESULT",
     
    8485        "short" => "int16",
    8586        "HYPER_T" => "hyper",
    86         "HRESULT" => "COMRESULT",
     87        "mode_t"        => "uint32",
    8788);
    8889
  • vendor/current/pidl/lib/Parse/Pidl/Util.pm

    r414 r988  
    77require Exporter;
    88@ISA = qw(Exporter);
    9 @EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper);
     9@EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper genpad);
    1010use vars qw($VERSION);
    1111$VERSION = '0.01';
     
    4444{
    4545        require Data::Dumper;
     46        $Data::Dumper::Sortkeys = 1;
    4647        my $s = shift;
    4748        return Data::Dumper::Dumper($s);
     
    176177}
    177178
     179=item B<genpad>
     180return an empty string consisting of tabs and spaces suitable for proper indent
     181of C-functions.
     182
     183=cut
     184sub genpad($)
     185{
     186        my ($s) = @_;
     187        my $nt = int((length($s)+1)/8);
     188        my $lt = ($nt*8)-1;
     189        my $ns = (length($s)-$lt);
     190        return "\t"x($nt)." "x($ns);
     191}
     192
    178193=back
    179194
  • vendor/current/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm

    r740 r988  
    2222Conformance files are simple text files with a single command on each line.
    2323Empty lines and lines starting with a '#' character are ignored.
    24 Arguments to commands are seperated by spaces.
     24Arguments to commands are separated by spaces.
    2525
    2626The following commands are currently supported:
     
    6060
    6161Remove the specified prefix from all function names (if present).
    62        
     62
    6363=item I<PROTOCOL> longname shortname filtername
    6464
     
    270270
    271271        if (defined($type)) {
    272             $data->{noemit}->{$type} = 1;
     272                $data->{noemit}->{$type} = 1;
    273273        } else {
    274             $data->{noemit_dissector} = 1;
     274                $data->{noemit_dissector} = 1;
    275275        }
    276276}
     
    285285        }
    286286
    287     $data->{manual}->{$fn} = 1;
     287        $data->{manual}->{$fn} = 1;
    288288}
    289289
     
    364364my %field_handlers = (
    365365        TYPE => \&handle_type,
    366         NOEMIT => \&handle_noemit, 
     366        NOEMIT => \&handle_noemit,
    367367        MANUAL => \&handle_manual,
    368         PARAM_VALUE => \&handle_param_value, 
    369         HF_FIELD => \&handle_hf_field, 
    370         HF_RENAME => \&handle_hf_rename, 
     368        PARAM_VALUE => \&handle_param_value,
     369        HF_FIELD => \&handle_hf_field,
     370        HF_RENAME => \&handle_hf_rename,
    371371        ETT_FIELD => \&handle_ett_field,
    372372        TFS => \&handle_tfs,
  • vendor/current/pidl/lib/Parse/Pidl/Wireshark/NDR.pm

    r740 r988  
    2828use Parse::Pidl::Dump qw(DumpType DumpFunction);
    2929use Parse::Pidl::Wireshark::Conformance qw(ReadConformance);
    30 use File::Basename;     
     30use File::Basename;
    3131
    3232use vars qw($VERSION);
     
    5858sub field2name($)
    5959{
    60     my($field) = shift;
    61 
    62     $field =~ s/_/ /g;          # Replace underscores with spaces
    63     $field =~ s/(\w+)/\u\L$1/g; # Capitalise each word
    64    
    65     return $field;
     60        my($field) = shift;
     61
     62        $field =~ s/_/ /g;              # Replace underscores with spaces
     63        $field =~ s/(\w+)/\u\L$1/g;     # Capitalise each word
     64
     65        return $field;
    6666}
    6767
     
    9292        my ($self, $d) = @_;
    9393        return if (defined($self->{cur_fn}) and defined($self->{conformance}->{manual}->{$self->{cur_fn}}));
    94  
     94
    9595        if ($d) {
    9696                $self->{res}->{code} .= $self->{tabs};
     
    144144        return if (defined($self->{conformance}->{noemit}->{StripPrefixes($name, $self->{conformance}->{strip_prefixes})}));
    145145
    146         foreach (@{$e->{ELEMENTS}}) {
     146        foreach (@{$e->{ELEMENTS}}) {
    147147                if (/([^=]*)=(.*)/) {
    148148                        $self->pidl_hdr("#define $1 ($2)");
    149149                }
    150150        }
    151        
     151
    152152        $self->pidl_hdr("extern const value_string $valsstring\[];");
    153         $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 *param _U_);");
     153        $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_);");
    154154
    155155        $self->pidl_def("const value_string ".$valsstring."[] = {");
    156         foreach (@{$e->{ELEMENTS}}) {
     156        foreach (@{$e->{ELEMENTS}}) {
    157157                next unless (/([^=]*)=(.*)/);
    158158                $self->pidl_def("\t{ $1, \"$1\" },");
     
    164164        $self->pidl_fn_start($dissectorname);
    165165        $self->pidl_code("int");
    166         $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 *param _U_)");
     166        $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_)");
    167167        $self->pidl_code("{");
    168168        $self->indent;
    169169        $self->pidl_code("g$e->{BASE_TYPE} parameter=0;");
    170         $self->pidl_code("if(param){");
     170        $self->pidl_code("if (param) {");
    171171        $self->indent;
    172         $self->pidl_code("parameter=(g$e->{BASE_TYPE})*param;");
     172        $self->pidl_code("parameter = *param;");
    173173        $self->deindent;
    174174        $self->pidl_code("}");
    175175        $self->pidl_code("offset = dissect_ndr_$e->{BASE_TYPE}(tvb, offset, pinfo, tree, drep, hf_index, &parameter);");
    176         $self->pidl_code("if(param){");
     176        $self->pidl_code("if (param) {");
    177177        $self->indent;
    178         $self->pidl_code("*param=(guint32)parameter;");
     178        $self->pidl_code("*param = parameter;");
    179179        $self->deindent;
    180180        $self->pidl_code("}");
     
    187187        $enum_size =~ s/uint//g;
    188188        $self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_UINT$enum_size", "BASE_DEC", "0", "VALS($valsstring)", $enum_size / 8);
     189}
     190
     191sub Pipe($$$$)
     192{
     193        my ($self,$e,$name,$ifname) = @_;
     194        error($e->{ORIGINAL}, "Pipe not yet supported");
     195        return;
    189196}
    190197
     
    206213        $self->pidl_code("proto_tree *tree = NULL;");
    207214        $self->pidl_code("");
    208                
     215
    209216        $self->pidl_code("g$e->{BASE_TYPE} flags;");
    210217        if ($e->{ALIGN} > 1) {
     
    216223        $self->pidl_code("if (parent_tree) {");
    217224        $self->indent;
    218         $self->pidl_code("item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, $e->{ALIGN}, TRUE);");
     225        $self->pidl_code("item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, $e->{ALIGN}, DREP_ENC_INTEGER(drep));");
    219226        $self->pidl_code("tree = proto_item_add_subtree(item,ett_$ifname\_$name);");
    220227        $self->deindent;
     
    234241
    235242                $self->{hf_used}->{$hf_bitname} = 1;
    236                
     243
    237244                $self->register_hf_field($hf_bitname, field2name($en), $filtername, "FT_BOOLEAN", $e->{ALIGN} * 8, "TFS(&$name\_$en\_tfs)", $ev, "");
    238245
     
    247254                }
    248255                $self->pidl_def("};");
    249                
     256
    250257                $self->pidl_code("proto_tree_add_boolean(tree, $hf_bitname, tvb, offset-$e->{ALIGN}, $e->{ALIGN}, flags);");
    251258                $self->pidl_code("if (flags&$ev){");
     
    271278}
    272279
    273 sub ElementLevel($$$$$$$)
    274 {
    275         my ($self,$e,$l,$hf,$myname,$pn,$ifname) = @_;
    276 
    277         my $param = 0;
     280sub ElementLevel($$$$$$$$)
     281{
     282        my ($self,$e,$l,$hf,$myname,$pn,$ifname,$param) = @_;
    278283
    279284        if (defined($self->{conformance}->{dissectorparams}->{$myname})) {
     
    317322
    318323                        ($bs = 1) if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_ASCII.*"));
    319                        
     324
    320325                        if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*") and property_matches($e, "flag", ".*LIBNDR_FLAG_STR_LEN4.*")) {
    321326                                $self->pidl_code("char *data;\n");
     
    324329                        } elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*")) {
    325330                                $self->pidl_code("offset = dissect_ndr_vstring(tvb, offset, pinfo, tree, drep, $bs, $hf, FALSE, NULL);");
     331                        } elsif (property_matches($e, "flag", ".*STR_NULLTERM.*")) {
     332                                if ($bs == 2) {
     333                                        $self->pidl_code("offset = dissect_null_term_wstring(tvb, offset, pinfo, tree, drep, $hf , 0);")
     334                                } else {
     335                                        $self->pidl_code("offset = dissect_null_term_string(tvb, offset, pinfo, tree, drep, $hf , 0);")
     336                                }
    326337                        } else {
    327338                                warn("Unable to handle string with flags $e->{PROPERTIES}->{flag}");
    328339                        }
     340                } elsif ($l->{DATA_TYPE} eq "DATA_BLOB") {
     341                        my $remain = 0;
     342                        $remain = 1 if (property_matches($e->{ORIGINAL}, "flag", ".*LIBNDR_FLAG_REMAINING.*"));
     343                        $self->pidl_code("offset = dissect_ndr_datablob(tvb, offset, pinfo, tree, drep, $hf, $remain);");
    329344                } else {
    330345                        my $call;
    331346
    332347                        if ($self->{conformance}->{imports}->{$l->{DATA_TYPE}}) {
    333                                 $call = $self->{conformance}->{imports}->{$l->{DATA_TYPE}}->{DATA};     
     348                                $call = $self->{conformance}->{imports}->{$l->{DATA_TYPE}}->{DATA};
    334349                                $self->{conformance}->{imports}->{$l->{DATA_TYPE}}->{USED} = 1;
    335                         } elsif (defined($self->{conformance}->{imports}->{"$pn.$e->{NAME}"})) {
    336                                 $call = $self->{conformance}->{imports}->{"$pn.$e->{NAME}"}->{DATA};
     350
     351                        } elsif (defined($self->{conformance}->{imports}->{"$pn.$e->{NAME}"})) {
     352                                $call = $self->{conformance}->{imports}->{"$pn.$e->{NAME}"}->{DATA};
    337353                                $self->{conformance}->{imports}->{"$pn.$e->{NAME}"}->{USED} = 1;
    338                            
     354
    339355                        } elsif (defined($self->{conformance}->{types}->{$l->{DATA_TYPE}})) {
    340356                                $call= $self->{conformance}->{types}->{$l->{DATA_TYPE}}->{DISSECTOR_NAME};
    341357                                $self->{conformance}->{types}->{$l->{DATA_TYPE}}->{USED} = 1;
    342358                        } else {
    343                                 $self->pidl_code("offset = $ifname\_dissect_struct_" . $l->{DATA_TYPE} . "(tvb,offset,pinfo,tree,drep,$hf,$param);");
     359                                my $t;
     360                                if (ref($l->{DATA_TYPE}) eq "HASH" ) {
     361                                        $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}";
     362                                } else {
     363                                        $t = $l->{DATA_TYPE};
     364                                }
     365
     366                                $self->pidl_code("offset = $ifname\_dissect_struct_" . $t . "(tvb,offset,pinfo,tree,drep,$hf,$param);");
    344367
    345368                                return;
     
    351374                }
    352375        } elsif ($_->{TYPE} eq "SUBCONTEXT") {
     376                my $varswitch;
     377                if (has_property($e, "switch_is")) {
     378                        $varswitch = $e->{PROPERTIES}->{switch_is};
     379                }
    353380                my $num_bits = ($l->{HEADER_SIZE}*8);
     381                my $hf2 = $self->register_hf_field($hf."_", "Subcontext length", "$ifname.$pn.$_->{NAME}subcontext", "FT_UINT$num_bits", "BASE_HEX", "NULL", 0, "");
     382                $num_bits = 3264 if ($num_bits == 32);
     383                $self->{hf_used}->{$hf2} = 1;
     384                $self->pidl_code("dcerpc_info *di = (dcerpc_info*)pinfo->private_data;");
    354385                $self->pidl_code("guint$num_bits size;");
    355                 $self->pidl_code("int start_offset = offset;");
     386                $self->pidl_code("int conformant = di->conformant_run;");
    356387                $self->pidl_code("tvbuff_t *subtvb;");
    357                 $self->pidl_code("offset = dissect_ndr_uint$num_bits(tvb, offset, pinfo, tree, drep, $hf, &size);");
    358                 $self->pidl_code("proto_tree_add_text(tree, tvb, start_offset, offset - start_offset + size, \"Subcontext size\");");
     388                $self->pidl_code("");
     389                # We need to be able to dissect the length of the context in every case
     390                # and conformant run skips the dissections of scalars ...
     391                $self->pidl_code("if (!conformant) {");
     392                $self->indent;
     393                $self->pidl_code("guint32 saved_flags = di->call_data->flags;");
     394                $self->pidl_code("offset = dissect_ndr_uint$num_bits(tvb, offset, pinfo, tree, drep, $hf2, &size);");
     395                # This is a subcontext, there is normally no such thing as
     396                # 64 bit NDR is subcontext so we clear the flag so that we can
     397                # continue to dissect handmarshalled stuff with pidl
     398                $self->pidl_code("di->call_data->flags &= ~DCERPC_IS_NDR64;");
    359399
    360400                $self->pidl_code("subtvb = tvb_new_subset(tvb, offset, size, -1);");
    361                 $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, drep);");
     401                if ($param ne 0) {
     402                        $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, drep, $param);");
     403                } else {
     404                        $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, drep);");
     405                }
     406                $self->pidl_code("offset += size;");
     407                $self->pidl_code("di->call_data->flags = saved_flags;");
     408                $self->deindent;
     409                $self->pidl_code("}");
     410        } elsif ($_->{TYPE} eq "PIPE") {
     411                error($e->{ORIGINAL}, "Type PIPE not yet supported");
    362412        } else {
    363413                die("Unknown type `$_->{TYPE}'");
     
    365415}
    366416
    367 sub Element($$$)
    368 {
    369         my ($self,$e,$pn,$ifname) = @_;
     417sub SwitchType($$;$)
     418{
     419        my ($e, $type, $nodiscriminant) = @_;
     420
     421        my $switch_dt =  getType($type);
     422        my $switch_type = undef;
     423        if ($switch_dt->{DATA}->{TYPE} eq "ENUM") {
     424                $switch_type = Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
     425        } elsif ($switch_dt->{DATA}->{TYPE} eq "BITMAP") {
     426                $switch_type = Parse::Pidl::Typelist::bitmap_type_fn($switch_dt->{DATA});
     427        } elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") {
     428                if (defined $e->{SWITCH_TYPE}) {
     429                        $switch_type = "$e->{SWITCH_TYPE}";
     430                } else {
     431                        $switch_type = "$switch_dt->{DATA}->{NAME}";
     432                }
     433        } elsif (not defined $e->{SWITCH_TYPE}) {
     434                $switch_type = $nodiscriminant;
     435        }
     436
     437        return $switch_type
     438}
     439
     440sub Element($$$$$)
     441{
     442        my ($self,$e,$pn,$ifname,$isoruseswitch) = @_;
    370443
    371444        my $dissectorname = "$ifname\_dissect\_element\_".StripPrefixes($pn, $self->{conformance}->{strip_prefixes})."\_".StripPrefixes($e->{NAME}, $self->{conformance}->{strip_prefixes});
    372445
    373         my $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep);";
     446        my ($call_code, $moreparam);
     447        my $param = 0;
     448        if (defined $isoruseswitch) {
     449                my $type = $isoruseswitch->[0];
     450                my $name = $isoruseswitch->[1];
     451
     452                my $switch_raw_type = SwitchType($e, $type, "uint32");
     453                if (not defined($switch_raw_type)) {
     454                        die("Unknown type[$type]\n");
     455                }
     456                my $switch_type = "g${switch_raw_type}";
     457
     458                $moreparam = ", $switch_type *".$name;
     459                $param = $name;
     460                $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep, &$name);";
     461        } else {
     462                $moreparam = "";
     463                $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep);";
     464        }
     465
    374466
    375467        my $type = $self->find_type($e->{TYPE});
     
    393485                };
    394486        }
     487        if (property_matches($e, "flag", ".*LIBNDR_FLAG_ALIGN.*")) {
     488                my $align_flag = $e->{PROPERTIES}->{flag};
     489                if ($align_flag =~ m/LIBNDR_FLAG_ALIGN(\d+)/) {
     490                        $call_code = "ALIGN_TO_$1_BYTES; ".$call_code;
     491                }
     492        }
    395493
    396494        my $hf = $self->register_hf_field("hf_$ifname\_$pn\_$e->{NAME}", field2name($e->{NAME}), "$ifname.$pn.$e->{NAME}", $type->{FT_TYPE}, $type->{BASE_TYPE}, $type->{VALSSTRING}, $type->{MASK}, "");
     
    404502        my $add = "";
    405503
     504        my $oldparam = undef;
    406505        foreach (@{$e->{LEVELS}}) {
     506                if (defined $_->{SWITCH_IS}) {
     507                        $oldparam = $param;
     508                        $param = "*$param";
     509                }
    407510                next if ($_->{TYPE} eq "SWITCH");
    408                 $self->pidl_def("static int $dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_);");
     511                $self->pidl_def("static int $dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_$moreparam);");
    409512                $self->pidl_fn_start("$dissectorname$add");
    410513                $self->pidl_code("static int");
    411                 $self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)");
     514                $self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_$moreparam)");
    412515                $self->pidl_code("{");
    413516                $self->indent;
    414517
    415                 $self->ElementLevel($e,$_,$hf,$dissectorname.$add,$pn,$ifname);
     518                $self->ElementLevel($e,$_,$hf,$dissectorname.$add,$pn,$ifname,$param);
     519                if (defined $oldparam) {
     520                        $param = $oldparam;
     521                }
    416522
    417523                $self->pidl_code("");
     
    434540
    435541        foreach (@{$fn->{ELEMENTS}}) {
    436             $dissectornames{$_->{NAME}} = $self->Element($_, $fn->{NAME}, $ifname) if not defined($dissectornames{$_->{NAME}});
    437         }
    438        
     542            $dissectornames{$_->{NAME}} = $self->Element($_, $fn->{NAME}, $ifname, undef) if not defined($dissectornames{$_->{NAME}});
     543        }
     544
    439545        my $fn_name = $_->{NAME};
    440546        $fn_name =~ s/^${ifname}_//;
     
    447553        $self->indent;
    448554        if ( not defined($fn->{RETURN_TYPE})) {
    449         } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS" or $fn->{RETURN_TYPE} eq "WERROR") 
     555        } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS" or $fn->{RETURN_TYPE} eq "WERROR")
    450556        {
    451557                $self->pidl_code("guint32 status;\n");
     
    456562                        $self->pidl_code("g$fn->{RETURN_TYPE} status;\n");
    457563                } else {
    458                 error($fn, "return type `$fn->{RETURN_TYPE}' not yet supported");
     564                        error($fn, "return type `$fn->{RETURN_TYPE}' not yet supported");
    459565                }
    460566        } else {
     
    474580        } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") {
    475581                $self->pidl_code("offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep, hf\_$ifname\_status, &status);\n");
    476                 $self->pidl_code("if (status != 0 && check_col(pinfo->cinfo, COL_INFO))");
     582                $self->pidl_code("if (status != 0)");
    477583                $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, NT_errors, \"Unknown NT status 0x%08x\"));\n");
    478584                $return_types{$ifname}->{"status"} = ["NTSTATUS", "NT Error"];
    479585        } elsif ($fn->{RETURN_TYPE} eq "WERROR") {
    480586                $self->pidl_code("offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf\_$ifname\_werror, &status);\n");
    481                 $self->pidl_code("if (status != 0 && check_col(pinfo->cinfo, COL_INFO))");
     587                $self->pidl_code("if (status != 0)");
    482588                $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, WERR_errors, \"Unknown DOS error 0x%08x\"));\n");
    483                
     589
    484590                $return_types{$ifname}->{"werror"} = ["WERROR", "Windows Error"];
    485591        } elsif (my $type = getType($fn->{RETURN_TYPE})) {
     
    489595
    490596                        $self->pidl_code("offset = $return_dissect(tvb, offset, pinfo, tree, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);");
    491                         $self->pidl_code("if (status != 0 && check_col(pinfo->cinfo, COL_INFO))");
     597                        $self->pidl_code("if (status != 0)");
    492598                        $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %s\", val_to_str(status, $ifname\_$fn->{RETURN_TYPE}\_vals, \"Unknown " . $fn->{RETURN_TYPE} . " error 0x%08x\"));\n");
    493599                        $return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}];
    494600                } elsif ($type->{DATA}->{TYPE} eq "SCALAR") {
    495601                        $self->pidl_code("offset = dissect_ndr_$fn->{RETURN_TYPE}(tvb, offset, pinfo, tree, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);");
    496                         $self->pidl_code("if (status != 0 && check_col(pinfo->cinfo, COL_INFO))");
     602                        $self->pidl_code("if (status != 0)");
    497603                        $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %d\", status);\n");
    498604                        $return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}];
     
    535641
    536642        my $res = "";
    537         ($res.="\t".$self->Element($_, $name, $ifname)."\n\n") foreach (@{$e->{ELEMENTS}});
     643        my $varswitchs = {};
     644        # will contain the switch var declaration;
     645        my $vars = [];
     646        foreach (@{$e->{ELEMENTS}}) {
     647                if (has_property($_, "switch_is")) {
     648                        $varswitchs->{$_->{PROPERTIES}->{switch_is}} = [];
     649                }
     650        }
     651        foreach (@{$e->{ELEMENTS}}) {
     652                my $switch_info = undef;
     653
     654                my $v = $_->{NAME};
     655                if (scalar(grep {/^$v$/} keys(%$varswitchs)) == 1) {
     656                        # This element is one of the switch attribute
     657                        my $switch_raw_type = SwitchType($e, $_->{TYPE}, "uint32");
     658                        if (not defined($switch_raw_type)) {
     659                                die("Unknown type[$_->{TYPE}]\n");
     660                        }
     661                        my $switch_type = "g${switch_raw_type}";
     662
     663                        push @$vars, "$switch_type $v;";
     664                        $switch_info = [ $_->{TYPE}, $v ];
     665                        $varswitchs->{$v} = $switch_info;
     666                }
     667
     668                if (has_property($_, "switch_is")) {
     669                        my $varswitch = $_->{PROPERTIES}->{switch_is};
     670                        $switch_info = $varswitchs->{$varswitch};
     671                }
     672
     673                $res.="\t".$self->Element($_, $name, $ifname, $switch_info)."\n\n";
     674        }
     675
     676        my $doalign = undef;
     677        if ($e->{ALIGN} > 1 and not property_matches($e, "flag", ".*LIBNDR_FLAG_NOALIGN.*")) {
     678                $doalign = 1;
     679        } elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_NOALIGN.*")) {
     680                $doalign = 0;
     681        }
    538682
    539683        $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);");
     
    544688        $self->pidl_code("{");
    545689        $self->indent;
     690        $self->pidl_code($_) foreach (@$vars);
    546691        $self->pidl_code("proto_item *item = NULL;");
    547692        $self->pidl_code("proto_tree *tree = NULL;");
    548         if ($e->{ALIGN} > 1) {
    549                 $self->pidl_code("dcerpc_info *di = pinfo->private_data;");
     693        if (defined($doalign)) {
     694                $self->pidl_code("dcerpc_info *di = (dcerpc_info *)pinfo->private_data;");
     695                if ($doalign == 0) {
     696                        $self->pidl_code("gboolean oldalign = di->no_align;");
     697                }
    550698        }
    551699        $self->pidl_code("int old_offset;");
    552700        $self->pidl_code("");
    553701
    554         if ($e->{ALIGN} > 1) {
    555                 $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
    556         }
    557         $self->pidl_code("");
     702        if (defined($doalign)) {
     703                if ($doalign == 1) {
     704                        $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
     705                }
     706                if ($doalign == 0) {
     707                        $self->pidl_code("di->no_align = TRUE;");
     708                }
     709                $self->pidl_code("");
     710        }
    558711
    559712        $self->pidl_code("old_offset = offset;");
     
    561714        $self->pidl_code("if (parent_tree) {");
    562715        $self->indent;
    563         $self->pidl_code("item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, -1, TRUE);");
     716        $self->pidl_code("item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, -1, ENC_NA);");
    564717        $self->pidl_code("tree = proto_item_add_subtree(item, ett_$ifname\_$name);");
    565718        $self->deindent;
     
    569722
    570723        $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
    571         if ($e->{ALIGN} > 1) {
     724        if (defined($doalign) and $doalign == 1) {
    572725                $self->pidl_code("");
    573726                $self->pidl_code("if (di->call_data->flags & DCERPC_IS_NDR64) {");
     
    577730                $self->pidl_code("}");
    578731        }
     732        if (defined($doalign) and $doalign == 0) {
     733                $self->pidl_code("");
     734                $self->pidl_code("di->no_align = oldalign;");
     735        }
    579736        $self->pidl_code("");
    580737        $self->pidl_code("return offset;");
     
    593750
    594751        return if (defined($self->{conformance}->{noemit}->{StripPrefixes($name, $self->{conformance}->{strip_prefixes})}));
    595        
     752
    596753        $self->register_ett("ett_$ifname\_$name");
    597754
     
    600757                $res.="\n\t\t$_->{CASE}:\n";
    601758                if ($_->{TYPE} ne "EMPTY") {
    602                         $res.="\t\t\t".$self->Element($_, $name, $ifname)."\n";
     759                        $res.="\t\t\t".$self->Element($_, $name, $ifname, undef)."\n";
    603760                }
    604761                $res.="\t\tbreak;\n";
    605762        }
    606763
    607         my $switch_type;
    608         my $switch_dissect;
    609         my $switch_dt = getType($e->{SWITCH_TYPE});
    610         if ($switch_dt->{DATA}->{TYPE} eq "ENUM") {
    611                 $switch_type = "g".Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
    612                 $switch_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
    613         } elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") {
    614                 $switch_type = "g$e->{SWITCH_TYPE}";
    615                 $switch_dissect = "dissect_ndr_$e->{SWITCH_TYPE}";
     764        my $switch_type = undef;
     765        my $switch_dissect = undef;
     766        my $switch_raw_type = SwitchType($e, $e->{SWITCH_TYPE});
     767        if (defined($switch_raw_type)) {
     768                $switch_type = "g${switch_raw_type}";
     769                $switch_dissect = "dissect_ndr_${switch_raw_type}";
    616770        }
    617771
     
    624778        $self->pidl_code("proto_tree *tree = NULL;");
    625779        $self->pidl_code("int old_offset;");
    626         $self->pidl_code("$switch_type level;");
     780        if (!defined $switch_type) {
     781                $self->pidl_code("guint32 level = param;");
     782        } else {
     783                $self->pidl_code("$switch_type level;");
     784        }
    627785        $self->pidl_code("");
    628786
     
    637795        $self->pidl_code("");
    638796
    639         $self->pidl_code("offset = $switch_dissect(tvb, offset, pinfo, tree, drep, hf_index, &level);");
    640 
    641         if ($e->{ALIGN} > 1) {
    642                 $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
    643                 $self->pidl_code("");
     797        if (defined $switch_type) {
     798                $self->pidl_code("offset = $switch_dissect(tvb, offset, pinfo, tree, drep, hf_index, &level);");
     799
     800                if ($e->{ALIGN} > 1) {
     801                        $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
     802                        $self->pidl_code("");
     803                }
    644804        }
    645805
     
    660820{
    661821        my ($self,$const,$ifname) = @_;
    662        
     822
    663823        if (!defined($const->{ARRAY_LEN}[0])) {
    664                 $self->pidl_hdr("#define $const->{NAME}\t( $const->{VALUE} )\n");
    665         } else {
    666                 $self->pidl_hdr("#define $const->{NAME}\t $const->{VALUE}\n");
    667         }
     824                $self->pidl_hdr("#define $const->{NAME}\t( $const->{VALUE} )\n");
     825        } else {
     826                $self->pidl_hdr("#define $const->{NAME}\t $const->{VALUE}\n");
     827        }
    668828}
    669829
     
    680840
    681841        $self->PrintIdl(DumpType($e->{ORIGINAL}));
    682 
    683842        {
    684843                ENUM => \&Enum,
     
    686845                UNION => \&Union,
    687846                BITMAP => \&Bitmap,
    688                 TYPEDEF => \&Typedef
     847                TYPEDEF => \&Typedef,
     848                PIPE    => \&Pipe
    689849        }->{$e->{TYPE}}->($self, $e, $name, $ifname);
    690850}
     
    701861        $self->{res}->{code}.=$self->DumpHfList()."\n";
    702862        $self->{res}->{code}.="\n".DumpEttList($self->{ett})."\n";
    703        
     863
    704864        if (defined($x->{UUID})) {
    705             # These can be changed to non-pidl_code names if the old dissectors
    706             # in epan/dissctors are deleted.
    707    
    708             my $name = uc($x->{NAME}) . " (pidl)";
    709             my $short_name = uc($x->{NAME});
    710             my $filter_name = $x->{NAME};
    711 
    712             if (has_property($x, "helpstring")) {
    713                 $name = $x->{PROPERTIES}->{helpstring};
    714             }
    715 
    716             if (defined($self->{conformance}->{protocols}->{$x->{NAME}})) {
     865                # These can be changed to non-pidl_code names if the old
     866                # dissectors in epan/dissectors are deleted.
     867
     868                my $name = uc($x->{NAME}) . " (pidl)";
     869                my $short_name = uc($x->{NAME});
     870                my $filter_name = $x->{NAME};
     871
     872                if (has_property($x, "helpstring")) {
     873                        $name = $x->{PROPERTIES}->{helpstring};
     874                }
     875
     876                if (defined($self->{conformance}->{protocols}->{$x->{NAME}})) {
    717877                $short_name = $self->{conformance}->{protocols}->{$x->{NAME}}->{SHORTNAME};
    718878                $name = $self->{conformance}->{protocols}->{$x->{NAME}}->{LONGNAME};
    719879                $filter_name = $self->{conformance}->{protocols}->{$x->{NAME}}->{FILTERNAME};
    720             }
    721 
    722             $self->pidl_code("proto_dcerpc_$x->{NAME} = proto_register_protocol(".make_str($name).", ".make_str($short_name).", ".make_str($filter_name).");");
    723            
    724             $self->pidl_code("proto_register_field_array(proto_dcerpc_$x->{NAME}, hf, array_length (hf));");
    725             $self->pidl_code("proto_register_subtree_array(ett, array_length(ett));");
     880                }
     881
     882                $self->pidl_code("proto_dcerpc_$x->{NAME} = proto_register_protocol(".make_str($name).", ".make_str($short_name).", ".make_str($filter_name).");");
     883
     884                $self->pidl_code("proto_register_field_array(proto_dcerpc_$x->{NAME}, hf, array_length (hf));");
     885                $self->pidl_code("proto_register_subtree_array(ett, array_length(ett));");
    726886        } else {
    727             $self->pidl_code("proto_dcerpc = proto_get_id_by_filter_name(\"dcerpc\");");
    728             $self->pidl_code("proto_register_field_array(proto_dcerpc, hf, array_length(hf));");
    729             $self->pidl_code("proto_register_subtree_array(ett, array_length(ett));");
    730         }
    731            
     887                $self->pidl_code("proto_dcerpc = proto_get_id_by_filter_name(\"dcerpc\");");
     888                $self->pidl_code("proto_register_field_array(proto_dcerpc, hf, array_length(hf));");
     889                $self->pidl_code("proto_register_subtree_array(ett, array_length(ett));");
     890        }
     891
    732892        $self->deindent;
    733893        $self->pidl_code("}\n");
     
    741901        if (defined($x->{UUID})) {
    742902                $self->pidl_fn_start("proto_reg_handoff_dcerpc_$x->{NAME}");
    743             $self->pidl_code("void proto_reg_handoff_dcerpc_$x->{NAME}(void)");
    744             $self->pidl_code("{");
    745             $self->indent;
    746             $self->pidl_code("dcerpc_init_uuid(proto_dcerpc_$x->{NAME}, ett_dcerpc_$x->{NAME},");
    747             $self->pidl_code("\t&uuid_dcerpc_$x->{NAME}, ver_dcerpc_$x->{NAME},");
    748             $self->pidl_code("\t$x->{NAME}_dissectors, hf_$x->{NAME}_opnum);");
    749             $self->deindent;
    750             $self->pidl_code("}");
     903                $self->pidl_code("void proto_reg_handoff_dcerpc_$x->{NAME}(void)");
     904                $self->pidl_code("{");
     905                $self->indent;
     906                $self->pidl_code("dcerpc_init_uuid(proto_dcerpc_$x->{NAME}, ett_dcerpc_$x->{NAME},");
     907                $self->pidl_code("\t&uuid_dcerpc_$x->{NAME}, ver_dcerpc_$x->{NAME},");
     908                $self->pidl_code("\t$x->{NAME}_dissectors, hf_$x->{NAME}_opnum);");
     909                $self->deindent;
     910                $self->pidl_code("}");
    751911                $self->pidl_fn_end("proto_reg_handoff_dcerpc_$x->{NAME}");
    752912
     
    771931        foreach (@imports) {
    772932                next if($_ eq "security");
    773                 s/\.idl\"$//;
    774933                s/^\"//;
     934                s/\.idl"?$//;
    775935                $self->pidl_hdr("#include \"packet-dcerpc-$_\.h\"");
    776936        }
     
    796956                my $if_uuid = $x->{UUID};
    797957
    798             $self->pidl_def("/* Version information */\n\n");
    799            
    800             $self->pidl_def("static e_uuid_t uuid_dcerpc_$x->{NAME} = {");
    801             $self->pidl_def("\t0x" . substr($if_uuid, 1, 8)
    802                 . ", 0x" . substr($if_uuid, 10, 4)
    803             . ", 0x" . substr($if_uuid, 15, 4) . ",");
    804             $self->pidl_def("\t{ 0x" . substr($if_uuid, 20, 2)
     958                $self->pidl_def("/* Version information */\n\n");
     959
     960                $self->pidl_def("static e_uuid_t uuid_dcerpc_$x->{NAME} = {");
     961                $self->pidl_def("\t0x" . substr($if_uuid, 1, 8)
     962                . ", 0x" . substr($if_uuid, 10, 4)
     963                . ", 0x" . substr($if_uuid, 15, 4) . ",");
     964                $self->pidl_def("\t{ 0x" . substr($if_uuid, 20, 2)
    805965                . ", 0x" . substr($if_uuid, 22, 2)
    806             . ", 0x" . substr($if_uuid, 25, 2)
    807             . ", 0x" . substr($if_uuid, 27, 2)
    808             . ", 0x" . substr($if_uuid, 29, 2)
    809             . ", 0x" . substr($if_uuid, 31, 2)
    810             . ", 0x" . substr($if_uuid, 33, 2)
    811             . ", 0x" . substr($if_uuid, 35, 2) . " }");
    812             $self->pidl_def("};");
    813        
    814             my $maj = $x->{VERSION};
    815             $maj =~ s/\.(.*)$//g;
    816             $self->pidl_def("static guint16 ver_dcerpc_$x->{NAME} = $maj;");
    817             $self->pidl_def("");
     966                . ", 0x" . substr($if_uuid, 25, 2)
     967                . ", 0x" . substr($if_uuid, 27, 2)
     968                . ", 0x" . substr($if_uuid, 29, 2)
     969                . ", 0x" . substr($if_uuid, 31, 2)
     970                . ", 0x" . substr($if_uuid, 33, 2)
     971                . ", 0x" . substr($if_uuid, 35, 2) . " }");
     972                $self->pidl_def("};");
     973
     974                my $maj = 0x0000FFFF & $x->{VERSION};
     975                $maj =~ s/\.(.*)$//g;
     976                $self->pidl_def("static guint16 ver_dcerpc_$x->{NAME} = $maj;");
     977                $self->pidl_def("");
    818978        }
    819979
     
    821981
    822982        $self->Interface($x);
    823 
    824983        $self->pidl_code("\n".DumpFunctionTable($x));
    825984
    826         foreach (keys %{$return_types{$x->{NAME}}}) {
     985        foreach (sort(keys %{$return_types{$x->{NAME}}})) {
    827986                my ($type, $desc) = @{$return_types{$x->{NAME}}->{$_}};
    828987                my $dt = $self->find_type($type);
     
    8691028        $self->{conformance} = {
    8701029                imports => {},
    871                 header_fields=> {} 
     1030                header_fields=> {}
    8721031        };
    8731032
    8741033        ReadConformance($cnf_file, $self->{conformance}) or print STDERR "warning: No conformance file `$cnf_file'\n";
    875        
     1034
    8761035        foreach my $bytes (qw(1 2 4 8)) {
    8771036                my $bits = $bytes * 8;
     
    8791038                $self->register_type("int$bits", "offset = PIDL_dissect_uint$bits(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_INT$bits", "BASE_DEC", 0, "NULL", $bytes);
    8801039        }
    881                
     1040
     1041        $self->register_type("uint3264", "offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);", "FT_UINT32", "BASE_DEC", 0, "NULL", 8);
     1042        $self->register_type("hyper", "offset = dissect_ndr_uint64(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);", "FT_UINT64", "BASE_DEC", 0, "NULL", 8);
    8821043        $self->register_type("udlong", "offset = dissect_ndr_duint32(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);", "FT_UINT64", "BASE_DEC", 0, "NULL", 4);
    8831044        $self->register_type("bool8", "offset = PIDL_dissect_uint8(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_INT8", "BASE_DEC", 0, "NULL", 1);
     
    8911052        $self->register_type("time_t", "offset = dissect_ndr_time_t(tvb, offset, pinfo,tree, drep, \@HF\@, NULL);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
    8921053        $self->register_type("NTTIME_1sec", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);", "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
    893         $self->register_type("SID", "
     1054        $self->register_type("dom_sid28", "{
    8941055                dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
    895 
    8961056                di->hf_index = \@HF\@;
    8971057
     1058                offset = dissect_ndr_nt_SID28(tvb, offset, pinfo, tree, drep);
     1059        }", "FT_STRING", "BASE_NONE", 0, "NULL", 4);
     1060        $self->register_type("SID", "{
     1061                dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
     1062
     1063                di->hf_index = \@HF\@;
     1064
    8981065                offset = dissect_ndr_nt_SID_with_options(tvb, offset, pinfo, tree, drep, param);
    899         ","FT_STRING", "BASE_NONE", 0, "NULL", 4);
    900         $self->register_type("WERROR", 
     1066        }", "FT_STRING", "BASE_NONE", 0, "NULL", 4);
     1067        $self->register_type("WERROR",
    9011068                "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(WERR_errors)", 4);
    902         $self->register_type("NTSTATUS", 
     1069        $self->register_type("NTSTATUS",
    9031070                "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(NT_errors)", 4);
     1071        $self->register_type("ipv6address", "proto_tree_add_item(tree, \@HF\@, tvb, offset, 16, ENC_NA); offset += 16;", "FT_IPv6", "BASE_NONE", 0, "NULL", 16);
     1072        $self->register_type("ipv4address", "proto_tree_add_item(tree, \@HF\@, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4;", "FT_IPv4", "BASE_NONE", 0, "NULL", 4);
    9041073
    9051074}
     
    9151084        return (undef, undef) if defined($self->{conformance}->{noemit_dissector});
    9161085
    917         my $notice = 
     1086        my $notice =
    9181087"/* DO NOT EDIT
    9191088        This filter was automatically generated
    9201089        from $idl_file and $cnf_file.
    921        
    922         Pidl is a perl based IDL compiler for DCE/RPC idl files. 
     1090
     1091        Pidl is a perl based IDL compiler for DCE/RPC idl files.
    9231092        It is maintained by the Samba team, not the Wireshark team.
    924         Instructions on how to download and install Pidl can be 
     1093        Instructions on how to download and install Pidl can be
    9251094        found at http://wiki.wireshark.org/Pidl
    9261095*/
     
    9311100
    9321101        $self->{res}->{headers} = "\n";
    933         $self->{res}->{headers} .= "#ifdef HAVE_CONFIG_H\n";
    9341102        $self->{res}->{headers} .= "#include \"config.h\"\n";
    935         $self->{res}->{headers} .= "#endif\n\n";
    9361103
    9371104        $self->{res}->{headers} .= "#ifdef _MSC_VER\n";
     
    9841151
    9851152        $self->CheckUsed($self->{conformance});
    986    
     1153
    9871154        return ($parser,$header);
    9881155}
     
    9961163        my ($self, $name) = @_;
    9971164
    998         push (@{$self->{ett}}, $name); 
     1165        push (@{$self->{ett}}, $name);
    9991166}
    10001167
     
    10251192###############################################################################
    10261193
    1027 sub register_hf_field($$$$$$$$$) 
     1194sub register_hf_field($$$$$$$$$)
    10281195{
    10291196        my ($self,$index,$name,$filter_name,$ft_type,$base_type,$valsstring,$mask,$blurb) = @_;
     
    10451212        };
    10461213
    1047         if ((not defined($blurb) or $blurb eq "") and 
     1214        if ((not defined($blurb) or $blurb eq "") and
    10481215                        defined($self->{conformance}->{fielddescription}->{$index})) {
    1049                 $self->{conformance}->{header_fields}->{$index}->{BLURB} = 
     1216                $self->{conformance}->{header_fields}->{$index}->{BLURB} =
    10501217                        $self->{conformance}->{fielddescription}->{$index}->{DESCRIPTION};
    10511218                $self->{conformance}->{fielddescription}->{$index}->{USED} = 1;
     
    10551222}
    10561223
     1224sub change_hf_field_type($$$$)
     1225{
     1226        my ($self,$index,$ft_type,$base_type) = @_;
     1227        if (defined ($self->{conformance}->{hf_renames}->{$index})) {
     1228                print "Field $index has been renamed to ".$self->{conformance}->{hf_renames}->{$index}->{NEWNAME}." you can't change it's type";
     1229                return 0;
     1230        }
     1231
     1232        if (!defined ($self->{conformance}->{header_fields}->{$index})) {
     1233                print "Field $index doesn't exists";
     1234                return 0;
     1235        }
     1236        $self->{conformance}->{header_fields}->{$index}->{FT_TYPE} = $ft_type;
     1237        $self->{conformance}->{header_fields}->{$index}->{BASE_TYPE} = $base_type;
     1238        return 1;
     1239}
     1240
    10571241sub DumpHfDeclaration($)
    10581242{
     
    10621246        $res = "\n/* Header field declarations */\n";
    10631247
    1064         foreach (keys %{$self->{conformance}->{header_fields}})
     1248        foreach (sort(keys %{$self->{conformance}->{header_fields}}))
    10651249        {
    10661250                $res .= "static gint $_ = -1;\n";
     
    10721256sub make_str_or_null($)
    10731257{
    1074       my $str = shift;
    1075       if (substr($str, 0, 1) eq "\"") {
    1076               $str = substr($str, 1, length($str)-2);
    1077       }
    1078       $str =~ s/^\s*//;
    1079       $str =~ s/\s*$//;
    1080       if ($str eq "") {
    1081               return "NULL";
    1082       }
    1083       return make_str($str);
     1258        my $str = shift;
     1259        if (substr($str, 0, 1) eq "\"") {
     1260                $str = substr($str, 1, length($str)-2);
     1261        }
     1262        $str =~ s/^\s*//;
     1263        $str =~ s/\s*$//;
     1264        if ($str eq "") {
     1265                return "NULL";
     1266        }
     1267        return make_str($str);
    10841268}
    10851269
     
    10891273        my $res = "\tstatic hf_register_info hf[] = {\n";
    10901274
    1091         foreach (values %{$self->{conformance}->{header_fields}})
     1275        foreach (sort {$a->{INDEX} cmp $b->{INDEX}} values %{$self->{conformance}->{header_fields}})
    10921276        {
    1093                 $res .= "\t{ &$_->{INDEX}, 
     1277                $res .= "\t{ &$_->{INDEX},
    10941278          { ".make_str($_->{NAME}).", ".make_str($_->{FILTER}).", $_->{FT_TYPE}, $_->{BASE_TYPE}, $_->{VALSSTRING}, $_->{MASK}, ".make_str_or_null($_->{BLURB}).", HFILL }},
    10951279";
     
    11101294        my $res = "static dcerpc_sub_dissector $if->{NAME}\_dissectors[] = {\n";
    11111295        foreach (@{$if->{FUNCTIONS}}) {
    1112                 my $fn_name = $_->{NAME};
     1296                my $fn_name = $_->{NAME};
    11131297                $fn_name =~ s/^$if->{NAME}_//;
    11141298                $res.= "\t{ $_->{OPNUM}, \"$fn_name\",\n";
  • vendor/current/pidl/lib/wscript_build

    r740 r988  
    22
    33# install the pidl modules
    4 bld.INSTALL_WILDCARD('${DATAROOTDIR}/perl5', '**/*.pm', flat=False)
     4bld.INSTALL_FILES(bld.env.PERL_LIB_INSTALL_DIR,
     5                  '''
     6                  Parse/Pidl.pm
     7                  Parse/Pidl/Samba4.pm
     8                  Parse/Pidl/CUtil.pm
     9                  Parse/Pidl/Expr.pm
     10                  Parse/Pidl/Wireshark/Conformance.pm
     11                  Parse/Pidl/Wireshark/NDR.pm
     12                  Parse/Pidl/ODL.pm
     13                  Parse/Pidl/Dump.pm
     14                  Parse/Pidl/Util.pm
     15                  Parse/Pidl/Samba4/Header.pm
     16                  Parse/Pidl/Samba4/COM/Header.pm
     17                  Parse/Pidl/Samba4/COM/Proxy.pm
     18                  Parse/Pidl/Samba4/COM/Stub.pm
     19                  Parse/Pidl/Samba4/TDR.pm
     20                  Parse/Pidl/Samba4/NDR/Server.pm
     21                  Parse/Pidl/Samba4/NDR/Client.pm
     22                  Parse/Pidl/Samba4/NDR/Parser.pm
     23                  Parse/Pidl/Samba4/Python.pm
     24                  Parse/Pidl/Samba4/Template.pm
     25                  Parse/Pidl/IDL.pm
     26                  Parse/Pidl/Typelist.pm
     27                  Parse/Pidl/Samba3/ClientNDR.pm
     28                  Parse/Pidl/Samba3/ServerNDR.pm
     29                  Parse/Pidl/Compat.pm
     30                  Parse/Pidl/NDR.pm
     31                  ''',
     32                  flat=False)
     33
     34if not bld.CONFIG_SET('USING_SYSTEM_PARSE_YAPP_DRIVER'):
     35    bld.INSTALL_FILES(bld.env.PERL_LIB_INSTALL_DIR,
     36                      'Parse/Yapp/Driver.pm',
     37                      flat=False)
  • vendor/current/pidl/pidl

    r919 r988  
    2222=head1 DESCRIPTION
    2323
    24 pidl is an IDL compiler written in Perl that aims to be somewhat 
    25 compatible with the midl compiler. IDL is short for 
     24pidl is an IDL compiler written in Perl that aims to be somewhat
     25compatible with the midl compiler. IDL is short for
    2626"Interface Definition Language".
    2727
    28 pidl can generate stubs for DCE/RPC server code, DCE/RPC 
     28pidl can generate stubs for DCE/RPC server code, DCE/RPC
    2929client code and Wireshark dissectors for DCE/RPC traffic.
    3030
    31 IDL compilers like pidl take a description 
    32 of an interface as their input and use it to generate C 
    33 (though support for other languages may be added later) code that 
    34 can use these interfaces, pretty print data sent 
    35 using these interfaces, or even generate Wireshark 
    36 dissectors that can parse data sent over the 
    37 wire by these interfaces. 
    38 
    39 pidl takes IDL files in the same format as is used by midl, 
     31IDL compilers like pidl take a description
     32of an interface as their input and use it to generate C
     33(though support for other languages may be added later) code that
     34can use these interfaces, pretty print data sent
     35using these interfaces, or even generate Wireshark
     36dissectors that can parse data sent over the
     37wire by these interfaces.
     38
     39pidl takes IDL files in the same format as is used by midl,
    4040converts it to a .pidl file (which contains pidl's internal representation of the interface) and can then generate whatever output you need.
    41 .pidl files should be used for debugging purposes only. Write your 
     41.pidl files should be used for debugging purposes only. Write your
    4242interface definitions in .idl format.
    4343
    44 The goal of pidl is to implement a IDL compiler that can be used 
    45 while developing the RPC subsystem in Samba (for 
     44The goal of pidl is to implement a IDL compiler that can be used
     45while developing the RPC subsystem in Samba (for
    4646both marshalling/unmarshalling and debugging purposes).
    4747
     
    5757
    5858Show pidl version
    59                
     59
    6060=item I<--outputdir OUTNAME>
    6161
    62 Write output files to the specified directory.  Defaults to the current 
     62Write output files to the specified directory.  Defaults to the current
    6363directory.
    6464
    6565=item I<--includedir DIR>
    6666
    67 Add DIR to the search path used by the preprocessor. This option can be 
     67Add DIR to the search path used by the preprocessor. This option can be
    6868specified multiple times.
    69                
     69
    7070=item I<--parse-idl-tree>
    7171
    72 Read internal tree structure from input files rather 
     72Read internal tree structure from input files rather
    7373than assuming they contain IDL.
    7474
     
    8383=item I<--ndr-parser>
    8484
    85 Generate a C file and C header containing NDR parsers. The filename for 
    86 the parser defaults to ndr_OUTNAME.c. The header filename will be the 
     85Generate a C file and C header containing NDR parsers. The filename for
     86the parser defaults to ndr_OUTNAME.c. The header filename will be the
    8787parser filename with the extension changed from .c to .h.
    8888
    8989=item I<--tdr-parser>
    9090
    91 Generate a C file and C header containing TDR parsers. The filename for 
    92 the parser defaults to tdr_OUTNAME.c. The header filename will be the 
     91Generate a C file and C header containing TDR parsers. The filename for
     92the parser defaults to tdr_OUTNAME.c. The header filename will be the
    9393parser filename with the extension changed from .c to .h.
    9494
     
    9999=item I<--server>
    100100
    101 Generate boilerplate for the RPC server that implements 
     101Generate boilerplate for the RPC server that implements
    102102the interface. Filename defaults to ndr_OUTNAME_s.c.
    103103
    104104=item I<--template>
    105105
    106 Generate stubs for a RPC server that implements the interface. Output will 
     106Generate stubs for a RPC server that implements the interface. Output will
    107107be written to stdout.
    108108
     
    110110
    111111Generate an Wireshark dissector (in C) and header file. The dissector filename
    112 defaults to packet-dcerpc-OUTNAME.c while the header filename defaults to 
     112defaults to packet-dcerpc-OUTNAME.c while the header filename defaults to
    113113packet-dcerpc-OUTNAME.h.
    114        
    115 Pidl will read additional data from an Wireshark conformance file if present. 
    116 Such a file should have the same location as the IDL file but with the 
     114
     115Pidl will read additional data from an Wireshark conformance file if present.
     116Such a file should have the same location as the IDL file but with the
    117117extension I<cnf> rather than I<idl>. See L<Parse::Pidl::Wireshark::Conformance>
    118118for details on the format of this file.
     
    120120=item I<--diff>
    121121
    122 Parse an IDL file,  generate a new IDL file based on the internal data 
    123 structures and see if there are any differences with the original IDL file. 
     122Parse an IDL file,  generate a new IDL file based on the internal data
     123structures and see if there are any differences with the original IDL file.
    124124Useful for debugging pidl.
    125125
    126126=item I<--dump-idl-tree>
    127127
    128 Tell pidl to dump the internal tree representation of an IDL 
     128Tell pidl to dump the internal tree representation of an IDL
    129129file the to disk. Useful for debugging pidl.
    130130
    131131=item I<--dump-ndr-tree>
    132132
    133 Tell pidl to dump the internal NDR information tree it generated 
     133Tell pidl to dump the internal NDR information tree it generated
    134134from the IDL file to disk.  Useful for debugging pidl.
    135135
    136136=item I<--samba3-ndr-client>
    137137
    138 Generate client calls for Samba3, to be placed in rpc_client/. Instead of 
    139 calling out to the code in Samba3's rpc_parse/, this will call out to 
     138Generate client calls for Samba3, to be placed in rpc_client/. Instead of
     139calling out to the code in Samba3's rpc_parse/, this will call out to
    140140Samba4's NDR code instead.
    141141
    142142=item I<--samba3-ndr-server>
    143143
    144 Generate server calls for Samba3, to be placed in rpc_server/. Instead of 
    145 calling out to the code in Samba3's rpc_parse/, this will call out to 
     144Generate server calls for Samba3, to be placed in rpc_server/. Instead of
     145calling out to the code in Samba3's rpc_parse/, this will call out to
    146146Samba4's NDR code instead.
    147147
     
    152152IDL files are always preprocessed using the C preprocessor.
    153153
    154 Pretty much everything in an interface (the interface itself, functions, 
    155 parameters) can have attributes (or properties whatever name you give them). 
    156 Attributes always prepend the element they apply to and are surrounded 
    157 by square brackets ([]). Multiple attributes are separated by comma's; 
    158 arguments to attributes are specified between parentheses. 
    159 
    160 See the section COMPATIBILITY for the list of attributes that 
     154Pretty much everything in an interface (the interface itself, functions,
     155parameters) can have attributes (or properties whatever name you give them).
     156Attributes always prepend the element they apply to and are surrounded
     157by square brackets ([]). Multiple attributes are separated by comma's;
     158arguments to attributes are specified between parentheses.
     159
     160See the section COMPATIBILITY for the list of attributes that
    161161pidl supports.
    162162
    163163C-style comments can be used.
    164        
     164
    165165=head2 CONFORMANT ARRAYS
    166166
    167167A conformant array is one with that ends in [*] or []. The strange
    168 things about conformant arrays are that they can only appear as the last 
    169 element of a structure (unless there is a pointer to the conformant array, 
    170 of course) and the array size appears before the structure itself on the wire. 
     168things about conformant arrays are that they can only appear as the last
     169element of a structure (unless there is a pointer to the conformant array,
     170of course) and the array size appears before the structure itself on the wire.
    171171
    172172So, in this example:
     
    174174        typedef struct {
    175175                long abc;
    176                 long count;     
     176                long count;
    177177                long foo;
    178178                [size_is(count)] long s[*];
     
    194194   typedef struct {
    195195                long abc;
    196                 long count;     
     196                long count;
    197197                long foo;
    198198                long s[1];
     
    203203    typedef struct {
    204204                long abc;
    205                 long count;     
     205                long count;
    206206                long foo;
    207207                long *s;
     
    214214        typedef struct {
    215215                long abc;
    216                 long count;     
     216                long count;
    217217                long foo;
    218218                [size_is(count)] long *s;
     
    249249
    250250Fixed arrays are an extension added to support some of the strange
    251 embedded structures in security descriptors and spoolss. 
    252 
    253 This section is by no means complete. See the OpenGroup and MSDN 
     251embedded structures in security descriptors and spoolss.
     252
     253This section is by no means complete. See the OpenGroup and MSDN
    254254        documentation for additional information.
    255255
     
    258258=head2 Missing features in pidl
    259259
    260 The following MIDL features are not (yet) implemented in pidl 
     260The following MIDL features are not (yet) implemented in pidl
    261261or are implemented with an incompatible interface:
    262262
     
    267267Asynchronous communication
    268268
    269 =item * 
     269=item *
    270270
    271271Typelibs (.tlb files)
     
    279279=head2 Supported attributes and statements
    280280
    281 in, out, ref, length_is, switch_is, size_is, uuid, case, default, string, 
    282 unique, ptr, pointer_default, v1_enum, object, helpstring, range, local, 
    283 call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as, 
     281in, out, ref, length_is, switch_is, size_is, uuid, case, default, string,
     282unique, ptr, pointer_default, v1_enum, object, helpstring, range, local,
     283call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as,
    284284transmit_as, import, include, cpp_quote.
    285285
     
    295295specify [public] then pull/push functions for other than top-level
    296296functions are declared static.
    297                                
     297
    298298=item noprint
    299299
     
    325325
    326326Specifies that a size of I<length>
    327 bytes should be read, followed by a blob of that size, 
     327bytes should be read, followed by a blob of that size,
    328328which will be parsed as NDR.
    329329
    330 subcontext() is deprecated now, and should not be used in new code. 
     330subcontext() is deprecated now, and should not be used in new code.
    331331Instead, use represent_as() or transmit_as().
    332332
    333333=item flag
    334334
    335 Specify boolean options, mostly used for 
    336 low-level NDR options. Several options 
     335Specify boolean options, mostly used for
     336low-level NDR options. Several options
    337337can be specified using the | character.
    338338Note that flags are inherited by substructures!
     
    347347=item charset(name)
    348348
    349 Specify that the array or string uses the specified 
    350 charset. If this attribute is specified, pidl will 
    351 take care of converting the character data from this format 
     349Specify that the array or string uses the specified
     350charset. If this attribute is specified, pidl will
     351take care of converting the character data from this format
    352352to the host format. Commonly used values are UCS2, DOS and UTF8.
    353353
     
    356356=head2 Unsupported MIDL properties or statements
    357357
    358 aggregatable, appobject, async_uuid, bindable, control, 
    359 defaultbind, defaultcollelem, defaultvalue, defaultvtable, dispinterface, 
    360 displaybind, dual, entry, first_is, helpcontext, helpfile, helpstringcontext, 
    361 helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib, 
    362 includelib, last_is, lcid, licensed, max_is, module, 
    363 ms_union, no_injected_text, nonbrowsable, noncreatable, nonextensible, odl, 
    364 oleautomation, optional, pragma, propget, propputref, propput, readonly, 
    365 requestedit, restricted, retval, source, uidefault, 
    366 usesgetlasterror, vararg, vi_progid, wire_marshal. 
     358aggregatable, appobject, async_uuid, bindable, control,
     359defaultbind, defaultcollelem, defaultvalue, defaultvtable, dispinterface,
     360displaybind, dual, entry, first_is, helpcontext, helpfile, helpstringcontext,
     361helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib,
     362includelib, last_is, lcid, licensed, max_is, module,
     363ms_union, no_injected_text, nonbrowsable, noncreatable, nonextensible, odl,
     364oleautomation, optional, pragma, propget, propputref, propput, readonly,
     365requestedit, restricted, retval, source, uidefault,
     366usesgetlasterror, vararg, vi_progid, wire_marshal.
    367367
    368368=head1 EXAMPLES
     
    370370        # Generating an Wireshark parser
    371371        $ ./pidl --ws-parser -- atsvc.idl
    372        
     372
    373373        # Generating a TDR parser and header
    374374        $ ./pidl --tdr-parser --header -- regf.idl
     
    383383
    384384L<http://msdn.microsoft.com/library/en-us/rpc/rpc/field_attributes.asp>,
    385 L<http://wiki.wireshark.org/DCE/RPC>, 
     385L<http://wiki.wireshark.org/DCE/RPC>,
    386386L<http://www.samba.org/>,
    387387L<yapp(1)>
     
    393393=head1 AUTHOR
    394394
    395 pidl was written by Andrew Tridgell, Stefan Metzmacher, Tim Potter and Jelmer 
     395pidl was written by Andrew Tridgell, Stefan Metzmacher, Tim Potter and Jelmer
    396396Vernooij. The current maintainer is Jelmer Vernooij.
    397397
    398 This manpage was written by Jelmer Vernooij, partially based on the original 
    399 pidl README by Andrew Tridgell. 
    400        
     398This manpage was written by Jelmer Vernooij, partially based on the original
     399pidl README by Andrew Tridgell.
     400
    401401=cut
    402402
     
    405405use FindBin qw($RealBin $Script);
    406406use lib "$RealBin/lib";
    407 use lib "$RealBin/../share/perl5";
    408407use Getopt::Long;
    409408use File::Basename;
     
    452451    my($v) = shift;
    453452    local(*FILE);
    454     open(FILE, ">$filename") || die "can't open $filename";   
     453    open(FILE, ">$filename") || die "can't open $filename";
    455454    print FILE $v;
    456455    close(FILE);
    457456}
    458457
    459 my(@opt_incdirs) = (); 
     458my(@opt_incdirs) = ();
    460459my($opt_help) = 0;
    461460my($opt_version) = 0;
     
    471470my($opt_samba3_ndr_client);
    472471my($opt_samba3_ndr_server);
     472my($opt_samba3_template) = 0;
    473473my($opt_template) = 0;
    474474my($opt_client);
     
    527527
    528528Samba 3 output:
    529  --samba3-ndr-client[=OUTF] create client calls for Samba3 
     529 --samba3-ndr-client[=OUTF] create client calls for Samba3
    530530                            using Samba4's NDR code [cli_BASENAME.c]
    531  --samba3-ndr-server[=OUTF] create server call wrapper for Samba3 
     531 --samba3-ndr-server[=OUTF] create server call wrapper for Samba3
    532532                            using Samba4's NDR code [srv_BASENAME.c]
     533 --samba3-template          print a template for a pipe
    533534
    534535Wireshark parsers:
     
    547548# main program
    548549my $result = GetOptions (
    549             'help|h|?' => \$opt_help, 
     550            'help|h|?' => \$opt_help,
    550551            'version' => \$opt_version,
    551552            'outputdir=s' => \$opt_outputdir,
     
    556557                'samba3-ndr-client:s' => \$opt_samba3_ndr_client,
    557558                'samba3-ndr-server:s' => \$opt_samba3_ndr_server,
     559            'samba3-template' => \$opt_samba3_template,
    558560                'header:s' => \$opt_header,
    559561            'server:s' => \$opt_server,
     
    667669        if (defined($opt_ws_parser) or
    668670            defined($opt_client) or
    669             defined($opt_server) or 
     671            defined($opt_server) or
    670672            defined($opt_header) or
    671673            defined($opt_ndr_parser) or
    672             defined($opt_python) or 
     674            defined($opt_python) or
    673675            defined($opt_dump_ndr_tree) or
    674             defined($opt_samba3_header) or 
    675             defined($opt_samba3_parser) or 
    676             defined($opt_samba3_server) or 
     676            defined($opt_samba3_header) or
     677            defined($opt_samba3_parser) or
     678            defined($opt_samba3_server) or
    677679            defined($opt_samba3_ndr_client) or
    678680            defined($opt_samba3_ndr_server)) {
     
    710712        if (defined($opt_python)) {
    711713                require Parse::Pidl::Samba4::Python;
    712                 my $generator = new Parse::Pidl::Samba4::Python(); 
    713                 my ($prsr) = $generator->Parse($basename, $ndr, 
     714                my $generator = new Parse::Pidl::Samba4::Python();
     715                my ($prsr) = $generator->Parse($basename, $ndr,
    714716                                        "$outputdir/ndr_$basename\_c.h", $h_filename);
    715717                FileSave("$outputdir/py_$basename.c", $prsr);
     
    769771        }
    770772
     773        if ($opt_samba3_template) {
     774                require Parse::Pidl::Samba3::Template;
     775                print Parse::Pidl::Samba3::Template::Parse($pidl);
     776        }
     777
    771778        if (defined($opt_samba3_ndr_client)) {
    772779                my $client = ($opt_samba3_ndr_client or "$outputdir/cli_$basename.c");
  • vendor/current/pidl/tests/Util.pm

    r740 r988  
    119119        my $outfile;
    120120        if (defined($test_data_prefix)) {
    121                 $outfile = "$test_data_prefix/test-$name";     
     121                $outfile = "$test_data_prefix/test-$name";
    122122        } else {
    123123                $outfile = "./test-$name";
  • vendor/current/pidl/tests/samba-ndr.pl

    r740 r988  
    222222                        ALIGN => 4,
    223223                        ELEMENTS => [ ]}, "ndr", "x");
    224 is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
     224is($generator->{res}, "NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
     225if (ndr_flags & NDR_SCALARS) {
    225226        NDR_CHECK(ndr_push_align(ndr, 4));
    226227        NDR_CHECK(ndr_push_trailer_align(ndr, 4));
     
    246247                        SURROUNDING_ELEMENT => $e,
    247248                        ELEMENTS => [ $e ]}, "ndr", "x");
    248 is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
     249is($generator->{res}, "NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
     250if (ndr_flags & NDR_SCALARS) {
    249251        NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1)));
    250252        NDR_CHECK(ndr_push_align(ndr, 4));
  • vendor/current/pidl/tests/typelist.pl

    r414 r988  
    5353
    5454is(1, hasType("foo"));
    55 is(0, hasType("nonexistant"));
     55is(0, hasType("nonexistent"));
    5656is(0, hasType({TYPE => "ENUM", NAME => "someUnknownType"}));
    5757is(1, hasType({TYPE => "ENUM", NAME => "foo"}));
     
    6060
    6161is(1, is_scalar("uint32"));
    62 is(0, is_scalar("nonexistant"));
     62is(0, is_scalar("nonexistent"));
    6363is(1, is_scalar({TYPE => "ENUM"}));
    6464is(0, is_scalar({TYPE => "STRUCT"}));
  • vendor/current/pidl/tests/wireshark-conf.pl

    r414 r988  
    1616{
    1717        my $str = shift;
    18     open(TMP, "+>", undef) or die("unable to open temp file");
     18        open(TMP, "+>", undef) or die("unable to open temp file");
    1919        print TMP $str;
    2020        seek(TMP, 0, 0);
  • vendor/current/pidl/tests/wireshark-ndr.pl

    r414 r988  
    228228
    229229is($x->DumpHfList(), "\tstatic hf_register_info hf[] = {
    230         { &hf_bla, 
     230        { &hf_bla,
    231231          { \"Bla\", \"bla.field\", FT_UINT32, BASE_DEC, NULL, 255, \"NULL\", HFILL }},
    232232        };
  • vendor/current/pidl/wscript

    r740 r988  
    11#!/usr/bin/env python
    22
    3 import os, sys, Logs
     3import os, Logs
    44from samba_utils import MODE_755
    55
     6# This function checks if a perl module is installed on the system.
     7def check_system_perl_module(conf, module, version=None):
     8    bundle_name = module.replace('::', '_')
     9    module_check = module
     10
     11    # Create module string with version
     12    if version:
     13        module_check = module + ' ' + str(version)
     14
     15    # Check if we have to bundle it.
     16    if conf.LIB_MUST_BE_BUNDLED(bundle_name.lower()):
     17        return False
     18
     19    # Check for system perl module
     20    if not conf.check_perl_module(module_check):
     21        return False
     22
     23    conf.define('USING_SYSTEM_%s' % bundle_name.upper(), 1)
     24
     25    return True
     26
    627def set_options(opt):
    7     opt.tool_options('perl')
     28    return
    829
    930def configure(conf):
    10     conf.check_tool('perl')
     31    # Check if perl(Parse::Yapp::Driver) is available.
     32    check_system_perl_module(conf, "Parse::Yapp::Driver", 1.05)
     33
    1134    # we need a recent version of MakeMaker to get the right man page names
    1235    if conf.CHECK_PERL_MANPAGE():
     
    2043
    2144def build(bld):
    22     bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=MODE_755)
     45    bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=MODE_755, perl_fixup=True)
    2346
    2447    bld.RECURSE('lib')
     
    2649    if not bld.CONFIG_SET('HAVE_PERL_MAKEMAKER'):
    2750        return
    28 
    29     pidl_src = ['pidl']
    30     pidl_src.extend(bld.path.ant_glob('lib/**/*.pm').split())
    3151
    3252    pidl_manpages = {
     
    4565    bld.env.pidl_srcdir = os.path.join(bld.srcnode.abspath(), 'pidl')
    4666
    47     blib_bld = os.path.join(bld.srcnode.abspath(bld.env), 'pidl/blib')
    48 
    4967    bld.SET_BUILD_GROUP('final')
    5068    if 'POD2MAN' in bld.env and bld.env['POD2MAN'] != '':
    5169        for src, manpage in pidl_manpages.iteritems():
    52             bld(rule='${PERL} ${POD2MAN} -c "Samba Documentation" ${SRC} ${TGT}',
     70            bld(rule='${POD2MAN} -c "Samba Documentation" ${SRC} ${TGT}',
    5371                shell=True,
    5472                source=src,
Note: See TracChangeset for help on using the changeset viewer.