mirror of
https://git.disroot.org/80486DX2-66/polonium.git
synced 2024-12-26 07:09:50 +05:30
64 lines
1.1 KiB
C
64 lines
1.1 KiB
C
#ifndef _CORRUPTER_H
|
|
#define _CORRUPTER_H
|
|
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
#include <inttypes.h>
|
|
#include <limits.h>
|
|
#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;
|
|
|
|
/* structures */
|
|
struct _corrupter_result {
|
|
bool error;
|
|
size_t 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 */
|