#include #include #include #include #include #include #include #include #include #include "utils.h" void parseCommand(int argc, char **argv) { int opt; jobs = 1; while ((opt = getopt(argc, argv, "j:")) != -1) { switch (opt) { case 'j': jobs = atoi(optarg); break; default: fprintf(stderr, "Usage: %s [-j jobs]\n", argv[0]); exit(0); } } int fileDescriptor; struct stat fileStatistics; fileCount = argc - optind; for (int i = 0; i < fileCount; i ++) { fileDescriptor = open(argv[optind + i], O_RDONLY); fstat(fileDescriptor, &fileStatistics); fileContents[i] = mmap(NULL, fileStatistics.st_size, PROT_READ, MAP_PRIVATE, fileDescriptor, 0); fileLengths[i] = fileStatistics.st_size; } }