From 12682f82d0647effbca1267ca3f141826c21d0cc Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sun, 8 Dec 2013 14:43:05 +0100 Subject: [PATCH] src/file_chm.c: code cleanup --- src/file_chm.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/file_chm.c b/src/file_chm.c index 5b2626fe..b7af3e49 100644 --- a/src/file_chm.c +++ b/src/file_chm.c @@ -31,7 +31,6 @@ #include "filegen.h" static void register_header_check_chm(file_stat_t *file_stat); -static int header_check_chm(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new); const file_hint_t file_hint_chm= { .extension="chm", @@ -43,24 +42,19 @@ const file_hint_t file_hint_chm= { .register_header_check=®ister_header_check_chm }; -static const unsigned char chm_header[16]={ 'I', 'T', 'S', 'F', 0x03, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}; +static int header_check_chm(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new) +{ + reset_file_recovery(file_recovery_new); + file_recovery_new->calculated_file_size=(buffer[104]<<0)+(buffer[105]<<8)+(buffer[106]<<16)+((uint64_t)buffer[107]<<24); + file_recovery_new->data_check=&data_check_size; + file_recovery_new->file_check=&file_check_size; + file_recovery_new->extension=file_hint_chm.extension; + return 1; +} static void register_header_check_chm(file_stat_t *file_stat) { + static const unsigned char chm_header[16]={ 'I', 'T', 'S', 'F', 0x03, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}; register_header_check(0, chm_header,sizeof(chm_header), &header_check_chm, file_stat); } - -static int header_check_chm(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new) -{ - if(memcmp(buffer, chm_header, sizeof(chm_header))==0) - { - reset_file_recovery(file_recovery_new); - file_recovery_new->calculated_file_size=(buffer[104]<<0)+(buffer[105]<<8)+(buffer[106]<<16)+(buffer[107]<<24); - file_recovery_new->data_check=&data_check_size; - file_recovery_new->file_check=&file_check_size; - file_recovery_new->extension=file_hint_chm.extension; - return 1; - } - return 0; -}