fix up compress.h
so that it can be used with c++ more conveniently
This commit is contained in:
parent
cfb89888c1
commit
e8fb851b50
4 changed files with 35 additions and 24 deletions
23
compress.c
23
compress.c
|
@ -16,6 +16,29 @@
|
|||
#define debug(...)
|
||||
#endif
|
||||
|
||||
// compression method values for backref_t and rle_t
|
||||
typedef enum {
|
||||
rle_8 = 0,
|
||||
rle_16 = 1,
|
||||
rle_seq = 2,
|
||||
|
||||
lz_norm = 0,
|
||||
lz_rot = 1,
|
||||
lz_rev = 2
|
||||
} method_e;
|
||||
|
||||
// used to store and compare backref candidates
|
||||
typedef struct {
|
||||
uint16_t offset, size;
|
||||
method_e method;
|
||||
} backref_t;
|
||||
|
||||
// used to store RLE candidates
|
||||
typedef struct {
|
||||
uint16_t size, data;
|
||||
method_e method;
|
||||
} rle_t;
|
||||
|
||||
uint8_t rotate (uint8_t);
|
||||
rle_t rle_check (uint8_t*, uint8_t*, uint32_t, int);
|
||||
backref_t ref_search (uint8_t*, uint8_t*, uint32_t, int);
|
||||
|
|
34
compress.h
34
compress.h
|
@ -9,40 +9,26 @@
|
|||
#ifndef _COMPRESS_H
|
||||
#define _COMPRESS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DATA_SIZE 65536
|
||||
#define RUN_SIZE 32
|
||||
#define LONG_RUN_SIZE 1024
|
||||
|
||||
// compression method values for backref_t and rle_t
|
||||
typedef enum {
|
||||
rle_8 = 0,
|
||||
rle_16 = 1,
|
||||
rle_seq = 2,
|
||||
|
||||
lz_norm = 0,
|
||||
lz_rot = 1,
|
||||
lz_rev = 2
|
||||
} method_e;
|
||||
|
||||
// used to store and compare backref candidates
|
||||
typedef struct {
|
||||
uint16_t offset, size;
|
||||
method_e method;
|
||||
} backref_t;
|
||||
|
||||
// used to store RLE candidates
|
||||
typedef struct {
|
||||
uint16_t size, data;
|
||||
method_e method;
|
||||
} rle_t;
|
||||
|
||||
size_t pack (uint8_t *unpacked, uint32_t inputsize, uint8_t *packed, int fast);
|
||||
size_t unpack (uint8_t *packed, uint8_t *unpacked);
|
||||
|
||||
size_t unpack_from_file (FILE *file, unsigned int offset, uint8_t *unpacked);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// end include guard
|
||||
#endif
|
||||
|
|
1
exhal.c
1
exhal.c
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "compress.h"
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
|
|
1
inhal.c
1
inhal.c
|
@ -11,6 +11,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "compress.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue