src/file_wks.c: add Frama-C annotations
This commit is contained in:
parent
cef9304cf0
commit
74a9277425
1 changed files with 35 additions and 14 deletions
|
@ -31,15 +31,16 @@
|
|||
#include "types.h"
|
||||
#include "filegen.h"
|
||||
|
||||
/*@ requires \valid(file_stat); */
|
||||
static void register_header_check_wks(file_stat_t *file_stat);
|
||||
|
||||
const file_hint_t file_hint_wks= {
|
||||
.extension="wks",
|
||||
.description="Lotus 1-2-3",
|
||||
.max_filesize=PHOTOREC_MAX_FILE_SIZE,
|
||||
.recover=1,
|
||||
.enable_by_default=1,
|
||||
.register_header_check=®ister_header_check_wks
|
||||
const file_hint_t file_hint_wks = {
|
||||
.extension = "wks",
|
||||
.description = "Lotus 1-2-3",
|
||||
.max_filesize = PHOTOREC_MAX_FILE_SIZE,
|
||||
.recover = 1,
|
||||
.enable_by_default = 1,
|
||||
.register_header_check = ®ister_header_check_wks
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -53,26 +54,46 @@ const file_hint_t file_hint_wks= {
|
|||
* http://www.schnarff.com/file-formats/lotus-1-2-3/WSFF1.TXT
|
||||
* http://www.schnarff.com/file-formats/lotus-1-2-3/WSFF2.TXT
|
||||
*/
|
||||
/*@
|
||||
@ requires buffer_size > 0;
|
||||
@ requires \valid_read(buffer+(0..buffer_size-1));
|
||||
@ requires valid_file_recovery(file_recovery);
|
||||
@ requires \valid(file_recovery_new);
|
||||
@ requires file_recovery_new->blocksize > 0;
|
||||
@ requires separation: \separated(&file_hint_wks, buffer+(..), file_recovery, file_recovery_new);
|
||||
@ ensures \result!=0 ==> valid_file_recovery(file_recovery_new);
|
||||
@ assigns *file_recovery_new;
|
||||
@*/
|
||||
static int header_check_wk4(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->extension="wk4";
|
||||
file_recovery_new->extension = "wk4";
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*@
|
||||
@ requires buffer_size > 0;
|
||||
@ requires \valid_read(buffer+(0..buffer_size-1));
|
||||
@ requires valid_file_recovery(file_recovery);
|
||||
@ requires \valid(file_recovery_new);
|
||||
@ requires file_recovery_new->blocksize > 0;
|
||||
@ requires separation: \separated(&file_hint_wks, buffer+(..), file_recovery, file_recovery_new);
|
||||
@ ensures \result!=0 ==> valid_file_recovery(file_recovery_new);
|
||||
@ assigns *file_recovery_new;
|
||||
@*/
|
||||
static int header_check_wks(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->extension=file_hint_wks.extension;
|
||||
file_recovery_new->extension = file_hint_wks.extension;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void register_header_check_wks(file_stat_t *file_stat)
|
||||
{
|
||||
static const unsigned char wks_header[10] = { 0x00, 0x00, 0x02, 0x00, 0x04, 0x04,
|
||||
0x06, 0x00, 0x08, 0x00};
|
||||
static const unsigned char wk4_header[8] = { 0x00, 0x00, 0x1a, 0x00, 0x02, 0x10, 0x04, 0x00};
|
||||
register_header_check(0, wks_header,sizeof(wks_header), &header_check_wks, file_stat);
|
||||
register_header_check(0, wk4_header,sizeof(wk4_header), &header_check_wk4, file_stat);
|
||||
static const unsigned char wks_header[10] = { 0x00, 0x00, 0x02, 0x00, 0x04, 0x04,
|
||||
0x06, 0x00, 0x08, 0x00 };
|
||||
static const unsigned char wk4_header[8] = { 0x00, 0x00, 0x1a, 0x00, 0x02, 0x10, 0x04, 0x00 };
|
||||
register_header_check(0, wks_header, sizeof(wks_header), &header_check_wks, file_stat);
|
||||
register_header_check(0, wk4_header, sizeof(wk4_header), &header_check_wk4, file_stat);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue