1
0
mirror of https://git.disroot.org/80486DX2-66/polonium.git synced 2024-12-25 23:00:07 +05:30
polonium/include/corrupter.h

64 lines
1.1 KiB
C
Raw 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"
/* typedefs */
typedef unsigned char byte;
2024-07-07 03:18:23 +05:30
/* structures */
struct _corrupter_result {
bool error;
size_t file_size,
2024-07-07 03:18:23 +05:30
damaged_bytes;
};
struct _corrupter_param {
FILE* file;
uint16_t probability;
byte threshold;
2024-07-07 03:18:23 +05:30
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);
2024-07-07 03:18:23 +05:30
#endif /* _CORRUPTER_H */