#ifndef _CORRUPTER_H #define _CORRUPTER_H #include #include #include #include #include #include #include #include #include #include "common.h" #include "MTPRNG.h" #include "file_boundaries.h" #include "file_type.h" /* typedefs */ typedef unsigned char byte; /* structures */ struct _corrupter_result { bool error; size_t hit_counter, file_size, damaged_bytes; }; struct _corrupter_param { FILE* file; uint16_t probability; byte threshold; size_t passes; uint8_t config; uint32_t* seed; file_type_t type; }; /* typedefs */ typedef struct _corrupter_param Corrupter_Param; typedef struct _corrupter_result Corrupter_Result; /* macros: procedures */ #ifdef DEBUG # define DBG_EXPECT(text, condition) do { \ if (!(condition)) \ die("[debug] Fail: %s", text); \ } while (0) #else # define DBG_EXPECT(text, condition) do { \ if (!(condition)) \ abort(); \ } while (0) #endif /* macros: lambdas */ #define FLIP_BIT(x, n) ((x) ^ (1 << (n))) /* functions definitions */ Corrupter_Result* corrupt_file(Corrupter_Param* param); #endif /* _CORRUPTER_H */