Manual Page Result
0
Command: huff | Section: 3 | Source: UNIX v10 | File: huff.3
HUFF(3) Library Functions Manual HUFF(3)
NAME
huff - huffman codebook/tree generator
SYNOPSIS
#include <huff.h>
NODE *huff(inrout)
int (*inrout)();
DESCRIPTION
Huff generates a binary Huffman codebook. It obtains a list of mes-
sages one at a time from an input routine, inrout, declared as
int inrout(str, p)
char ** str;
float *p;
Inrout makes *str point to a null-terminated string identifying a mes-
sage, and places in *p the (arbitrarily normalized) frequency of the
message. Inrout returns non-zero when data is returned and zero when
there is no more data.
Huff returns a pointer to a root of type NODE:
typedef struct node {
char *datump;
struct node *to;
struct node *from;
struct node *ldad;
struct node *rdad;
struct node *kid;
float prob;
} NODE;
The root heads a linked list and the Huffman tree. The doubly linked
list, connected via from and to, is ordered as the codebook was gener-
ated. The tree is connected via kid, ldad, and rdad, with null point-
ers at the various ends. The kid field points towards the root, ldad
and rdad point away: node->ldad->kid==node and node->rdad->kid==node.
the datump field is null or points to a message identifier.
The codeword for a message may be read off from the path from the root
to the node containing the message identifier, counting ldad branches
as 0 and rdad branches as 1.
BUGS
A code with only one message dumps core.
HUFF(3)