summaryrefslogtreecommitdiff
path: root/source4/pidl/pidl.1.xml
blob: 6dd0d475306867c32f9813c1b905cd31cf98f4f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
<refentry id="pidl.1">

<refmeta>
	<refentrytitle>pidl</refentrytitle>
	<manvolnum>1</manvolnum>
</refmeta>

<refnamediv>
	<refname>pidl</refname>
	<refpurpose>IDL Compiler written in Perl</refpurpose>
</refnamediv>

<refsynopsisdiv>
	<cmdsynopsis>
		<command>pidl</command>
		<arg choice="opt">--help</arg>
		<arg choice="opt">--outputdir OUTNAME</arg>
		<arg choice="opt">--parse-tree</arg>
		<arg choice="opt">--dump-tree</arg>
		<arg choice="opt">--ndr-header[=OUTPUT]</arg>
		<arg choice="opt">--header[=OUTPUT]</arg>
		<arg choice="opt">--ejs[=OUTPUT]</arg>
		<arg choice="opt">--swig[=OUTPUT]</arg>
		<arg choice="opt">--uint-enums</arg>
		<arg choice="opt">--ndr-parser[=OUTPUT]</arg>
		<arg choice="opt">--client</arg>
		<arg choice="opt">--server</arg>
		<arg choice="opt">--dcom-proxy</arg>
		<arg choice="opt">--com-header</arg>
		<arg choice="opt">--odl</arg>
		<arg choice="opt">--warn-compat</arg>
		<arg choice="opt">--quiet</arg>
		<arg choice="opt">--verbose</arg>
		<arg choice="opt">--template</arg>
		<arg choice="opt">--eth-parser[=OUTPUT]</arg>
		<arg choice="opt">--diff</arg>
		<arg choice="opt">--dump-idl</arg>
		<arg choice="req">idlfile</arg>
		<arg choice="opt">idlfile2</arg>
		<arg choice="opt">...</arg>
	</cmdsynopsis>
</refsynopsisdiv>

