Reorganise the project

This commit is contained in:
Abdelrahman Said 2023-07-02 19:28:48 +01:00
parent 301ea44759
commit 50f881c655
6 changed files with 11 additions and 58 deletions

View File

@ -1,5 +1,5 @@
#ifndef ARGPARSER_H #ifndef GEN_ARGPARSER_H
#define ARGPARSER_H #define GEN_ARGPARSER_H
#include "aliases.h" #include "aliases.h"
#include <argp.h> #include <argp.h>
@ -12,4 +12,4 @@ struct GeneratorArgs {
GeneratorArgs parse_args(i32 argc, char *argv[]); GeneratorArgs parse_args(i32 argc, char *argv[]);
#endif // !ARGPARSER_H #endif // !GEN_ARGPARSER_H

View File

@ -1,15 +1,16 @@
#include "argparser.h" #include "generator/gen_argparser.h"
#include "aliases.h"
#include <argp.h> #include <argp.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
static error_t argp_parser(i32 key, char *arg, argp_state *state); INTERNAL error_t argp_parser(i32 key, char *arg, argp_state *state);
static argp parser = {}; INTERNAL argp parser = {};
static argp_option options[] = { INTERNAL argp_option options[] = {
{.name = "seed", .key = 's', .arg = "SEED"}, {.name = "seed", .key = 's', .arg = "SEED"},
{.name = "cluster", .key = 'c'}, {.name = "cluster", .key = 'c'},
{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},

View File

@ -1,4 +1,4 @@
#include "generator.h" #include "generator/generator.h"
#include "aliases.h" #include "aliases.h"
#include "point_types.h" #include "point_types.h"
#include <math.h> #include <math.h>

View File

@ -1,11 +1,10 @@
#include "aliases.h" #include "aliases.h"
#include "argparser.h" #include "generator/gen_argparser.h"
#include "generator.h" #include "generator/generator.h"
#include "haversine.h" #include "haversine.h"
#include "point_types.h" #include "point_types.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h>
#define EARTH_RADIUS_KM 6371.0 #define EARTH_RADIUS_KM 6371.0

View File

@ -1,47 +0,0 @@
#include "aliases.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
i32 main(i32 argc, char *argv[]) {
if (argc < 2) {
printf("Missing filename\n");
return EXIT_FAILURE;
}
const char *filename = argv[1];
FILE *fp = fopen(filename, "r");
if (!fp) {
printf("Failed to open file: %s\n", filename);
return EXIT_FAILURE;
}
fseek(fp, 0, SEEK_END);
u64 length = ftell(fp);
fseek(fp, 0, SEEK_SET);
char text[length + 1];
memset(text, 0, length);
fread(text, sizeof(char), length, fp);
text[length] = '\0';
const char *delim = ", \t\n";
char *token = strtok(text, delim);
while (token) {
printf("TOKEN: %s\n", token);
token = strtok(NULL, delim);
}
fclose(fp);
return EXIT_SUCCESS;
}