pidl decode/encode from/to buffer
Martin Vogt
mvogt1 at googlemail.com
Fri Dec 31 07:16:19 MST 2010
Hello,
I'm currently writing a IDL based smartcard interface for freerdp:
http://www.freerdp.com/
http://msdn.microsoft.com/en-us/library/cc242792%28v=PROT.10%29.aspx
with Visual Studio (and midl) everything works fine, but now I like to
use pidl for linux in a similar way like Microsoft midl.
midl has the option to do the serialization to/from a buffer, they
call it "pickle" and in the windows SDK there is an example for it.
(writing a structure as "wire" data into a file and reading
it back from the file into the structure)
The setup with midl is like this: (first define the structures
for marshalling)
sc.idl:
[
uuid(A35AF600-9CF4-11CD-A076-08002B2BD711),
version(1.0),
pointer_default(unique)
]
interface IRepresentation
{
typedef struct _REDIR_SCARDCONTEXT
{
[range(0, 16)] unsigned long cbContext;
[unique] [size_is(cbContext)] byte *pbContext;
} REDIR_SCARDCONTEXT;
typedef struct _EstablishContext_Call
{
unsigned long dwScope;
} EstablishContext_Call;
typedef struct _EstablishContext_Return
{
long ReturnCode;
REDIR_SCARDCONTEXT Context;
} EstablishContext_Return;
}
then put additional information into an .ACF file (which is evaluated by
midl). This adds generic functions for marshalling from/to buffers, with
handles.
sc.acf:
interface IRepresentation
{
typedef [encode, decode] EstablishContext_Call;
typedef [encode, decode] EstablishContext_Return;
}
with these options in the ACL file "encode,decode" the midl
compiler will now generate interfaces for decoding/encoding from/to
a buffer:
sc_c.c:
EstablishContext_Call_Encode(handle_t _MidlEsHandle,
EstablishContext_Call *_pType)
EstablishContext_Call_Decode(handle_t _MidlEsHandle,
EstablishContext_Call * _pType)
EstablishContext_Return_Encode(handle_t _MidlEsHandle,
EstablishContext_Return * _pType)
EstablishContext_Return_Decode(handle_t _MidlEsHandle,
EstablishContext_Return * _pType)
And the handles are (more or less) callbacks for marshalling:
created with:
MesEncodeIncrementalHandleCreate
MesDecodeIncrementalHandleCreate
The C interfaces are: MIDL_ES_READ,MIDL_ES_ALLOC,MIDL_ES_WRITE
These generated interface, plus some additional serialization buffers
then should be used in freerdp to decode/encode the wire data,
based on the IDL file.
Is there a similar way to achieve this kind of serialization from/to a
buffer with pidl?
regards,
Martin
More information about the samba-technical
mailing list