OpenCores
URL https://opencores.org/ocsvn/zet86/zet86/trunk

Subversion Repositories zet86

[/] [zet86/] [trunk/] [src/] [tools/] [incr-img.c] - Blame information for rev 49

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 zeus
#include <sys/types.h>
2
#include <sys/stat.h>
3
#include <fcntl.h>
4
#include <stdio.h>
5
#include <string.h>
6
#include <stdlib.h>
7
 
8
int main(int argc, char *argv[])
9
{
10
  int  f1, f2, c1, c2;
11
  char err[50];
12
  unsigned char *buf1, *buf2;
13
 
14
  if (argc!=3)
15
    {
16
      sprintf(err, "Usage: %s hdnew.img hdref.img\n", argv[0]);
17
      write(2, &err, strlen(err));
18
      exit(1);
19
    }
20
 
21
  f1 = open (argv[1], O_RDONLY);
22
  if (f1<0)
23
    {
24
      sprintf(err, "Could not open file %s\n", argv[1]);
25
      write(2, &err, strlen(err));
26
      exit(1);
27
    }
28
 
29
  f2 = open (argv[2], O_RDONLY);
30
  if (f2<0)
31
    {
32
      sprintf(err, "Could not open file %s\n", argv[2]);
33
      write(2, &err, strlen(err));
34
      exit(1);
35
    }
36
 
37
  buf1 = malloc(131072);
38
  if (!buf1)
39
    {
40
      sprintf(err, "Could not allocate 128kb of memory for the 1st buffer\n");
41
      write(2, &err, strlen(err));
42
      exit(1);
43
    }
44
 
45
  buf2 = malloc(131072);
46
  if (!buf2)
47
    {
48
      sprintf(err, "Could not allocate 128kb of memory for the 2nd buffer\n");
49
      write(2, &err, strlen(err));
50
      exit(1);
51
    }
52
 
53
 
54
    c1=read(f1, &buf1, 131072); // 128kb block
55
    c2=read(f2, &buf2, 131072);
56
 
57
    memcmp (buf1, buf2, 131072);
58
 
59
  return 0;
60
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.