12 int getbits(int numbits)
23 for(; numbits > 0; numbits--)
37 int main(int argc, char **argv) {
41 int chars[256], lens[256];
43 for(i = 0; i < 512; i++)
44 tree[i].l = tree[i].r = tree[i].c = -1;
45 if((getc(stdin) != 'H') ||
46 (getc(stdin) != 'E') ||
47 (getc(stdin) != '3') ||
48 (getc(stdin) != 13)) {
49 fprintf(stderr, "not a HE3 file\n");
53 fread(&size, 4, 1, stdin);
55 fread(&ts, 2, 1, stdin);
56 for(i = 0; i < ts; i++) {
57 chars[i] = getc(stdin);
58 lens[i] = getc(stdin);
60 for(i = 0; i < ts; i++) {
62 for(o = 0; o < lens[i]; o++) {
65 n = tree[n].r = newnode++;
70 n = tree[n].l = newnode++;
76 fprintf(stderr, "double-used node: \"%c\"\n", chars[i]);
83 for(i = 0; i < size;) {
89 fprintf(stderr, "invalid path");
93 putc(tree[n].c, stdout);