1
0

28 lines
1.0 KiB
C
Raw Normal View History

2020-10-13 15:04:59 +02:00
/******************************************************************************/
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
2020-10-13 15:04:59 +02:00
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#ifndef INC_UTILS_H
#define INC_UTILS_H
#include "platform.h"
2020-10-13 19:50:29 +02:00
#include <stdint.h>
2020-10-13 15:04:59 +02:00
2020-10-20 19:13:11 +02:00
typedef void (signal_handler_t)(int);
void init_terminal(void);
2020-10-20 19:13:11 +02:00
void setup_signal_handler(const int signo, signal_handler_t* const handler);
uint64_t swap_bytes_u64(const uint64_t value);
2020-10-13 19:33:01 +02:00
char* CHR_to_utf8(const CHR *const input);
2020-10-13 15:04:59 +02:00
uint64_t get_file_size(FILE* const file);
const CHR *get_file_name(const CHR *path);
uint64_t round_down(const uint64_t value, const uint64_t base);
2020-10-13 15:04:59 +02:00
#define ARRAY_SIZE(X) (sizeof((X)) / sizeof(*(X)))
#define BOUND(MIN,VAL,MAX) (((VAL) < (MIN)) ? (MIN) : (((VAL) > (MAX)) ? (MAX) : (VAL)))
2020-12-01 02:24:35 +01:00
#define GET_NIBBLE(X) ((X) & 0x0F)
#define SET_NIBBLE(X, Y) do { X = ((X) & 0xF0) | ((Y) & 0x0F); } while(0)
2020-10-13 15:04:59 +02:00
#endif