iclr.c
832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* 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));
}