changed support

This commit is contained in:
Pin
2021-11-02 22:42:49 -04:00
parent 7649feee82
commit cbee739c91
3 changed files with 46 additions and 24 deletions

View File

@@ -1,13 +1,17 @@
LIBRARIES = `pkg-config --libs zlib libsodium` -Iinclude LIBRARIES = `pkg-config --libs zlib libsodium` -Iinclude
SOURCES = ./src/* ./cmd/crc.c SOURCES = ./src/* ./cmd/pspng.c
OUTPUT_DIR = ./bin OUTPUT_DIR = ./bin
OUTPUT = -o ${OUTPUT_DIR}/PROG OUTPUT = -o ${OUTPUT_DIR}/PROG
INSTALL_OUTPUT = ${OUTPUT_DIR}/PROG
build: output_dir build: output_dir
gcc -Wall -pthread ${LIBRARIES} ${SOURCES} ${OUTPUT:PROG=crc} gcc -Wall -pthread ${LIBRARIES} ${SOURCES} ${OUTPUT:PROG=pspng}
debug: output_dir debug: output_dir
gcc -Wall -g -pthread ${LIBRARIES} ${SOURCES} ${OUTPUT:PROG=crc} gcc -Wall -g -pthread ${LIBRARIES} ${SOURCES} ${OUTPUT:PROG=pspng}
install:
mv ${INSTALL_OUTPUT:PROG=pspng} /usr/bin/
output_dir: output_dir:
mkdir -p ${OUTPUT_DIR} mkdir -p ${OUTPUT_DIR}
@@ -16,4 +20,4 @@ clean:
rm -rf $(OUTPUT_DIR) **.h.gch rm -rf $(OUTPUT_DIR) **.h.gch
memcheck: debug memcheck: debug
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes -s ${OUTPUT_DIR}/crc valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes -s ${OUTPUT_DIR}/pspng

View File

@@ -10,7 +10,7 @@
#include <pthread.h> #include <pthread.h>
#include "crc_util.h" #include "crc_util.h"
#include "CRCLib.h" #include "CRCLib.h"
#include "crc.h" #include "pspng.h"
#include "compress_util.h" #include "compress_util.h"
//#define MAX_IDAT_SIZE 16384 //#define MAX_IDAT_SIZE 16384
@@ -74,6 +74,7 @@ static void random_window_bit_change(unsigned char *data, int width, int rounds,
size_t random_num = 0; size_t random_num = 0;
size_t filter_chunk_byte = 0; size_t filter_chunk_byte = 0;
size_t change_num = 0; size_t change_num = 0;
long prior_chuck_check = 0;
for (int i = 0; i < rounds; i++) { for (int i = 0; i < rounds; i++) {
random_num = 0; random_num = 0;
do { do {
@@ -109,7 +110,15 @@ static void random_window_bit_change(unsigned char *data, int width, int rounds,
data[random_num]++; data[random_num]++;
} }
} else if(data[filter_chunk_byte] == 3) { } else if(data[filter_chunk_byte] == 3) {
printf("3\n"); // Average Filter Type Change
//printf("HEE: %d\n", data[(filter_chunk_byte - (width * color_range))-1]);
prior_chuck_check = filter_chunk_byte;
do {
//printf("C: %d\n", data[prior_chuck_check]);
prior_chuck_check = (prior_chuck_check - (width * color_range)-1);
//printf("CH: %ld\n", prior_chuck_check);
} while(prior_chuck_check >= 0);
if(data[random_num] == 255) { if(data[random_num] == 255) {
data[random_num]--; data[random_num]--;
} else { } else {
@@ -487,8 +496,9 @@ int main(int argc, char **argv) {
}; };
const char* usage = const char* usage =
"Usage: crc [options]\n" "Usage: pspng [options]\n\n"
" -c --compress Compress Message\n" " -c --compress Compress Message\n"
" -u --uncompress Currently used for debugging\n"
" -h, --help Shows help message\n" " -h, --help Shows help message\n"
" -f, --file Denotes input file\n" " -f, --file Denotes input file\n"
" -o, --outfile Denotes output file\n" " -o, --outfile Denotes output file\n"
@@ -559,29 +569,37 @@ int main(int argc, char **argv) {
if(uncompress_call == 1) { if(uncompress_call == 1) {
size_t idat_byte_length = 0; size_t idat_byte_length = 0;
unsigned long cur_idat_len = 0;
//unsigned char message_data[8192];
unsigned char* idat_data = populate_idat_array(file_data, offset, &idat_byte_length); unsigned char* idat_data = populate_idat_array(file_data, offset, &idat_byte_length);
for(int i = 0; i < idat_byte_length; i++) { //for(int i = 0; i < idat_byte_length; i++) {
//printf("%02X ", idat_data[i]); //printf("%02X ", idat_data[i]);
} //}
printf("\nDecompressed Data:\n\n"); printf("\nDecompressed Data:\n\n");
// Decompressing data // Decompressing data
unsigned char *uncom_data_buff = NULL; //unsigned char *uncom_data_buff = NULL;
size_t uncom_data_size = 0; //size_t uncom_data_size = 0;
zlib_decompress_data(idat_data, idat_byte_length, &uncom_data_buff, &uncom_data_size); //zlib_decompress_data(idat_data, idat_byte_length, &uncom_data_buff, &uncom_data_size);
for(int i = 0; i < uncom_data_size; i++) { //for(int i = 0; i < uncom_data_size; i++) {
printf("%02X ", uncom_data_buff[i]); // printf("%02X ", uncom_data_buff[i]);
//}
//printf("\n");
do {
for(int j = 0; j < 64; j++) {
cur_idat_len = 0;
for(int i = 0; i < 4; i++) {
cur_idat_len += (file_data[offset+i] << (24-(8*i)));
} }
printf("\n"); //printf("%c", file_data[offset+cur_idat_len+8]);
//for(int k=0;k<20;k++) { if((j % 4) == 0) {
// printf("%d: %d\n", (0+k), uncom_data_buff[0+k]); printf("%c", file_data[offset+cur_idat_len+8]);
//} }
//printf("\n"); // Offset Plus idat length + 3 bytes
//printf("\n"); offset += cur_idat_len + 12;
//for(int k=0;k<20;k++) { }
// printf("%d: %d\n", (24000+k), uncom_data_buff[24000+k]); } while(offset < idat_byte_length);
//}
printf("\n");
free(idat_data); free(idat_data);
free(file_data); free(file_data);