tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Proposed addition of strcodecs(3) library - review requested



>> Though for that to not suck, there'd need to be some way to
>> mux/demux, so things like hash values or crc32 could come back "on
>> the side" of the main data stream.
> I wonder if we could have multiple parents in a layer, or,
> alternatively, think of it as a tee-style FILE on the side.

Certainly.  First API that comes to mind:

FILE *fopen_crc32_r(FILE *sub, FILE *crc, unsigned int flags)
FILE *fopen_crc32_w(FILE *sub, FILE *crc, unsigned int flags)

The returned FILE is just like sub for read (_r) or write (_w), but, at
EOF, writes the generated CRC to crc.  If FSTACK_CASCADE_CLOSE is set
in flags, closing the returned stream also closes sub, othewise not; if
FSTACK_CASCADE_CLOSE_SIDE is set, crc.

I've done a lot of stdio stacking in various programs (funopen() makes
this sort of thing relatively easy), and it is a very pleasant kind of
API to use.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index