/******************************************************************************/ /* SlunkCrypt, by LoRd_MuldeR */ /* This work has been released under the CC0 1.0 Universal license! */ /******************************************************************************/ #ifndef INC_UTILS_H #define INC_UTILS_H #include "platform.h" #include typedef void (signal_handler_t)(int); void init_terminal(void); void setup_signal_handler(const int signo, signal_handler_t* const handler); uint64_t swap_bytes_u64(const uint64_t value); char* CHR_to_utf8(const CHR *const input); 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); #define ARRAY_SIZE(X) (sizeof((X)) / sizeof(*(X))) #define BOUND(MIN,VAL,MAX) (((VAL) < (MIN)) ? (MIN) : (((VAL) > (MAX)) ? (MAX) : (VAL))) #define GET_NIBBLE(X) ((X) & 0x0F) #define SET_NIBBLE(X, Y) do { X = ((X) & 0xF0) | ((Y) & 0x0F); } while(0) #endif