From 987a7083038493aa5a4c6c5e4c297c089a270fb3 Mon Sep 17 00:00:00 2001 From: marcsello Date: Thu, 5 Nov 2020 19:31:29 +0100 Subject: [PATCH] Created utils file --- CMakeLists.txt | 2 +- src/ciff_tools.c | 12 +----------- src/utils.c | 14 ++++++++++++++ src/utils.h | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 src/utils.c create mode 100644 src/utils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index cd8ade4..6afb2c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,4 @@ project(caff_previewer C) set(CMAKE_C_STANDARD 11) -add_executable(caff_previewer src/main.c src/magic_memory.c src/magic_memory.h src/ciff_tools.h src/ciff_tools.c src/libtarga.c src/libtarga.h src/pixeldata_utils.c src/pixeldata_utils.h) \ No newline at end of file +add_executable(caff_previewer src/main.c src/magic_memory.c src/magic_memory.h src/ciff_tools.h src/ciff_tools.c src/libtarga.c src/libtarga.h src/pixeldata_utils.c src/pixeldata_utils.h src/utils.c src/utils.h) \ No newline at end of file diff --git a/src/ciff_tools.c b/src/ciff_tools.c index 5180c05..291962f 100644 --- a/src/ciff_tools.c +++ b/src/ciff_tools.c @@ -3,17 +3,7 @@ // #include "ciff_tools.h" -#include "stdbool.h" - -uint8_t contains(const uint8_t* data, uint64_t data_len, uint8_t what) { - for (uint64_t i = 0; i < data_len; i++) { - if (data[i] == what) { - return true; - } - } - return false; -} - +#include "utils.h" uint8_t parse_ciff_from_mem(const uint8_t* data, uint64_t data_len, uint64_t* width, uint64_t* height, uint64_t* pixel_data_starts) { /** diff --git a/src/utils.c b/src/utils.c new file mode 100644 index 0000000..730202d --- /dev/null +++ b/src/utils.c @@ -0,0 +1,14 @@ +// +// Created by marcsello on 05/11/2020. +// + +#include "utils.h" + +bool contains(const uint8_t* data, uint64_t data_len, uint8_t what) { + for (uint64_t i = 0; i < data_len; i++) { + if (data[i] == what) { + return true; + } + } + return false; +} diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..5d9770d --- /dev/null +++ b/src/utils.h @@ -0,0 +1,14 @@ +// +// Created by marcsello on 05/11/2020. +// + +#ifndef CAFF_PREVIEWER_UTILS_H +#define CAFF_PREVIEWER_UTILS_H + +#include +#include + +bool contains(const uint8_t *data, uint64_t data_len, uint8_t what); + + +#endif //CAFF_PREVIEWER_UTILS_H