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

Subversion Repositories zet86

[/] [zet86/] [trunk/] [src/] [tools/] [read-addr.c] - Blame information for rev 55

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 45 zeus
#include <stdio.h>
2
#include <sys/stat.h>
3
#include <fcntl.h>
4
#include <string.h>
5
 
6
int main (int argc, char *argv[])
7
{
8
  int fd, n;
9
  char buf[4096];
10
  char *p, *q;
11
  char s1[6], s2[6];
12
 
13
  if (argc != 2) fprintf(stderr, "Syntax: %s tracefile\n",
14
                         argv[0]);
15
 
16
  fd=open(argv[1], O_RDONLY);
17
  if(fd < 0)
18
    {
19
      fprintf(stderr, "Error opening file\n");
20
      return 1;
21
    }
22
 
23
  strcpy (s1, "");
24
  strcpy (s2, "");
25
 
26
  while (1)
27
    {
28
      n=read(fd, &buf, 4096);
29
      if (n<11) break;
30
 
31
      p=buf;
32
      q=&buf[n-11];
33
      while (1)
34
        {
35
          if (p = strstr(p, "[0x"))
36
            {
37
              // String found
38
              if (p > q) break;
39
              p+=6;
40
              strncpy (s2, p, 5);
41
              if (strcmp (s1, s2))
42
                {
43
                  // They are different
44
                  printf ("%s\n", s2);
45
                  strcpy (s1, s2);
46
                }
47
            }
48
          else break;
49
        }
50
 
51
      if (p > q) lseek(fd, (off_t) -10, SEEK_CUR);
52
      if (buf[n-1]=='[') lseek(fd, (off_t) -1, SEEK_CUR);
53
      else if (buf[n-2]=='[' && buf[n-1]=='0')
54
        lseek(fd, (off_t) -2, SEEK_CUR);
55
    }
56
 
57
  return 0;
58
}

powered by: WebSVN 2.1.0

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