1
0
mirror of https://git.disroot.org/80486DX2-66/polonium.git synced 2024-09-19 18:45:33 +05:30
polonium/include/corrupter.h

63 lines
1.1 KiB
C
Raw Permalink Normal View History

2024-07-07 03:18:23 +05:30
#ifndef _CORRUPTER_H
#define _CORRUPTER_H
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
2024-07-07 03:18:23 +05:30
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "MTPRNG.h"
#include "file_boundaries.h"
#include "file_type.h"
/* structures */
struct _corrupter_result {
bool error;
size_t hit_counter,
file_size,
damaged_bytes;
};
struct _corrupter_param {
FILE* file;
uint16_t probability;
uint8_t 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;
typedef unsigned char byte;
/* 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 */