-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
58 lines (47 loc) · 2.7 KB
/
main.c
File metadata and controls
58 lines (47 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "front.h"
#include "./tests/tests.h"
int main(int argc, char *argv[]) {
#ifndef DEBUG
printf("\n");
printf(HYEL "██╗███╗ ███╗██████╗ ██████╗ █████╗ ███╗ ██╗ █████╗ ██╗ ██╗ ██╗███████╗██╗███████╗\n"
"██║████╗ ████║██╔══██╗██╔══██╗ ██╔══██╗████╗ ██║██╔══██╗██║ ╚██╗ ██╔╝██╔════╝██║██╔════╝\n"
"██║██╔████╔██║██║ ██║██████╔╝ ███████║██╔██╗ ██║███████║██║ ╚████╔╝ ███████╗██║███████╗\n"
"██║██║╚██╔╝██║██║ ██║██╔══██╗ ██╔══██║██║╚██╗██║██╔══██║██║ ╚██╔╝ ╚════██║██║╚════██║\n"
"██║██║ ╚═╝ ██║██████╔╝██████╔╝ ██║ ██║██║ ╚████║██║ ██║███████╗██║ ███████║██║███████║\n"
"╚═╝╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝╚═╝╚══════╝\n\n" reset);
if (argc != 2) {
fprintf(stderr, BHRED "Something's not right." HRED " A path to a file must be supplied as argument.\n" reset);
return ARG_ERROR;
}
printf(HGRN "Analysing data...\n" reset);
FILE * csv;
csv = fopen(argv[1], "r");
if (csv == NULL) {
handleErrors(FILE_ERROR, NULL);
}
ERROR_CODE k = NO_ERROR;
// Crea el objeto de queries para ser loadeado
Queries queries;
k = loadAllQueries(&queries);
handleErrors(k, &queries);
k = parseAndInsert(csv, &queries);
handleErrors(k, &queries);
int c = fclose(csv);
if (c != 0) {
k = FILE_ERROR;
handleErrors(k, &queries);
}
k = writeAllQueries(&queries);
handleErrors(k, &queries);
freeAllQueries(&queries);
printf(HGRN "FINISHED! Four CSV files were saved.\n\n" reset);
#endif
#ifdef DEBUG
FILE * csv;
csv = fopen(argv[1], "r");
if (csv == NULL) {
handleErrors(FILE_ERROR, NULL);
}
timing_test(csv);
#endif
}