Annotation of researchv10dc/man/adm/man3/huff.3, revision 1.1.1.1

1.1       root        1: .TH HUFF 3
                      2: .CT 2 data_man
                      3: .SH NAME
                      4: huff \(mi huffman codebook/tree generator
                      5: .SH SYNOPSIS
                      6: .nf
                      7: .B #include <huff.h>
                      8: .PP
                      9: .B NODE *huff(inrout)
                     10: .B int (*inrout)();
                     11: .fi
                     12: .SH DESCRIPTION
                     13: .I Huff
                     14: generates a binary Huffman codebook.
                     15: It obtains a list of messages one at a time from an input routine,
                     16: .I inrout,
                     17: declared as
                     18: .IP
                     19: .EX
                     20: int inrout(str, p)
                     21: char ** str;
                     22: float *p;
                     23: .EE
                     24: .LP
                     25: .I Inrout
                     26: makes
                     27: .I *str
                     28: point to a null-terminated string identifying a message,
                     29: and places in
                     30: .I *p
                     31: the (arbitrarily normalized) frequency of the message.
                     32: .I Inrout
                     33: returns non-zero when data is returned and zero when there
                     34: is no more data.
                     35: .PP
                     36: .I Huff
                     37: returns a pointer to a root of type 
                     38: .BR NODE :
                     39: .IP
                     40: .EX
                     41: typedef struct node {
                     42:        char *datump;
                     43:        struct node *to;
                     44:        struct node *from;
                     45:        struct node *ldad;
                     46:        struct node *rdad;
                     47:        struct node *kid;
                     48:        float prob;
                     49: } NODE;
                     50: .EE
                     51: .LP
                     52: The root heads a linked list and the Huffman tree.
                     53: The doubly linked list,
                     54: connected via
                     55: .B from
                     56: and
                     57: .BR to ,
                     58: is ordered as the codebook was generated.
                     59: The tree is connected
                     60: via
                     61: .BR kid ,
                     62: .BR ldad ,
                     63: and 
                     64: .BR rdad ,
                     65: with null pointers at the various ends.
                     66: The
                     67: .B kid
                     68: field points towards the root,
                     69: .B ldad
                     70: and
                     71: .B rdad
                     72: point away:
                     73: .B node->ldad->kid==node
                     74: and
                     75: .BR node->rdad->kid==node .
                     76: the
                     77: .B datump
                     78: field is null or points to a message identifier.
                     79: .PP
                     80: The codeword for a message may be read off from the
                     81: path from the root to the node containing the message identifier,
                     82: counting
                     83: .I ldad
                     84: branches as 0 and
                     85: .I rdad
                     86: branches as 1.
                     87: .SH "BUGS"
                     88: A code with only one message dumps core.
                     89: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.