diff options
| author | johannes <johannes.herman@gmail.com> | 2024-01-31 10:01:01 +0100 |
|---|---|---|
| committer | johannes <johannes.herman@gmail.com> | 2024-01-31 10:01:01 +0100 |
| commit | 1bdee2153953e23bf71f7a5e83145bb4d67db567 (patch) | |
| tree | 878890b78170f9e72e09d89e92631b9b6f060fa1 /inc | |
initial init, huffman and demoheader
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/demo.h | 34 | ||||
| -rw-r--r-- | inc/huffman.h | 16 |
2 files changed, 50 insertions, 0 deletions
diff --git a/inc/demo.h b/inc/demo.h new file mode 100644 index 0000000..154a333 --- /dev/null +++ b/inc/demo.h @@ -0,0 +1,34 @@ +#ifndef DEMO_H +#define DEMO_H + +#include <stdio.h> + +/* demoheader struct */ +typedef struct +{ + unsigned char version; + char netversion[64]; + char mapname[64]; + unsigned char mapsize[4]; // Big endian int + unsigned char mapcrc[4]; // Big endian int + char type[8]; + unsigned char length[4]; // Big endian int + char timestamp[20]; +} demoheader; + +/* demotimeline struct, only contains the raw data */ +typedef struct +{ + char data[260]; +} demotimeline; + +/* Read demo header from demofile into given demoheader */ +/* Returns a positive number on success, negative on fail */ +int readdemoheader(FILE *demofile, demoheader *demoheader); + +/* Read demo timeline from demofile into given demoheader */ +/* Returns a positive number on success, negative on fail */ +/* Must have read the header from demofile beforehand */ +int readdemotimeline(FILE *demofile, demotimeline *demotimeline); + +#endif // DEMO_H
\ No newline at end of file diff --git a/inc/huffman.h b/inc/huffman.h new file mode 100644 index 0000000..1ac7ff6 --- /dev/null +++ b/inc/huffman.h @@ -0,0 +1,16 @@ +#ifndef HUFFMAN_H +#define HUFFMAN_H + +/* Initialize huffman */ +/* Uses the standard frequency table if NULL is provided */ +void inithuff(const unsigned int *frequencies); + +/* Compress contents of input buffer, result in output buffer */ +/* Returns -1 on too small output buffer */ +int compresshuff(const char *inputbuff, int inputsize, char *outputbuff, int outputsize); + +/* Decompress contents of input buffer, result in output buffer */ +/* Returns -1 on decompress error */ +int decompresshuff(const char *inputbuff, int inputsize, char *outputbuff, int outputsize); + +#endif // HUFFMAN_H |
