--bCsyhTFzCvuiizWE
Content-Type: multipart/mixed; boundary="liOOAslEiF7prFVr"
Content-Disposition: inline


--liOOAslEiF7prFVr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi again,

This time *with* the patch..

Cheers,

Jelmer

On Wed, Feb 16, 2005 at 10:50:19PM +0100, Jelmer Vernooij wrote about 'Re: =
eparser and pidl':
> Hi Tridge,


> On Wed, Feb 16, 2005 at 04:40:15PM +1100, Andrew Tridgell wrote about 'ep=

arser and pidl':
> > I like the pidl restructuring you are doing as it makes the code much
> > cleaner, but I thought I should mention that your changes have broken
> > the pidl ethereal plugin generator.=20


> > I can see two obvious ways to fix this:


> > 1) fix eparser.pm to use the new function names from ndr.pm


> I've just fixed it this (1) way.=20


> > 2) change eparser.pm to not use the "rewrite using regex" technique


> > One approach might be to change ndr.pm to generate code that uses
> > substitution templates to set things up for the right type of output.


> > For example we could have ndr_ethereal.tpl and ndr_samba.tpl as two
> > template files, which would contain things like this:


> > my $tmpl_hf_declare =3D "static int hf_%{NAME} =3D -1;\n"


> > Then ndr.pm would load the template, and do this:


> > template_set("PIPE" =3D> "lsa");
> > template_set("NAME" =3D> $thename);
> > pidl $hf_declare_tmpl


> > where the pidl function would be changed to always take a template. If
> > the template is empty (as it would be in ndr_samba.tpl in the above
> > example) then it does nothing. If it is non-empty then it does the
> > hash substitution and outputs the result;


> > The templating itself is pretty easy - there are plenty of perl
> > template systems around, or writing a new one is just a few lines of
> > code.


> > A slightly less trivial template might be:


> > my $tmpl_rqst =3D "
> > int %{PIPE}_%{FUNCTION}_rqst(tvbuff_t *tvb, int offset,=20
> > packet_info *pinfo, proto_tree *tree, guin=

t8 *drep)
> > {
> > struct pidl_pull *ndr =3D pidl_pull_init(tvb, offset, pinfo, dr=

ep);
> > struct %{PIPE}_%{FUNCTION} *r =3D talloc_p(NULL, struct %{PIPE}=

_%{FUNCTION});
> > pidl_tree ptree;
> > ptree.proto_tree =3D tree;
> > ptree.subtree_list =3D NULL;
> > ndr_pull_%{PIPE}_%{FUNCTION}(ndr, NDR_IN, &ptree, r);
> > return ndr->offset;
> > }
> > ";


> > which would generate all the _rqst() functions needed by ethereal.


> > Obviously we will need to break many functions up into separate
> > parts.

> I like the idea of moving the lumps of C code out of the current perl fil=

es. I'll keep working on=20
> ndr.pm's internals and multi level pointers first.=20


> I have attached a first "draft" of the=20
> multi-level-pointers patch to this email, for those interested. It's quit=

e simple and
> generates exactly the same code for 1-level pointers as pidl did
> before. The only issue at the moment is the fact that it crashes on
> 2-level pointers ;-)=20


> Cheers,


> Jelmer


> --=20
> Jelmer Vernooij - http://jelmer.vernstok.nl/ - ctrlsof=

t@jabber.org



--=20
Jelmer Vernooij - http://jelmer.vernstok.nl/ - ctrlsoft@=
jabber.org
OSS Contributions in the last 5 days:=20


--liOOAslEiF7prFVr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mlp.diff"
Content-Transfer-Encoding: quoted-printable

