iclr.c 832 Bytes
/*
 *	iclr - clear the "incore" area of image file so cmp on 2 images works
 *
 */
#ifdef __sgi__
#include <gl/image.h>
#endif
#include <PRimage.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stddef.h>

main(argc,argv)
int argc;
char **argv;
{
    int fd;
    IMAGE header;

    if (argc != 2) {
	fprintf(stderr, "usage: %s filename\n", argv[0]);
	exit(1);
    }

    fd = open(argv[1], O_RDWR);
    if (fd == -1) {
	fprintf(stderr, "Couldn't open %s image file\n", argv[1]);
	exit(1);
    }

    read(fd, &header, sizeof(IMAGE));
    if (header.imagic != IMAGIC) {
	fprintf(stderr, "%s is not an image file\n", argv[1]);
    }

    bzero(&header.file , sizeof(IMAGE) - offsetof(IMAGE, file));
    lseek(fd, 0, SEEK_SET);
    write(fd, &header, sizeof(IMAGE));
}