usaa24/sk1/compressor.h
2025-01-19 19:46:52 +01:00

36 lines
926 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef COMPRESSOR_H
#define COMPRESSOR_H
int compress_1(const char* input_file_name, const char* output_file_name);
int decompress_1(const char* input_file_name, const char* output_file_name);
int compress_2(const char* input_file_name, const char* output_file_name);
int decompress_2(const char* input_file_name, const char* output_file_name);
unsigned char* read_file(const char* file_name, size_t* size);
int write_file(const char* file_name, const unsigned char* buffer, size_t size);
typedef struct HuffmanNode {
unsigned char symbol;
size_t frequency;
struct HuffmanNode* left;
struct HuffmanNode* right;
} HuffmanNode;
HuffmanNode* build_huffman_tree(const unsigned char* data, size_t size);
void generate_huffman_codes(HuffmanNode* root, char** codes, char* buffer, int depth);
void free_huffman_tree(HuffmanNode* root);
#endif