51
include/CRCLib.h
Normal file
51
include/CRCLib.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Table of CRCs of all 8-bit messages. */
|
||||
unsigned long crc_table[256];
|
||||
|
||||
/* Flag: has the table been computed? Initially false. */
|
||||
int crc_table_computed = 0;
|
||||
|
||||
/* Make the table for a fast CRC. */
|
||||
void make_crc_table(void)
|
||||
{
|
||||
unsigned long c;
|
||||
int n, k;
|
||||
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = (unsigned long) n;
|
||||
for (k = 0; k < 8; k++) {
|
||||
if (c & 1)
|
||||
c = 0xedb88320L ^ (c >> 1);
|
||||
else
|
||||
c = c >> 1;
|
||||
}
|
||||
crc_table[n] = c;
|
||||
}
|
||||
crc_table_computed = 1;
|
||||
}
|
||||
|
||||
|
||||
/* Update a running CRC with the bytes buf[0..len-1]--the CRC
|
||||
should be initialized to all 1's, and the transmitted value
|
||||
is the 1's complement of the final running CRC (see the
|
||||
crc() routine below). */
|
||||
|
||||
unsigned long update_crc(unsigned long crc, unsigned char *buf,
|
||||
int len)
|
||||
{
|
||||
unsigned long c = crc;
|
||||
int n;
|
||||
|
||||
if (!crc_table_computed)
|
||||
make_crc_table();
|
||||
for (n = 0; n < len; n++) {
|
||||
c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Return the CRC of the bytes buf[0..len-1]. */
|
||||
unsigned long crc(unsigned char *buf, int len)
|
||||
{
|
||||
return update_crc(0xffffffffL, buf, len) ^ 0xffffffffL;
|
||||
}
|
||||
|
||||
8
include/compress_util.h
Normal file
8
include/compress_util.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include <zlib.h>
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
void zlib_decompress_data(unsigned char *data_chunk, size_t file_length, unsigned char **buff, size_t *sz);
|
||||
void zlib_compress_data(unsigned char *data_chunk, size_t file_length, unsigned char **buff, size_t *sz);
|
||||
6
include/crc.h
Normal file
6
include/crc.h
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
int check_file_header(char *addr);
|
||||
int check_header_length(unsigned char *addr, long offset);
|
||||
unsigned long first_idat(unsigned char *addr);
|
||||
int total_idat(unsigned char *addr);
|
||||
int change_idat_content(unsigned char *addr, unsigned char *message, int accuracy, unsigned long offset);
|
||||
11
include/crc_util.h
Normal file
11
include/crc_util.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// PNG File Struct
|
||||
struct PNG
|
||||
|
||||
extern const long png_signature[8];
|
||||
|
||||
int check_header_length(unsigned char *addr, long offset);
|
||||
int check_file_header(char *addr);
|
||||
int create_cc_file(unsigned char *addr, unsigned long file_length);
|
||||
unsigned char* file_to_char_array(FILE *in_file, size_t* size);
|
||||
Reference in New Issue
Block a user