eparser and pidl

Jelmer Vernooij jelmer at samba.org
Wed Feb 16 21:50:19 GMT 2005


Hi Tridge,

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

> 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. 

> 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 = "static int hf_%{NAME} = -1;\n"

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

>   template_set("PIPE" => "lsa");
>   template_set("NAME" => $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 = "
> int %{PIPE}_%{FUNCTION}_rqst(tvbuff_t *tvb, int offset, 
>                              packet_info *pinfo, proto_tree *tree, guint8 *drep)
> {
>         struct pidl_pull *ndr = pidl_pull_init(tvb, offset, pinfo, drep);
>         struct %{PIPE}_%{FUNCTION} *r = talloc_p(NULL, struct %{PIPE}_%{FUNCTION});
>         pidl_tree ptree;
>         ptree.proto_tree = tree;
>         ptree.subtree_list = 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. I'll keep working on 
ndr.pm's internals and multi level pointers first. 

I have attached a first "draft" of the 
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 ;-) 

Cheers,

Jelmer

-- 
Jelmer Vernooij <jelmer at samba.org> - http://jelmer.vernstok.nl/ - ctrlsoft at jabber.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/samba-technical/attachments/20050216/1348f00f/attachment.bin


More information about the samba-technical mailing list