Commit | Line | Data |
---|---|---|
42a58cd1 JA |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <fcntl.h> | |
4 | #include <unistd.h> | |
5 | ||
6 | int main(int argc, char *argv[]) | |
7 | { | |
8 | double this_time, last_time; | |
9 | char line[256], *p; | |
63c7bd75 | 10 | int major, minor, cpu, seq, nr, alias, last_seq; |
42a58cd1 JA |
11 | FILE *f; |
12 | ||
13 | if (argc < 2) { | |
14 | fprintf(stderr, "%s: file\n", argv[0]); | |
15 | return 1; | |
16 | } | |
17 | ||
18 | f = fopen(argv[1], "r"); | |
19 | if (!f) { | |
20 | perror("fopen"); | |
21 | return 1; | |
22 | } | |
23 | ||
24 | last_time = 0; | |
63c7bd75 | 25 | last_seq = alias = nr = 0; |
42a58cd1 | 26 | while ((p = fgets(line, sizeof(line), f)) != NULL) { |
b99d1637 | 27 | if (sscanf(p, "%3d,%3d %2d %8d %lf", &major, &minor, &cpu, &seq, &this_time) == -1) |
42a58cd1 JA |
28 | break; |
29 | ||
cf4b68a5 JA |
30 | if (this_time < last_time) { |
31 | fprintf(stdout, "%s", p); | |
32 | nr++; | |
33 | } else | |
42a58cd1 | 34 | last_time = this_time; |
63c7bd75 | 35 | |
b99d1637 JA |
36 | if (last_seq == seq) { |
37 | fprintf(stdout, "alias on sequence %u\n", seq); | |
63c7bd75 | 38 | alias++; |
b99d1637 | 39 | } |
63c7bd75 JA |
40 | |
41 | last_seq = seq; | |
42a58cd1 JA |
42 | } |
43 | ||
63c7bd75 | 44 | fprintf(stdout, "%d unordered events, %d aliases\n", nr, alias); |
42a58cd1 | 45 | fclose(f); |
cf4b68a5 JA |
46 | |
47 | return nr != 0; | |
42a58cd1 | 48 | } |