Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/pack/huffman.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1993-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* David Korn <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Header file for Huffman coding
23
* The coding is the same as that used with the System V pack program
24
*
25
* David Korn
26
* AT&T Laboratories
27
*/
28
29
#ifndef _HUFFMAN_H_
30
#define _HUFFMAN_H_ 1
31
32
#include <ast.h>
33
34
#define HUFFLEV 32 /* maximum number of bits per code */
35
#define HUFFMAG1 037 /* ascii <US> */
36
#define HUFFMAG2 036 /* ascii <RS> */
37
38
typedef struct
39
{
40
char length[(1<<CHAR_BIT)+1];
41
unsigned char levcount[HUFFLEV+1];
42
Sfoff_t insize;
43
Sfoff_t outsize;
44
long buffer;
45
long id;
46
int left;
47
int maxlev;
48
int nchars;
49
int excess;
50
} Huff_t;
51
52
Huff_t* huffinit(Sfio_t*,Sfoff_t);
53
Huff_t* huffgethdr(Sfio_t*);
54
int huffputhdr(Huff_t*,Sfio_t*);
55
Sfoff_t huffencode(Huff_t*,Sfio_t*,Sfio_t*,int);
56
Sfoff_t huffdecode(Huff_t*,Sfio_t*,Sfio_t*,int);
57
Sfio_t* huffdisc(Sfio_t*);
58
59
#define huffend(hp) free((void*)(hp))
60
#define huffisize(hp) ((hp)->insize)
61
#define huffosize(hp) ((hp)->outsize)
62
#define huffhsize(hp) ((hp)->maxlev+(hp)->nchars+7)
63
64
#endif /* !_HUFFMAN_H_ */
65
66