From 9ea5de7c075bcb956b7fafd4efe42f0181e753ba Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 29 Jun 2022 10:50:55 +0200 Subject: [PATCH] Chore: Add cmake, split helper, add .vscode --- .vscode/extensions.json | 5 ++ .vscode/settings.json | 6 ++ Implementierung/.gitignore | 5 ++ Implementierung/CMakeLists.txt | 17 ++++ Implementierung/Makefile | 14 --- Implementierung/lib/helper.h | 20 +++++ Implementierung/main | Bin 21648 -> 0 bytes Implementierung/main.c | 152 --------------------------------- Implementierung/src/helper.c | 87 +++++++++++++++++++ Implementierung/src/main.c | 87 +++++++++++++++++++ 10 files changed, 227 insertions(+), 166 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 Implementierung/.gitignore create mode 100644 Implementierung/CMakeLists.txt delete mode 100644 Implementierung/Makefile create mode 100644 Implementierung/lib/helper.h delete mode 100755 Implementierung/main delete mode 100644 Implementierung/main.c create mode 100644 Implementierung/src/helper.c create mode 100644 Implementierung/src/main.c diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..5a9a397 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "ms-vscode.cpptools" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8aae49a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "C_Cpp.clang_format_fallbackStyle": "Google", + "files.associations": { + "functional": "c" + } +} \ No newline at end of file diff --git a/Implementierung/.gitignore b/Implementierung/.gitignore new file mode 100644 index 0000000..a811ad3 --- /dev/null +++ b/Implementierung/.gitignore @@ -0,0 +1,5 @@ +Makefile +cmake_install.cmake +CMakeCache.txt +md2 +CMakeFiles \ No newline at end of file diff --git a/Implementierung/CMakeLists.txt b/Implementierung/CMakeLists.txt new file mode 100644 index 0000000..91d978d --- /dev/null +++ b/Implementierung/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 2.6.0) + +# here we specify that the project is C language only, so the default +# C compiler on the system will be used +project(md2 C) +add_executable(md2 "") + +set(SOURCE_FILES + src/main.c + src/helper.c +) + +target_sources(md2 PRIVATE ${SOURCE_FILES}) + +target_include_directories(md2 PUBLIC + lib +) \ No newline at end of file diff --git a/Implementierung/Makefile b/Implementierung/Makefile deleted file mode 100644 index ac2efc2..0000000 --- a/Implementierung/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -FLAGS=-O3 -std=c11 -g -Wall -Wextra -no-pie - -.PHONY: all -all: main -main: main.c - $(CC) $(CFLAGS) -o $@ $^ - -.PHONY: clean -clean: - rm -f main - -.PHONY: run -run: - ./main diff --git a/Implementierung/lib/helper.h b/Implementierung/lib/helper.h new file mode 100644 index 0000000..5495952 --- /dev/null +++ b/Implementierung/lib/helper.h @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include + +enum argumentParseResult { + RESULT_OK = 0, + RESULT_EXIT_SUCCESS, + RESULT_EXIT_FAILURE +}; + +struct configuration { + char* filename; + int implementationToUse; + int doBenchmark; + int benchmarkingCycles; +}; + +enum argumentParseResult parseArguments(int argc, char** argv, struct configuration* c); \ No newline at end of file diff --git a/Implementierung/main b/Implementierung/main deleted file mode 100755 index 0f5f1439b8a22b0c61e85063d29f57c8713510e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21648 zcmeHP33MFAnXaBgGqSA1wrp%L@z~(l21c@cA=?N`vd12SulV5D#2H32Eoq)dGhz-b z6WDcP%tH}M4B3Pnycd(rwaF&S5<h8Y@ZQ1BD455=-Tq?-bO|y_zRk7o8RRC!f z&7vClLUF#R0Pm5QRo`k6)LQAJtCac`?gpjaY!=GUxfU!m)gF>kZ=$q#idCbjsIz$L zd0AAvliudDQS=l>eIA^%$Gsprtq5Qc88dyOqAyW4Nd{ru4>?o~Ebh z5R#@ko{S0q&B~sWwxW)yRpvrC_4<^alWtJ*nz9Y1UC-y@|CRQ3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~v4%)In??*$aem05bcSYqzoJCj`j$lrgo__s8tqPR z#(W+_gI}fS$Yzz7@;evmBNQcC@|zbW2)9M7+l=kY=6kG%@*)v@W#~vx(U3jRlZ$qM;)@xQcIy(RUM4QO8sxMQ*PIQw z@ar`*xdS#xUhoES6=g}awQmk`mfS#bIlvm?2U2K4NSe!7HP@LLKJ-|^L{OJ8lTiw) z60T}RgY>*1XZE4YeGzqOIp`Y9ZngJu0$$`S4Qn^FG;|q;amf-xt7+Im)*u_OjA7G> z242HrCx^3~8AC6c>cXKzvGPh&S9Nq`%WEauYxO^G*; za4NwZ%SycY&!j2WkL-!E_H-T?E-`BTW~Hxbt6dmneO}h^DirMceM(=`^R=L&`uwWl z%?^D%U)D6B1r>GbUkUtGtc_~_hgAETE>(IJiaPy|0>?ecV*mAevZlP_&cr@4c3K~2 zM41xE*`#h?uTN__-w|*JE3Snu*M7CWUhmbEcgmQw|5{GdzeXL`k~Oc_lQrETwcqN$ zg5^Cy##HO;^=wT8%3pk5!>bcanJv+K9S?=D~z(e{h;05u=r__inK z_P-OAcKv|T({$9XjIydO(l0pl^<7s@b4AB2Lt0;({fa|h&zm)^)`E&U{r{TM*YOtt zC8#J@*6c~gUt`}!fg)O8U)N~5MGGqGY@Z8~cKyHtOHk9f|3Ukl=i(|+?gP}+-x<>1 zPjmXKc};%_9nL}3Zd<$#9p!CsBrRuggj+nY5nXj=a@P z5v{MkV|22S(n7AxTO}*k`kKB5*sd>HmGn}J-lAAdw4SCeDBJaqwpx-$mHstaQPF^d z_d}VswEx9try*{Hq$hL{zosiBtGs?aIiwI+-YMr8eDBLT=};r2P-ZIK+G9G-&#wHtCRMm z^)0{y;qme!?OP#MvzrkzUP-UiF}wOUBKMT)uB(*SvwW^8n<)naZ@@jnkNFFp0R m)#txTV8yX#smT1`MvK|ysC2eJZ36u#IWa)G&Y|F7#lHi_bV!l_ diff --git a/Implementierung/main.c b/Implementierung/main.c deleted file mode 100644 index e70fa4c..0000000 --- a/Implementierung/main.c +++ /dev/null @@ -1,152 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// The file "testfile" should lead to this hash: fc982e558db259f298b43cd4c1241c66 - -void md2_checksum(size_t len, uint8_t* buf) { - -} - -void md2_hash(size_t len, const uint8_t buf[len], uint8_t out[16]) { - -} - -static uint8_t* read_file(const char* path, size_t* size) { - // Read the contents of the file specified by path into a heap-allocated - // buffer and return a pointer to that buffer. - FILE* f = fopen(path, "r"); - if(f == NULL) { - printf("Fopen error: %d\n", errno); - fclose(f); - return NULL; - } - - struct stat statOfFile; - int status = fstat(fileno(f), &statOfFile); - if(status == -1) { - printf("Fstat error: %d\n", errno); - fclose(f); - return NULL; - }; - - if((statOfFile.st_mode & S_IFMT) != S_IFREG){ - printf("File is not a regular file!\n"); - fclose(f); - return NULL; - } - - uint8_t* data = malloc(statOfFile.st_size); - - size_t bytesRead = fread(data, statOfFile.st_blksize, statOfFile.st_blocks, f); - // Or: size_t bytesRead = fread(data, sizeof(char), statOfFile.st_size, f); - if(bytesRead != 0 && !feof(f)) { - printf("Error reading file!\n"); - fclose(f); - return NULL; - } - - fclose(f); - - (*size) = bytesRead; - return data; -} - -int stringToInt(char* string) { - char* leftover = ""; - errno = 0; - int x = strtold(string, &leftover); - if(*leftover != '\0' || leftover == string) { - errno = EINVAL; - return -1; - } - if(errno == ERANGE) { - printf("Number is too large or too small!\n"); - errno = EINVAL; - return -1; - } - errno = 0; - return x; -} - -void help(char* progname) { - fprintf(stderr, "usage: %s [-V implementation] [-B [repetitons]] [-h] [--help] file\n", progname); -} - -int main(int argc, char** argv) { - - int opt; - int implementationTosUse = 0; - int doBenchmark = 0; - int benchmarkingCycles = 1; - - while (1) { - - static struct option longOptions[] = - { - /* These options set a flag. */ - {"help", no_argument, NULL, 'h'}, - NULL - }; - int longOptionIndex = 0; - - opt = getopt_long(argc, argv, "V:B::h", longOptions, &longOptionIndex); - - if(-1 == opt) - break; - - switch (opt) { - case 'B': - doBenchmark = 1; - if(optarg != NULL) { - benchmarkingCycles = stringToInt(optarg); - if(errno == 0) break; - fprintf(stderr, "%s: invalid argument, has to be int -- 'B' got '%s'\n", argv[0], optarg); - help(argv[0]); - return EXIT_FAILURE; - } - break; - case 'V': - implementationTosUse = stringToInt(optarg); - if(errno == 0) break; - fprintf(stderr, "%s: invalid argument, has to be int -- 'V' got '%s'\n", argv[0], optarg); - help(argv[0]); - return EXIT_FAILURE; - - case 'h': - help(argv[0]); - return EXIT_SUCCESS; - - default: - help(argv[0]); - return EXIT_FAILURE; - } - } - - char* filename = ""; - - if(argc > optind) { - filename = argv[optind]; - } - else { - fprintf(stderr, "%s: missing poisional argument -- 'file'\n", argv[0]); - help(argv[0]); - return EXIT_FAILURE; - } - - printf("Hashing file: %s\nUsing implementation: %d, doing benchmark: %d, benchmark cycles: %d\n", filename, implementationTosUse, doBenchmark, benchmarkingCycles); - - return 0; -} diff --git a/Implementierung/src/helper.c b/Implementierung/src/helper.c new file mode 100644 index 0000000..2c9a519 --- /dev/null +++ b/Implementierung/src/helper.c @@ -0,0 +1,87 @@ +#include "helper.h" + +int stringToInt(char *string) { + char *leftover = ""; + errno = 0; + int x = strtold(string, &leftover); + if (*leftover != '\0' || leftover == string) { + errno = EINVAL; + return -1; + } + if (errno == ERANGE) { + printf("Number is too large or too small!\n"); + errno = EINVAL; + return -1; + } + errno = 0; + return x; +} + +void help(char *progname) { + fprintf( + stderr, + "usage: %s [-V implementation] [-B [repetitons]] [-h] [--help] file\n", + progname); +} + +enum argumentParseResult parseArguments(int argc, char **argv, struct configuration* c) { + if(c == NULL) { + return RESULT_EXIT_FAILURE; + } + + c->implementationToUse = 0; + c->doBenchmark = 0; + c->benchmarkingCycles = 1; + + int opt; + + while (1) { + static struct option longOptions[] = {{"help", no_argument, NULL, 'h'}, + NULL}; + int longOptionIndex = 0; + + opt = getopt_long(argc, argv, "V:B::h", longOptions, &longOptionIndex); + + if (-1 == opt) break; + + switch (opt) { + case 'B': + c->doBenchmark = 1; + if (optarg != NULL) { + c->benchmarkingCycles = stringToInt(optarg); + if (errno == 0) break; + fprintf(stderr, + "%s: invalid argument, has to be int -- 'B' got '%s'\n", + argv[0], optarg); + help(argv[0]); + return RESULT_EXIT_FAILURE; + } + break; + case 'V': + c->implementationToUse = stringToInt(optarg); + if (errno == 0) break; + fprintf(stderr, "%s: invalid argument, has to be int -- 'V' got '%s'\n", + argv[0], optarg); + help(argv[0]); + return RESULT_EXIT_FAILURE; + + case 'h': + help(argv[0]); + return RESULT_EXIT_SUCCESS; + + default: + help(argv[0]); + return RESULT_EXIT_FAILURE; + } + } + + if (argc > optind) { + c->filename = argv[optind]; + } else { + fprintf(stderr, "%s: missing poisional argument -- 'file'\n", argv[0]); + help(argv[0]); + return RESULT_EXIT_FAILURE; + } + + return RESULT_OK; +} \ No newline at end of file diff --git a/Implementierung/src/main.c b/Implementierung/src/main.c new file mode 100644 index 0000000..b20a89a --- /dev/null +++ b/Implementierung/src/main.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "helper.h" + +// The file "testfile" should lead to this hash: fc982e558db259f298b43cd4c1241c66 + +void md2_checksum(size_t len, uint8_t* buf) { + +} + +void md2_hash(size_t len, const uint8_t buf[len], uint8_t out[16]) { + +} + +static uint8_t* read_file(const char* path, size_t* size) { + // Read the contents of the file specified by path into a heap-allocated + // buffer and return a pointer to that buffer. + FILE* f = fopen(path, "r"); + if(f == NULL) { + printf("Fopen error: %d\n", errno); + fclose(f); + return NULL; + } + + struct stat statOfFile; + int status = fstat(fileno(f), &statOfFile); + if(status == -1) { + printf("Fstat error: %d\n", errno); + fclose(f); + return NULL; + }; + + if((statOfFile.st_mode & S_IFMT) != S_IFREG){ + printf("File is not a regular file!\n"); + fclose(f); + return NULL; + } + + uint8_t* data = malloc(statOfFile.st_size); + + size_t bytesRead = fread(data, statOfFile.st_blksize, statOfFile.st_blocks, f); + // Or: size_t bytesRead = fread(data, sizeof(char), statOfFile.st_size, f); + if(bytesRead != 0 && !feof(f)) { + printf("Error reading file!\n"); + fclose(f); + return NULL; + } + + fclose(f); + + (*size) = bytesRead; + return data; +} + +int main(int argc, char** argv) { + + struct configuration c; + enum argumentParseResult result = parseArguments(argc, argv, &c); + + switch (result) + { + case RESULT_EXIT_SUCCESS: + return EXIT_SUCCESS; + case RESULT_EXIT_FAILURE: + return EXIT_FAILURE; + default: + break; + } + + printf("Hashing file: %s\nUsing implementation: %d, doing benchmark: %d, benchmark cycles: %d\n", c.filename, c.implementationToUse, c.doBenchmark, c.benchmarkingCycles); + + return 0; +}