shithub: dfc

ref: 2e08190b534ac79e33d1813c8d0aa9d71dbd1d02
dir: /dfc.1/

View raw version
.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.