Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
Universitaet Berlin. See the accompanying file "COPYRIGHT" for
details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
U
BITTER 1
NAME
bitter, sweet \(em code-generators for packing bits
SYNOPSIS
bitter < input > output
sweet < input > output
"DESCRIPTION"
Bitter and sweet are two filters which turn a description of the
form
name number-of-bits name number-of-bits ...into code.Bitter generates code that packs the specified bits from their variables into an array of unsigned char referenced by an advancing pointer c.
Sweet generates code that unpacks the specified bits from an array of unsigned char referenced by a mutable pointer c into the named variables. .SH OPTIONS
.SH "RETURN VALUE"
.SH ERRORSEXAMPLES% cat in amaretto 1 banana 2 cherry 3 strawberry 4 vanilla 15 walnut 15 % bitter < in *c++ = ((amaretto & 0x1) << 7) | ((banana & 0x3) << 5) | ((cherry & 0x7) << 2) | ((strawberry >> 2) & 0x3); *c++ = ((strawberry & 0x3) << 6) | ((vanilla >> 9) & 0x3F); *c++ = ((vanilla >> 1) & 0xFF); *c++ = ((vanilla & 0x1) << 7) | ((walnut >> 8) & 0x7F); *c++ = walnut & 0xFF; % sweet < in amaretto = (*c >> 7) & 0x1; banana = (*c >> 5) & 0x3; cherry = (*c >> 2) & 0x7; strawberry = (*c++ & 0x3) << 2; strawberry |= (*c >> 6) & 0x3; vanilla = (*c++ & 0x3F) << 9; vanilla |= (*c++ & 0xFF) << 1; vanilla |= (*c >> 7) & 0x1; walnut = (*c++ & 0x7F) << 8; walnut |= *c++;NOTESThis is a quick hack for the gsm_encode() and gsm_decode() routines.BUGSPlease direct bug reports to jutta@pobox.com and cabo@tzi.org.