summaryrefslogtreecommitdiffstats
path: root/src/file_chm.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-12-08 14:43:05 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-12-08 14:43:05 +0100
commit12682f82d0647effbca1267ca3f141826c21d0cc (patch)
tree8d62cae3c4df892cfdb2b747a6174796750033cd /src/file_chm.c
parentccc47d5bf2c28e40857912b7c65e3f97415ebe7a (diff)
src/file_chm.c: code cleanup
Diffstat (limited to 'src/file_chm.c')
-rw-r--r--src/file_chm.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/file_chm.c b/src/file_chm.c
index 5b2626f..b7af3e4 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=&register_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 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)
{
- register_header_check(0, chm_header,sizeof(chm_header), &header_check_chm, file_stat);
+ 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 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)
+static void register_header_check_chm(file_stat_t *file_stat)
{
- 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;
+ 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);
}