#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; }