#include #include #include #include #include #include #include #include #include #include "e2e.h" int main(int argc, char **argv) { 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]); return 1; } inpath = argv[1]; fd = open(inpath, O_RDONLY); if (fd == -1) { perror("open"); return 1; } if (fstat(fd, &st) == -1) { perror("fstat"); ret = 1; goto error_mmap; } input = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (!input) { perror("mmap"); ret = 1; goto error_mmap; } if (e2e_read(&data, input, input + st.st_size)) perror("e2e_read"); e2e_destroy(&data); munmap(input, st.st_size); error_mmap: close(fd); return ret; }