1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
6 <refentrytitle>pidl</refentrytitle>
7 <manvolnum>1</manvolnum>
11 <refname>pidl</refname>
12 <refpurpose>IDL Compiler written in Perl</refpurpose>
17 <command>pidl</command>
18 <arg choice="opt">--help</arg>
19 <arg choice="opt">--output OUTNAME</arg>
20 <arg choice="opt">--parse</arg>
21 <arg choice="opt">--dump</arg>
22 <arg choice="opt">--header[=OUTPUT]</arg>
23 <arg choice="opt">--parser[=OUTPUT]</arg>
24 <arg choice="opt">--server</arg>
25 <arg choice="opt">--template</arg>
26 <arg choice="opt">--eth-parser[=OUTPUT]</arg>
27 <arg choice="opt">--eth-header[=OUTPUT]</arg>
28 <arg choice="opt">--diff</arg>
29 <arg choice="opt">--keep</arg>
30 <arg choice="req">idlfile</arg>
31 <arg choice="opt">idlfile2</arg>
32 <arg choice="opt">...</arg>
37 <title>DESCRIPTION</title>
39 <para>pidl is an IDL compiler written in Perl that aims to be somewhat
40 compatible with the midl compiler. IDL stands for
41 "Interface Definition Language".</para>
43 <para>pidl can generate stubs for DCE/RPC server code, DCE/RPC
44 client code and ethereal dissectors for DCE/RPC traffic.</para>
46 <para>IDL compilers like <emphasis>pidl</emphasis> take a description
47 of an interface as their input and use it to generate C
48 (though support for other languages may be added later) code that
49 can use these interfaces, pretty print data sent
50 using these interfaces, or even generate ethereal
51 dissectors that can parse data sent over the
52 wire by these interfaces. </para>
54 <para>pidl takes IDL files in the same format as is used by midl,
55 converts it to a .pidl file (which contains pidl's internal representation of the interface) and can then generate whatever output you need.
56 .pidl files should be used for debugging purposes only. Write your
57 interface definitions in .idl format.
61 The goal of pidl is to implement a IDL compiler that can be used
62 while developing the RPC subsystem in Samba (for
63 both marshalling/unmarshalling and debugging purposes).
69 <title>OPTIONS</title>
75 Show list of available options.</para></listitem>
79 <term>--output OUTNAME</term>
80 <listitem><para>Write output files to OUTNAME.*, e.g.
81 OUTNAME.pidl. If --output is not used, the name of
82 the input IDL file is used without the extension and the dot
90 Tell pidl the files specified are (midl-style) IDL files.</para></listitem>
97 Convert .pidl files to (midl-style) IDL files. FIle will be named OUTNAME.idl.</para></listitem>
102 <term>--header</term>
104 Generate a C header file for the specified interface. File will be named OUTNAME.h.</para></listitem>
109 <term>--parser</term>
111 Generate a C file capable of parsing data sent using the interface.
112 File will be named OUTNAME.c.
118 <term>--server</term>
120 Generate boilerplate for the RPC server that implements
121 the interface. Generates OUTNAME_s.c</para></listitem>
126 <term>--template</term>
128 Generate stubs for a RPC server that implements
129 the interface. Output will be written to stdout.
135 <term>--eth-parser</term>
137 Generate an Ethereal dissector (in C) for the interface. Output will
138 be written to packet-dcerpc-OUTNAME.c.
143 <term>--eth-header</term>
145 Generate a header file for the Ethereal dissector. Output will
146 be written to packet-dcerpc-OUTNAME.h.
153 Convert an IDL file to a pidl file and then back to a
154 IDL file and see if there are any differences with the
155 original IDL file. Useful for debugging pidl.</para></listitem>
162 Tell pidl to keep the pidl files (used as intermediate files
163 between the IDL files and the parser/server/etc code). Useful
164 for debugging pidl.</para></listitem>
170 <title>SYNTAX</title>
172 <para>IDL files are always preprocessed using the C preprocessor.</para>
174 <para>Each IDL file describes exactly one interface. Interfaces
175 can contain several C-like function definitions.</para>
177 <para>Pretty much everything in an interface (the interface itself,
178 functions, parameters) can have attributes (or properties
179 whatever name you give them). Attributes
180 always prepend the element they apply to and are surrounded
181 by square brackets ([]). Multiple attributes
182 are separated by comma's; arguments to attributes are
183 specified between parentheses. </para>
185 <para>See the section COMPATIBILITY for the list of attributes that
186 pidl supports.</para>
188 <para>C-style comments can be used.</para>
193 <title>MIDL TYPES</title>
196 pidl uses slightly different types to midl by default. The following
197 defines in your MS IDL may make things easier to use the same IDL on
202 #define unistr [string] wchar_t *
206 #define HYPER_T hyper
210 Let's look at the multiple ways you can encode an array.
214 <title>CONFORMANT ARRAYS</title>
217 A conformant array is one with that ends in [*] or []. The strange
218 things about conformant arrays are:
222 <member>they can only appear as the last element of a structure</member>
223 <member>the array size appears before the structure itself on the wire. </member>
235 [size_is(count)] long s[*];
240 it appears like this:
244 [size_is] [abc] [count] [foo] [s...]
248 the first [size_is] field is the allocation size of the array, and
249 occurs before the array elements and even before the structure
254 Note that size_is() can refer to a constant, but that doesn't change
255 the wire representation. It does not make the array a fixed array.
259 midl.exe would write the above array as the following C header:
272 pidl takes a different approach, and writes it like this:
287 <title>VARYING ARRAYS</title>
291 A varying array looks like this:
299 [size_is(count)] long *s;
304 This will look like this on the wire:
308 [abc] [count] [foo] [PTR_s] [count] [s...]
314 <title>FIXED ARRAYS</title>
317 A fixed array looks like this:
327 The NDR representation looks just like 10 separate long
328 declarations. The array size is not encoded on the wire.
332 pidl also supports "inline" arrays, which are not part of the IDL/NDR
333 standard. These are declared like this:
346 This appears like this:
350 [foo] [count] [bar] [s...]
354 Fixed arrays are an extension added to support some of the strange
355 embedded structures in security descriptors and spoolss.
362 <title>COMPATIBILITY WITH MIDL</title>
365 <title>Asynchronous communication</title>
371 <title>Typelibs (.tlb files)</title>
377 <title>strings</title>
379 <para>Strings in pidl are a data type rather then an attribute.</para>
384 <title>Datagram support</title>
386 <para>ncadg is not supported yet.</para>
390 <title>Supported properties (attributes is the MIDL term)</title>
393 in, out, ref, length_is, switch_is, size_is, uuid, case, default, string, unique, ptr, pointer_default, v1_enum, object, helpstring, range, local, call_as, endpoint, switch_type, progid, coclass, iid_is.
399 <title>PIDL Specific properties</title>
402 <varlistentry><term>public</term>
404 The [public] property on a structure or union is a pidl extension that
405 forces the generated pull/push functions to be non-static. This allows
406 you to declare types that can be used between modules. If you don't
407 specify [public] then pull/push functions for other than top-level
408 functions are declared static.
412 <varlistentry><term>noprint</term>
414 The [noprint] property is a pidl extension that allows you to specify
415 that pidl should not generate a ndr_print_*() function for that
416 structure or union. This is used when you wish to define your own
417 print function that prints a structure in a nicer manner. A good
418 example is the use of [noprint] on dom_sid, which allows the
419 pretty-printing of SIDs.
423 <varlistentry><term>value</term>
425 The [value(expression)] property is a pidl extension that allows you
426 to specify the value of a field when it is put on the wire. This
427 allows fields that always have a well-known value to be automatically
428 filled in, thus making the API more programmer friendly. The
429 expression can be any C expression, although if you refer to variables
430 in the current structure you will need to dereference them with
431 r->. See samr_Name as a good example.
435 <varlistentry><term>relative</term>
437 The [relative] property can be supplied on a pointer. When it is used
438 it declares the pointer as a spoolss style "relative" pointer, which
439 means it appears on the wire as an offset within the current
440 encapsulating structure. This is not part of normal IDL/NDR, but it is
441 a very useful extension as it avoids the manual encoding of many
446 <varlistentry><term>subcontext(length)</term>
448 Specifies that a size of <replaceable>length</replaceable>
449 bytes should be read, followed by a blob of that size,
450 which will be parsed as NDR.
454 <varlistentry><term>flag</term>
456 Specify boolean options, mostly used for
457 low-level NDR options. Several options
458 can be specified using the | character.
459 Note that flags are inherited by substructures!
463 <varlistentry><term>nodiscriminant</term>
465 The [nodiscriminant] property on a union means that the usual uint16
466 discriminent field at the start of the union on the wire is
467 omitted. This is not normally allowed in IDL/NDR, but is used for some
472 <varlistentry><term>align</term>
474 Force the alignment of the field this attribute is placed
475 on to the number of bytes specified.
482 <title>Unsupported MIDL properties</title>
484 <para>aggregatable, appobject, async_uuid, bindable, control, cpp_quote, defaultbind, defaultcollelem, defaultvalue, defaultvtable, dispinterface, displaybind, dual, entry, first_is, helpcontext, helpfile, helpstringcontext, helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib, import, include, includelib, last_is, lcid, licensed, max_is, module, ms_union, no_injected_text, nonbrowsable, noncreatable, nonextensible, odl, oleautomation, optional, pragma, propget, propputref, propput, readonly, requestedit, restricted, retval, source, transmit_as, uidefault, usesgetlasterror, vararg, vi_progid, wire_marshal. </para>
491 <title>VERSION</title>
493 <para>This man page is correct for version 4.0 of the Samba suite.</para>
497 <title>SEE ALSO</title>
499 <para><ulink url="http://msdn.microsoft.com/library/en-us/rpc/rpc/field_attributes.asp">Field Attributes [Remote Procedure Call]</ulink>, ethereal</para>
504 <title>AUTHOR</title>
508 <para>pidl was written by Andrew Tridgell, Stefan Metzmacher, Tim
509 Potter and Jelmer Vernooij. </para>
511 <para>This manpage was written by Andrew Tridgell and Jelmer Vernooij. </para>