summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2019-07-14 15:42:30 +0200
committerPaweł Redman <pawel.redman@gmail.com>2019-07-14 15:42:30 +0200
commite7d138caba5178118c6466584b77d791318d9082 (patch)
tree63ebc4ffef4d712df7ff8ae6a67ec37313453167 /src/main.c
parentdcf3c8f677ed0d864604ba0a43d3b971510962e6 (diff)
Refactor the data structure
Move away from ad-hoc prints to being able to store the entire file structure in memory for later processing or storing.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index e51d863..19d2957 100644
--- a/src/main.c
+++ b/src/main.c
@@ -10,15 +10,14 @@
#include "e2e.h"
-uint32_t u32le(const char*);
-
int main(int argc, char **argv)
{
- int rv = 0;
+ int ret = 0;
char *inpath;
int fd;
struct stat st;
void *input;
+ struct e2e_data data;
if (argc < 2) {
fprintf(stderr, "%s [FILE]\n", argv[0]);
@@ -35,21 +34,22 @@ int main(int argc, char **argv)
if (fstat(fd, &st) == -1) {
perror("fstat");
- rv = 1;
+ ret = 1;
goto error_mmap;
}
input = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (!input) {
perror("mmap");
- rv = 1;
+ ret = 1;
goto error_mmap;
}
- e2e_read(input, input + st.st_size);
+ e2e_read(&data, input, input + st.st_size);
+ e2e_destroy(&data);
munmap(input, st.st_size);
error_mmap:
close(fd);
- return rv;
+ return ret;
} \ No newline at end of file