-
Notifications
You must be signed in to change notification settings - Fork 0
/
dfc.1
74 lines (74 loc) · 1.48 KB
/
dfc.1
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
.TH DFC 1
.SH NAME
dfc \- data field compiler
.SH SYNOPSIS
.B dfc
[
.B -lb
]
.I dat.h
.SH DESCRIPTION
.I Dfc
reads C structure definitions defined in
.I dat.h
and outputs machine portable C functions on stdout
to convert those structures to and from byte arrays.
The
.B -b
and
.B -l
flags change the byte order of the data to little and
big endian respectively. If none are specified
.I dfc
defaults to big endian.
.SH GRAMMER
The grammer accepted is a subset of C, specifically
enum and structure definitions are understood. Additionally
.I dfc
defines some pragmas for its own use, each in the form:
.EX
#pragma dfc <directive>
.EE
.TF little
.TP
little
Change the byte order to little endian
.TP
big
Change the byte order to big endian
.TP
done
Instructs
.I dfc
to not parse anything after this line.
.PD
.PP
All other preprocessor directives are ignored. Likewise
typedef's are parsed but do not have any impact; Any struct defined
is expected to be typedef'd.
.PP
Struct member types must be one of
.BR u64int ,
.BR u32int ,
.BR u16int ,
.BR u8int ,
.BR uchar ,
or a struct previously defined.
.SH OUTPUT
For each struct defined
.I dfc
outputs two functions. For a struct called
.L Block
the following functions are generated:
.IP
.EX
long getblock(Block *dst, uchar *src);
long putblock(uchar *dst, Block *src);
.EE
.PP
The return value for each is the total number
of bytes consumed or generated respectively.
.SH SOURCE
.B /sys/src/cmd/dfc.y
.SH BUGS
Calling the input grammer a subset of C is generous.