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 | ||
8c0221bf | 25 | last_seq = -1; |
42a58cd1 | 26 | last_time = 0; |
8c0221bf | 27 | alias = nr = 0; |
fd8a68ba | 28 | total_entries = 0; |
42a58cd1 | 29 | while ((p = fgets(line, sizeof(line), f)) != NULL) { |
58261c75 | 30 | if (sscanf(p, "%3d,%3d %2d %8d %lf", &major, &minor, &cpu, &seq, &this_time) != 5) |
42a58cd1 JA |
31 | break; |
32 | ||
cf4b68a5 JA |
33 | if (this_time < last_time) { |
34 | fprintf(stdout, "%s", p); | |
35 | nr++; | |
36 | } else | |
42a58cd1 | 37 | last_time = this_time; |
63c7bd75 | 38 | |
b99d1637 JA |
39 | if (last_seq == seq) { |
40 | fprintf(stdout, "alias on sequence %u\n", seq); | |
63c7bd75 | 41 | alias++; |
b99d1637 | 42 | } |
63c7bd75 JA |
43 | |
44 | last_seq = seq; | |
fd8a68ba | 45 | total_entries++; |
42a58cd1 JA |
46 | } |
47 | ||
fd8a68ba | 48 | fprintf(stdout, "Events %Lu: %d unordered, %d aliases\n", total_entries, nr, alias); |
42a58cd1 | 49 | fclose(f); |
cf4b68a5 JA |
50 | |
51 | return nr != 0; | |
42a58cd1 | 52 | } |