New version of pidl

This commit is contained in:
Wilco Baan Hofman 2016-11-15 22:10:08 +01:00
parent d595112e01
commit 2186300bd2
74 changed files with 23043 additions and 988 deletions

View file

@ -39,7 +39,7 @@ sub DumpProperties($)
my $res = "";
foreach my $d ($props) {
foreach my $k (keys %{$d}) {
foreach my $k (sort(keys %{$d})) {
if ($k eq "in") {
$res .= "[in] ";
next;
@ -244,7 +244,7 @@ sub DumpInterfaceProperties($)
my($res);
$res .= "[\n";
foreach my $k (keys %{$data}) {
foreach my $k (sort(keys %{$data})) {
$first || ($res .= ",\n"); $first = 0;
$res .= "$k($data->{$k})";
}

View file

@ -2576,7 +2576,9 @@ again:
for ($parser->YYData->{INPUT}) {
if (/^\#/) {
if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
# Linemarker format is described at
# http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
if (s/^\# (\d+) \"(.*?)\"(( \d+){1,4}|)//) {
$parser->YYData->{LINE} = $1-1;
$parser->YYData->{FILE} = $2;
goto again;

View file

@ -35,7 +35,7 @@ use vars qw($VERSION);
$VERSION = '0.01';
@ISA = qw(Exporter);
@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe ContainsString);
@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType can_contain_deferred is_charset_array);
@EXPORT_OK = qw(GetElementLevelTable ParseElement ReturnTypeElement ValidElement align_type mapToScalar ParseType can_contain_deferred is_charset_array);
use strict;
use Parse::Pidl qw(warning fatal);
@ -805,6 +805,25 @@ sub ParseFunction($$$$)
};
}
sub ReturnTypeElement($)
{
my ($fn) = @_;
return undef unless defined($fn->{RETURN_TYPE});
my $e = {
"NAME" => "result",
"TYPE" => $fn->{RETURN_TYPE},
"PROPERTIES" => undef,
"POINTERS" => 0,
"ARRAY_LEN" => [],
"FILE" => $fn->{FILE},
"LINE" => $fn->{LINE},
};
return ParseElement($e, 0, 0);
}
sub CheckPointerTypes($$)
{
my ($s,$default) = @_;
@ -891,7 +910,8 @@ sub ParseInterface($)
FUNCTIONS => \@functions,
CONSTS => \@consts,
TYPES => \@types,
ENDPOINTS => \@endpoints
ENDPOINTS => \@endpoints,
ORIGINAL => $idl
};
}
@ -952,9 +972,19 @@ sub ContainsString($)
if (property_matches($e, "flag", ".*STR_NULLTERM.*")) {
return 1;
}
if (exists($e->{LEVELS}) and $e->{LEVELS}->[0]->{TYPE} eq "ARRAY" and
($e->{LEVELS}->[0]->{IS_FIXED} or $e->{LEVELS}->[0]->{IS_INLINE}) and
has_property($e, "charset"))
{
return 1;
}
foreach my $l (@{$e->{LEVELS}}) {
return 1 if ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED});
}
if (property_matches($e, "charset", ".*DOS.*")) {
return 1;
}
return 0;
}
@ -1073,6 +1103,7 @@ my %property_list = (
"noprint" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "ELEMENT", "PIPE"],
"nopython" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
"todo" => ["FUNCTION"],
"skip" => ["ELEMENT"],
# union
"switch_is" => ["ELEMENT"],

View file

