From: Bastian Dehn Date: Sat, 9 Mar 2024 09:34:21 +0000 (+0100) Subject: remove convert and read config tool X-Git-Tag: v1.0.0^2~127 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=5bf38a790bd5a9f981b1338332725061527bc413;p=sane-kds-s2000w-net.git remove convert and read config tool --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e2c20af..5e09393 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.25.1) project("kds_s2000w_net" VERSION "0.0.1") add_subdirectory(src) -add_subdirectory(tools) set(RUN_TESTS OFF CACHE BOOL "build and run tests") diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt deleted file mode 100644 index d31d605..0000000 --- a/tools/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.25.1) - -add_executable("convert" "convert.c") -add_dependencies("convert" sane-kds_s2000w_net) -target_link_libraries("convert" sane-kds_s2000w_net) - -add_executable("read_config" "read_config.c") -add_dependencies("read_config" sane-kds_s2000w_net) -target_link_libraries("read_config" sane-kds_s2000w_net) \ No newline at end of file diff --git a/tools/convert.c b/tools/convert.c deleted file mode 100644 index 073a946..0000000 --- a/tools/convert.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include "../src/kds_s2000w_image_converter.h" - -void read_file(const char* filename, blobdata* input) -{ - FILE* fptr = fopen(filename, "r"); - if (fptr == NULL) { - printf("file %s not found\n", filename); - exit(1); - } - - input->data = malloc(sizeof(char)); - while(fread(input->data, sizeof(char), 1, fptr)) { - input->size++; - } - fseek(fptr, 0L, SEEK_SET); - printf("file size of %s: %i bytes\n", filename, input->size); - - input->data = malloc(sizeof(char) * input->size); - fread(input->data, input->size, 1, fptr); - fclose(fptr); - fptr = NULL; -} - -void write_file(blobdata* output) -{ - FILE* fptr = fopen("output.pnm", "w"); - fwrite(output->data, output->size, 1, fptr); - printf("file size of output.pnm: %i bytes\n", output->size); - fclose(fptr); - fptr = NULL; -} - -void printf_header_bytes(const char* data) -{ - const int header_spaces = 3; - const char space = 0x0a; - int space_count = 0; - int byte_count = 0; - - while(space_count < header_spaces && byte_count < 50) { - printf("%02hhx ", data[byte_count]); - if (data[byte_count] == space) { - space_count++; - } - - byte_count++; - } - - char* header = malloc(sizeof(char) * byte_count); - snprintf(header, byte_count, "%s", data); - printf("\nheader:\n%s\n", header); - printf("header has %i bytes\n", byte_count); - free(header); - header = NULL; -} - -int main(int argc, char* argv[]) -{ - blobdata input; - input.size = 0; - input.data = NULL; - blobdata output; - output.size = 0; - output.data = NULL; - - read_file(argv[1], &input); - - kds_s2000w_convert_init(); - kds_s2000w_convert_jpg_to_pnm_with_depth(&input, &output, 8); - kds_s2000w_convert_terminate(); - - printf_header_bytes((const char*) output.data); - write_file(&output); - - free(input.data); - input.data = NULL; - free(output.data); - output.data = NULL; - return 0; -} \ No newline at end of file diff --git a/tools/read_config.c b/tools/read_config.c deleted file mode 100644 index 849cbed..0000000 --- a/tools/read_config.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include "../src/kds_s2000w_config.h" - -int main(int argc, char** argv) -{ - program_config* config = malloc(sizeof(program_config)); - - printf("config file %s\n", argv[1]); - char* config_stream = read_config_file(argv[1]); - load_config(config, config_stream); - - printf("scanner_url: %s\n", config->scanner_url); - printf("username: %s\n", config->username); - - free(config_stream); - config_stream = NULL; - free(config->scanner_url); - config->scanner_url = NULL; - free(config->username); - config->username = NULL; - free(config); - config = NULL; - - return 0; -} \ No newline at end of file