<refsect1>
	<title>DESCRIPTION</title>

	<para>pidl is an IDL compiler written in Perl that aims to be somewhat 
		compatible with the midl compiler. IDL stands for 
		"Interface Definition Language".</para>

	<para>pidl can generate stubs for DCE/RPC server code, DCE/RPC 
		client code and ethereal dissectors for DCE/RPC traffic.</para>

	<para>IDL compilers like <emphasis>pidl</emphasis> take a description 
		of an interface as their input and use it to generate C 
		(though support for other languages may be added later) code that 
		can use these interfaces, pretty print data sent 
		using these interfaces, or even generate ethereal 
		dissectors that can parse data sent over the 
		wire by these interfaces. </para>

	<para>pidl takes IDL files in the same format as is used by midl, 
		converts it to a .pidl file (which contains pidl's internal representation of the interface) and can then generate whatever output you need.
		.pidl files should be used for debugging purposes only. Write your 
		interface definitions in .idl format.
	</para>

	<para>
		The goal of pidl is to implement a IDL compiler that can be used 
		while developing the RPC subsystem in Samba (for 
		both marshalling/unmarshalling and debugging purposes).
	</para>

</refsect1>

<refsect1>
	<title>OPTIONS</title>

	<variablelist>
		<varlistentry>
		<term>--help</term>
		<listitem><para>
		Show list of available options.</para></listitem>
		</varlistentry>
		
		<varlistentry>
		<term>--outputdir OUTNAME</term>
		<listitem><para>Write output files to the specified directory. 
				Defaults to the current directory.
		</para></listitem>
		</varlistentry>
		
		<varlistentry>
		<term>--parse-tree</term>
		<listitem><para>
				Read internal tree structure from input files rather 
		then assuming they contain IDL.</para></listitem>
		</varlistentry>


		<varlistentry>
		<term>--dump-idl</term>
		<listitem><para>
				Generate a new IDL file. File will be named OUTNAME.idl.</para></listitem>
		</varlistentry>


		<varlistentry>
		<term>--header</term>
		<listitem><para>
				Generate a C header file for the specified interface. Filename defaults to OUTNAME.h.</para></listitem>
		</varlistentry>

		<varlistentry>
		<term>--ndr-header</term>
		<listitem><para>
				Generate a C header file with the prototypes for the NDR parsers. Filename defaults to ndr_OUTNAME.h.</para></listitem>
		</varlistentry>

		<varlistentry>
		<term>--ndr-parser</term>
		<listitem><para>
				Generate a C file containing NDR parsers. 
				Filename defaults to ndr_OUTNAME.c.
		</para></listitem>
		</varlistentry>


		<varlistentry>
		<term>--server</term>
		<listitem><para>
		Generate boilerplate for the RPC server that implements 
		the interface. Filename defaults to ndr_OUTNAME_s.c</para></listitem>
		</varlistentry>


		<varlistentry>
		<term>--template</term>
		<listitem><para>
		Generate stubs for a RPC server that implements 
		the interface. Output will be written to stdout.
		</para></listitem>
		</varlistentry>


		<varlistentry>
		<term>--eth-parser</term>
		<listitem><para>
		Generate an Ethereal dissector (in C) for the interface. Filename
		defaults to packet-dcerpc-OUTNAME.c. 
		</para>
	
		<para>Pidl will read additional data 
			from an ethereal conformance file if present. Such a file should 
			have the same location as the IDL file but with the extension 
			<quote>cnf</quote> rather then <quote>idl</quote>. See 
			below for details on the format of this file.
		</para></listitem>
		</varlistentry>

		<varlistentry>
		<term>--diff</term>
		<listitem><para>
				Parse an IDL file,  generate a new IDL file based 
				on the internal data structures and see if there are 
				any differences with the 
		original IDL file. Useful for debugging pidl.</para></listitem>
		</varlistentry>


		<varlistentry>
		<term>--dump-tree</term>
		<listitem><para>
		Tell pidl to dump the internal tree representation of an IDL 
		file the to disk. Useful 
		for debugging pidl.</para></listitem>
		</varlistentry>
	</variablelist>
</refsect1>

<refsect1>
	<title>IDL SYNTAX</title>

	<para>IDL files are always preprocessed using the C preprocessor.</para>

	<para>Pretty much everything in an interface (the interface itself,
		functions, parameters) can have attributes (or properties 
		whatever name you give them). Attributes 
		always prepend the element they apply to and are surrounded 
		by square brackets ([]). Multiple attributes 
		are separated by comma's; arguments to attributes are 
		specified between parentheses. </para>

	<para>See the section COMPATIBILITY for the list of attributes that 
		pidl supports.</para>

	<para>C-style comments can be used.</para>
	
<refsect2>
	<title>CONFORMANT ARRAYS</title>

	<para>
A conformant array is one with that ends in [*] or []. The strange
things about conformant arrays are:
</para>

<simplelist>
	<member>they can only appear as the last element of a structure</member>
	<member>the array size appears before the structure itself on the wire. </member>
</simplelist>

<para>
	So, in this example:
</para>

<programlisting>
	typedef struct {
		long abc;
		long count;     
		long foo;
		[size_is(count)] long s[*];
	} Struct1;
</programlisting>

<para>
it appears like this:
</para>

<programlisting>
[size_is] [abc] [count] [foo] [s...]
</programlisting>

<para>
the first [size_is] field is the allocation size of the array, and
occurs before the array elements and even before the structure
alignment.
</para>

<para>
Note that size_is() can refer to a constant, but that doesn't change
the wire representation. It does not make the array a fixed array.
</para>

<para>
midl.exe would write the above array as the following C header:
</para>

<programlisting>
   typedef struct {
		long abc;
		long count;     
		long foo;
		long s[1];
	} Struct1;
</programlisting>

<para>
pidl takes a different approach, and writes it like this:
</para>

<programlisting>
    typedef struct {
		long abc;
		long count;     
		long foo;
		long *s;
	} Struct1;
</programlisting>

</refsect2>

<refsect2>
	<title>VARYING ARRAYS</title>

<para>
A varying array looks like this:
</para>

<programlisting>
	typedef struct {
		long abc;
		long count;     
		long foo;
		[size_is(count)] long *s;
	} Struct1;
</programlisting>

<para>
This will look like this on the wire:
</para>

<programlisting>
[abc] [count] [foo] [PTR_s]    [count] [s...]
</programlisting>

</refsect2>

<refsect2>
	<title>FIXED ARRAYS</title>

<para>
A fixed array looks like this:
</para>

<programlisting>
    typedef struct {
	    long s[10];
    } Struct1;
</programlisting>

<para>
The NDR representation looks just like 10 separate long
declarations. The array size is not encoded on the wire.
</para>

<para>
pidl also supports "inline" arrays, which are not part of the IDL/NDR
standard. These are declared like this:
</para>

<programlisting>
    typedef struct {
	    uint32 foo;
	    uint32 count;
	    uint32 bar;
	    long s[count];
    } Struct1;
</programlisting>

<para>
This appears like this:
</para>

<programlisting>
[foo] [count] [bar] [s...]
</programlisting>

<para>
Fixed arrays are an extension added to support some of the strange
embedded structures in security descriptors and spoolss. 
</para>

</refsect2>

<para>This section is by no means complete. See the OpenGroup and MSDN 
	documentation for additional information.</para>
</refsect1>

<refsect1>
	<title>COMPATIBILITY WITH MIDL</title>

	<refsect2>
		<title>Missing features in pidl</title>
		<para>
			The following MIDL features are not (yet) implemented in pidl 
			or are implemented with an incompatible interface:
		</para>

		<simplelist>
			<member>Asynchronous communication</member>
			<member>Typelibs (.tlb files)</member>
			<member>Datagram support (ncadg_*)</member>
		</simplelist>
	</refsect2>

	<refsect2>
		<title>Supported properties (attributes is the MIDL term)</title>

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

</refsect2>

<refsect2>
	<title>PIDL Specific properties</title>

<variablelist>
	<varlistentry><term>public</term>
		<listitem><para>
The [public] property on a structure or union is a pidl extension that
forces the generated pull/push functions to be non-static. This allows
you to declare types that can be used between modules. If you don't
specify [public] then pull/push functions for other than top-level
functions are declared static.
		</para></listitem>
	</varlistentry>
				
	<varlistentry><term>noprint</term>
		<listitem><para>
The [noprint] property is a pidl extension that allows you to specify
that pidl should not generate a ndr_print_*() function for that
structure or union. This is used when you wish to define your own
print function that prints a structure in a nicer manner. A good
example is the use of [noprint] on dom_sid, which allows the
pretty-printing of SIDs.
		</para></listitem>
	</varlistentry>

	<varlistentry><term>value</term>
		<listitem><para>
The [value(expression)] property is a pidl extension that allows you
to specify the value of a field when it is put on the wire. This
allows fields that always have a well-known value to be automatically
filled in, thus making the API more programmer friendly. The
expression can be any C expression.
		</para></listitem>
	</varlistentry>
		
	<varlistentry><term>relative</term>
		<listitem><para>
The [relative] property can be supplied on a pointer. When it is used
it declares the pointer as a spoolss style "relative" pointer, which
means it appears on the wire as an offset within the current
encapsulating structure. This is not part of normal IDL/NDR, but it is
a very useful extension as it avoids the manual encoding of many
complex structures.
		</para></listitem>
	</varlistentry>

	<varlistentry><term>subcontext(length)</term>
		<listitem><para>
				Specifies that a size of <replaceable>length</replaceable>
				bytes should be read, followed by a blob of that size, 
				which will be parsed as NDR.
		</para></listitem>
	</varlistentry>

	<varlistentry><term>flag</term>
		<listitem><para>
				Specify boolean options, mostly used for 
				low-level NDR options. Several options 
				can be specified using the | character.
				Note that flags are inherited by substructures!
		</para></listitem>
	</varlistentry>

	<varlistentry><term>nodiscriminant</term>
		<listitem><para>
The [nodiscriminant] property on a union means that the usual uint16
discriminent field at the start of the union on the wire is
omitted. This is not normally allowed in IDL/NDR, but is used for some
spoolss structures.
		</para></listitem>
	</varlistentry>

	<varlistentry><term>charset(name)</term>
		<listitem><para>
				Specify that the array or string uses the specified 
				charset. If this attribute is specified, pidl will 
				take care of converting the character data from this format 
				to the host format. Commonly used values are UCS2, DOS and UTF8.
		</para></listitem>
	</varlistentry>
</variablelist>
</refsect2>

<refsect2>
	<title>Unsupported MIDL properties</title>

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

</refsect2>

</refsect1>

<refsect1>
	<title>ETHEREAL CONFORMANCE FILES</title>

<para>
Pidl needs additional data for ethereal output. This data is read from 
so-called conformance files. This section describes the format of these 
files.</para>

<para>
Conformance files are simple text files with a single command on each line.
Empty lines and lines starting with a '#' character are ignored.
Arguments to commands are seperated by spaces.
</para>

<para>
The following commands are currently supported:
</para>

<variablelist>

<varlistentry>
	<term>TYPE name dissector ft_type base_type mask valsstring alignment</term>
	<listitem><para>Register new data type with specified name, what dissector function to call and what properties to give header fields for elements of this type.</para></listitem>
</varlistentry>

<varlistentry>
	<term>NOEMIT type</term>
	<listitem><para>
	Suppress emitting a dissect_type function for the specified type
	</para></listitem>
</varlistentry>

<varlistentry>
	<term>PARAM_VALUE type param</term>
	<listitem><para>
	Set parameter to specify to dissector function for given type.
	</para></listitem>
</varlistentry>

<varlistentry>
	<term>HF_FIELD hf title filter ft_type base_type valsstring mask description</term>
	<listitem><para>
	Generate a custom header field with specified properties.
	</para></listitem>
</varlistentry>

<varlistentry>
	<term>HF_RENAME old_hf_name new_hf_name</term>
	<listitem><para>
	Force the use of new_hf_name when the parser generator was going to 
	use old_hf_name.
	</para>

	<para>
	This can be used in conjunction with HF_FIELD in order to make more then 
	one element use the same filter name.
	</para>
	</listitem>
</varlistentry>

<varlistentry>
	<term>STRIP_PREFIX prefix</term>
	<listitem><para>
	Remove the specified prefix from all function names (if present).
	</para></listitem>
</varlistentry>
	
<varlistentry>
	<term>PROTOCOL longname shortname filtername</term>
	<listitem><para>
	Change the short-, long- and filter-name for the current interface in
	Ethereal.
	</para></listitem>
</varlistentry>

<varlistentry>
	<term>FIELD_DESCRIPTION field desc</term>
	<listitem><para>Change description for the specified header field. `field' is the hf name of the field.
	</para></listitem>
</varlistentry>

<varlistentry>
	<term>IMPORT dissector code...</term>
	<listitem><para>
	Code to insert when generating the specified dissector. @HF@ and 
	@PARAM@ will be substituted.
	</para></listitem>
</varlistentry>

</variablelist>

</refsect1>

<refsect1>
	<title>EXAMPLES</title>

	<programlisting>
	# Generating an ethereal parser
	$ ./pidl --eth-parser -- atsvc.idl
	
	# Generating a TDR parser
	$ ./pidl --tdr-parser --tdr-header --header -- regf.idl
	</programlisting>

</refsect1>

<refsect1>
	<title>VERSION</title>

	<para>This man page is correct for version 4.0 of the Samba suite.</para>
</refsect1>

<refsect1>
	<title>SEE ALSO</title>

	<para><ulink url="http://msdn.microsoft.com/library/en-us/rpc/rpc/field_attributes.asp">Field Attributes [Remote Procedure Call]</ulink>, <ulink url="http://wiki.ethereal.com/DCE/RPC">Ethereal Wiki on DCE/RPC</ulink>.</para>

</refsect1>

<refsect1>
	<title>AUTHOR</title>

	<para>pidl was written by Andrew Tridgell, Stefan Metzmacher, Tim 
		Potter and Jelmer Vernooij. </para>

	<para>This manpage was written by Jelmer Vernooij, partially based on the original pidl README by Andrew Tridgell. </para>
	
</refsect1>

</refentry>