@ -70,7 +70,7 @@ sub ODL2IDL
next;
}
my $podl = Parse::Pidl::IDL::parse_file($idl_path, $opt_incdirs);
if (defined(@$podl)) {
if (defined($podl)) {
require Parse::Pidl::Typelist;
my $basename = basename($idl_path, ".idl");

View file

@ -13,7 +13,7 @@ use Exporter;
use strict;
use Parse::Pidl qw(fatal warning error);
use Parse::Pidl::Util qw(has_property ParseExpr);
use Parse::Pidl::Util qw(has_property ParseExpr genpad);
use Parse::Pidl::NDR qw(ContainsPipe);
use Parse::Pidl::Typelist qw(mapTypeName);
use Parse::Pidl::Samba4 qw(DeclLong);
@ -25,18 +25,9 @@ $VERSION = '0.01';
sub indent($) { my ($self) = @_; $self->{tabs}.="\t"; }
sub deindent($) { my ($self) = @_; $self->{tabs} = substr($self->{tabs}, 1); }
sub pidl($$) { my ($self,$txt) = @_; $self->{res} .= $txt ? "$self->{tabs}$txt\n" : "\n"; }
sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; }
sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; }
sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); }
sub genpad($)
{
my ($s) = @_;
my $nt = int((length($s)+1)/8);
my $lt = ($nt*8)-1;
my $ns = (length($s)-$lt);
return "\t"x($nt)." "x($ns);
}
sub new($)
{
my ($class) = shift;
@ -59,7 +50,7 @@ sub HeaderProperties($$)
my($props,$ignores) = @_;
my $ret = "";
foreach my $d (keys %{$props}) {
foreach my $d (sort(keys %{$props})) {
next if (grep(/^$d$/, @$ignores));
if($props->{$d} ne "1") {
$ret.= "$d($props->{$d}),";

View file

@ -14,7 +14,7 @@ use strict;
use Parse::Pidl qw(warning error fatal);
use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
use Parse::Pidl::Util qw(ParseExpr has_property is_constant);
use Parse::Pidl::NDR qw(GetNextLevel);
use Parse::Pidl::NDR qw(GetNextLevel ContainsPipe);
use Parse::Pidl::Samba4 qw(ElementStars DeclLong);
use Parse::Pidl::Samba4::Header qw(GenerateFunctionOutEnv);
@ -24,6 +24,8 @@ $VERSION = '0.01';
my $res;
my $res_hdr;
my $tabs = "";
sub pidl_reset() { $res=""; $res_hdr="", $tabs=""; }
sub pidl_return() { my $s = $res; my $h = $res_hdr; pidl_reset(); return ($s, $h) }
sub indent() { $tabs.="\t"; }
sub deindent() { $tabs = substr($tabs, 1); }
sub pidl($) { my ($txt) = @_; $res .= $txt?$tabs.(shift)."\n":"\n"; }
@ -48,9 +50,9 @@ sub DeclLevel($$)
return $res;
}
sub AllocOutVar($$$$$)
sub AllocOutVar($$$$$$$)
{
my ($e, $mem_ctx, $name, $env, $fail) = @_;
my ($e, $mem_ctx, $name, $env, $check, $cleanup, $return) = @_;
my $l = $e->{LEVELS}[0];
@ -83,15 +85,18 @@ sub AllocOutVar($$$$$)
pidl "$name = talloc_zero($mem_ctx, " . DeclLevel($e, 1) . ");";
}
pidl "if ($name == NULL) {";
$fail->();
pidl "if (" . $check->($name) . ") {";
indent;
pidl $cleanup->($name) if defined($cleanup);
pidl $return->($name) if defined($return);
deindent;
pidl "}";
pidl "";
}
sub CallWithStruct($$$$)
sub CallWithStruct($$$$$$)
{
my ($pipes_struct, $mem_ctx, $fn, $fail) = @_;
my ($pipes_struct, $mem_ctx, $fn, $check, $cleanup, $return) = @_;
my $env = GenerateFunctionOutEnv($fn);
my $hasout = 0;
foreach (@{$fn->{ELEMENTS}}) {
@ -100,8 +105,6 @@ sub CallWithStruct($$$$)
pidl "ZERO_STRUCT(r->out);" if ($hasout);
my $proto = "_$fn->{NAME}(struct pipes_struct *p, struct $fn->{NAME} *r";
my $ret = "_$fn->{NAME}($pipes_struct, r";
foreach (@{$fn->{ELEMENTS}}) {
my @dir = @{$_->{DIRECTION}};
if (grep(/in/, @dir) and grep(/out/, @dir)) {
@ -110,25 +113,28 @@ sub CallWithStruct($$$$)
}
foreach (@{$fn->{ELEMENTS}}) {
next if ContainsPipe($_, $_->{LEVELS}[0]);
my @dir = @{$_->{DIRECTION}};
if (grep(/in/, @dir) and grep(/out/, @dir)) {
# noop
} elsif (grep(/out/, @dir) and not
has_property($_, "represent_as")) {
AllocOutVar($_, $mem_ctx, "r->out.$_->{NAME}", $env, $fail);
AllocOutVar($_, $mem_ctx, "r->out.$_->{NAME}", $env,
$check, $cleanup, $return);
}
}
$ret .= ")";
$proto .= ");";
my $proto = "_$fn->{NAME}(struct pipes_struct *p, struct $fn->{NAME} *r)";
my $ret = "_$fn->{NAME}($pipes_struct, r)";
if ($fn->{RETURN_TYPE}) {
$ret = "r->out.result = $ret";
$proto = "$fn->{RETURN_TYPE} $proto";
$proto = mapTypeName($fn->{RETURN_TYPE})." $proto";
} else {
$proto = "void $proto";
}
pidl_hdr "$proto";
pidl_hdr "$proto;";
pidl "$ret;";
}
@ -175,15 +181,23 @@ sub ParseFunction($$)
pidl "}";
pidl "";
CallWithStruct("p", "r", $fn,
sub {
pidl "\ttalloc_free(r);";
pidl "\treturn false;";
CallWithStruct("p", "r", $fn,
sub ($) {
my ($name) = @_;
return "${name} == NULL";
},
sub ($) {
my ($name) = @_;
return "talloc_free(r);";
},
sub ($) {
my ($name) = @_;
return "return false;";
}
);
pidl "";
pidl "if (p->rng_fault_state) {";
pidl "if (p->fault_state) {";
pidl "\ttalloc_free(r);";
pidl "\t/* Return true here, srv_pipe_hnd.c will take care */";
pidl "\treturn true;";
@ -285,8 +299,7 @@ sub Parse($$$)
{
my($ndr,$header,$ndr_header) = @_;
$res = "";
$res_hdr = "";
pidl_reset();
pidl "/*";
pidl " * Unix SMB/CIFS implementation.";
@ -303,7 +316,7 @@ sub Parse($$$)
ParseInterface($_) if ($_->{TYPE} eq "INTERFACE");
}
return ($res, $res_hdr);
return pidl_return();
}
1;

View file

@ -0,0 +1,98 @@
###################################################
# server template function generator
# Copyright tridge@samba.org 2003
# released under the GNU GPL
package Parse::Pidl::Samba3::Template;
use vars qw($VERSION);
$VERSION = '0.01';
use Parse::Pidl::Util qw(genpad);
use strict;
my($res);
#####################################################################
# produce boilerplate code for a interface
sub Template($)
{
my($interface) = shift;
my($data) = $interface->{DATA};
my $name = $interface->{NAME};
$res .=
"/*
Unix SMB/CIFS implementation.
endpoint server for the $name pipe
Copyright (C) YOUR NAME HERE YEAR
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include \"includes.h\"
#include \"ntdomain.h\"
#include \"../librpc/gen_ndr/srv_$name.h\"
";
foreach my $d (@{$data}) {
if ($d->{TYPE} eq "FUNCTION") {
my $fname = $d->{NAME};
my $pad = genpad("$d->{RETURN_TYPE} _$fname");
$res .=
"
/****************************************************************
_$fname
****************************************************************/
$d->{RETURN_TYPE} _$fname(struct pipes_struct *p,
$pad"."struct $fname *r)
{
";
$res .= "\tp->fault_state = DCERPC_FAULT_OP_RNG_ERROR;\n";
if ($d->{RETURN_TYPE} eq "NTSTATUS") {
$res .= "\treturn NT_STATUS_NOT_IMPLEMENTED;\n";
} elsif ($d->{RETURN_TYPE} eq "WERROR") {
$res .= "\treturn WERR_NOT_SUPPORTED;\n";
} elsif ($d->{RETURN_TYPE} eq "HRESULT") {
$res .= "\treturn HRES_ERROR_NOT_SUPPORTED;\n";
}
$res .= "}
";
}
}
}
#####################################################################
# parse a parsed IDL structure back into an IDL file
sub Parse($)
{
my($idl) = shift;
$res = "";
foreach my $x (@{$idl}) {
($x->{TYPE} eq "INTERFACE") &&
Template($x);
}
return $res;
}
1;

View file

@ -38,7 +38,7 @@ sub HeaderProperties($$)
my($props,$ignores) = @_;
my $ret = "";
foreach my $d (keys %{$props}) {
foreach my $d (sort(keys %{$props})) {
next if (grep(/^$d$/, @$ignores));
if($props->{$d} ne "1") {
$ret.= "$d($props->{$d}),";
@ -142,7 +142,7 @@ sub HeaderEnum($$;$)
my $count = 0;
my $with_val = 0;
my $without_val = 0;
pidl " { __donnot_use_enum_$name=0x7FFFFFFF}\n";
pidl " { __do_not_use_enum_$name=0x7FFFFFFF}\n";
foreach my $e (@{$enum->{ELEMENTS}}) {
my $t = "$e";
my $name;

View file

@ -11,7 +11,7 @@ use Exporter;
@EXPORT_OK = qw(Parse);
use Parse::Pidl qw(fatal warning error);
use Parse::Pidl::Util qw(has_property ParseExpr);
use Parse::Pidl::Util qw(has_property ParseExpr genpad);
use Parse::Pidl::NDR qw(ContainsPipe);
use Parse::Pidl::Typelist qw(mapTypeName);
use Parse::Pidl::Samba4 qw(choose_header is_intree DeclLong);
@ -29,15 +29,6 @@ sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; }
sub pidl_both($$) { my ($self, $txt) = @_; $self->{hdr} .= "$txt\n"; $self->{res_hdr} .= "$txt\n"; }
sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); }
sub genpad($)
{
my ($s) = @_;
my $nt = int((length($s)+1)/8);
my $lt = ($nt*8)-1;
my $ns = (length($s)-$lt);
return "\t"x($nt)." "x($ns);
}
sub new($)
{
my ($class) = shift;
@ -158,9 +149,9 @@ sub ParseFunction_r_Done($$$$)
$self->pidl("");
$self->pidl("status = dcerpc_binding_handle_call_recv(subreq);");
$self->pidl("if (!NT_STATUS_IS_OK(status)) {");
$self->pidl("TALLOC_FREE(subreq);");
$self->pidl("if (tevent_req_nterror(req, status)) {");
$self->indent;
$self->pidl("tevent_req_nterror(req, status);");
$self->pidl("return;");
$self->deindent;
$self->pidl("}");
@ -259,7 +250,7 @@ sub HeaderProperties($$)
my($props,$ignores) = @_;
my $ret = "";
foreach my $d (keys %{$props}) {
foreach my $d (sort(keys %{$props})) {
next if (grep(/^$d$/, @$ignores));
if($props->{$d} ne "1") {
$ret.= "$d($props->{$d}),";
@ -400,11 +391,16 @@ sub ParseOutputArgument($$$$$$)
$self->pidl("$copy_len_var = $out_length_is;");
}
my $dest_ptr = "$o$e->{NAME}";
my $elem_size = "sizeof(*$dest_ptr)";
$self->pidl("if ($dest_ptr != $out_var) {");
$self->indent;
if (has_property($e, "charset")) {
$self->pidl("memcpy(discard_const_p(uint8_t *, $o$e->{NAME}), $out_var, $copy_len_var * sizeof(*$o$e->{NAME}));");
} else {
$self->pidl("memcpy($o$e->{NAME}, $out_var, $copy_len_var * sizeof(*$o$e->{NAME}));");
$dest_ptr = "discard_const_p(uint8_t *, $dest_ptr)";
}
$self->pidl("memcpy($dest_ptr, $out_var, $copy_len_var * $elem_size);");
$self->deindent;
$self->pidl("}");
$self->deindent;
$self->pidl("}");
@ -563,9 +559,8 @@ sub ParseFunction_Done($$$$)
$self->pidl("status = dcerpc_$name\_r_recv(subreq, mem_ctx);");
$self->pidl("TALLOC_FREE(subreq);");
$self->pidl("if (!NT_STATUS_IS_OK(status)) {");
$self->pidl("if (tevent_req_nterror(req, status)) {");
$self->indent;
$self->pidl("tevent_req_nterror(req, status);");
$self->pidl("return;");
$self->deindent;
$self->pidl("}");
@ -693,6 +688,20 @@ sub ParseFunction_Sync($$$$)
}
$self->pidl("");
$self->pidl("/* Out parameters */");
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless grep(/out/, @{$e->{DIRECTION}});
$self->ParseCopyArgument($fn, $e, "r.out.", "_");
}
$self->pidl("");
if (defined($fn->{RETURN_TYPE})) {
$self->pidl("/* Result */");
$self->pidl("ZERO_STRUCT(r.out.result);");
$self->pidl("");
}
$self->pidl("status = dcerpc_$name\_r(h, mem_ctx, &r);");
$self->pidl("if (!NT_STATUS_IS_OK(status)) {");
$self->indent;

View file

@ -261,7 +261,7 @@ sub check_fully_dereferenced($$)
$nump = $_->{POINTER_INDEX}+1;
}
}
warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully derefenced variable") if ($nump > length($ptr));
warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully dereferenced variable") if ($nump > length($ptr));
return ($origvar);
}
}
@ -321,39 +321,118 @@ sub check_null_pointer($$$$)
}
}
sub is_deferred_switch_non_empty($)
{
# 1 if there needs to be a deferred branch in an ndr_pull/push,
# 0 otherwise.
my ($e) = @_;
my $have_default = 0;
foreach my $el (@{$e->{ELEMENTS}}) {
if ($el->{CASE} eq "default") {
$have_default = 1;
}
if ($el->{TYPE} ne "EMPTY") {
if (ContainsDeferred($el, $el->{LEVELS}[0])) {
return 1;
}
}
}
return ! $have_default;
}
sub ParseArrayPullGetSize($$$$$$)
{
my ($self,$e,$l,$ndr,$var_name,$env) = @_;
my $size;
if ($l->{IS_CONFORMANT}) {
$size = "ndr_get_array_size($ndr, " . get_pointer_to($var_name) . ")";
} elsif ($l->{IS_ZERO_TERMINATED} and $l->{SIZE_IS} == 0 and $l->{LENGTH_IS} == 0) { # Noheader arrays
$size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
} else {
$size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->pidl(shift); },
"return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
check_fully_dereferenced($e, $env));
}
$self->pidl("size_$e->{NAME}_$l->{LEVEL_INDEX} = $size;");
my $array_size = "size_$e->{NAME}_$l->{LEVEL_INDEX}";
if (my $range = has_property($e, "range")) {
my ($low, $high) = split(/,/, $range, 2);
if ($low < 0) {
warning(0, "$low is invalid for the range of an array size");
}
if ($low == 0) {
$self->pidl("if ($array_size > $high) {");
} else {
$self->pidl("if ($array_size < $low || $array_size > $high) {");
}
$self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
$self->pidl("}");
}
return $array_size;
}
#####################################################################
# parse an array - pull side
sub ParseArrayPullGetLength($$$$$$;$)
{
my ($self,$e,$l,$ndr,$var_name,$env,$array_size) = @_;
if (not defined($array_size)) {
$array_size = $self->ParseArrayPullGetSize($e, $l, $ndr, $var_name, $env);
}
if (not $l->{IS_VARYING}) {
return $array_size;
}
my $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
$self->pidl("length_$e->{NAME}_$l->{LEVEL_INDEX} = $length;");
my $array_length = "length_$e->{NAME}_$l->{LEVEL_INDEX}";
if (my $range = has_property($e, "range")) {
my ($low, $high) = split(/,/, $range, 2);
if ($low < 0) {
warning(0, "$low is invalid for the range of an array size");
}
if ($low == 0) {
$self->pidl("if ($array_length > $high) {");
} else {
$self->pidl("if ($array_length < $low || $array_length > $high) {");
}
$self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
$self->pidl("}");
}
return $array_length;
}
#####################################################################
# parse an array - pull side
sub ParseArrayPullHeader($$$$$$)
{
my ($self,$e,$l,$ndr,$var_name,$env) = @_;
my $length;
my $size;
if ($l->{IS_CONFORMANT}) {
$length = $size = "ndr_get_array_size($ndr, " . get_pointer_to($var_name) . ")";
} elsif ($l->{IS_ZERO_TERMINATED} and $l->{SIZE_IS} == 0 and $l->{LENGTH_IS} == 0) { # Noheader arrays
$length = $size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
} else {
$length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->pidl(shift); },
"return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
check_fully_dereferenced($e, $env));
}
if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
$self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, " . get_pointer_to($var_name) . "));");
}
if ($l->{IS_VARYING}) {
$self->pidl("NDR_CHECK(ndr_pull_array_length($ndr, " . get_pointer_to($var_name) . "));");
$length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
}
if ($length ne $size) {
$self->pidl("if ($length > $size) {");
my $array_size = $self->ParseArrayPullGetSize($e, $l, $ndr, $var_name, $env);
my $array_length = $self->ParseArrayPullGetLength($e, $l, $ndr, $var_name, $env, $array_size);
if ($array_length ne $array_size) {
$self->pidl("if ($array_length > $array_size) {");
$self->indent;
$self->pidl("return ndr_pull_error($ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should exceed array length %u\", $size, $length);");
$self->pidl("return ndr_pull_error($ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should exceed array length %u\", $array_size, $array_length);");
$self->deindent;
$self->pidl("}");
}
@ -383,10 +462,10 @@ sub ParseArrayPullHeader($$$$$$)
}
if (ArrayDynamicallyAllocated($e,$l) and not is_charset_array($e,$l)) {
$self->AllocateArrayLevel($e,$l,$ndr,$var_name,$size);
$self->AllocateArrayLevel($e,$l,$ndr,$var_name,$array_size);
}
return $length;
return $array_length;
}
sub compression_alg($$)
@ -610,7 +689,7 @@ sub ParseElementPushLevel
$var_name = get_array_element($var_name, $counter);
if ((($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) and not $array_pointless) {
$self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
$self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
$self->indent;
$self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 0);
$self->deindent;
@ -618,12 +697,12 @@ sub ParseElementPushLevel
}
if ($deferred and ContainsDeferred($e, $l) and not $array_pointless) {
$self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
$self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
$self->indent;
$self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 0, 1);
$self->deindent;
$self->pidl("}");
}
}
} elsif ($l->{TYPE} eq "SWITCH") {
$self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, $primitives, $deferred);
}
@ -677,13 +756,15 @@ sub ParsePtrPush($$$$$)
my ($self,$e,$l,$ndr,$var_name) = @_;
if ($l->{POINTER_TYPE} eq "ref") {
$self->pidl("if ($var_name == NULL) {");
$self->indent;
$self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
$self->deindent;
$self->pidl("}");
if ($l->{LEVEL_INDEX} > 0) {
$self->pidl("if ($var_name == NULL) {");
$self->indent;
$self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
$self->deindent;
$self->pidl("}");
}
if ($l->{LEVEL} eq "EMBEDDED") {
$self->pidl("NDR_CHECK(ndr_push_ref_ptr(ndr));");
$self->pidl("NDR_CHECK(ndr_push_ref_ptr(ndr)); /* $var_name */");
}
} elsif ($l->{POINTER_TYPE} eq "relative") {
$self->pidl("NDR_CHECK(ndr_push_relative_ptr1($ndr, $var_name));");
@ -815,7 +896,7 @@ sub ParseElementPrint($$$$$)
$self->pidl("$ndr->print($ndr, \"\%s: ARRAY(\%d)\", \"$e->{NAME}\", (int)$length);");
$self->pidl("$ndr->depth++;");
$self->pidl("for ($counter=0;$counter<$length;$counter++) {");
$self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
$self->indent;
$var_name = get_array_element($var_name, $counter);
@ -898,7 +979,11 @@ sub ParseDataPull($$$$$$$)
$var_name = get_pointer_to($var_name);
$self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
if (has_property($e, "skip")) {
$self->pidl("/* [skip] '$var_name' */");
} else {
$self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
}
my $pl = GetPrevLevel($e, $l);
@ -936,7 +1021,11 @@ sub ParseDataPush($$$$$$$)
$var_name = get_pointer_to($var_name);
}
$self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
if (has_property($e, "skip")) {
$self->pidl("/* [skip] '$var_name' */");
} else {
$self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
}
} else {
$self->ParseTypePush($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred);
}
@ -1034,6 +1123,7 @@ sub ParseElementPullLevel
my($self,$e,$l,$ndr,$var_name,$env,$primitives,$deferred) = @_;
my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
my $array_length = undef;
if ($l->{TYPE} eq "ARRAY" and ($l->{IS_VARYING} or $l->{IS_CONFORMANT})) {
$var_name = get_pointer_to($var_name);
@ -1047,20 +1137,7 @@ sub ParseElementPullLevel
$self->ParseSubcontextPullEnd($e, $l, $ndr, $env);
} elsif ($l->{TYPE} eq "ARRAY") {
my $length = $self->ParseArrayPullHeader($e, $l, $ndr, $var_name, $env);
if (my $range = has_property($e, "range")) {
my ($low, $high) = split(/,/, $range, 2);
if ($low < 0) {
warning(0, "$low is invalid for the range of an array size");
}
if ($low == 0) {
$self->pidl("if ($length > $high) {");
} else {
$self->pidl("if ($length < $low || $length > $high) {");
}
$self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
$self->pidl("}");
}
$array_length = $length;
my $nl = GetNextLevel($e, $l);
@ -1115,7 +1192,7 @@ sub ParseElementPullLevel
$self->ParseMemCtxPullEnd($e, $l, $ndr);
if ($l->{POINTER_TYPE} ne "ref") {
if ($l->{POINTER_TYPE} eq "relative") {
if ($l->{POINTER_TYPE} eq "relative" or $l->{POINTER_TYPE} eq "relative_short") {
$self->pidl("if ($ndr->offset > $ndr->relative_highest_offset) {");
$self->indent;
$self->pidl("$ndr->relative_highest_offset = $ndr->offset;");
@ -1128,26 +1205,12 @@ sub ParseElementPullLevel
}
} elsif ($l->{TYPE} eq "ARRAY" and
not has_fast_array($e,$l) and not is_charset_array($e, $l)) {
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
my $length = $array_length;
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
my $array_name = $var_name;
if ($l->{IS_VARYING}) {
$length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
}
if (my $range = has_property($e, "range")) {
my ($low, $high) = split(/,/, $range, 2);
if ($low < 0) {
warning(0, "$low is invalid for the range of an array size");
}
if ($low == 0) {
$self->pidl("if ($length > $high) {");
} else {
$self->pidl("if ($length < $low || $length > $high) {");
}
$self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
$self->pidl("}");
if (not defined($length)) {
$length = $self->ParseArrayPullGetLength($e, $l, $ndr, $var_name, $env);
}
$var_name = get_array_element($var_name, $counter);
@ -1161,7 +1224,7 @@ sub ParseElementPullLevel
$self->CheckStringTerminator($ndr,$e,$l,$length);
}
$self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
$self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
$self->indent;
$self->ParseElementPullLevel($e, $nl, $ndr, $var_name, $env, 1, 0);
$self->deindent;
@ -1169,7 +1232,7 @@ sub ParseElementPullLevel
}
if ($deferred and ContainsDeferred($e, $l)) {
$self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
$self->pidl("for ($counter = 0; $counter < ($length); $counter++) {");
$self->indent;
$self->ParseElementPullLevel($e,GetNextLevel($e,$l), $ndr, $var_name, $env, 0, 1);
$self->deindent;
@ -1289,10 +1352,30 @@ sub ParsePtrPull($$$$$)
$self->pidl("}");
}
sub CheckRefPtrs($$$$)
{
my ($self,$e,$ndr,$env) = @_;
return if ContainsPipe($e, $e->{LEVELS}[0]);
return if ($e->{LEVELS}[0]->{TYPE} ne "POINTER");
return if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref");
my $var_name = $env->{$e->{NAME}};
$var_name = append_prefix($e, $var_name);
$self->pidl("if ($var_name == NULL) {");
$self->indent;
$self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
$self->deindent;
$self->pidl("}");
}
sub ParseStructPushPrimitives($$$$$)
{
my ($self, $struct, $ndr, $varname, $env) = @_;
$self->CheckRefPtrs($_, $ndr, $env) foreach (@{$struct->{ELEMENTS}});
# see if the structure contains a conformant array. If it
# does, then it must be the last element of the structure, and
# we need to push the conformant length early, as it fits on
@ -1578,16 +1661,21 @@ sub DeclarePtrVariables($$)
}
}
sub DeclareArrayVariables($$)
sub DeclareArrayVariables($$;$)
{
my ($self,$e) = @_;
my ($self,$e,$pull) = @_;
foreach my $l (@{$e->{LEVELS}}) {
next if ($l->{TYPE} ne "ARRAY");
if (defined($pull)) {
$self->pidl("uint32_t size_$e->{NAME}_$l->{LEVEL_INDEX} = 0;");
if ($l->{IS_VARYING}) {
$self->pidl("uint32_t length_$e->{NAME}_$l->{LEVEL_INDEX} = 0;");
}
}
next if has_fast_array($e,$l);
next if is_charset_array($e,$l);
if ($l->{TYPE} eq "ARRAY") {
$self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
}
$self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
}
}
@ -1596,15 +1684,14 @@ sub DeclareArrayVariablesNoZero($$$)
my ($self,$e,$env) = @_;
foreach my $l (@{$e->{LEVELS}}) {
next if ($l->{TYPE} ne "ARRAY");
next if has_fast_array($e,$l);
next if is_charset_array($e,$l);
if ($l->{TYPE} eq "ARRAY") {
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
if ($length eq "0") {
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
if ($length eq "0") {
warning($e->{ORIGINAL}, "pointless array cntr: 'cntr_$e->{NAME}_$l->{LEVEL_INDEX}': length=$length");
} else {
} else {
$self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
}
}
}
}
@ -1620,7 +1707,7 @@ sub DeclareMemCtxVariables($$)
}
if (defined($mem_flags)) {
$self->pidl("TALLOC_CTX *_mem_save_$e->{NAME}_$l->{LEVEL_INDEX};");
$self->pidl("TALLOC_CTX *_mem_save_$e->{NAME}_$l->{LEVEL_INDEX} = NULL;");
}
}
}
@ -1675,7 +1762,7 @@ sub ParseStructPull($$$$)
# declare any internal pointers we need
foreach my $e (@{$struct->{ELEMENTS}}) {
$self->DeclarePtrVariables($e);
$self->DeclareArrayVariables($e);
$self->DeclareArrayVariables($e, "pull");
$self->DeclareMemCtxVariables($e);
}
@ -1788,7 +1875,9 @@ sub ParseUnionPushPrimitives($$$$)
$self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
}
$self->DeclareArrayVariables($el);
$self->ParseElementPush($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
my $el_env = {$el->{NAME} => "$varname->$el->{NAME}"};
$self->CheckRefPtrs($el, $ndr, $el_env);
$self->ParseElementPush($el, $ndr, $el_env, 1, 0);
$self->deindent;
}
$self->pidl("break; }");
@ -1853,11 +1942,13 @@ sub ParseUnionPush($$$$)
$self->ParseUnionPushPrimitives($e, $ndr, $varname);
$self->deindent;
$self->pidl("}");
$self->pidl("if (ndr_flags & NDR_BUFFERS) {");
$self->indent;
$self->ParseUnionPushDeferred($e, $ndr, $varname);
$self->deindent;
$self->pidl("}");
if (is_deferred_switch_non_empty($e)) {
$self->pidl("if (ndr_flags & NDR_BUFFERS) {");
$self->indent;
$self->ParseUnionPushDeferred($e, $ndr, $varname);
$self->deindent;
$self->pidl("}");
}
$self->end_flags($e, $ndr);
}
@ -1940,8 +2031,6 @@ sub ParseUnionPullPrimitives($$$$$)
if ($el->{TYPE} ne "EMPTY") {
$self->indent;
$self->DeclarePtrVariables($el);
$self->DeclareArrayVariables($el);
if (defined($e->{PROPERTIES}{relative_base})) {
$self->pidl("NDR_CHECK(ndr_pull_align($ndr, $el->{ALIGN}));");
# set the current offset as base for relative pointers
@ -2004,7 +2093,7 @@ sub ParseUnionPull($$$$)
{
my ($self,$e,$ndr,$varname) = @_;
my $switch_type = $e->{SWITCH_TYPE};
my $needs_deferred_switch = is_deferred_switch_non_empty($e);
$self->pidl("uint32_t level;");
if (defined($switch_type)) {
if (Parse::Pidl::Typelist::typeIs($switch_type, "ENUM")) {
@ -2018,26 +2107,34 @@ sub ParseUnionPull($$$$)
next if ($el->{TYPE} eq "EMPTY");
next if ($double_cases{"$el->{NAME}"});
$self->DeclareMemCtxVariables($el);
$self->DeclarePtrVariables($el);
$self->DeclareArrayVariables($el, "pull");
$double_cases{"$el->{NAME}"} = 1;
}
$self->start_flags($e, $ndr);
$self->pidl("level = ndr_pull_get_switch_value($ndr, $varname);");
$self->pidl("NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);");
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
$self->indent;
if (! $needs_deferred_switch) {
$self->pidl("/* This token is not used again */");
$self->pidl("level = ndr_pull_steal_switch_value($ndr, $varname);");
} else {
$self->pidl("level = ndr_pull_get_switch_value($ndr, $varname);");
}
$self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type);
$self->deindent;
$self->pidl("}");
$self->pidl("if (ndr_flags & NDR_BUFFERS) {");
$self->indent;
$self->ParseUnionPullDeferred($e,$ndr,$varname);
$self->deindent;
$self->pidl("}");
if ($needs_deferred_switch) {
$self->pidl("if (ndr_flags & NDR_BUFFERS) {");
$self->indent;
$self->pidl("/* The token is not needed after this. */");
$self->pidl("level = ndr_pull_steal_switch_value($ndr, $varname);");
$self->ParseUnionPullDeferred($e,$ndr,$varname);
$self->deindent;
$self->pidl("}");
}
$self->add_deferred();
$self->end_flags($e, $ndr);
@ -2317,6 +2414,12 @@ sub ParseFunctionPush($$)
EnvSubstituteValue($env, $fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$e->{DIRECTION}})) {
$self->CheckRefPtrs($e, $ndr, $env);
}
}
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$e->{DIRECTION}})) {
$self->ParseElementPush($e, $ndr, $env, 1, 1);
@ -2330,6 +2433,14 @@ sub ParseFunctionPush($$)
$self->indent;
$env = GenerateFunctionOutEnv($fn);
EnvSubstituteValue($env, $fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$e->{DIRECTION}})) {
$self->CheckRefPtrs($e, $ndr, $env);
}
}
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$e->{DIRECTION}})) {
$self->ParseElementPush($e, $ndr, $env, 1, 1);
@ -2386,7 +2497,7 @@ sub ParseFunctionPull($$)
# declare any internal pointers we need
foreach my $e (@{$fn->{ELEMENTS}}) {
$self->DeclarePtrVariables($e);
$self->DeclareArrayVariables($e);
$self->DeclareArrayVariables($e, "pull");
}
my %double_cases = ();

View file

@ -322,6 +322,7 @@ sub Parse($$)
$res = "";
$res .= "/* server functions auto-generated by pidl */\n";
$res .= "#include \"$header\"\n";
$res .= "#include <util/debug.h>\n";
$res .= "\n";
foreach my $x (@{$ndr}) {

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,8 @@ package Parse::Pidl::Samba4::Template;
use vars qw($VERSION);
$VERSION = '0.01';
use Parse::Pidl::Util qw(genpad);
use strict;
my($res);
@ -20,24 +22,24 @@ sub Template($)
my($data) = $interface->{DATA};
my $name = $interface->{NAME};
$res .=
"/*
$res .=
"/*
Unix SMB/CIFS implementation.
endpoint server for the $name pipe
Copyright (C) YOUR NAME HERE YEAR
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -52,13 +54,16 @@ sub Template($)
foreach my $d (@{$data}) {
if ($d->{TYPE} eq "FUNCTION") {
my $fname = $d->{NAME};
my $pad = genpad("static $d->{RETURN_TYPE} dcesrv_$fname");
$res .=
"
/*
$fname
/*
$fname
*/
static $d->{RETURN_TYPE} dcesrv_$fname(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct $fname *r)
static $d->{RETURN_TYPE} dcesrv_$fname(struct dcesrv_call_state *dce_call,
$pad"."TALLOC_CTX *mem_ctx,
$pad"."struct $fname *r)
{
";
@ -74,7 +79,7 @@ static $d->{RETURN_TYPE} dcesrv_$fname(struct dcesrv_call_state *dce_call, TALLO
}
}
$res .=
$res .=
"
/* include the generated boilerplate */
#include \"librpc/gen_ndr/ndr_$name\_s.c\"
@ -89,7 +94,7 @@ sub Parse($)
my($idl) = shift;
$res = "";
foreach my $x (@{$idl}) {
($x->{TYPE} eq "INTERFACE") &&
($x->{TYPE} eq "INTERFACE") &&
Template($x);
}
return $res;

View file

@ -60,6 +60,7 @@ my %scalars = (
"NTTIME_1sec" => "NTTIME",
"NTTIME_hyper" => "NTTIME",
"WERROR" => "WERROR",
"HRESULT" => "HRESULT",
"NTSTATUS" => "NTSTATUS",
"COMRESULT" => "COMRESULT",
"dns_string" => "const char *",
@ -83,7 +84,7 @@ my %aliases = (
"long" => "int32",
"short" => "int16",
"HYPER_T" => "hyper",
"HRESULT" => "COMRESULT",
"mode_t" => "uint32",
);
sub expandAlias($)

View file

@ -6,7 +6,7 @@ package Parse::Pidl::Util;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper);
@EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper genpad);
use vars qw($VERSION);
$VERSION = '0.01';
@ -43,6 +43,7 @@ unless we actually need it
sub MyDumper($)
{
require Data::Dumper;
$Data::Dumper::Sortkeys = 1;
my $s = shift;
return Data::Dumper::Dumper($s);
}
@ -175,6 +176,20 @@ sub ParseExprExt($$$$$)
$deref, $use);
}
=item B<genpad>
return an empty string consisting of tabs and spaces suitable for proper indent
of C-functions.
=cut
sub genpad($)
{
my ($s) = @_;
my $nt = int((length($s)+1)/8);
my $lt = ($nt*8)-1;
my $ns = (length($s)-$lt);
return "\t"x($nt)." "x($ns);
}
=back
=cut

View file

@ -21,7 +21,7 @@ files.
Conformance files are simple text files with a single command on each line.
Empty lines and lines starting with a '#' character are ignored.
Arguments to commands are seperated by spaces.
Arguments to commands are separated by spaces.
The following commands are currently supported:
@ -59,7 +59,7 @@ Register a custom ett field
=item I<STRIP_PREFIX> prefix
Remove the specified prefix from all function names (if present).
=item I<PROTOCOL> longname shortname filtername
Change the short-, long- and filter-name for the current interface in
@ -89,6 +89,14 @@ to write a function manually. This can be used to remove the function
for only one level for a particular element rather than all the functions and
ett/hf variables for a particular element as the NOEMIT command does.
=item I<CODE START>/I<CODE END>
Begin and end a section of code to be put directly into the generated
source file for the dissector.
=item I<HEADER START>/I<HEADER END>
Begin and end a section of code to be put directly into the generated
header file for the dissector.
=back
=head1 EXAMPLE
@ -269,9 +277,9 @@ sub handle_noemit($$$)
my ($pos,$data,$type) = @_;
if (defined($type)) {
$data->{noemit}->{$type} = 1;
$data->{noemit}->{$type} = 1;
} else {
$data->{noemit_dissector} = 1;
$data->{noemit_dissector} = 1;
}
}
@ -284,7 +292,7 @@ sub handle_manual($$$)
return;
}
$data->{manual}->{$fn} = 1;
$data->{manual}->{$fn} = 1;
}
sub handle_protocol($$$$$$)
@ -363,11 +371,11 @@ sub handle_include
my %field_handlers = (
TYPE => \&handle_type,
NOEMIT => \&handle_noemit,
NOEMIT => \&handle_noemit,
MANUAL => \&handle_manual,
PARAM_VALUE => \&handle_param_value,
HF_FIELD => \&handle_hf_field,
HF_RENAME => \&handle_hf_rename,
PARAM_VALUE => \&handle_param_value,
HF_FIELD => \&handle_hf_field,
HF_RENAME => \&handle_hf_rename,
ETT_FIELD => \&handle_ett_field,
TFS => \&handle_tfs,
STRIP_PREFIX => \&handle_strip_prefix,
@ -396,6 +404,7 @@ sub ReadConformanceFH($$$)
my ($fh,$data,$f) = @_;
my $incodeblock = 0;
my $inheaderblock = 0;
my $ln = 0;
@ -407,9 +416,27 @@ sub ReadConformanceFH($$$)
s/[\r\n]//g;
if ($_ eq "CODE START") {
if ($incodeblock) {
warning({ FILE => $f, LINE => $ln },
"CODE START inside CODE section");
}
if ($inheaderblock) {
error({ FILE => $f, LINE => $ln },
"CODE START inside HEADER section");
return undef;
}
$incodeblock = 1;
next;
} elsif ($incodeblock and $_ eq "CODE END") {
} elsif ($_ eq "CODE END") {
if (!$incodeblock) {
warning({ FILE => $f, LINE => $ln },
"CODE END outside CODE section");
}
if ($inheaderblock) {
error({ FILE => $f, LINE => $ln },
"CODE END inside HEADER section");
return undef;
}
$incodeblock = 0;
next;
} elsif ($incodeblock) {
@ -419,6 +446,37 @@ sub ReadConformanceFH($$$)
$data->{override} = "$_\n";
}
next;
} elsif ($_ eq "HEADER START") {
if ($inheaderblock) {
warning({ FILE => $f, LINE => $ln },
"HEADER START inside HEADER section");
}
if ($incodeblock) {
error({ FILE => $f, LINE => $ln },
"HEADER START inside CODE section");
return undef;
}
$inheaderblock = 1;
next;
} elsif ($_ eq "HEADER END") {
if (!$inheaderblock) {
warning({ FILE => $f, LINE => $ln },
"HEADER END outside HEADER section");
}
if ($incodeblock) {
error({ FILE => $f, LINE => $ln },
"CODE END inside HEADER section");
return undef;
}
$inheaderblock = 0;
next;
} elsif ($inheaderblock) {
if (exists $data->{header}) {
$data->{header}.="$_\n";
} else {
$data->{header} = "$_\n";
}
next;
}
my @fields = /([^ "]+|"[^"]+")/g;

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,37 @@
#!/usr/bin/env python
# install the pidl modules
bld.INSTALL_WILDCARD('${DATAROOTDIR}/perl5', '**/*.pm', flat=False)
bld.INSTALL_FILES(bld.env.PERL_LIB_INSTALL_DIR,
'''
Parse/Pidl.pm
Parse/Pidl/Samba4.pm
Parse/Pidl/CUtil.pm
Parse/Pidl/Expr.pm
Parse/Pidl/Wireshark/Conformance.pm
Parse/Pidl/Wireshark/NDR.pm
Parse/Pidl/ODL.pm
Parse/Pidl/Dump.pm
Parse/Pidl/Util.pm
Parse/Pidl/Samba4/Header.pm
Parse/Pidl/Samba4/COM/Header.pm
Parse/Pidl/Samba4/COM/Proxy.pm
Parse/Pidl/Samba4/COM/Stub.pm
Parse/Pidl/Samba4/TDR.pm
Parse/Pidl/Samba4/NDR/Server.pm
Parse/Pidl/Samba4/NDR/Client.pm
Parse/Pidl/Samba4/NDR/Parser.pm
Parse/Pidl/Samba4/Python.pm
Parse/Pidl/Samba4/Template.pm
Parse/Pidl/IDL.pm
Parse/Pidl/Typelist.pm
Parse/Pidl/Samba3/ClientNDR.pm
Parse/Pidl/Samba3/ServerNDR.pm
Parse/Pidl/Compat.pm
Parse/Pidl/NDR.pm
''',
flat=False)
if not bld.CONFIG_SET('USING_SYSTEM_PARSE_YAPP_DRIVER'):
bld.INSTALL_FILES(bld.env.PERL_LIB_INSTALL_DIR,
'Parse/Yapp/Driver.pm',
flat=False)