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; |
fd8a68ba | 11 | unsigned long long total_entries; |
42a58cd1 JA |
12 | FILE *f; |
13 | ||
14 | if (argc < 2) { | |
15 | fprintf(stderr, "%s: file\n", argv[0]); | |
16 | return 1; | |
17 | } | |
18 | ||
19 | f = fopen(argv[1], "r"); | |
20 | if (!f) { | |
21 | perror("fopen"); | |
22 | return 1; | |
23 | } | |
24 | ||
25 | last_time = 0; | |
63c7bd75 | 26 | last_seq = alias = nr = 0; |
fd8a68ba | 27 | total_entries = 0; |
42a58cd1 | 28 | while ((p = fgets(line, sizeof(line), f)) != NULL) { |
58261c75 | 29 | if (sscanf(p, "%3d,%3d %2d %8d %lf", &major, &minor, &cpu, &seq, &this_time) != 5) |
42a58cd1 JA |
30 | break; |
31 | ||
cf4b68a5 JA |
32 | if (this_time < last_time) { |
33 | fprintf(stdout, "%s", p); | |
34 | nr++; | |
35 | } else | |
42a58cd1 | 36 | last_time = this_time; |
63c7bd75 | 37 | |
b99d1637 JA |
38 | if (last_seq == seq) { |
39 | fprintf(stdout, "alias on sequence %u\n", seq); | |
63c7bd75 | 40 | alias++; |
b99d1637 | 41 | } |
63c7bd75 JA |
42 | |
43 | last_seq = seq; | |
fd8a68ba | 44 | total_entries++; |
42a58cd1 JA |
45 | } |
46 | ||
fd8a68ba | 47 | fprintf(stdout, "Events %Lu: %d unordered, %d aliases\n", total_entries, nr, alias); |
42a58cd1 | 48 | fclose(f); |
cf4b68a5 JA |
49 | |
50 | return nr != 0; | |
42a58cd1 | 51 | } |