summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexbrownbear <mymailbox002@gmail.com>2018-04-14 14:54:25 +0300
committeralexbrownbear <mymailbox002@gmail.com>2018-04-14 14:54:25 +0300
commit5b31ef4e1cbf61fa33cad1c9628ec2a5c005983e (patch)
treeef9e3614ffc04a0b847fab55a02bc8987f021608
parent7982d05a429f56f024789fa45d2e1e1c366dfd77 (diff)
Improving code readability
-rw-r--r--src/file_rar.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/file_rar.c b/src/file_rar.c
index 8531968..c4a0004 100644
--- a/src/file_rar.c
+++ b/src/file_rar.c
@@ -44,45 +44,47 @@ const file_hint_t file_hint_rar= {
.register_header_check=&register_header_check_rar
};
+rar15fmt_header[7]={0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
+rar50fmt_header[8]={0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
+
+rar15fmt_footer[7]={0xc4, 0x3d, 0x7b, 0x00, 0x40, 0x07, 0x00 };
+rar50fmt_footer[8]={0x1d, 0x77, 0x56, 0x51, 0x03, 0x05, 0x04, 0x00 };
+
#define MHD_PASSWORD 0x0080U
-static void file_check_rar(file_recovery_t *file_recovery)
+static void file_check_rar15fmt(file_recovery_t *file_recovery)
{
- static const unsigned char rar_footer[7]={0xc4, 0x3d, 0x7b, 0x00, 0x40, 0x07, 0x00 };
- file_search_footer(file_recovery, rar_footer, sizeof(rar_footer), 0);
+ file_search_footer(file_recovery, rar15fmt_footer, sizeof(rar15fmt_footer), 0);
}
-static int header_check_rar(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 int header_check_rar15fmt(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->min_filesize=70;
if((buffer[0xa] & MHD_PASSWORD)==0)
- file_recovery_new->file_check=&file_check_rar;
+ file_recovery_new->file_check=&file_check_rar15fmt;
file_recovery_new->extension=file_hint_rar.extension;
return 1;
}
-static void file_check_rar5(file_recovery_t *file_recovery)
+static void file_check_rar50fmt(file_recovery_t *file_recovery)
{
- static const unsigned char rar5_footer[8]={0x1d, 0x77, 0x56, 0x51, 0x03, 0x05, 0x04, 0x00 }; //RAR5 footer
- file_search_footer(file_recovery, rar5_footer, sizeof(rar5_footer), 0);
+ file_search_footer(file_recovery, rar50fmt_footer, sizeof(rar50fmt_footer), 0);
}
-static int header_check_rar5(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 int header_check_rar50fmt(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->min_filesize=70;
+ file_recovery_new->min_filesize=60;
if((buffer[0xa] & MHD_PASSWORD)==0)
- file_recovery_new->file_check=&file_check_rar5;
+ file_recovery_new->file_check=&file_check_rar50fmt;
file_recovery_new->extension=file_hint_rar.extension;
return 1;
}
static void register_header_check_rar(file_stat_t *file_stat)
{
- static const unsigned char rar_header[7]={0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
- register_header_check(0, rar_header,sizeof(rar_header), &header_check_rar, file_stat);
- static const unsigned char rar5_header[8]={0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 }; //RAR5 header
- register_header_check(0, rar5_header,sizeof(rar5_header), &header_check_rar5, file_stat);
+ register_header_check(0, rar15fmt_header,sizeof(rar15fmt_header), &header_check_rar15fmt, file_stat);
+ register_header_check(0, rar50fmt_header,sizeof(rar50fmt_header), &header_check_rar50fmt, file_stat);
}