summaryrefslogtreecommitdiff
path: root/src/tools/dehuff.c
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2001-08-15 05:23:32 +0000
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:36 +0200
commit3ea03344ec2b9c5cd17b0ef253adece705558019 (patch)
treeea26fd2828bb9e4c55f32f6239e092221ea456e4 /src/tools/dehuff.c
parent14d3cc45bcf1a9dce1e982fd82b79d7053be4048 (diff)
Removing junk.
Diffstat (limited to 'src/tools/dehuff.c')
-rw-r--r--src/tools/dehuff.c67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/tools/dehuff.c b/src/tools/dehuff.c
deleted file mode 100644
index d5805b8..0000000
--- a/src/tools/dehuff.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "huffman.hpp"
-
-#include "util.h"
-
-int main(int argc, char *argv[])
-{
- FILE *fp;
- char str[8];
- unsigned char *buf, *dbuf;
- int len;
-
- if (argc != 3) {
- fprintf(stderr, "usage: %s <compressed.rif> <outfile>\n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- fp = fopen(argv[1], "rb");
- if (fp == NULL) {
- perror("fopen");
- exit(EXIT_FAILURE);
- }
-
- fread(str, 1, 8, fp);
- if (strncmp(str, COMPRESSED_RIF_IDENTIFIER, 8) != 0) {
- fprintf(stderr, "%s: invalid compressed rif file\n", argv[1]);
- exit(EXIT_FAILURE);
- }
-
- len = fsize(argv[1]);
- buf = (unsigned char *)malloc(len);
- if (buf == NULL) {
- fprintf(stderr, "could not allocate %d bytes to load %s\n", len, argv[1]);
- exit(EXIT_FAILURE);
- }
-
- fseek(fp, 0, SEEK_SET);
-
- fread(buf, 1, len, fp);
- fclose(fp);
-
- len = ((HuffmanPackage *)buf)->UncompressedDataSize;
-
- dbuf = (unsigned char *)HuffmanDecompress((HuffmanPackage *)buf);
- if (dbuf == NULL) {
- fprintf(stderr, "Something went wrong with HuffmanDecompress\n");
- exit(EXIT_FAILURE);
- }
-
- free(buf);
-
- fp = fopen(argv[2], "wb");
- if (fp == NULL) {
- perror("fopen");
- exit(EXIT_FAILURE);
- }
-
- fwrite(dbuf, 1, len, fp);
- fclose(fp);
-
- free(dbuf);
-
- return 0;
-}