gra-projekt/Implementierung/lib/helper.h

54 lines
No EOL
1.2 KiB
C

#ifndef HELPER_H
#define HELPER_H
#define _POSIX_C_SOURCE 200809L
#include <errno.h>
#include <getopt.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "md2.h"
enum argumentParseResult {
RESULT_OK = 0,
RESULT_EXIT_SUCCESS,
RESULT_EXIT_FAILURE
};
struct configuration {
char* filename;
int implementationToUse;
bool doBenchmark;
int benchmarkingCycles;
bool runTests;
};
/**
* @brief parse commandline arguments to config and print errors, if any
*
* @param argc argc
* @param argv argv
* @param c pointer where the configuration should be stored
* @return enum argumentParseResult
*/
enum argumentParseResult parseArguments(int argc, char** argv,
struct configuration* c);
double current_time();
/**
* @brief Run an md2_hash_func with benchmark timing
*
* @param cycles the number of cycles to execute
* @param func the function to run
* @param len the lenght of buf
* @param buf the data to hash
* @param out the target array for the hash
* @return double
*/
double run_benchmark(unsigned cycles, md2_hash_func func, size_t len,
uint8_t* buf, uint8_t* out);
#endif // HELPER_H