pidl [in,out] helpers

Sam Liddicott sam at liddicott.com
Fri Sep 18 02:33:27 MDT 2009


For pidl samba4 output, is it possible that I can express:

[out] int *count;
or
[out,MAGIC] int *count;

and have my out struct look like:

struct out {
   int count;
}

but without changing the wire packing?

Consider the case of
   [in,out] int count;

which must properly be expressed as
   [in,out] int *count;

Passing the initial value of count using async rpc goes something like 
this (where r is a pointer to a pidl generated struct):

   r->in.count = talloc(r, int);
   NT_STATUS_NO_MEMORY(r);
   *r->count = 1;

Which is a bit grim, especially if there are a few, and much less 
readable than:

   r->in.count = 1;

For "readability" I have contrived this foul macro which nonetheless 
expresses the intent for easy grok-ability:

   #define talloc_literal(OWNER, VAR, DATA) ((VAR=talloc(OWNER, 
typeof(*VAR)))?(*VAR=DATA,VAR):NULL)

which can be used thus:

   NT_STATUS_HAVE_NO_MEMORY(talloc_literal(r, r->in.count, 1));

However it is still foul.

For samba4 declarations it makes sense to leave it as "int *count", as 
in samba3 the caller provides the storage for count, but in samba4 as 
pidl has already generated a big struct (with in and out as seperate 
branches), I wonder why the struct can't just hold the values as well.

Sam


More information about the samba-technical mailing list