From e7d138caba5178118c6466584b77d791318d9082 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sun, 14 Jul 2019 15:42:30 +0200 Subject: 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. --- src/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main.c') 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 -- cgit