void print_deps(void) { struct stat st; int fd; void *map; fd = open(depfile, O_RDONLY); if (fd < 0) { fprintf(stderr, "fixdep: "); perror(depfile); exit(2); } fstat(fd, &st); if (st.st_size == 0) { fprintf(stderr,"fixdep: %s is empty\n",depfile); close(fd); return; } map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if ((long) map == -1) { perror("fixdep: mmap"); close(fd); return; } parse_dep_file(map, st.st_size); munmap(map, st.st_size); close(fd); }
/* global functions */ int main(int argc, char *argv[]){ int fd; void *map; unsigned int size; /* init */ traps(); if(argc != 4){ fprintf(stderr, "Usage: %s <depfile> <config_header> <config_dir>\n", argv[0]); return 1; } depfile = argv[1]; conf_header = argv[2]; conf_dir = argv[3]; /* open and mmap depfile */ if(file_map(depfile, &fd, &map, &size) != 0) return 1; /* parse depfile */ parse_dep_file(map, size); /* exit */ file_unmap(fd, map, size); return 0; }