All pastes #273527 Raw Edit

Untitled

public c v1 · immutable
·published 2006-12-09 23:43 UTC
rendered paste body
#include <stdlib.h>#include <stdio.h>#include <sys/mman.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>int main(int argc, char **argv) {	int bitmap_fd=0;	char *bitmap;		if((bitmap_fd=open(argv[1],O_RDONLY))<0) {		fprintf(stderr,"Unable to open bitmap\n");		return -1;	}	bitmap=mmap(0,lseek(bitmap_fd,0,SEEK_SET)-1,PROT_READ,MAP_PRIVATE,bitmap_fd,0);	close(bitmap_fd);		if(bitmap==MAP_FAILED) {		fprintf(stderr,"Error mapping file to memory:%d\n",errno);		return -1;	}		printf("%c%c%c%c",*(bitmap+1),*(bitmap+2),*(bitmap+3),*(bitmap+4));		munmap(bitmap,lseek(bitmap_fd,0,SEEK_SET)-1);	return 0;}