From ac855a7e9d9970e4f1b658b679c05c893d991be7 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Fri, 12 Jul 2019 15:34:26 +0200 Subject: Initial commit --- src/main.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main.c (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..e51d863 --- /dev/null +++ b/src/main.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "e2e.h" + +uint32_t u32le(const char*); + +int main(int argc, char **argv) +{ + int rv = 0; + char *inpath; + int fd; + struct stat st; + void *input; + + if (argc < 2) { + fprintf(stderr, "%s [FILE]\n", argv[0]); + return 1; + } + + inpath = argv[1]; + + fd = open(inpath, O_RDONLY); + if (fd == -1) { + perror("open"); + return 1; + } + + if (fstat(fd, &st) == -1) { + perror("fstat"); + rv = 1; + goto error_mmap; + } + + input = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (!input) { + perror("mmap"); + rv = 1; + goto error_mmap; + } + + e2e_read(input, input + st.st_size); + + munmap(input, st.st_size); +error_mmap: + close(fd); + return rv; +} \ No newline at end of file -- cgit