Index: build/pidl/ndr.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D
--- build/pidl/ndr.pm (revision 5418)
+++ build/pidl/ndr.pm (working copy)
@@ -785,13 +785,21 @@
=20
start_flags($e);
=20
- if (need_wire_pointer($e)) {
- pidl "if ($var_prefix$e->{NAME}) {";
+ my $pointers =3D "";
+ for my $i (1..$e->{POINTERS}) {
+ if ($pointers) {
+ ParseElementPushScalar($e,$pointers.$var_prefix,$n dr_flags);
+ }
+ pidl "if ($pointers$var_prefix$e->{NAME}) {";
indent;
- if (util::has_property($e, "relative")) {
- pidl "NDR_CHECK(ndr_push_relative_ptr2(ndr, $var_prefix$e->{NAME}));";
- }
+ $pointers.=3D"*";
}
+ =09
+ $var_prefix =3D substr($pointers,0,-1) . $var_prefix;
+ =09
+ if (util::has_property($e, "relative")) {
+ pidl "NDR_CHECK(ndr_push_relative_ptr2(ndr, $var_prefix$e->{NAME}));";
+ }
=20
if (util::is_inline_array($e)) {
ParseArrayPush($e, "r->", "NDR_BUFFERS");
@@ -813,10 +821,10 @@
pidl "NDR_CHECK(ndr_push_$e->{TYPE}(ndr, $ndr_flags, $cprefix$var_prefix=
$e->{NAME}));";
}
=20
- if (need_wire_pointer($e)) {
+ for my $i (1..$e->{POINTERS}) {
deindent;
pidl "}";
- }=09
+ }
=20
end_flags($e);
}
@@ -829,10 +837,24 @@
my($var_prefix) =3D shift;
my $cprefix =3D c_push_prefix($e);
=20
- if (need_wire_pointer($e)) {
- pidl "if ($var_prefix$e->{NAME}) {";
- indent;
+ my $pointers =3D "";
+
+ for my $i (1..$e->{POINTERS}) {
+ if ($pointers) {
+ pidl "ndr_print_ptr(ndr, \"$e->{NAME}\", $var_prefix$e->{NAME});";
+ pidl "ndr->depth++;";
+ pidl "/* FIXME */";
+ #FIXME ParseElementPrintScalar($e,$pointers.$var_prefix);
+ }
+ =09
+ if (pointer_type($e) ne "ref") {
+ pidl "if ($pointers$var_prefix$e->{NAME}) {";
+ indent;
+ }
+ $pointers .=3D "*";
}
+=09
+ $var_prefix =3D substr($pointers,0,-1) . $var_prefix;
=20
if (util::array_size($e)) {
ParseArrayPrint($e, $var_prefix)
@@ -842,10 +864,15 @@
pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $cprefix$var_prefix$e->{=
NAME});";
}
=20
- if (need_wire_pointer($e)) {
- deindent;
- pidl "}";
- }=09
+ for my $i (1..$e->{POINTERS}) {
+ if (pointer_type($e) ne "ref") {
+ deindent;
+ pidl "}";
+ }
+ if ($i > 1) {
+ pidl "ndr->depth--;";
+ }
+ }
}
=20
=20
@@ -865,15 +892,23 @@
=20
start_flags($e);
=20
- if (need_wire_pointer($e)) {
- pidl "if ($var_prefix$e->{NAME}) {";
+ my $pointers =3D "";
+ for my $i (1..$e->{POINTERS}) {
+ if ($pointers) {
+ ParseElementPullScalar($e,$pointers.$var_prefix,$n dr_flags);
+ }
+ pidl "if ($pointers$var_prefix$e->{NAME}) {";
indent;
- if (util::has_property($e, "relative")) {
- pidl "struct ndr_pull_save _relative_save;";
- pidl "ndr_pull_save(ndr, &_relative_save);";
- pidl "NDR_CHECK(ndr_pull_relative_ptr2(ndr, $var_prefix$e->{NAME}));";
- }
+ $pointers.=3D"*";
}
+
+ $var_prefix =3D substr($pointers, 0, -1) . $var_prefix;
+
+ if (util::has_property($e, "relative")) {
+ pidl "struct ndr_pull_save _relative_save;";
+ pidl "ndr_pull_save(ndr, &_relative_save);";
+ pidl "NDR_CHECK(ndr_pull_relative_ptr2(ndr, $var_prefix$e->{NAME}));";
+ }
=20
if (util::is_inline_array($e)) {
ParseArrayPull($e, "r->", "NDR_BUFFERS");
@@ -895,13 +930,13 @@
pidl "NDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $ndr_flags, $cprefix$var_prefix=
$e->{NAME}));";
}
=20
- if (need_wire_pointer($e)) {
- if (util::has_property($e, "relative")) {
- pidl "ndr_pull_restore(ndr, &_relative_save);";
- }
+ if (util::has_property($e, "relative")) {
+ pidl "ndr_pull_restore(ndr, &_relative_save);";
+ }
+ for my $i (1..$e->{POINTERS}) {
deindent;
pidl "}";
- }=09
+ }
=20
end_flags($e);
}
@@ -2107,3 +2142,4 @@
RegisterPrimitives();
=20
1;
+
Index: build/pidl/validator.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D
--- build/pidl/validator.pm (revision 5418)
+++ build/pidl/validator.pm (working copy)
@@ -40,10 +40,6 @@
sub ValidElement($)
{
my $e =3D shift;
- if ($e->{POINTERS} && $e->{POINTERS} > 1) {
- fatal(el_name($e) . " : pidl cannot handle multiple pointer levels. Use =
a sub-structure containing a pointer instead\n");
- }
-
if ($e->{POINTERS} && $e->{ARRAY_LEN}) {
fatal(el_name($e) . " : pidl cannot handle pointers to arrays. Use a sub=
structure instead\n");
}

--liOOAslEiF7prFVr--

--bCsyhTFzCvuiizWE
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCE8G6Pa9Uoh7vUnYRAmZ8AJwNubB1v5pM+HquWrl2xc kpjooLxgCfUpPF
bGw8OEDWzDHUF0/aVYXNJfI=
=I8tK
-----END PGP SIGNATURE-----

--bCsyhTFzCvuiizWE--