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

Hi Tridge,

On Wed, Feb 16, 2005 at 04:40:15PM +1100, Andrew Tridgell wrote about 'epar=
ser 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, guint8=

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

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

> 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 files=
=2E 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 quite =
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



Jelmer Vernooij - http://jelmer.vernstok.nl/ - ctrlsoft@=

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

Version: GnuPG v1.2.5 (GNU/Linux)