-
Notifications
You must be signed in to change notification settings - Fork 0
/
payredu.c
72 lines (62 loc) · 1.67 KB
/
payredu.c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <signal.h>
#include <unistd.h>
#include <book.h>
#define MAX_MEMORY 4064
#define WINDOW_WIDTH 512
#define WINDOW_HEIGHT 512
#define BUFFER_SIZE 256
int should_exit = 0;
void sig_handle() {
printf("Reloaded\n");
system("date");
should_exit = 1;
}
typedef void* (*module_main_func)(const char*, size_t);
int main(int argc, char* argv[]) {
FILE* in = fopen("october-2023.txt", "r");
char* data = (char*)malloc(2048 * sizeof(char));
size_t data_size = 0;
size_t c_read = 0;
while((c_read = fread(data + data_size + 0, 1, BUFFER_SIZE, in)) != 0) {
data_size += c_read;
}
if (ferror(in)) fprintf(stderr, "Error reading file\n");
fprintf(stdout, "Startig loop\n");
ledger_parse_data(data, data_size);
return 0;
}
/*
int main(int argc, char* argv[]) {
signal(SIGQUIT, sig_handle);
//while(1) {
void* module = dlopen("./libbook.so", RTLD_NOW);
while(module == NULL){
fprintf(stderr, "Failed to load module. (%s)\n", dlerror());
fprintf(stderr, "Press return to try again.\n");
getchar();
module = dlopen("./libbook.so", RTLD_NOW);
}
module_main_func module_main = dlsym(module, "module_main");
FILE* in = fopen("october-2023.txt", "r");
char* data = (char*)malloc(2048 * sizeof(char));
size_t data_size = 0;
size_t c_read = 0;
while((c_read = fread(data + data_size + 0, 1, BUFFER_SIZE, in)) != 0) {
data_size += c_read;
}
if (ferror(in)) fprintf(stderr, "Error reading file\n");
fprintf(stdout, "Startig loop\n");
module_main(data, data_size);
while(should_exit == 0) {
sleep(1);
}
should_exit = 0;
dlclose(module);
fprintf(stderr, "Continue?\n");
//}
return 0;
}
*/